mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Fix ALFCOM-2872: CMIS: checkout does not work for a previously versioned document
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14918 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,8 @@ package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISJoinEnum;
|
||||
@@ -102,6 +104,10 @@ public class CMISScript extends BaseScopableProcessorExtension
|
||||
private CMISQueryService cmisQueryService;
|
||||
private Paging paging;
|
||||
|
||||
// versioned objectId pattern
|
||||
// TODO: encapsulate elsewhere
|
||||
private static final Pattern versionedObjectIdPattern = Pattern.compile(".+://.+/.+/.+");
|
||||
|
||||
|
||||
/**
|
||||
* Set the service registry
|
||||
@@ -229,7 +235,7 @@ public class CMISScript extends BaseScopableProcessorExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a Node with the repository given a reference
|
||||
* Finds a Node given a repository reference
|
||||
*
|
||||
* @param referenceType node, path
|
||||
* @param reference node => id, path => path
|
||||
@@ -246,6 +252,29 @@ public class CMISScript extends BaseScopableProcessorExtension
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a Node given CMIS ObjectId
|
||||
*
|
||||
* @param objectId
|
||||
* @return node (or null, if not found)
|
||||
*/
|
||||
public ScriptNode findNode(String objectId)
|
||||
{
|
||||
NodeRef nodeRef;
|
||||
Matcher matcher = versionedObjectIdPattern.matcher(objectId);
|
||||
if (matcher.matches())
|
||||
{
|
||||
// TODO: handle version id
|
||||
nodeRef = new NodeRef(objectId.substring(0, objectId.lastIndexOf("/")));
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeRef = new NodeRef(objectId);
|
||||
}
|
||||
String[] reference = new String[] {nodeRef.getStoreRef().getProtocol(), nodeRef.getStoreRef().getIdentifier(), nodeRef.getId()};
|
||||
return findNode("node", reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an Association
|
||||
*
|
||||
|
Reference in New Issue
Block a user