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.1) to HEAD (5.1)
121800 rneamtu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1) 121772 amorarasu: Merged DEV to 5.0.N (5.0.4) 120891 121263 amorarasu: MNT-14951: Using CMIS it is not possible to retrieve the secondary or the list of the parents of a folder - Changed getObjectParents() to return all the parents, not just the first one. - Added junit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123653 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -848,27 +848,30 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
List<CMISNodeInfo> parentInfos = info.getParents();
|
List<CMISNodeInfo> parentInfos = info.getParents();
|
||||||
if (!parentInfos.isEmpty())
|
if (!parentInfos.isEmpty())
|
||||||
{
|
{
|
||||||
CMISNodeInfo parentInfo = addNodeInfo(parentInfos.get(0));
|
for (CMISNodeInfo parent : parentInfos)
|
||||||
|
|
||||||
ObjectData object = connector.createCMISObject(
|
|
||||||
parentInfo, filter, includeAllowableActions,
|
|
||||||
includeRelationships, renditionFilter, false, false);
|
|
||||||
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
|
|
||||||
if (isObjectInfoRequired)
|
|
||||||
{
|
{
|
||||||
getObjectInfo(repositoryId, object.getId(), includeRelationships);
|
CMISNodeInfo parentInfo = addNodeInfo(parent);
|
||||||
|
|
||||||
|
ObjectData object = connector.createCMISObject(
|
||||||
|
parentInfo, filter, includeAllowableActions,
|
||||||
|
includeRelationships, renditionFilter, false, false);
|
||||||
|
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
|
||||||
|
if (isObjectInfoRequired)
|
||||||
|
{
|
||||||
|
getObjectInfo(repositoryId, object.getId(), includeRelationships);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
|
||||||
|
objectParent.setObject(object);
|
||||||
|
|
||||||
|
// include relative path segment
|
||||||
|
if (includeRelativePathSegment)
|
||||||
|
{
|
||||||
|
objectParent.setRelativePathSegment(info.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(objectParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
|
|
||||||
objectParent.setObject(object);
|
|
||||||
|
|
||||||
// include relative path segment
|
|
||||||
if (includeRelativePathSegment)
|
|
||||||
{
|
|
||||||
objectParent.setRelativePathSegment(info.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
result.add(objectParent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (info.isCurrentVersion() || info.isPWC())
|
else if (info.isCurrentVersion() || info.isPWC())
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -113,6 +113,7 @@ import org.apache.chemistry.opencmis.commons.data.ObjectData;
|
|||||||
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
|
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
|
||||||
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
|
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
|
||||||
import org.apache.chemistry.opencmis.commons.data.ObjectList;
|
import org.apache.chemistry.opencmis.commons.data.ObjectList;
|
||||||
|
import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
|
||||||
import org.apache.chemistry.opencmis.commons.data.Properties;
|
import org.apache.chemistry.opencmis.commons.data.Properties;
|
||||||
import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
||||||
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
|
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
|
||||||
@@ -3504,4 +3505,71 @@ public class CMISTest
|
|||||||
AuthenticationUtil.popAuthentication();
|
AuthenticationUtil.popAuthentication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MNT-14951: Test that the list of parents can be retrieved for a folder.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCMISGetObjectParents() throws Exception
|
||||||
|
{
|
||||||
|
// setUp audit subsystem
|
||||||
|
setupAudit();
|
||||||
|
|
||||||
|
AuthenticationUtil.pushAuthentication();
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final NodeRef folderWithTwoParents = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
|
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
|
||||||
|
|
||||||
|
String folder1 = GUID.generate();
|
||||||
|
FileInfo folderInfo1 = fileFolderService.create(companyHomeNodeRef, folder1, ContentModel.TYPE_FOLDER);
|
||||||
|
assertNotNull(folderInfo1);
|
||||||
|
|
||||||
|
String folder2 = GUID.generate();
|
||||||
|
FileInfo folderInfo2 = fileFolderService.create(companyHomeNodeRef, folder2, ContentModel.TYPE_FOLDER);
|
||||||
|
assertNotNull(folderInfo2);
|
||||||
|
|
||||||
|
// Create folder11 as a subfolder of folder1
|
||||||
|
String folder11 = GUID.generate();
|
||||||
|
FileInfo folderInfo11 = fileFolderService.create(folderInfo1.getNodeRef(), folder11, ContentModel.TYPE_FOLDER);
|
||||||
|
assertNotNull(folderInfo11);
|
||||||
|
|
||||||
|
// Add folder2 as second parent for folder11
|
||||||
|
nodeService.addChild(folderInfo2.getNodeRef(), folderInfo11.getNodeRef(), ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS);
|
||||||
|
|
||||||
|
return folderInfo11.getNodeRef();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
withCmisService(new CmisServiceCallback<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void execute(CmisService cmisService)
|
||||||
|
{
|
||||||
|
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||||
|
assertNotNull(repositories);
|
||||||
|
assertTrue(repositories.size() > 0);
|
||||||
|
String repositoryId = repositories.iterator().next().getId();
|
||||||
|
|
||||||
|
List<ObjectParentData> parents = cmisService.getObjectParents(repositoryId, folderWithTwoParents.getId(), null, Boolean.FALSE, IncludeRelationships.NONE,
|
||||||
|
"cmis:none", Boolean.FALSE, null);
|
||||||
|
// Check if the second parent was also returned.
|
||||||
|
assertEquals(2, parents.size());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, CmisVersion.CMIS_1_1);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
auditSubsystem.destroy();
|
||||||
|
AuthenticationUtil.popAuthentication();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user