mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
127393 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1) 127370 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 127309 aleahu: MNT-14332 : Alfresco stops working when Type Hierarchy creates a circular reference - added validation to check if circular dependency was introduced when a new namespace is imported git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127885 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -45,6 +46,7 @@ import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.NamespaceDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
@@ -71,6 +73,7 @@ public class ModelValidatorImpl implements ModelValidator
|
||||
private static final Log logger = LogFactory.getLog(ModelValidatorImpl.class);
|
||||
|
||||
private DictionaryDAO dictionaryDAO;
|
||||
private DictionaryService dictionaryService;
|
||||
private QNameDAO qnameDAO;
|
||||
private NamespaceService namespaceService;
|
||||
private TransactionService transactionService;
|
||||
@@ -119,6 +122,11 @@ public class ModelValidatorImpl implements ModelValidator
|
||||
this.tenantAdminService = tenantAdminService;
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
private void checkCustomModelNamespace(M2Model model, String tenantDomain)
|
||||
{
|
||||
if(tenantDomain != null && !tenantDomain.equals("") && enforceTenantInNamespace)
|
||||
@@ -477,8 +485,37 @@ public class ModelValidatorImpl implements ModelValidator
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to validate model update - found non-incrementally updated " + modelDiff.getElementType() + " '" + modelDiff.getElementName() + "'");
|
||||
}
|
||||
|
||||
if(modelDiff.getDiffType().equals(M2ModelDiff.DIFF_CREATED))
|
||||
{
|
||||
if (modelDiff.getElementType().equals(M2ModelDiff.TYPE_NAMESPACE))
|
||||
{
|
||||
ModelDefinition importedModel = dictionaryService.getModelByNamespaceUri(modelDiff.getNamespaceDefinition().getUri());
|
||||
if(importedModel != null && !model.getNamespaces().isEmpty())
|
||||
{
|
||||
checkCircularDependency(importedModel, model, importedModel.getName().getLocalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO validate that any deleted constraints are not being referenced - else currently will become anon - or push down into model compilation (check backwards compatibility ...)
|
||||
}
|
||||
|
||||
private void checkCircularDependency(ModelDefinition model, M2Model existingModel, String parentPrefixedName) throws AlfrescoRuntimeException
|
||||
{
|
||||
for (NamespaceDefinition importedNamespace : model.getImportedNamespaces())
|
||||
{
|
||||
ModelDefinition md = null;
|
||||
if ((md = dictionaryService.getModelByNamespaceUri(importedNamespace.getUri())) != null)
|
||||
{
|
||||
if (existingModel.getNamespace(importedNamespace.getUri()) != null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to validate model update - found circular dependency. You can't set parent " + parentPrefixedName + " as it's model already depends on " + existingModel.getName());
|
||||
}
|
||||
checkCircularDependency(md, existingModel, parentPrefixedName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user