Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

100261: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      100252: Merged 5.0.1 (5.0.1) to 5.0.N (5.0.2)
         99925: MNT-13677:  Added model validation to make sure the model cannot be deleted/deactivated when its types/aspects are parent to other models� types/aspects.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@100570 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-03-27 23:15:36 +00:00
parent e72f8ed937
commit e19772b892

View File

@@ -207,12 +207,44 @@ public class ModelValidatorImpl implements ModelValidator
for (TypeDefinition type : typeDefs)
{
validateClass(tenantDomain, type);
// check if the type of the model being deleted/deactivated is the parent of another model's type
Collection<QName> subTypes = dictionaryDAO.getSubTypes(type.getName(), false);
if (subTypes.size() > 0)
{
QName ModelBeingValidated = type.getModel().getName();
for(QName typeName : subTypes)
{
ModelDefinition dependantModel = dictionaryDAO.getType(typeName).getModel();
// ignore type dependency check within the model itself
if (!ModelBeingValidated.equals(dependantModel.getName()))
{
throw new AlfrescoRuntimeException("Failed to validate model delete/deactivate. Model's type '" + type.getName().toPrefixString() + "' is the parent of type '" + typeName.toPrefixString() + "' within model '" + dependantModel.getName().getLocalName() + "'.");
}
}
}
}
// check for aspect usages
for (AspectDefinition aspect : aspectDefs)
{
validateClass(tenantDomain, aspect);
// check if the aspect of the model being deleted/deactivated is the parent of another model's aspect
Collection<QName> subAspects = dictionaryDAO.getSubAspects(aspect.getName(), false);
if (subAspects.size() > 0)
{
QName ModelBeingValidated = aspect.getModel().getName();
for(QName aspectName : subAspects)
{
ModelDefinition dependantModel = dictionaryDAO.getAspect(aspectName).getModel();
// ignore aspect dependency check within the model itself
if (!ModelBeingValidated.equals(dependantModel.getName()))
{
throw new AlfrescoRuntimeException("Failed to validate model delete/deactivate. Model's aspect '" + aspect.getName().toPrefixString() + "' is the parent of aspect '" + aspectName.toPrefixString() + "' within model '" + dependantModel.getName().getLocalName() + "'.");
}
}
}
}
}