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

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


        List<MultipartMetaVO> metaVO;
        try {

            metaVO = mpartMetaDao.getByUploadID(uploadId);
            for (MultipartMetaVO multipartMetaVO : metaVO) {
                S3MetaDataEntry oneMeta = new S3MetaDataEntry();
                oneMeta.setNamemultipartMetaVO.getName());
                oneMeta.setValue( multipartMetaVO.getValue());
                metaList.add( oneMeta );
                count++;
            }

            if ( 0 == count )
View Full Code Here


        Transaction txn = null;
        try {
            txn = Transaction.open(Transaction.AWSAPI_DB);
            for( int i=0; i < meta.length; i++ )
            {
                S3MetaDataEntry entry = meta[i];
                MultipartMetaVO metaVO = new MultipartMetaVO();
                metaVO.setUploadID(uploadId);
                metaVO.setName(entry.getName());
                metaVO.setValue(entry.getValue());
                metaVO=mpartMetaDao.persist(metaVO);
            }
            txn.commit();
        } finally {
            txn.close();
View Full Code Here

            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

TOP

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

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.