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;
}
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;
}
Aggregations