Search in sources :

Example 1 with UpgradeHelper

use of org.forgerock.openam.upgrade.UpgradeHelper in project OpenAM by OpenRock.

the class ServiceSchemaModifications method getAttributesAdded.

private Set<AttributeSchemaImpl> getAttributesAdded(Set<AttributeSchemaImpl> newAttrs, Set<AttributeSchemaImpl> existingAttrs) throws UpgradeException {
    Set<AttributeSchemaImpl> attrAdded = new HashSet<AttributeSchemaImpl>();
    for (AttributeSchemaImpl newAttr : newAttrs) {
        boolean found = false;
        for (AttributeSchemaImpl existingAttr : existingAttrs) {
            if (newAttr.getName().equals(existingAttr.getName())) {
                found = true;
            }
        }
        if (!found) {
            UpgradeHelper serviceHelper = ServerUpgrade.getServiceHelper(serviceName);
            if (serviceHelper != null) {
                newAttr = serviceHelper.addNewAttribute(existingAttrs, newAttr);
            }
            attrAdded.add(newAttr);
        }
    }
    return attrAdded;
}
Also used : UpgradeHelper(org.forgerock.openam.upgrade.UpgradeHelper) HashSet(java.util.HashSet)

Example 2 with UpgradeHelper

use of org.forgerock.openam.upgrade.UpgradeHelper in project OpenAM by OpenRock.

the class ServiceSchemaModifications method getAttributesModified.

private Set<AttributeSchemaImpl> getAttributesModified(Set<AttributeSchemaImpl> newAttrs, Set<AttributeSchemaImpl> existingAttrs) throws UpgradeException {
    Set<AttributeSchemaImpl> attrMods = new HashSet<AttributeSchemaImpl>();
    for (AttributeSchemaImpl newAttr : newAttrs) {
        // skip attributes that are not explicitly named for upgrade
        if (ServerUpgrade.getServiceHelper(serviceName) == null || !ServerUpgrade.getServiceHelper(serviceName).getAttributes().contains(newAttr.getName())) {
            continue;
        }
        for (AttributeSchemaImpl existingAttr : existingAttrs) {
            if (!existingAttr.getName().equals(newAttr.getName())) {
                continue;
            }
            try {
                UpgradeHelper helper = ServerUpgrade.getServiceHelper(serviceName);
                AttributeSchemaImpl upgradedAttr = helper.upgradeAttribute(existingAttr, newAttr);
                if (upgradedAttr != null) {
                    attrMods.add(upgradedAttr);
                }
            } catch (UpgradeException ue) {
                UpgradeUtils.debug.error("Unable to process upgrade helper", ue);
                throw ue;
            }
        }
    }
    return attrMods;
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) UpgradeHelper(org.forgerock.openam.upgrade.UpgradeHelper) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 UpgradeHelper (org.forgerock.openam.upgrade.UpgradeHelper)2 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)1