mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75759: Reverse Merge HEAD-BUG-FIX (5.0) 74605 : Reverse Merge HEAD-BUG-FIX (5.0) << Caused 1 build error https://bamboo.alfresco.com/bamboo/browse/THOR-CLOUD0-384 >> 74567 : Merged DEV to HEAD-BUG-FIX (5.0) 69634 : MNT-11339 : Unable to create relationship between cmis:document and cmis:item - TYPE_BASE is valid CMIS type 73710 : MNT-11339 : Unable to create relationship between cmis:document and cmis:item - Create association between cmis:document and cmis:item test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77545 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1305,9 +1305,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
String sourceId = connector.getSourceIdProperty(properties);
|
String sourceId = connector.getSourceIdProperty(properties);
|
||||||
CMISNodeInfo sourceInfo = getOrCreateNodeInfo(sourceId, "Source");
|
CMISNodeInfo sourceInfo = getOrCreateNodeInfo(sourceId, "Source");
|
||||||
|
|
||||||
if (!sourceInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !sourceInfo.isVariant(CMISObjectVariant.FOLDER))
|
if (!sourceInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !sourceInfo.isVariant(CMISObjectVariant.FOLDER) && !sourceInfo.isVariant(CMISObjectVariant.ITEM))
|
||||||
{
|
{
|
||||||
throw new CmisInvalidArgumentException("Source is not the latest version of a document or a folder object!");
|
throw new CmisInvalidArgumentException("Source is not the latest version of a document, a folder or an item object!");
|
||||||
}
|
}
|
||||||
|
|
||||||
final NodeRef sourceNodeRef = sourceInfo.getNodeRef();
|
final NodeRef sourceNodeRef = sourceInfo.getNodeRef();
|
||||||
@@ -1316,10 +1316,10 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
String targetId = connector.getTargetIdProperty(properties);
|
String targetId = connector.getTargetIdProperty(properties);
|
||||||
CMISNodeInfo targetInfo = getOrCreateNodeInfo(targetId, "Target");
|
CMISNodeInfo targetInfo = getOrCreateNodeInfo(targetId, "Target");
|
||||||
|
|
||||||
if (!targetInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !targetInfo.isVariant(CMISObjectVariant.FOLDER))
|
if (!targetInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !targetInfo.isVariant(CMISObjectVariant.FOLDER) && !targetInfo.isVariant(CMISObjectVariant.ITEM))
|
||||||
{
|
{
|
||||||
throw new CmisInvalidArgumentException(
|
throw new CmisInvalidArgumentException(
|
||||||
"Target is not the latest version of a document or a folder object!!");
|
"Target is not the latest version of a document, a folder or an item object!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
final NodeRef targetNodeRef = targetInfo.getNodeRef();
|
final NodeRef targetNodeRef = targetInfo.getNodeRef();
|
||||||
|
@@ -1705,6 +1705,110 @@ public class CMISTest
|
|||||||
}, CmisVersion.CMIS_1_1);
|
}, CmisVersion.CMIS_1_1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MNT-11339 related test :
|
||||||
|
* Unable to create relationship between cmis:document and cmis:item
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testItemRelations()
|
||||||
|
{
|
||||||
|
AuthenticationUtil.pushAuthentication();
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
|
final String TEST_NAME = "testItemRelations-";
|
||||||
|
final String FOLDER_NAME = TEST_NAME + "FOLDER" + GUID.generate();
|
||||||
|
final String DOCUMENT_NAME = TEST_NAME + "DOCUMENT" + GUID.generate();
|
||||||
|
final String CLIENT_NAME = "Some Test Client " + GUID.generate();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||||
|
new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
|
||||||
|
|
||||||
|
/* Create folder within companyHome */
|
||||||
|
FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, FOLDER_NAME, ContentModel.TYPE_FOLDER);
|
||||||
|
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, FOLDER_NAME);
|
||||||
|
assertNotNull(folderInfo);
|
||||||
|
|
||||||
|
// and document
|
||||||
|
FileInfo document = fileFolderService.create(folderInfo.getNodeRef(), DOCUMENT_NAME, ContentModel.TYPE_CONTENT);
|
||||||
|
assertNotNull(document);
|
||||||
|
nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, DOCUMENT_NAME);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
withCmisService(new CmisServiceCallback<String>() {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public String execute(CmisService cmisService) {
|
||||||
|
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||||
|
assertTrue(repositories.size() > 0);
|
||||||
|
RepositoryInfo repo = repositories.get(0);
|
||||||
|
String repositoryId = repo.getId();
|
||||||
|
|
||||||
|
// ensure there are custom type, aspect and association defined
|
||||||
|
TypeDefinition tpdfn = cmisService.getTypeDefinition(repositoryId, "I:sctst:client", null);
|
||||||
|
assertNotNull("the I:sctst:client type is not defined", tpdfn);
|
||||||
|
TypeDefinition aspectDfn = cmisService.getTypeDefinition(repositoryId, "P:sctst:clientRelated", null);
|
||||||
|
assertNotNull("the P:sctst:clientRelated aspect is not defined", aspectDfn);
|
||||||
|
TypeDefinition relDfn = cmisService.getTypeDefinition(repositoryId, "R:sctst:relatedClients", null);
|
||||||
|
assertNotNull("the R:sctst:relatedClients association is not defined", relDfn);
|
||||||
|
|
||||||
|
// create cmis:item within test folder
|
||||||
|
PropertiesImpl properties = new PropertiesImpl();
|
||||||
|
properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, tpdfn.getId()));
|
||||||
|
properties.addProperty(new PropertyStringImpl(PropertyIds.NAME, CLIENT_NAME));
|
||||||
|
properties.addProperty(new PropertyStringImpl("sctst:clientId", "id" + GUID.generate()));
|
||||||
|
properties.addProperty(new PropertyStringImpl("sctst:clientName", CLIENT_NAME));
|
||||||
|
|
||||||
|
ObjectData folderData = cmisService.getObjectByPath(repositoryId, "/" + FOLDER_NAME, null, null, null, null, null, null, null);
|
||||||
|
|
||||||
|
cmisService.createItem(repositoryId, properties, folderData.getId(), null, null, null, null);
|
||||||
|
|
||||||
|
ObjectData contentData = cmisService.getObjectByPath(repositoryId, "/" + FOLDER_NAME + "/" + DOCUMENT_NAME, null, null, null, null, null, null, null);
|
||||||
|
|
||||||
|
// add test aspect sctst:clientRelated to document
|
||||||
|
Properties props = cmisService.getProperties(repositoryId, contentData.getId(), null, null);
|
||||||
|
|
||||||
|
PropertyData<?> propAspects = props.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
List aspects = propAspects.getValues();
|
||||||
|
aspects.add("P:sctst:clientRelated");
|
||||||
|
|
||||||
|
properties = new PropertiesImpl();
|
||||||
|
properties.addProperty(new PropertyStringImpl(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects));
|
||||||
|
cmisService.updateProperties(repositoryId, new Holder<String>(contentData.getId()), null, properties, null);
|
||||||
|
// ensure document has sctst:clientRelated aspect applied
|
||||||
|
aspects = cmisService.getProperties(repositoryId, contentData.getId(), null, null).getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
|
||||||
|
assertTrue("P:sctst:clientRelated excpected", aspects.contains("P:sctst:clientRelated"));
|
||||||
|
|
||||||
|
ObjectData itemData = cmisService.getObjectByPath(repositoryId, "/" + FOLDER_NAME + "/" + CLIENT_NAME, null, null, null, null, null, null, null);
|
||||||
|
// create relationship between cmis:document and cmis:item
|
||||||
|
properties = new PropertiesImpl();
|
||||||
|
properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "R:sctst:relatedClients"));
|
||||||
|
properties.addProperty(new PropertyIdImpl(PropertyIds.SOURCE_ID, contentData.getId()));
|
||||||
|
properties.addProperty(new PropertyIdImpl(PropertyIds.TARGET_ID, itemData.getId()));
|
||||||
|
cmisService.createRelationship(repositoryId, properties, null, null, null, null);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
|
||||||
|
};
|
||||||
|
}, CmisVersion.CMIS_1_1);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
AuthenticationUtil.popAuthentication();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMNT10529() throws Exception
|
public void testMNT10529() throws Exception
|
||||||
|
64
source/test-resources/opencmis/testcmis_item_model.xml
Normal file
64
source/test-resources/opencmis/testcmis_item_model.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!-- Definition of web site model -->
|
||||||
|
|
||||||
|
<model name="sctst:myTestItemModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||||
|
|
||||||
|
<!-- Meta-data about the model -->
|
||||||
|
<description>Test CMIS Item relations model</description>
|
||||||
|
<author>SSergey</author>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Imports are required to allow references to definitions in other
|
||||||
|
models
|
||||||
|
-->
|
||||||
|
<imports>
|
||||||
|
<!-- Import Alfresco Dictionary Definitions -->
|
||||||
|
<import uri="http://www.alfresco.org/model/dictionary/1.0"
|
||||||
|
prefix="d" />
|
||||||
|
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
|
||||||
|
</imports>
|
||||||
|
|
||||||
|
<!-- Sites Namespace -->
|
||||||
|
<namespaces>
|
||||||
|
<namespace uri="http://scTestCMISModel/1.0/"
|
||||||
|
prefix="sctst" />
|
||||||
|
</namespaces>
|
||||||
|
|
||||||
|
<types>
|
||||||
|
<type name="sctst:client">
|
||||||
|
<title>Someco Test Client</title>
|
||||||
|
<parent>sys:base</parent>
|
||||||
|
<properties>
|
||||||
|
<property name="sctst:clientName">
|
||||||
|
<type>d:text</type>
|
||||||
|
</property>
|
||||||
|
<property name="sctst:clientId">
|
||||||
|
<type>d:text</type>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</type>
|
||||||
|
</types>
|
||||||
|
|
||||||
|
<aspects>
|
||||||
|
<aspect name="sctst:clientRelated">
|
||||||
|
<title>Someco Test Client Related</title>
|
||||||
|
<associations>
|
||||||
|
<association name="sctst:relatedClients">
|
||||||
|
<title>Related Clients</title>
|
||||||
|
<source>
|
||||||
|
<mandatory>false</mandatory>
|
||||||
|
<many>true</many>
|
||||||
|
</source>
|
||||||
|
<target>
|
||||||
|
<class>sctst:client</class>
|
||||||
|
<mandatory>false</mandatory>
|
||||||
|
<many>true</many>
|
||||||
|
</target>
|
||||||
|
</association>
|
||||||
|
</associations>
|
||||||
|
</aspect>
|
||||||
|
</aspects>
|
||||||
|
|
||||||
|
</model>
|
@@ -7,6 +7,7 @@
|
|||||||
<property name="models">
|
<property name="models">
|
||||||
<list>
|
<list>
|
||||||
<value>opencmis/testcmisinteger_model.xml</value>
|
<value>opencmis/testcmisinteger_model.xml</value>
|
||||||
|
<value>opencmis/testcmis_item_model.xml</value>
|
||||||
<value>tenant/exampleModel.xml</value>
|
<value>tenant/exampleModel.xml</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
|
Reference in New Issue
Block a user