mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged WEBAPP-API (5.2.1) to 5.2.N (5.2.1)
132578 jkaabimofrad: APPSREPO-59: Modified the model validator to ignore the TYPE_NAMESPACE when there is a DIFF_DELETED type. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@132589 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.dictionary;
|
package org.alfresco.repo.dictionary;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -477,7 +476,16 @@ public class ModelValidatorImpl implements ModelValidator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to validate model update - found deleted " + modelDiff.getElementType() + " '" + modelDiff.getElementName() + "'");
|
/*
|
||||||
|
* As the M2Model#compile method will detect and throw exception for any missing namespace which
|
||||||
|
* is required to define any Type, Aspect or Property, we can safely add this extra check.
|
||||||
|
* See APPSREPO-59 comment for details.
|
||||||
|
*/
|
||||||
|
if (!modelDiff.getElementType().equals(M2ModelDiff.TYPE_NAMESPACE))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Failed to validate model update - found deleted " + modelDiff.getElementType() + " '" + modelDiff
|
||||||
|
.getElementName() + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@ import org.alfresco.repo.domain.qname.QNameDAO;
|
|||||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
@@ -50,6 +51,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -102,6 +104,12 @@ public class ModelValidatorTest
|
|||||||
addModel();
|
addModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void cleanUp()
|
||||||
|
{
|
||||||
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
|
}
|
||||||
|
|
||||||
private QName addModel()
|
private QName addModel()
|
||||||
{
|
{
|
||||||
this.testNamespace = "http://www.alfresco.org/test/" + modelName;
|
this.testNamespace = "http://www.alfresco.org/test/" + modelName;
|
||||||
@@ -449,4 +457,54 @@ public class ModelValidatorTest
|
|||||||
};
|
};
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(deleteModelAgainCallback, false, true);
|
transactionService.getRetryingTransactionHelper().doInTransaction(deleteModelAgainCallback, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that an unused imported namespace can be deleted.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDeleteNamespace() throws Exception
|
||||||
|
{
|
||||||
|
// authenticate
|
||||||
|
AuthenticationUtil.pushAuthentication();
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
|
// Remove the only property (created in setup method)
|
||||||
|
this.type.removeProperty(this.property.getName());
|
||||||
|
// We don't have any property that references the imported dictionary namespace, so remove it.
|
||||||
|
this.model.removeImport(NamespaceService.DICTIONARY_MODEL_1_0_URI);
|
||||||
|
|
||||||
|
// Check that it compiles
|
||||||
|
CompiledModel compiledModel = model.compile(dictionaryDAO, namespaceDAO, true);
|
||||||
|
modelValidator.validateModel(compiledModel);
|
||||||
|
|
||||||
|
// Remove the imported content model namespace
|
||||||
|
this.model.removeImport(NamespaceService.CONTENT_MODEL_1_0_URI);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
model.compile(dictionaryDAO, namespaceDAO, true);
|
||||||
|
fail("Should have failed as the model's type references the content model (cm:folder).");
|
||||||
|
}
|
||||||
|
catch (DictionaryException dx)
|
||||||
|
{
|
||||||
|
//expected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the content model namespace back
|
||||||
|
model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
|
||||||
|
model.compile(dictionaryDAO, namespaceDAO, true);
|
||||||
|
|
||||||
|
// Remove the defined namespace
|
||||||
|
this.model.removeNamespace(testNamespace);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
model.compile(dictionaryDAO, namespaceDAO, true);
|
||||||
|
fail("Should have failed as the type's name references the namespace.");
|
||||||
|
}
|
||||||
|
catch (DictionaryException dx)
|
||||||
|
{
|
||||||
|
//expected
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user