use of com.sun.identity.entitlement.EntitlementCombiner in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method initialize.
@Override
public void initialize() throws UpgradeException {
DEBUG.message("Initialising the upgrade entitlement sub-config step");
final Set<ApplicationType> existingApplicationTypes = entitlementService.getApplicationTypes();
final Set<String> existingResourceTypeUUIDs = getResourceTypeUUIDs(ROOT_REALM);
final Set<String> presentTypes = extract(existingApplicationTypes, new TypeNameExtractor());
final Set<String> presentApps = extract(entitlementService.getApplications(), new AppNameExtractor());
final Document entitlementDoc = getEntitlementXML();
final NodeList subConfigs = entitlementDoc.getElementsByTagName(SMSUtils.SUB_CONFIG);
for (int idx = 0; idx < subConfigs.getLength(); idx++) {
final Node subConfig = subConfigs.item(idx);
final String id = getNodeAttributeValue(subConfig, ID);
final String name = getNodeAttributeValue(subConfig, NAME);
if (APPLICATION_TYPE.equals(id)) {
captureMissingEntry(name, subConfig, presentTypes, missingApplicationTypes);
captureMissingActions(name, subConfig);
} else if (APPLICATION.equals(id)) {
captureMissingEntry(name, subConfig, presentApps, missingApps);
//app will be null if application needs to be created (see missing entries)
final Application app = getApplication(name);
final Map<String, Set<String>> subConfigAttrs = parseAttributeValuePairTags(subConfig);
captureDifferentSet(app == null ? null : app.getSubjects(), getSubjects(subConfigAttrs), changedSubjects, name);
captureDifferentSet(app == null ? null : app.getConditions(), getConditions(subConfigAttrs), changedConditions, name);
captureDifferentSet(app == null ? null : app.getResourceTypeUuids(), EntitlementUtils.getResourceTypeUUIDs(subConfigAttrs), changedResourceTypeUUIDs, name);
Set<String> configDescriptionSet = getDescription(subConfigAttrs);
String configDescription = null;
if (configDescriptionSet != null && !configDescriptionSet.isEmpty()) {
configDescription = configDescriptionSet.iterator().next();
}
captureDifferentString(app == null ? null : app.getDescription(), configDescription, changedDescriptions, name);
final EntitlementCombiner combiner = (app == null ? null : app.getEntitlementCombiner());
captureDifferentEntitlementCombiner(combiner == null ? null : combiner.getName(), getCombiner(subConfigAttrs), name);
} else if (RESOURCE_TYPE.equals(id)) {
// note that the name variable actually holds the UUID of the ResourceType
// the name is buried in the config.
//
captureMissingEntry(name, subConfig, existingResourceTypeUUIDs, missingResourceTypes);
}
}
}
Aggregations