mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
127371 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 127311 aleahu: MNT-14332 : Alfresco stops working when Type Hierarchy creates a circular reference - fixed compilation error git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127394 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1142,8 +1142,59 @@ public class DictionaryModelTypeTest extends BaseSpringTest
|
||||
// Delete the model
|
||||
DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* MNT-15345 test */
|
||||
public void testImportingSameNamespaceFailsWithinSingleModel() throws Exception
|
||||
{
|
||||
// Create model
|
||||
txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
PropertyMap properties = new PropertyMap(1);
|
||||
properties.put(ContentModel.PROP_MODEL_ACTIVE, true);
|
||||
final NodeRef modelNode = this.nodeService.createNode(
|
||||
this.rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"),
|
||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||
properties).getChildRef();
|
||||
assertNotNull(modelNode);
|
||||
txn.commit();
|
||||
|
||||
// update model to introduce self referencing dependency
|
||||
try
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
|
||||
public Void execute() throws Exception {
|
||||
|
||||
ContentWriter contentWriter = contentService.getWriter(modelNode, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
contentWriter.putContent(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary/modelWithCurrentNamespaceImported.xml"));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("Validation should fail as a circular dependency was introduced");
|
||||
} catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
assertTrue(e.getCause().getMessage().contains("URI http://www.alfresco.org/model/dictionary/1.0 cannot be imported as it is already contained in the model's namespaces"));
|
||||
}
|
||||
|
||||
//delete model
|
||||
finally
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionCallback<Object>() {
|
||||
public Object execute() throws Exception {
|
||||
// Delete the model
|
||||
DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void testCircularDependencyDetected() throws Exception
|
||||
@@ -1225,73 +1276,3 @@ public class DictionaryModelTypeTest extends BaseSpringTest
|
||||
return modelNode;
|
||||
}
|
||||
}
|
||||
|
||||
/* MNT-15345 test */
|
||||
public void testImportingSameNamespaceFailsWithinSingleModel() throws Exception
|
||||
{
|
||||
// Create model
|
||||
txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
PropertyMap properties = new PropertyMap(1);
|
||||
properties.put(ContentModel.PROP_MODEL_ACTIVE, true);
|
||||
final NodeRef modelNode = this.nodeService.createNode(
|
||||
this.rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"),
|
||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||
properties).getChildRef();
|
||||
assertNotNull(modelNode);
|
||||
txn.commit();
|
||||
|
||||
// update model to introduce self referencing dependency
|
||||
try
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
|
||||
public Void execute() throws Exception {
|
||||
|
||||
ContentWriter contentWriter = contentService.getWriter(modelNode, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
contentWriter.putContent(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary/modelWithCurrentNamespaceImported.xml"));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("Validation should fail as a circular dependency was introduced");
|
||||
} catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
assertTrue(e.getCause().getMessage().contains("URI http://www.alfresco.org/model/dictionary/1.0 cannot be imported as it is already contained in the model's namespaces"));
|
||||
}
|
||||
|
||||
//delete model
|
||||
finally
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionCallback<Object>() {
|
||||
public Object execute() throws Exception {
|
||||
// Delete the model
|
||||
DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private NodeRef createActiveModel(String contentFile)
|
||||
{
|
||||
PropertyMap properties = new PropertyMap(1);
|
||||
properties.put(ContentModel.PROP_MODEL_ACTIVE, true);
|
||||
NodeRef modelNode = this.nodeService.createNode(
|
||||
this.rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"),
|
||||
ContentModel.TYPE_DICTIONARY_MODEL,
|
||||
properties).getChildRef();
|
||||
assertNotNull(modelNode);
|
||||
|
||||
ContentWriter contentWriter = this.contentService.getWriter(modelNode, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
contentWriter.putContent(Thread.currentThread().getContextClassLoader().getResourceAsStream(contentFile));
|
||||
return modelNode;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user