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

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


        S3ListAllMyBucketsRequest engineRequest = new S3ListAllMyBucketsRequest();
        engineRequest.setAccessKey(UserContext.current().getAccessKey());
        engineRequest.setRequestTimestamp(cal);
        engineRequest.setSignature("");

        S3ListAllMyBucketsResponse engineResponse = ServiceProvider
                .getInstance().getS3Engine().handleRequest(engineRequest);

        // To allow the all buckets list to be serialized via Axiom classes
        ListAllMyBucketsResponse allBuckets = S3SerializableServiceImplementation
                .toListAllMyBucketsResponse(engineResponse);

        OutputStream outputStream = response.getOutputStream();
        response.setStatus(200);
        response.setContentType("application/xml");
        // The content-type literally should be "application/xml; charset=UTF-8"
        // but any compliant JVM supplies utf-8 by default

        // MTOMAwareResultStreamWriter resultWriter = new
        // MTOMAwareResultStreamWriter ("ListAllMyBucketsResult", outputStream
        // );
        // resultWriter.startWrite();
        // resultWriter.writeout(allBuckets);
        // resultWriter.stopWrite();
        StringBuffer xml = new StringBuffer();
        xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        xml.append("<ListAllMyBucketsResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">");
        xml.append("<Owner><ID>");
        xml.append(engineResponse.getOwner().getID()).append("</ID>");
        xml.append("<DisplayName>")
        .append(engineResponse.getOwner().getDisplayName())
        .append("</DisplayName>");
        xml.append("</Owner>").append("<Buckets>");
        SimpleDateFormat sdf = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        for (S3ListAllMyBucketsEntry entry : engineResponse.getBuckets()) {
            xml.append("<Bucket>").append("<Name>").append(entry.getName())
            .append("</Name>");
            xml.append("<CreationDate>")
            .append(sdf.format(entry.getCreationDate().getTime()))
            .append("</CreationDate>");
View Full Code Here


    // after authentication, we should setup user context
    return toListBucketResponse(engine.listBucketContents(toEngineListBucketRequest(listBucket), false));
    }
 
  private S3ListBucketRequest toEngineListBucketRequest(ListBucket listBucket) {
    S3ListBucketRequest request = new S3ListBucketRequest();
   
    request.setAccessKey(listBucket.getAWSAccessKeyId());
    request.setRequestTimestamp(listBucket.getTimestamp());
    request.setSignature(listBucket.getSignature());
   
    request.setBucketName(listBucket.getBucket());
    request.setDelimiter(listBucket.getDelimiter());
    request.setMarker(listBucket.getMarker());
    request.setMaxKeys(listBucket.getMaxKeys());
    request.setPrefix(listBucket.getPrefix());
    return request;
  }
View Full Code Here

    }

    public void executeGetBucket(HttpServletRequest request, HttpServletResponse response)
            throws IOException, XMLStreamException
            {
        S3ListBucketRequest engineRequest = new S3ListBucketRequest();
        engineRequest.setBucketName((String) request
                .getAttribute(S3Constants.BUCKET_ATTR_KEY));
        engineRequest.setDelimiter(request.getParameter("delimiter"));
        engineRequest.setMarker(request.getParameter("marker"));
        engineRequest.setPrefix(request.getParameter("prefix"));

        int maxKeys = Converter.toInt(request.getParameter("max-keys"), 1000);
        engineRequest.setMaxKeys(maxKeys);
        try {
            S3ListBucketResponse engineResponse = ServiceProvider.getInstance()
                    .getS3Engine().listBucketContents(engineRequest, false);

            // To allow the all list buckets result to be serialized via Axiom
View Full Code Here

        S3RestServlet.endResponse(response, xml.toString());
    }

    public void executeGetBucketObjectVersions(HttpServletRequest request, HttpServletResponse response) throws IOException
    {  
        S3ListBucketRequest engineRequest = new S3ListBucketRequest();
        String keyMarker       = request.getParameter("key-marker");
        String versionIdMarker = request.getParameter("version-id-marker");

        engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));
        engineRequest.setDelimiter(request.getParameter("delimiter"));
        engineRequest.setMarker( keyMarker )
        engineRequest.setPrefix(request.getParameter("prefix"));
        engineRequest.setVersionIdMarker( versionIdMarker );

        int maxKeys = Converter.toInt(request.getParameter("max-keys"), 1000);
        engineRequest.setMaxKeys(maxKeys);
        S3ListBucketResponse engineResponse = ServiceProvider.getInstance().getS3Engine().listBucketContents( engineRequest, true );

        // -> the SOAP version produces different XML
        StringBuffer xml = new StringBuffer();
        xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
