mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)
129050 jvonka: V1 REST API: fix 500 (NPE) when trying to get a version (info or content) for a node that has no version history REPO-1051, REPO-327, REPO-229 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129194 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -282,6 +282,11 @@ public class NodeVersionsRelation extends AbstractNodeRelation implements
|
||||
private Version findVersion(String nodeId, String versionLabelId)
|
||||
{
|
||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
|
||||
return versionService.getVersionHistory(nodeRef).getVersion(versionLabelId);
|
||||
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
||||
if (vh != null)
|
||||
{
|
||||
return vh.getVersion(versionLabelId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -1128,7 +1128,27 @@ public class NodeVersionsApiTest extends AbstractSingleNetworkSiteTest
|
||||
|
||||
// -ve test - unknown node
|
||||
getAll(getNodeVersionsUrl("dummy"), paging, null, 404);
|
||||
|
||||
//
|
||||
// -ve tests for non-versionable node with no version history (could be content, folder or some other node type)
|
||||
//
|
||||
|
||||
// folder node - no version history
|
||||
String f99Id = createFolder(f1Id, "f99").getId();
|
||||
getSingle(getNodeVersionsUrl(f99Id), "1.0", null, 404);
|
||||
getSingle(getNodeVersionsUrl(f99Id), "1.0/content", null, 404);
|
||||
|
||||
//content node - no version history
|
||||
n = new Node();
|
||||
n.setName("z1");
|
||||
n.setNodeType(TYPE_CM_CONTENT);
|
||||
response = post(getNodeChildrenUrl(f1Id), toJsonAsStringNonNull(n), 201);
|
||||
String z1Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
|
||||
|
||||
getSingle(getNodeVersionsUrl(z1Id), "1.0", null, 404);
|
||||
getSingle(getNodeVersionsUrl(z1Id), "1.0/content", null, 404);
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
Reference in New Issue
Block a user