/** * @return true if this ACL can be set via an HTTP header, rather than via an XML document. */ public boolean isRESTHeaderACL() { return getValueForRESTHeaderACL() != null; }
/** * @return true if this ACL can be set via an HTTP header, rather than via an XML document. */ public boolean isRESTHeaderACL() { return getValueForRESTHeaderACL() != null; }
/** * Set the object's ACL. If a pre-canned REST ACL is used, the plain-text representation * of the canned ACL is also added as a metadata header <code>x-amz-acl</code>. * * @param acl */ @Override public void setAcl(AccessControlList acl) { this.acl = acl; if (acl != null) { String restHeaderAclValue = acl.getValueForRESTHeaderACL(); if (restHeaderAclValue != null) { addMetadata(Constants.REST_HEADER_PREFIX + "acl", restHeaderAclValue); } else { // Non-REST canned ACLs are not added as headers... } } }
/** * Prepares the metadata with the given ACL * an ACL is provided and can be represented with a HTTP header. * * @param metadata Metadata request headers * @param acl Access control list * @return true if no acl or standard, false otherwise * false if an ACL was provided but it could not be applied as a canned ACL. */ protected boolean prepareRESTHeaderAcl(Map<String, Object> metadata, AccessControlList acl) { if(metadata == null) { throw new IllegalArgumentException("Null metadata not allowed."); } if(acl != null) { String restHeaderAclValue = acl.getValueForRESTHeaderACL(); if(restHeaderAclValue != null) { metadata.put(this.getRestHeaderPrefix() + "acl", restHeaderAclValue); } else { return false; } } return true; }
/** * Set the object's ACL. If a pre-canned REST ACL is used, the plain-text representation * of the canned ACL is also added as a metadata header <code>x-amz-acl</code>. * * @param acl */ @Override public void setAcl(AccessControlList acl) { this.acl = acl; if (acl != null) { String restHeaderAclValue = acl.getValueForRESTHeaderACL(); if (restHeaderAclValue != null) { addMetadata(Constants.REST_HEADER_PREFIX + "acl", restHeaderAclValue); } else { // Non-REST canned ACLs are not added as headers... } } }
/** * Prepares the metadata with the given ACL * an ACL is provided and can be represented with a HTTP header. * * @param metadata Metadata request headers * @param acl Access control list * @return true if no acl or standard, false otherwise * false if an ACL was provided but it could not be applied as a canned ACL. */ protected boolean prepareRESTHeaderAcl(Map<String, Object> metadata, AccessControlList acl) { if(metadata == null) { throw new IllegalArgumentException("Null metadata not allowed."); } if(acl != null) { String restHeaderAclValue = acl.getValueForRESTHeaderACL(); if(restHeaderAclValue != null) { metadata.put(this.getRestHeaderPrefix() + "acl", restHeaderAclValue); } else { return false; } } return true; }
/** * 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); }
&& object.getAcl().getValueForRESTHeaderACL() == null)
&& object.getAcl().getValueForRESTHeaderACL() == null)