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

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


     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
      S3PutObjectRequest  putRequest  = null;
      S3PutObjectResponse putResponse = null;
      int                 bytesRead   = 0;
     
        S3Engine engine = new S3Engine();
     
        try {  
          logRequest(request);
         
            MultiPartDimeInputStream ds = new MultiPartDimeInputStream( request.getInputStream());
         
            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream())
            {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read( buffer, 0, 8192 );
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream( buffer, 0, bytesRead );
                putRequest = toEnginePutObjectRequest( bis );
            }
           
            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream())
            {
              InputStream is = ds.getInputStream();
              putRequest.setData( is );
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
        UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
        try
        {   S3SoapAuth.verifySignature( putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());    
       
        } catch( AxisFault e ) {
          String reason = e.toString();
          int start = reason.indexOf( ".AxisFault:" );
          if (-1 != start) reason = reason.substring( start+11 );
             
                xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
                xml.append( "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >\n" );
                xml.append( "<soap:Body>\n" );              
                xml.append( "<soap:Fault>\n" );
                xml.append( "<faultcode>" ).append( e.getFaultCode().toString()).append( "</faultcode>\n" );
                xml.append( "<faultstring>" ).append( reason ).append( "</faultstring>\n" );
                xml.append( "</soap:Fault>\n" );
                xml.append( "</soap:Body></soap:Envelope>" );
         
                endResponse(response, xml.toString());
            PersistContext.commitTransaction();
            return;
        }
              
        // -> PutObject S3 Bucket Policy would be done in the engine.handleRequest() call
        UserContext.current().initContext( AWSAccessKey, info.getSecretKey(), AWSAccessKey, "S3 DIME request", request );
            putResponse = engine.handleRequest( putRequest );
           
            xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
            xml.append( "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://s3.amazonaws.com/doc/2006-03-01/\">" );
            xml.append( "<soap:Body>" );
            xml.append( "<tns:PutObjectResponse>" );
            xml.append( "<tns:PutObjectResponse>" );
            xml.append( "<tns:ETag>\"").append( putResponse.getETag()).append( "\"</tns:ETag>" );
            xml.append( "<tns:LastModified>").append( DatatypeConverter.printDateTime(putResponse.getLastModified())).append( "</tns:LastModified>" );
            xml.append( "</tns:PutObjectResponse></tns:PutObjectResponse>" );
            xml.append( "</soap:Body></soap:Envelope>" );
               
          endResponse(response, xml.toString());
      PersistContext.commitTransaction();
View Full Code Here


     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
        S3PutObjectRequest putRequest = null;
        S3PutObjectResponse putResponse = null;
        int bytesRead = 0;

        S3Engine engine = new S3Engine();

        try {
            logRequest(request);

            MultiPartDimeInputStream ds = new MultiPartDimeInputStream(request.getInputStream());

            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream()) {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read(buffer, 0, 8192);
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream(buffer, 0, bytesRead);
                putRequest = toEnginePutObjectRequest(bis);
            }

            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream()) {
                InputStream is = ds.getInputStream();
                putRequest.setData(is);
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
            UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
            try {
                S3SoapAuth.verifySignature(putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());

            } catch (AxisFault e) {
                String reason = e.toString();
                int start = reason.indexOf(".AxisFault:");
                if (-1 != start)
                    reason = reason.substring(start + 11);

                xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                xml.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >\n");
                xml.append("<soap:Body>\n");
                xml.append("<soap:Fault>\n");
                xml.append("<faultcode>").append(e.getFaultCode().toString()).append("</faultcode>\n");
                xml.append("<faultstring>").append(reason).append("</faultstring>\n");
                xml.append("</soap:Fault>\n");
                xml.append("</soap:Body></soap:Envelope>");

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

            // -> PutObject S3 Bucket Policy would be done in the engine.handleRequest() call
            UserContext.current().initContext(AWSAccessKey, info.getSecretKey(), AWSAccessKey, "S3 DIME request", request);
            putResponse = engine.handleRequest(putRequest);

            xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            xml.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://s3.amazonaws.com/doc/2006-03-01/\">");
            xml.append("<soap:Body>");
            xml.append("<tns:PutObjectResponse>");
            xml.append("<tns:PutObjectResponse>");
            xml.append("<tns:ETag>\"").append(putResponse.getETag()).append("\"</tns:ETag>");
            xml.append("<tns:LastModified>").append(DatatypeConverter.printDateTime(putResponse.getLastModified())).append("</tns:LastModified>");
            xml.append("</tns:PutObjectResponse></tns:PutObjectResponse>");
            xml.append("</soap:Body></soap:Envelope>");

            endResponse(response, xml.toString());
        } catch (PermissionDeniedException e) {
View Full Code Here

     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
      S3PutObjectRequest  putRequest  = null;
      S3PutObjectResponse putResponse = null;
      int                 bytesRead   = 0;
     
        S3Engine engine = new S3Engine();
     
        try {  
          logRequest(request);
         
            MultiPartDimeInputStream ds = new MultiPartDimeInputStream( request.getInputStream());
         
            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream())
            {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read( buffer, 0, 8192 );
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream( buffer, 0, bytesRead );
                putRequest = toEnginePutObjectRequest( bis );
            }
           
            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream())
            {
              InputStream is = ds.getInputStream();
              putRequest.setData( is );
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
        UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
        try
        {   S3SoapAuth.verifySignature( putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());    
       
        } catch( AxisFault e ) {
          String reason = e.toString();
          int start = reason.indexOf( ".AxisFault:" );
          if (-1 != start) reason = reason.substring( start+11 );
             
                xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
                xml.append( "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >\n" );
                xml.append( "<soap:Body>\n" );              
                xml.append( "<soap:Fault>\n" );
                xml.append( "<faultcode>" ).append( e.getFaultCode().toString()).append( "</faultcode>\n" );
                xml.append( "<faultstring>" ).append( reason ).append( "</faultstring>\n" );
                xml.append( "</soap:Fault>\n" );
                xml.append( "</soap:Body></soap:Envelope>" );
         
                endResponse(response, xml.toString());
            return;
        }
              
        // -> PutObject S3 Bucket Policy would be done in the engine.handleRequest() call
        UserContext.current().initContext( AWSAccessKey, info.getSecretKey(), AWSAccessKey, "S3 DIME request", request );
            putResponse = engine.handleRequest( putRequest );
           
            xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
            xml.append( "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://s3.amazonaws.com/doc/2006-03-01/\">" );
            xml.append( "<soap:Body>" );
            xml.append( "<tns:PutObjectResponse>" );
            xml.append( "<tns:PutObjectResponse>" );
            xml.append( "<tns:ETag>\"").append( putResponse.getETag()).append( "\"</tns:ETag>" );
            xml.append( "<tns:LastModified>").append( DatatypeConverter.printDateTime(putResponse.getLastModified())).append( "</tns:LastModified>" );
            xml.append( "</tns:PutObjectResponse></tns:PutObjectResponse>" );
            xml.append( "</soap:Body></soap:Envelope>" );
               
          endResponse(response, xml.toString());
        }
View Full Code Here

     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
        S3PutObjectRequest  putRequest  = null;
        S3PutObjectResponse putResponse = null;
        int                 bytesRead   = 0;

        S3Engine engine = new S3Engine();

        try {  
            logRequest(request);

            MultiPartDimeInputStream ds = new MultiPartDimeInputStream( request.getInputStream());

            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream())
            {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read( buffer, 0, 8192 );
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream( buffer, 0, bytesRead );
                putRequest = toEnginePutObjectRequest( bis );
            }

            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream())
            {
                InputStream is = ds.getInputStream();
                putRequest.setData( is );
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
            UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
            try
            {   S3SoapAuth.verifySignature( putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());    

            } catch( AxisFault e ) {
                String reason = e.toString();
                int start = reason.indexOf( ".AxisFault:" );
                if (-1 != start) reason = reason.substring( start+11 );

                xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
                xml.append( "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >\n" );
                xml.append( "<soap:Body>\n" );              
                xml.append( "<soap:Fault>\n" );
                xml.append( "<faultcode>" ).append( e.getFaultCode().toString()).append( "</faultcode>\n" );
                xml.append( "<faultstring>" ).append( reason ).append( "</faultstring>\n" );
                xml.append( "</soap:Fault>\n" );
                xml.append( "</soap:Body></soap:Envelope>" );

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

            // -> PutObject S3 Bucket Policy would be done in the engine.handleRequest() call
            UserContext.current().initContext( AWSAccessKey, info.getSecretKey(), AWSAccessKey, "S3 DIME request", request );
            putResponse = engine.handleRequest( putRequest );

            xml.append( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
            xml.append( "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://s3.amazonaws.com/doc/2006-03-01/\">" );
            xml.append( "<soap:Body>" );
            xml.append( "<tns:PutObjectResponse>" );
            xml.append( "<tns:PutObjectResponse>" );
            xml.append( "<tns:ETag>\"").append( putResponse.getETag()).append( "\"</tns:ETag>" );
            xml.append( "<tns:LastModified>").append( DatatypeConverter.printDateTime(putResponse.getLastModified())).append( "</tns:LastModified>" );
            xml.append( "</tns:PutObjectResponse></tns:PutObjectResponse>" );
            xml.append( "</soap:Body></soap:Envelope>" );

            endResponse(response, xml.toString());
        }
View Full Code Here

                        if (key_data.getLength() == 2) {
                            versionID = getTagValue(elements[1], eElement);
                            engineRequest.setVersion(versionID);
                        }

                        S3Response engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest( engineRequest );
                        int resultCode = engineResponse.getResultCode();
                        String resutlDesc = engineResponse.getResultDescription();
                        if(resultCode == 204) {
                            if (quite) { // show response depending on quite/verbose
                                xmlDeleteResponse.append("<Deleted><Key>"+key_name+"</Key>");
                                if (resutlDesc != null)
                                    xmlDeleteResponse.append(resutlDesc);
                                xmlDeleteResponse.append("</Deleted>");
                            }
                        }
                        else {
                            logger.debug("Error in delete ::" + key_name + " eng response:: " + engineResponse.getResultDescription());
                            xmlDeleteResponse.append("<Error><Key>"+key_name+"</Key>" );
                            if (resutlDesc != null)
                                xmlDeleteResponse.append(resutlDesc);
                            xmlDeleteResponse.append("</Error>");
                        }
View Full Code Here

        engineRequest.setAcl(aclRequest);
        engineRequest.setBucketName(bucketName);

        // [C] Allow an S3Engine to handle the
        // S3SetBucketAccessControlPolicyRequest
        S3Response engineResponse = ServiceProvider.getInstance().getS3Engine()
                .handleRequest(engineRequest);
        response.setStatus(engineResponse.getResultCode());

    }
View Full Code Here

    public void executeDeleteBucket(HttpServletRequest request, HttpServletResponse response) throws IOException
    {
        S3DeleteBucketRequest engineRequest = new S3DeleteBucketRequest();
        engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));
        S3Response engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest)
        response.setStatus(engineResponse.getResultCode());
        response.flushBuffer();
    }
