use of com.aliyun.oss.model.CannedAccessControlList in project aliyun-oss-java-sdk by aliyun.
the class ResponseParsers method parseGetBucketAcl.
/**
* Unmarshall get bucket acl response body to ACL.
*/
public static AccessControlList parseGetBucketAcl(InputStream responseBody) throws ResponseParseException {
try {
Element root = getXmlRootElement(responseBody);
AccessControlList acl = new AccessControlList();
String id = root.getChild("Owner").getChildText("ID");
String displayName = root.getChild("Owner").getChildText("DisplayName");
Owner owner = new Owner(id, displayName);
acl.setOwner(owner);
String aclString = root.getChild("AccessControlList").getChildText("Grant");
CannedAccessControlList cacl = CannedAccessControlList.parse(aclString);
acl.setCannedACL(cacl);
switch(cacl) {
case PublicRead:
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
break;
case PublicReadWrite:
acl.grantPermission(GroupGrantee.AllUsers, Permission.FullControl);
break;
default:
break;
}
return acl;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}
Aggregations