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:
@@ -5,7 +5,7 @@ script:
|
|||||||
var folderId = args[cmis.ARG_FOLDER_ID];
|
var folderId = args[cmis.ARG_FOLDER_ID];
|
||||||
if (folderId !== null)
|
if (folderId !== null)
|
||||||
{
|
{
|
||||||
model.folder = search.findNode(folderId);
|
model.folder = cmis.findNode(folderId);
|
||||||
if (model.folder === null)
|
if (model.folder === null)
|
||||||
{
|
{
|
||||||
status.code = 400;
|
status.code = 400;
|
||||||
|
@@ -21,11 +21,11 @@ script:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// locate node
|
// locate node
|
||||||
model.node = search.findNode(objectId);
|
model.node = cmis.findNode(objectId);
|
||||||
if (model.node === null)
|
if (model.node === null)
|
||||||
{
|
{
|
||||||
status.code = 400;
|
status.code = 400;
|
||||||
status.message = "Repository node " + model.node + " not found";
|
status.message = "Repository node " + objectId + " not found";
|
||||||
status.redirect = true;
|
status.redirect = true;
|
||||||
break script;
|
break script;
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@ package org.alfresco.repo.cmis.rest;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.alfresco.cmis.CMISDictionaryService;
|
import org.alfresco.cmis.CMISDictionaryService;
|
||||||
import org.alfresco.cmis.CMISJoinEnum;
|
import org.alfresco.cmis.CMISJoinEnum;
|
||||||
@@ -102,6 +104,10 @@ public class CMISScript extends BaseScopableProcessorExtension
|
|||||||
private CMISQueryService cmisQueryService;
|
private CMISQueryService cmisQueryService;
|
||||||
private Paging paging;
|
private Paging paging;
|
||||||
|
|
||||||
|
// versioned objectId pattern
|
||||||
|
// TODO: encapsulate elsewhere
|
||||||
|
private static final Pattern versionedObjectIdPattern = Pattern.compile(".+://.+/.+/.+");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the service registry
|
* 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 referenceType node, path
|
||||||
* @param reference node => id, path => path
|
* @param reference node => id, path => path
|
||||||
@@ -246,6 +252,29 @@ public class CMISScript extends BaseScopableProcessorExtension
|
|||||||
return node;
|
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
|
* Finds an Association
|
||||||
*
|
*
|
||||||
|
@@ -1068,6 +1068,10 @@ public class CMISTest extends BaseCMISWebScriptTest
|
|||||||
args2.put("checkin", "true");
|
args2.put("checkin", "true");
|
||||||
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
|
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
|
||||||
assertNotNull(checkinRes);
|
assertNotNull(checkinRes);
|
||||||
|
|
||||||
|
// use result of checkin (i.e. document returned), for next checkout
|
||||||
|
xml = checkinRes.getContentAsString();
|
||||||
|
assertNotNull(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all versions
|
// get all versions
|
||||||
|
Reference in New Issue
Block a user