Search in sources :

Example 1 with EntitlementCombiner

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);
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) ApplicationType(com.sun.identity.entitlement.ApplicationType) Application(com.sun.identity.entitlement.Application) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap) EntitlementCombiner(com.sun.identity.entitlement.EntitlementCombiner) DenyOverride(com.sun.identity.entitlement.DenyOverride)

Aggregations

Application (com.sun.identity.entitlement.Application)1 ApplicationType (com.sun.identity.entitlement.ApplicationType)1 DenyOverride (com.sun.identity.entitlement.DenyOverride)1 EntitlementCombiner (com.sun.identity.entitlement.EntitlementCombiner)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 EntitlementUtils.resourceTypeFromMap (org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1