protected HttpResponse performRequest(HttpUriRequest httpMethod, int[] expectedResponseCodes) throws ServiceException { return performRequest(httpMethod, expectedResponseCodes, null); }
protected HttpResponse performRequest(HttpUriRequest httpMethod, int[] expectedResponseCodes) throws ServiceException { return performRequest(httpMethod, expectedResponseCodes, null); }
/** * Deletes an object using a pre-signed DELETE URL generated for that object. * This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}. * <p> * This operation does not required any S3 functionality as it merely * deletes the object by performing a standard HTTP DELETE using the signed URL. * * @param signedDeleteUrl a signed DELETE URL generated with {@link org.jets3t.service.S3Service#createSignedDeleteUrl}. * @throws org.jets3t.service.ServiceException * */ public void deleteObjectWithSignedUrl(String signedDeleteUrl) throws ServiceException { HttpDelete deleteMethod = new HttpDelete(signedDeleteUrl); HttpResponse response = performRequest(deleteMethod, new int[]{204, 200}); releaseConnection(response); }
/** * Deletes an object using a pre-signed DELETE URL generated for that object. * This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}. * <p> * This operation does not required any S3 functionality as it merely * deletes the object by performing a standard HTTP DELETE using the signed URL. * * @param signedDeleteUrl a signed DELETE URL generated with {@link org.jets3t.service.S3Service#createSignedDeleteUrl}. * @throws org.jets3t.service.ServiceException * */ public void deleteObjectWithSignedUrl(String signedDeleteUrl) throws ServiceException { HttpDelete deleteMethod = new HttpDelete(signedDeleteUrl); HttpResponse response = performRequest(deleteMethod, new int[]{204, 200}); releaseConnection(response); }
/** * Performs an HTTP HEAD request using the {@link #performRequest} method. * * @param bucketName the bucket's name * @param objectKey the object's key name, may be null if the operation is on a bucket only. * @param requestParameters parameters to add to the request URL as GET params * @param requestHeaders headers to add to the request * @return the HTTP method object used to perform the request * @throws org.jets3t.service.ServiceException * */ protected HttpResponse performRestHead(String bucketName, String objectKey, Map<String, String> requestParameters, Map<String, Object> requestHeaders) throws ServiceException { HttpUriRequest httpMethod = setupConnection( HTTP_METHOD.HEAD, bucketName, objectKey, requestParameters); // Add all request headers. addRequestHeadersToConnection(httpMethod, requestHeaders); return performRequest(httpMethod, new int[]{200}); }
/** * Performs an HTTP GET request using the {@link #performRequest} method. * * @param bucketName the bucket's name * @param objectKey the object's key name, may be null if the operation is on a bucket only. * @param requestParameters parameters to add to the request URL as GET params * @param requestHeaders headers to add to the request * @param expectedStatusCodes HTTP status response codes expected, anything else causes an exception. * @return The HTTP method object used to perform the request. * @throws org.jets3t.service.ServiceException * */ protected HttpResponse performRestGet(String bucketName, String objectKey, Map<String, String> requestParameters, Map<String, Object> requestHeaders, int[] expectedStatusCodes) throws ServiceException { HttpUriRequest httpMethod = setupConnection( HTTP_METHOD.GET, bucketName, objectKey, requestParameters); // Add all request headers. addRequestHeadersToConnection(httpMethod, requestHeaders); return performRequest(httpMethod, expectedStatusCodes); }
/** * Performs an HTTP HEAD request using the {@link #performRequest} method. * * @param bucketName the bucket's name * @param objectKey the object's key name, may be null if the operation is on a bucket only. * @param requestParameters parameters to add to the request URL as GET params * @param requestHeaders headers to add to the request * @return the HTTP method object used to perform the request * @throws org.jets3t.service.ServiceException * */ protected HttpResponse performRestHead(String bucketName, String objectKey, Map<String, String> requestParameters, Map<String, Object> requestHeaders) throws ServiceException { HttpUriRequest httpMethod = setupConnection( HTTP_METHOD.HEAD, bucketName, objectKey, requestParameters); // Add all request headers. addRequestHeadersToConnection(httpMethod, requestHeaders); return performRequest(httpMethod, new int[]{200}); }
/** * Performs an HTTP GET request using the {@link #performRequest} method. * * @param bucketName the bucket's name * @param objectKey the object's key name, may be null if the operation is on a bucket only. * @param requestParameters parameters to add to the request URL as GET params * @param requestHeaders headers to add to the request * @param expectedStatusCodes HTTP status response codes expected, anything else causes an exception. * @return The HTTP method object used to perform the request. * @throws org.jets3t.service.ServiceException * */ protected HttpResponse performRestGet(String bucketName, String objectKey, Map<String, String> requestParameters, Map<String, Object> requestHeaders, int[] expectedStatusCodes) throws ServiceException { HttpUriRequest httpMethod = setupConnection( HTTP_METHOD.GET, bucketName, objectKey, requestParameters); // Add all request headers. addRequestHeadersToConnection(httpMethod, requestHeaders); return performRequest(httpMethod, expectedStatusCodes); }
/** * Performs an HTTP DELETE request using the {@link #performRequest} method. * * @param bucketName the bucket's name * @param objectKey the object's key name, may be null if the operation is on a bucket only. * @return The HTTP method object used to perform the request. * @throws org.jets3t.service.ServiceException * */ protected HttpResponse performRestDelete(String bucketName, String objectKey, Map<String, String> requestParameters, String multiFactorSerialNumber, String multiFactorAuthCode) throws ServiceException { HttpUriRequest httpMethod = setupConnection( HTTP_METHOD.DELETE, bucketName, objectKey, requestParameters); // Set Multi-Factor Serial Number and Authentication code if provided. if(multiFactorSerialNumber != null || multiFactorAuthCode != null) { httpMethod.setHeader(Constants.AMZ_MULTI_FACTOR_AUTH_CODE, multiFactorSerialNumber + " " + multiFactorAuthCode); } HttpResponse result = performRequest(httpMethod, new int[]{204, 200}); // Release connection after DELETE (there's no response content) if(log.isDebugEnabled()) { log.debug("Releasing HttpMethod after delete"); } releaseConnection(result); return result; }
/** * Performs an HTTP DELETE request using the {@link #performRequest} method. * * @param bucketName the bucket's name * @param objectKey the object's key name, may be null if the operation is on a bucket only. * @return The HTTP method object used to perform the request. * @throws org.jets3t.service.ServiceException * */ protected HttpResponse performRestDelete(String bucketName, String objectKey, Map<String, String> requestParameters, String multiFactorSerialNumber, String multiFactorAuthCode) throws ServiceException { HttpUriRequest httpMethod = setupConnection( HTTP_METHOD.DELETE, bucketName, objectKey, requestParameters); // Set Multi-Factor Serial Number and Authentication code if provided. if(multiFactorSerialNumber != null || multiFactorAuthCode != null) { httpMethod.setHeader(Constants.AMZ_MULTI_FACTOR_AUTH_CODE, multiFactorSerialNumber + " " + multiFactorAuthCode); } HttpResponse result = performRequest(httpMethod, new int[]{204, 200}); // Release connection after DELETE (there's no response content) if(log.isDebugEnabled()) { log.debug("Releasing HttpMethod after delete"); } releaseConnection(result); return result; }
/** * Sets an object's ACL details using a pre-signed PUT URL generated for that object. * This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}. * * @param signedAclUrl a signed URL generated with {@link org.jets3t.service.S3Service#createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)}. * @param acl the ACL settings to apply to the object represented by the signed URL. * @throws org.jets3t.service.ServiceException * */ public void putObjectAclWithSignedUrl(String signedAclUrl, AccessControlList acl) throws ServiceException { HttpPut putMethod = new HttpPut(signedAclUrl); if(acl != null) { String restHeaderAclValue = acl.getValueForRESTHeaderACL(); if(restHeaderAclValue != null) { putMethod.addHeader(this.getRestHeaderPrefix() + "acl", restHeaderAclValue); } else { String aclAsXml = acl.toXml(); putMethod.setEntity(new StringEntity( aclAsXml, ContentType.create("text/plain", Constants.DEFAULT_ENCODING))); } } HttpResponse httpResponse = performRequest(putMethod, new int[]{200}); // Consume response data and release connection. releaseConnection(httpResponse); }
/** * Sets an object's ACL details using a pre-signed PUT URL generated for that object. * This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}. * * @param signedAclUrl a signed URL generated with {@link org.jets3t.service.S3Service#createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)}. * @param acl the ACL settings to apply to the object represented by the signed URL. * @throws org.jets3t.service.ServiceException * */ public void putObjectAclWithSignedUrl(String signedAclUrl, AccessControlList acl) throws ServiceException { HttpPut putMethod = new HttpPut(signedAclUrl); if(acl != null) { String restHeaderAclValue = acl.getValueForRESTHeaderACL(); if(restHeaderAclValue != null) { putMethod.addHeader(this.getRestHeaderPrefix() + "acl", restHeaderAclValue); } else { String aclAsXml = acl.toXml(); putMethod.setEntity(new StringEntity( aclAsXml, ContentType.create("text/plain", Constants.DEFAULT_ENCODING))); } } HttpResponse httpResponse = performRequest(putMethod, new int[]{200}); // Consume response data and release connection. releaseConnection(httpResponse); }
/** * Gets an object's ACL details using a pre-signed GET URL generated for that object. * This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}. * * @param signedAclUrl a signed URL generated with {@link org.jets3t.service.S3Service#createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)}. * @return the AccessControlList settings of the object in S3. * @throws org.jets3t.service.ServiceException * */ public AccessControlList getObjectAclWithSignedUrl(String signedAclUrl) throws ServiceException { HttpGet httpMethod = new HttpGet(signedAclUrl); HttpResponse httpResponse = performRequest(httpMethod, new int[]{200}); return getXmlResponseSaxParser() .parseAccessControlListResponse( new HttpMethodReleaseInputStream(httpResponse)).getAccessControlList(); }
/** * Gets an object's ACL details using a pre-signed GET URL generated for that object. * This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}. * * @param signedAclUrl a signed URL generated with {@link org.jets3t.service.S3Service#createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)}. * @return the AccessControlList settings of the object in S3. * @throws org.jets3t.service.ServiceException * */ public AccessControlList getObjectAclWithSignedUrl(String signedAclUrl) throws ServiceException { HttpGet httpMethod = new HttpGet(signedAclUrl); HttpResponse httpResponse = performRequest(httpMethod, new int[]{200}); return getXmlResponseSaxParser() .parseAccessControlListResponse( new HttpMethodReleaseInputStream(httpResponse)).getAccessControlList(); }
HttpResponse result = performRequest(postMethod, new int[]{200});
HttpResponse result = performRequest(postMethod, new int[]{200});
HttpResponse httpResponse = performRequest(httpMethod, new int[]{200});
HttpResponse result = performRequest(httpMethod, new int[]{200, 204});
HttpResponse result = performRequest(httpMethod, new int[]{200, 204});
HttpResponse httpResponse = performRequest(httpMethod, new int[]{200});