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

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


        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


        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>");
            xml.append("</Bucket>");
        }
        xml.append("</Buckets>").append("</ListAllMyBucketsResult>");
View Full Code Here

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

    S3ListAllMyBucketsResponse engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);
   
    // -> serialize using the apache's Axiom classes
    ListAllMyBucketsResponse allBuckets = S3SoapServiceImpl.toListAllMyBucketsResponse( engineResponse );

    OutputStream os = response.getOutputStream();
View Full Code Here

  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

        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

TOP

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

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.