ManagementView managementView = null;
ComponentType componentType = new ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE);
ManagedComponent managedComponent = null;
ManagedProperty anyAuthenticatedMp = null;
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(
((VDBComponent) this.resourceContext
.getParentResourceComponent()).name, componentType);
ManagedProperty mp = managedComponent.getProperty("dataPolicies");//$NON-NLS-1$
CollectionValueSupport dataRolesListMp = (CollectionValueSupport) mp
.getValue();
String name = resourceConfiguration.getSimpleValue("name", null); //$NON-NLS-1$
String anyAuthenticated = resourceConfiguration.getSimpleValue(
"anyAuthenticated", null); //$NON-NLS-1$
for (MetaValue val : dataRolesListMp.getElements()) {
GenericValueSupport genValueSupport = (GenericValueSupport) val;
ManagedObjectImpl managedObject = (ManagedObjectImpl) genValueSupport
.getValue();
for (String dataRolesProp : managedObject.getPropertyNames()) {
ManagedProperty property = managedObject
.getProperty(dataRolesProp);
String pname = ProfileServiceUtil.stringValue(managedObject
.getProperty("name").getValue()); //$NON-NLS-1$
if (!pname.equals(name)) {
continue;
}
anyAuthenticatedMp = managedObject
.getProperty("anyAuthenticated"); //$NON-NLS-1$
anyAuthenticatedMp.setValue(ProfileServiceUtil.wrap(
SimpleMetaType.BOOLEAN, anyAuthenticated));
List<Property> mappedRoleNamePropertyList = resourceConfiguration.getList("mappedRoleNameList").getList(); //$NON-NLS-1$
List<String> mappedRoleNameList = new ArrayList<String>();
for (Property mappedRoleNameProperty : mappedRoleNamePropertyList){
String mappedRoleNameString = ((PropertyMap)mappedRoleNameProperty).getSimpleValue("name", null); //$NON-NLS-1$
mappedRoleNameList.add(mappedRoleNameString);
}
ManagedProperty mappedRoleNameMp = managedObject.getProperty("mappedRoleNames"); //$NON-NLS-1$
mappedRoleNameMp.setValue(convertListOfStringsToMetaValue(mappedRoleNameList));
}
try {
managementView.updateComponent(managedComponent);
managementView.load();
} catch (Exception e) {
LOG.error("Unable to update component [" //$NON-NLS-1$
+ managedComponent.getName() + "] of type " //$NON-NLS-1$
+ componentType + ".", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
}