This is an example of invoking AuthorizationInfoInterface.setAuthorizations with a List of AuthorizationInfoInterface instances that represent permissions set for multiple IdentityInterface objects.
try
{
MetadataInterface object; // any Services-level MetadataInterface object type will work here (your code must fill this in)
AuthorizationUtilInterface authUtil = object.getAuthorizationUtil();
// Instance a List to contain MdAuthorizationInfo instances created below
List <AuthorizationInfoInterface>authInfoList = new ArrayList<AuthorizationInfoInterface>(2);
IdentityInterface identity1; // The first IdentityInterface for which permissions are being set (your code must set this Identity object value)
List <MdPermissionInfo>permInfoList1 = new ArrayList<MdPermissionInfo>(2);
permInfoList1.add(new PermissionInfo(
PermissionType.GRANT, PermissionInfoInterface.PERMISSION_READMETADATA ));
permInfoList1.add(new PermissionInfoInterfaceImpl(
PermissionType.DENY, PermissionInfoInterface.PERMISSION_WRITEMETADATA ));
authInfoList.add(new AuthorizationInfo(identity1, permInfoList1);
IdentityInterface identity2; // The second IdentityInterface for which permissions are being set (your code must set this Identity object value)
List <PermissionInfoInterface>permInfoList2 = new ArrayList<PermissionInfoInterface>(3);
permInfoList2.add(new PermissionInfo(
PermissionType.DENY, PermissionInfoInterface.PERMISSION_READ ));
permInfoList2.add(new PermissionInfo(
PermissionType.DENY, PermissionInfoInterface.PERMISSION_WRITE ));
permInfoList2.add(new PermissionInfo(
PermissionType.DENY, PermissionInfoInterface.PERMISSION_DELETE ));
authInfoList.add(new AuthorizationInfo(identity2, permInfoList2);
IdentityInterface identity3; // The third IdentityInterface for which permissions are being set (your code must set this Identity object value)
List <PermissionInfoInterface>permInfoList3 = new ArrayList<PermissionInfoInterface>(4);
permInfoList3.add(new PermissionInfo(
PermissionType.GRANT, PermissionInfoInterface.PERMISSION_CHECKINMETADATA ));
permInfoList3.add(new PermissionInfo(
PermissionType.GRANT, PermissionInfoInterface.PERMISSION_CREATE ));
permInfoList3.add(new PermissionInfo(
PermissionType.GRANT, PermissionInfoInterface.PERMISSION_ADMINISTER ));
permInfoList3.add(new PermissionInfo(
PermissionType.DENY, PermissionInfoInterface.PERMISSION_DELETE ));
authInfoList.add(new AuthorizationInfo(identity3, permInfoList3);
authUtil.setAuthorizations(authInfoList);
}
catch (ServiceException e)
{
e.printStackTrace();
}
catch (RemoteException e)
{
e.printStackTrace();
}