View Full Code Here

        engineRequest.setPrefix(request.getParameter("prefix"));

        int maxKeys = Converter.toInt(request.getParameter("max-keys"), 1000);
        engineRequest.setMaxKeys(maxKeys);
        try {
            S3ListBucketResponse engineResponse = ServiceProvider.getInstance()
                    .getS3Engine().listBucketContents(engineRequest, false);

            // To allow the all list buckets result to be serialized via Axiom
            // classes
            ListBucketResponse oneBucket = S3SerializableServiceImplementation
View Full Code Here

        engineRequest.setPrefix(request.getParameter("prefix"));
        engineRequest.setVersionIdMarker( versionIdMarker );

        int maxKeys = Converter.toInt(request.getParameter("max-keys"), 1000);
        engineRequest.setMaxKeys(maxKeys);
        S3ListBucketResponse engineResponse = ServiceProvider.getInstance().getS3Engine().listBucketContents( engineRequest, true );

        // -> the SOAP version produces different XML
        StringBuffer xml = new StringBuffer();
        xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
        xml.append( "<ListVersionsResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">" );
        xml.append( "<Name>" ).append( engineResponse.getBucketName()).append( "</Name>" );

        if ( null == keyMarker )
            xml.append( "<KeyMarker/>" );
        else xml.append( "<KeyMarker>" ).append( keyMarker ).append( "</KeyMarker" );

        if ( null == versionIdMarker )
            xml.append( "<VersionIdMarker/>" );
        else xml.append( "<VersionIdMarker>" ).append( keyMarker ).append( "</VersionIdMarker" );

        xml.append( "<MaxKeys>" ).append( engineResponse.getMaxKeys()).append( "</MaxKeys>" );
        xml.append( "<IsTruncated>" ).append( engineResponse.isTruncated()).append( "</IsTruncated>" );

        S3ListBucketObjectEntry[] versions = engineResponse.getContents();
        for( int i=0; null != versions && i < versions.length; i++ )
        {
            S3CanonicalUser owner    = versions[i].getOwner();
            boolean isDeletionMarker = versions[i].getIsDeletionMarker();
            String displayName       = owner.getDisplayName();
View Full Code Here

 
  private S3MetaDataEntry[] toEngineMetaEntries(MetadataEntry[] metaEntries) {
    if(metaEntries != null) {
      S3MetaDataEntry[] engineMetaEntries = new S3MetaDataEntry[metaEntries.length];
      for(int i = 0; i < metaEntries.length; i++) {
        engineMetaEntries[i] = new S3MetaDataEntry();
        engineMetaEntries[i].setName(metaEntries[i].getName());
        engineMetaEntries[i].setValue(metaEntries[i].getValue());
      }
      return engineMetaEntries;
    }
View Full Code Here

                uploadId = uploadVO.getId().intValue();
                if (null != meta) {
                    for (int i = 0; i < meta.length; i++) {
                        MultipartMetaVO mpartMeta = new MultipartMetaVO();
                        mpartMeta.setUploadID(uploadId);
                        S3MetaDataEntry entry = meta[i];
                        mpartMeta.setName(entry.getName());
                        mpartMeta.setValue(entry.getValue());
                        mpartMetaDao.persist(mpartMeta);
                    }
                    txn.commit();
                }
            }
View Full Code Here

        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

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.