throw new AdminProcessingException(IntegrationPlugin.Util.getString("vdb_not_found", vdbName, vdbVersion)); //$NON-NLS-1$
}
ManagedProperty mp = mc.getProperty("dataPolicies");//$NON-NLS-1$
List<ManagedObject> policies = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(mp.getValue());
ManagedObject managedPolicy = null;
if (policies != null && !policies.isEmpty()) {
for(ManagedObject mo:policies) {
String name = ManagedUtil.getSimpleValue(mo, "name", String.class); //$NON-NLS-1$
if (policyName.equals(name)) {
managedPolicy = mo;
}
}
}
if (managedPolicy == null) {
throw new AdminProcessingException(IntegrationPlugin.Util.getString("policy_not_found", policyName, vdbName, vdbVersion)); //$NON-NLS-1$
}
if (role != null) {
ManagedProperty mappedRoleNames = managedPolicy.getProperty("mappedRoleNames");//$NON-NLS-1$
CollectionValueSupport roleCollection = (CollectionValueSupport)mappedRoleNames.getValue();
ArrayList<MetaValue> modifiedRoleNames = new ArrayList<MetaValue>();
if (roleCollection != null) {
MetaValue[] roleNames = roleCollection.getElements();
for (MetaValue mv:roleNames) {
String existing = (String)((SimpleValueSupport)mv).getValue();
if (!existing.equals(role)) {
modifiedRoleNames.add(mv);
}
}
}
else {
roleCollection = new CollectionValueSupport(new CollectionMetaType("java.util.List", SimpleMetaType.STRING)); //$NON-NLS-1$
mappedRoleNames.setValue(roleCollection);
}
if (add) {
modifiedRoleNames.add(ManagedUtil.wrap(SimpleMetaType.STRING, role));
}
roleCollection.setElements(modifiedRoleNames.toArray(new MetaValue[modifiedRoleNames.size()]));
} else {
ManagedProperty anyAuthenticated = managedPolicy.getProperty("anyAuthenticated");//$NON-NLS-1$
anyAuthenticated.setValue(SimpleValueSupport.wrap(add));
}
try {
getView().updateComponent(mc);