Package com.cloud.bridge.service.core.s3

Examples of com.cloud.bridge.service.core.s3.S3ConditionalHeaders


            S3MetaDataEntry[] metaEntry = new S3MetaDataEntry[ count ];

            for( int i=0; i < count; i++ )
            {
                parent = part.item(i);
                metaEntry[i] = new S3MetaDataEntry();

                // -> get a list of all the children elements of the 'Metadata' parent element
                if (null != (children = parent.getChildNodes()))
                {
                    int numChildren = children.getLength();
View Full Code Here


                    }
                    else if (name.equalsIgnoreCase( "x-amz-acl" )) {
                        engineRequest.setCannedAccess( value );
                    }
                    else if (isMetaTag) {
                        S3MetaDataEntry oneMeta = new S3MetaDataEntry();
                        oneMeta.setName( metaName );
                        oneMeta.setValue( value );
                        metaSet.add( oneMeta );
                        countMeta++;
                        metaName = null;
                    }
View Full Code Here

            if (key.startsWith( "x-amz-meta-" ))
            {
                String name  = key.substring( 11 );
                String value = request.getHeader( key );
                if (null != value) {
                    S3MetaDataEntry oneMeta = new S3MetaDataEntry();
                    oneMeta.setName( name );
                    oneMeta.setValue( value );
                    metaSet.add( oneMeta );
                    count++;
                }
            }
        }   