View Full Code Here

    response.setGetBucketAccessControlPolicyResponse(toAccessControlPolicy(policy));
    return response;
  }
  public SetBucketAccessControlPolicyResponse setBucketAccessControlPolicy(SetBucketAccessControlPolicy setBucketAccessControlPolicy) {
    S3SetBucketAccessControlPolicyRequest request = new S3SetBucketAccessControlPolicyRequest();
    request.setAccessKey(setBucketAccessControlPolicy.getAWSAccessKeyId());
    request.setRequestTimestamp(setBucketAccessControlPolicy.getTimestamp());
    request.setSignature(setBucketAccessControlPolicy.getSignature());
    request.setBucketName(setBucketAccessControlPolicy.getBucket());
    request.setAcl(toEngineAccessControlList(setBucketAccessControlPolicy.getAccessControlList()));
   
    SetBucketAccessControlPolicyResponse response = new SetBucketAccessControlPolicyResponse();
    return response;
    }
View Full Code Here

        }

        // [B] Obtain the grant request which applies to the acl request string.
        // This latter is supplied as the value of the x-amz-acl header.

        S3SetBucketAccessControlPolicyRequest engineRequest = new S3SetBucketAccessControlPolicyRequest();
        S3Grant grantRequest = new S3Grant();
        S3AccessControlList aclRequest = new S3AccessControlList();

        String aclRequestString = request.getHeader("x-amz-acl");
        OrderedPair<Integer, Integer> accessControlsForBucketOwner = SAclVO.getCannedAccessControls(aclRequestString, "SBucket");
        grantRequest.setPermission(accessControlsForBucketOwner.getFirst());
        grantRequest.setGrantee(accessControlsForBucketOwner.getSecond());
        grantRequest.setCanonicalUserID(owner);
        aclRequest.addGrant(grantRequest);
        engineRequest.setAcl(aclRequest);
        engineRequest.setBucketName(bucketName);

        // [C] Allow an S3Engine to handle the
        // S3SetBucketAccessControlPolicyRequest
        S3Response engineResponse = ServiceProvider.getInstance().getS3Engine()
                .handleRequest(engineRequest);
View Full Code Here

    return response;
  }
  public SetObjectAccessControlPolicyResponse setObjectAccessControlPolicy(SetObjectAccessControlPolicy setObjectAccessControlPolicy)
  { 
    S3SetObjectAccessControlPolicyRequest request = new S3SetObjectAccessControlPolicyRequest();
    request.setAccessKey(setObjectAccessControlPolicy.getAWSAccessKeyId());
    request.setRequestTimestamp(setObjectAccessControlPolicy.getTimestamp());
    request.setSignature(setObjectAccessControlPolicy.getSignature());
    request.setBucketName(setObjectAccessControlPolicy.getBucket());
    request.setKey(setObjectAccessControlPolicy.getKey());
    request.setAcl(toEngineAccessControlList(setObjectAccessControlPolicy.getAccessControlList()));
   
    engine.handleRequest(request);
    SetObjectAccessControlPolicyResponse response = new SetObjectAccessControlPolicyResponse();
    return response;
    }
View Full Code Here

TOP

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

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.