use of org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper in project OpenAM by OpenRock.
the class ServiceSchemaModifications method calculateSchemaChanges.
private boolean calculateSchemaChanges(Map<String, ServiceSchemaImpl> newSchemaMap, Map<String, ServiceSchemaImpl> existingSchemaMap) throws UpgradeException {
schemaModifications = new HashSet<SchemaUpgradeWrapper>();
for (Map.Entry<String, ServiceSchemaImpl> entry : newSchemaMap.entrySet()) {
String schemaName = entry.getKey();
ServiceSchemaImpl schema = entry.getValue();
if (!existingSchemaMap.containsKey(schemaName)) {
ServiceSchemaModificationWrapper newAttrs = new ServiceSchemaModificationWrapper(serviceName, schemaName, schema.getAttributeSchemas());
//NB: only schema additions are currently supported.
schemaModifications.add(new SchemaUpgradeWrapper(newAttrs));
}
}
return !schemaModifications.isEmpty();
}
use of org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper in project OpenAM by OpenRock.
the class ServiceSchemaModifications method getServiceAdditionsRecursive.
private ServiceSchemaModificationWrapper getServiceAdditionsRecursive(String schemaName, ServiceSchemaImpl newSchema, ServiceSchemaImpl existingSchema) throws SMSException, UpgradeException {
Set<AttributeSchemaImpl> attrsAdded = new HashSet<AttributeSchemaImpl>();
ServiceSchemaModificationWrapper attrAddedResult = new ServiceSchemaModificationWrapper(serviceName, schemaName);
if (newSchema.getAttributeSchemas() != null) {
attrsAdded = getAttributesAdded(newSchema.getAttributeSchemas(), existingSchema.getAttributeSchemas());
}
if (!(attrsAdded.isEmpty())) {
attrAddedResult.setAttributes(attrsAdded);
}
if (!newSchema.getSubSchemaNames().isEmpty()) {
for (String subSchemaName : (Set<String>) newSchema.getSubSchemaNames()) {
if (!(existingSchema.getSubSchemaNames().contains(subSchemaName))) {
// new sub schema so skip attribute checking
continue;
}
ServiceSchemaModificationWrapper subSchemaResult = getServiceAdditionsRecursive(subSchemaName, newSchema.getSubSchema(subSchemaName), existingSchema.getSubSchema(subSchemaName));
if (subSchemaResult.hasBeenModified()) {
attrAddedResult.addSubSchema(subSchemaName, subSchemaResult);
}
}
}
return attrAddedResult;
}
use of org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper in project OpenAM by OpenRock.
the class ServiceSchemaModifications method getServiceDeletionsRecursive.
private ServiceSchemaModificationWrapper getServiceDeletionsRecursive(String schemaName, ServiceSchemaImpl newSchema, ServiceSchemaImpl existingSchema) throws SMSException {
Set<AttributeSchemaImpl> attrsDeleted = new HashSet<AttributeSchemaImpl>();
ServiceSchemaModificationWrapper attrDeletedResult = new ServiceSchemaModificationWrapper(serviceName, schemaName);
;
if (newSchema.getAttributeSchemas() != null) {
attrsDeleted = getAttributesDeleted(newSchema.getAttributeSchemas(), existingSchema.getAttributeSchemas());
}
if (!(attrsDeleted.isEmpty())) {
attrDeletedResult.setAttributes(attrsDeleted);
}
if (!newSchema.getSubSchemaNames().isEmpty()) {
for (String subSchemaName : (Set<String>) newSchema.getSubSchemaNames()) {
if (!(existingSchema.getSubSchemaNames().contains(subSchemaName))) {
// new sub schema so skip attribute checking
continue;
}
ServiceSchemaModificationWrapper subSchemaResult = getServiceDeletionsRecursive(subSchemaName, newSchema.getSubSchema(subSchemaName), existingSchema.getSubSchema(subSchemaName));
if (subSchemaResult.hasBeenModified()) {
attrDeletedResult.addSubSchema(subSchemaName, subSchemaResult);
}
}
}
return attrDeletedResult;
}
use of org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper in project OpenAM by OpenRock.
the class ServiceSchemaModifications method calculateServiceModifications.
private boolean calculateServiceModifications(Map<String, ServiceSchemaImpl> newSchemaMap, Map<String, ServiceSchemaImpl> existingSchemaMap) throws UpgradeException {
modifications = new HashMap<String, ServiceSchemaUpgradeWrapper>();
try {
for (Map.Entry<String, ServiceSchemaImpl> newAttrSchemaEntry : newSchemaMap.entrySet()) {
ServiceSchemaImpl schema = existingSchemaMap.get(newAttrSchemaEntry.getKey());
if (schema == null) {
//calculateSchemaChanges
continue;
}
ServiceSchemaModificationWrapper attrsAdded = getServiceAdditionsRecursive(newAttrSchemaEntry.getKey(), newAttrSchemaEntry.getValue(), schema);
ServiceSchemaModificationWrapper attrsModified = getServiceModificationsRecursive(newAttrSchemaEntry.getKey(), newAttrSchemaEntry.getValue(), schema);
ServiceSchemaModificationWrapper attrsDeleted = getServiceDeletionsRecursive(newAttrSchemaEntry.getKey(), newAttrSchemaEntry.getValue(), schema);
if (attrsAdded.hasBeenModified() || attrsModified.hasBeenModified() || attrsDeleted.hasBeenModified()) {
modifications.put(newAttrSchemaEntry.getKey(), new ServiceSchemaUpgradeWrapper(attrsAdded, attrsModified, attrsDeleted));
}
}
} catch (SMSException smse) {
UpgradeUtils.debug.error("error whilst determining schema changes for service: " + serviceName, smse);
throw new UpgradeException(smse.getMessage());
}
if (UpgradeUtils.debug.messageEnabled()) {
UpgradeUtils.debug.message("calculateServiceModifications returning " + (!(modifications.isEmpty())));
}
return !(modifications.isEmpty());
}
use of org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper in project OpenAM by OpenRock.
the class ServiceSchemaModifications method getServiceModificationsRecursive.
private ServiceSchemaModificationWrapper getServiceModificationsRecursive(String schemaName, ServiceSchemaImpl newSchema, ServiceSchemaImpl existingSchema) throws SMSException, UpgradeException {
Set<AttributeSchemaImpl> attrsModified = new HashSet<AttributeSchemaImpl>();
ServiceSchemaModificationWrapper attrModifiedResult = new ServiceSchemaModificationWrapper(serviceName, schemaName);
if (newSchema.getAttributeSchemas() != null) {
attrsModified = getAttributesModified(newSchema.getAttributeSchemas(), existingSchema.getAttributeSchemas());
}
if (!(attrsModified.isEmpty())) {
attrModifiedResult.setAttributes(attrsModified);
}
if (!newSchema.getSubSchemaNames().isEmpty()) {
for (String subSchemaName : (Set<String>) newSchema.getSubSchemaNames()) {
if (!(existingSchema.getSubSchemaNames().contains(subSchemaName))) {
// new sub schema so skip attribute checking
continue;
}
ServiceSchemaModificationWrapper subSchemaResult = getServiceModificationsRecursive(subSchemaName, newSchema.getSubSchema(subSchemaName), existingSchema.getSubSchema(subSchemaName));
if (subSchemaResult.hasBeenModified()) {
attrModifiedResult.addSubSchema(subSchemaName, subSchemaResult);
}
}
}
return attrModifiedResult;
}
Aggregations