View Full Code Here

            for (MultiPartPartsVO partVO : partsVO) {
                Calendar tod = Calendar.getInstance();
                tod.setTime(partVO.getCreateTime());

                parts[i] = new S3MultipartPart();
                parts[i].setPartNumber(partVO.getPartNumber());
                parts[i].setEtag(partVO.getMd5());
                parts[i].setLastModified(tod);
                parts[i].setSize(partVO.getStoredSize().intValue());
                parts[i].setPath(partVO.getStoredPath());
View Full Code Here

        xml.append( "</Owner>" );      

        StringBuffer partsList = new StringBuffer();
        for( int i=0; i < parts.length; i++ )
        {
            S3MultipartPart onePart = parts[i];
            if (null == onePart) break;

            nextMarker = onePart.getPartNumber();
            partsList.append( "<Part>" );
            partsList.append( "<PartNumber>" ).append( nextMarker ).append( "</PartNumber>" );
            partsList.append( "<LastModified>" ).append( DatatypeConverter.printDateTime( onePart.getLastModified())).append( "</LastModified>" );
            partsList.append( "<ETag>\"" ).append( onePart.getETag()).append( "\"</ETag>" );
            partsList.append( "<Size>" ).append( onePart.getSize()).append( "</Size>" );
            partsList.append( "</Part>" );         
       

        xml.append( "<StorageClass>STANDARD</StorageClass>" );
        xml.append( "<PartNumberMarker>" ).append( partMarker ).append( "</PartNumberMarker>" );
View Full Code Here

        try {
            uploadList = mpartUploadDao.getInitiatedUploads(bucketName, maxParts, prefix, keyMarker, uploadIdMarker);
            for (MultiPartUploadsVO uploadsVO : uploadList) {
                Calendar tod = Calendar.getInstance();
                tod.setTime(uploadsVO.getCreateTime());
                inProgress[i] = new S3MultipartUpload();
                inProgress[i].setId( uploadsVO.getId().intValue());
                inProgress[i].setAccessKey(uploadsVO.getAccessKey());
                inProgress[i].setLastModified( tod );
                inProgress[i].setBucketName( bucketName );
                inProgress[i].setKey(uploadsVO.getNameKey());
View Full Code Here

        int maxUploads = 1000;
        int nextUploadId = 0;
        String nextKey = null;
        boolean isTruncated = false;
        S3MultipartUpload[] uploads = null;
        S3MultipartUpload onePart = null;
        String temp = request.getParameter("max-uploads");
        if (null != temp) {
            maxUploads = Integer.parseInt(temp);
            if (maxUploads > 1000 || maxUploads < 0)
                maxUploads = 1000;
        }

        // -> upload-id-marker is ignored unless key-marker is also specified
        String uploadIdMarker = request.getParameter("upload-id-marker");
        if (null == keyMarker)
            uploadIdMarker = null;

        // -> does the bucket exist, we may need it to verify access permissions
        SBucketVO bucket = bucketDao.getByName(bucketName);
        if (bucket == null) {
            logger.error("listMultipartUpload failed since " + bucketName
                    + " does not exist");
            response.setStatus(404);
            return;
        }

        S3PolicyContext context = new S3PolicyContext(
                PolicyActions.ListBucketMultipartUploads, bucketName);
        context.setEvalParam(ConditionKeys.Prefix, prefix);
        context.setEvalParam(ConditionKeys.Delimiter, delimiter);
        S3Engine.verifyAccess(context, "SBucket", bucket.getId(),
                SAcl.PERMISSION_READ);

        // [B] Query the multipart table to get the list of current uploads
        try {
            MultipartLoadDao uploadDao = new MultipartLoadDao();
            OrderedPair<S3MultipartUpload[], Boolean> result = uploadDao
                    .getInitiatedUploads(bucketName, maxUploads, prefix,
                            keyMarker, uploadIdMarker);
            uploads = result.getFirst();
            isTruncated = result.getSecond().booleanValue();
        } catch (Exception e) {
            logger.error(
                    "List Multipart Uploads failed due to " + e.getMessage(), e);
            response.setStatus(500);
        }

        StringBuffer xml = new StringBuffer();
        xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        xml.append("<ListMultipartUploadsResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">");
        xml.append("<Bucket>").append(bucketName).append("</Bucket>");
        xml.append("<KeyMarker>").append((null == keyMarker ? "" : keyMarker))
        .append("</KeyMarker>");
        xml.append("<UploadIdMarker>")
        .append((null == uploadIdMarker ? "" : uploadIdMarker))
        .append("</UploadIdMarker>");

        // [C] Construct the contents of the <Upload> element
        StringBuffer partsList = new StringBuffer();
        for (int i = 0; i < uploads.length; i++) {
            onePart = uploads[i];
            if (null == onePart)
                break;

            if (delimiter != null && !delimiter.isEmpty()) {
                // -> is this available only in the CommonPrefixes element?
                if (StringHelper.substringInBetween(onePart.getKey(), prefix,
                        delimiter) != null)
                    continue;
            }

            nextKey = onePart.getKey();
            nextUploadId = onePart.getId();
            partsList.append("<Upload>");
            partsList.append("<Key>").append(nextKey).append("</Key>");
            partsList.append("<UploadId>").append(nextUploadId)
            .append("</UploadId>");
            partsList.append("<Initiator>");
            partsList.append("<ID>").append(onePart.getAccessKey())
            .append("</ID>");
            partsList.append("<DisplayName></DisplayName>");
            partsList.append("</Initiator>");
            partsList.append("<Owner>");
            partsList.append("<ID>").append(onePart.getAccessKey())
            .append("</ID>");
            partsList.append("<DisplayName></DisplayName>");
            partsList.append("</Owner>");
            partsList.append("<StorageClass>STANDARD</StorageClass>");
            partsList
            .append("<Initiated>")
            .append(DatatypeConverter.printDateTime(onePart
                    .getLastModified())).append("</Initiated>");
            partsList.append("</Upload>");
        }

        // [D] Construct the contents of the <CommonPrefixes> elements (if any)
        for (int i = 0; i < uploads.length; i++) {
            onePart = uploads[i];
            if (null == onePart)
                break;

            if (delimiter != null && !delimiter.isEmpty()) {
                String subName = StringHelper.substringInBetween(
                        onePart.getKey(), prefix, delimiter);
                if (subName != null) {
                    partsList.append("<CommonPrefixes>");
                    partsList.append("<Prefix>");
                    if (prefix != null && prefix.length() > 0)
                        partsList.append(prefix + delimiter + subName);
View Full Code Here

   
   
    // [B] Is the operationRequested included in the policy statement?
    //  -> if the value in "NotAction:" matches that requested then the statement does not apply
    //  (i.e., "refers to all actions other" than defined).
    PolicyActions notActions = oneStatement.getNotAction();
      //System.out.println( "Statement: NotAction:" + notActions + " op requested: " + operationRequested );

      if ( PolicyActions.UnknownAction != notActions ) {
         if (notActions == operationRequested) return false;
      }
View Full Code Here

        //
        SBucketVO sbucket = bucketDao.getByName(bucketName);
        if (sbucket == null) throw new NoSuchObjectException("Bucket " + bucketName + " does not exist");

        PolicyActions action = (includeVersions ? PolicyActions.ListBucketVersions : PolicyActions.ListBucket);
        S3PolicyContext context = new S3PolicyContext( action, bucketName );
        context.setEvalParam( ConditionKeys.MaxKeys, new String( "" + maxKeys ));
        context.setEvalParam( ConditionKeys.Prefix, prefix );
        context.setEvalParam( ConditionKeys.Delimiter, delimiter );
        verifyAccess( context, "SBucket", sbucket.getId(), SAcl.PERMISSION_READ );
View Full Code Here


        // [B] "The bucket owner by default has permissions to attach bucket policies to their buckets using PUT Bucket policy."
        //  -> the bucket owner may want to restrict the IP address from where this can be executed
        String client = UserContext.current().getCanonicalUserId();
        S3PolicyContext context = new S3PolicyContext(
                PolicyActions.PutBucketPolicy, bucketName);

        switch (S3Engine.verifyPolicy(context)) {
        case ALLOW:
            break;
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.core.s3.S3ConditionalHeaders

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.