private Grant[] convertACLtoGrants(AccessControlList acl) throws S3ServiceException {
if (acl == null) {
return null;
}
if (acl.isCannedRestACL()) {
throw new S3ServiceException("Cannot use canned REST ACLs with SOAP service");
}
Grant[] grants = new Grant[acl.getGrants().size()];
Iterator grantIter = acl.getGrants().iterator();
int index = 0;
while (grantIter.hasNext()) {
GrantAndPermission jets3tGaP = (GrantAndPermission) grantIter.next();
GranteeInterface jets3tGrantee = jets3tGaP.getGrantee();
Grant grant = new Grant();
if (jets3tGrantee instanceof GroupGrantee) {
GroupGrantee groupGrantee = (GroupGrantee) jets3tGrantee;
Group group = new Group();
group.setURI(groupGrantee.getIdentifier());
grant.setGrantee(group);
} else if (jets3tGrantee instanceof CanonicalGrantee) {
CanonicalGrantee canonicalGrantee = (CanonicalGrantee) jets3tGrantee;
CanonicalUser canonicalUser = new CanonicalUser();
canonicalUser.setID(canonicalGrantee.getIdentifier());
canonicalUser.setDisplayName(canonicalGrantee.getDisplayName());
grant.setGrantee(canonicalUser);
} else if (jets3tGrantee instanceof EmailAddressGrantee) {
EmailAddressGrantee emailGrantee = (EmailAddressGrantee) jets3tGrantee;
AmazonCustomerByEmail customerByEmail = new AmazonCustomerByEmail();
customerByEmail.setEmailAddress(emailGrantee.getIdentifier());
grant.setGrantee(customerByEmail);
} else {
throw new S3ServiceException("Unrecognised jets3t grantee type: "
+ jets3tGrantee.getClass());
}
Permission permission = Permission.fromString(jets3tGaP.getPermission().toString());
grant.setPermission(permission);
grants[index++] = grant;