private Collection<Permission> getPermissions(cfSession _session, cfStructData cc) throws cfmRunTimeException { List<Permission> permissions = new LinkedList<Permission>(); if (!cc.containsKey("permissions")) return permissions; cfArrayData arr = (cfArrayData) cc.getData("permissions"); for (int x = 0; x < arr.size(); x++) { cfStructData cs = (cfStructData) arr.getData(x + 1); Permission p = new Permission(); p.setGranteeType(cs.getData("granteetype").getString()); p.setGrantee(cs.getData("grantee").getString()); cfArrayData access = (cfArrayData) cs.getData("access"); List<String> accessList = new LinkedList<String>(); for (int a = 0; a < access.size(); a++) { accessList.add(access.getData(a + 1).getString()); } p.setAccess(accessList); permissions.add(p); } return permissions; }
public Permission unmarshall(JsonUnmarshallerContext context) throws Exception { Permission permission = new Permission(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) return null; while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("GranteeType", targetDepth)) { context.nextToken(); permission.setGranteeType(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.testExpression("Grantee", targetDepth)) { context.nextToken(); permission.setGrantee(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.testExpression("Access", targetDepth)) { context.nextToken(); permission.setAccess( new ListUnmarshaller<String>(context.getUnmarshaller(String.class)) .unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return permission; }
/** * The AWS user or group that you want to have access to transcoded files and playlists. To * identify the user or group, you can specify the canonical user ID for an AWS account, an origin * access identity for a CloudFront distribution, the registered email address of an AWS account, * or a predefined Amazon S3 group. * * @param grantee The AWS user or group that you want to have access to transcoded files and * playlists. To identify the user or group, you can specify the canonical user ID for an AWS * account, an origin access identity for a CloudFront distribution, the registered email * address of an AWS account, or a predefined Amazon S3 group. * @return Returns a reference to this object so that method calls can be chained together. */ public Permission withGrantee(String grantee) { setGrantee(grantee); return this; }