Search in sources :

Example 1 with ServiceSchemaModificationWrapper

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();
}
Also used : ServiceSchemaModificationWrapper(org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper) SchemaUpgradeWrapper(org.forgerock.openam.upgrade.SchemaUpgradeWrapper) ServiceSchemaUpgradeWrapper(org.forgerock.openam.upgrade.ServiceSchemaUpgradeWrapper) SubSchemaUpgradeWrapper(org.forgerock.openam.upgrade.SubSchemaUpgradeWrapper) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ServiceSchemaModificationWrapper

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;
}
Also used : ServiceSchemaModificationWrapper(org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper) Set(java.util.Set) HashSet(java.util.HashSet) HashSet(java.util.HashSet)

Example 3 with ServiceSchemaModificationWrapper

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;
}
Also used : ServiceSchemaModificationWrapper(org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper) Set(java.util.Set) HashSet(java.util.HashSet) HashSet(java.util.HashSet)

Example 4 with ServiceSchemaModificationWrapper

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());
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceSchemaModificationWrapper(org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper) ServiceSchemaUpgradeWrapper(org.forgerock.openam.upgrade.ServiceSchemaUpgradeWrapper) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ServiceSchemaModificationWrapper

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;
}
Also used : ServiceSchemaModificationWrapper(org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper) Set(java.util.Set) HashSet(java.util.HashSet) HashSet(java.util.HashSet)

Aggregations

ServiceSchemaModificationWrapper (org.forgerock.openam.upgrade.ServiceSchemaModificationWrapper)6 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 Set (java.util.Set)3 ServiceSchemaUpgradeWrapper (org.forgerock.openam.upgrade.ServiceSchemaUpgradeWrapper)2 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)2 NewServiceWrapper (org.forgerock.openam.upgrade.NewServiceWrapper)1 SchemaUpgradeWrapper (org.forgerock.openam.upgrade.SchemaUpgradeWrapper)1 SubSchemaUpgradeWrapper (org.forgerock.openam.upgrade.SubSchemaUpgradeWrapper)1