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