mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
REPO-3627 / MNT-19630: CMIS: Unable to call getAllVersions() if node is checked out and if binding type is WSDL (#229)
- removed code that was made useless by previous code changes (see MNT-15338) - added junit for the case when getAllVersions() is used with null objectId (Cmis WS binding)
This commit is contained in:
@@ -2385,18 +2385,6 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
// what kind of object is it?
|
// what kind of object is it?
|
||||||
CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
|
CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
|
||||||
|
|
||||||
// when webservices binding is used, objectId points to null and versionSeriesId points to original node instead of PWC
|
|
||||||
// see MNT-13839
|
|
||||||
if (objectId == null)
|
|
||||||
{
|
|
||||||
info = getOrCreateNodeInfo(versionSeriesId);
|
|
||||||
if (info.hasPWC())
|
|
||||||
{
|
|
||||||
NodeRef nodeRef = info.getNodeRef();
|
|
||||||
info = getOrCreateNodeInfo(connector.getCheckOutCheckInService().getWorkingCopy(nodeRef).toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION))
|
if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION))
|
||||||
{
|
{
|
||||||
// the version series id is the id of current version, which is a
|
// the version series id is the id of current version, which is a
|
||||||
|
@@ -3920,4 +3920,61 @@ public class CMISTest
|
|||||||
AuthenticationUtil.popAuthentication();
|
AuthenticationUtil.popAuthentication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* REPO-3627 / MNT-19630: CMIS: Unable to call getAllVersions() if node is checked out and if binding type is WSDL
|
||||||
|
*
|
||||||
|
* For WS binding the getAllVersions call is made with null objectId
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getAllVersionsWithNullObjectId()
|
||||||
|
{
|
||||||
|
AuthenticationUtil.pushAuthentication();
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
|
// Create folder with file
|
||||||
|
String folderName = "testfolder" + GUID.generate();
|
||||||
|
String docName = "testdoc.txt" + GUID.generate();
|
||||||
|
NodeRef folderRef = createContent(folderName, docName, false).getNodeRef();
|
||||||
|
List<FileInfo> folderFileList = fileFolderService.list(folderRef);
|
||||||
|
final NodeRef fileRef = folderFileList.get(0).getNodeRef();
|
||||||
|
|
||||||
|
// Create new version for file
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
// create a new version
|
||||||
|
versionService.createVersion(fileRef, null);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Checkout document and get all versions
|
||||||
|
List<ObjectData> versions = withCmisService(new CmisServiceCallback<List<ObjectData>>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public List<ObjectData> execute(CmisService cmisService)
|
||||||
|
{
|
||||||
|
String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId();
|
||||||
|
ObjectData objectData = cmisService.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true, IncludeRelationships.NONE, null,
|
||||||
|
false, true, null);
|
||||||
|
|
||||||
|
// Checkout
|
||||||
|
Holder<String> objectId = new Holder<String>(objectData.getId());
|
||||||
|
cmisService.checkOut(repositoryId, objectId, null, new Holder<Boolean>(true));
|
||||||
|
|
||||||
|
// Call get all versions with null objectId
|
||||||
|
List<ObjectData> versions = cmisService.getAllVersions(repositoryId, null, fileRef.toString(), null, null, null);
|
||||||
|
|
||||||
|
return versions;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check that the correct versions are retrieved
|
||||||
|
assertEquals(2, versions.size());
|
||||||
|
assertEquals(versions.get(0).getProperties().getProperties().get("cmis:versionLabel").getFirstValue(), "pwc");
|
||||||
|
assertEquals(versions.get(1).getProperties().getProperties().get("cmis:versionLabel").getFirstValue(), "0.1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user