Merged 5.2.N (5.2.1) to HEAD (5.2)

129716 amorarasu: REPO-340 / REPO-1136 - V1 REST API: Unlock Node


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@130220 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-09-06 14:41:44 +00:00
parent 2953ce53de
commit bd54639d22
7 changed files with 275 additions and 24 deletions

View File

@@ -87,6 +87,7 @@ import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.PathInfo;
import org.alfresco.rest.api.model.PathInfo.ElementInfo;
import org.alfresco.rest.api.model.QuickShareLink;
import org.alfresco.rest.api.model.UnlockInfo;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.rest.api.nodes.NodeAssocService;
import org.alfresco.rest.framework.core.exceptions.ApiException;
@@ -2970,6 +2971,40 @@ public class NodesImpl implements Nodes
return lockInfo;
}
@Override
public Node unlock(String nodeId, UnlockInfo unlockInfo, Parameters parameters)
{
NodeRef nodeRef = validateOrLookupNode(nodeId, null);
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
{
throw new PermissionDeniedException("Current user doesn't have permission to unlock node " + nodeId);
}
if (unlockInfo.getIncludeChildren() == null)
{
unlockInfo.setIncludeChildren(false);
}
if (unlockInfo.getAllowCheckedOut() == null)
{
unlockInfo.setAllowCheckedOut(false);
}
// If there is no lock placed on the node skip the operation.
if (lockService.getLockStatus(nodeRef) != LockStatus.NO_LOCK)
{
if (permissionService.hasPermission(nodeRef, PermissionService.UNLOCK).equals(AccessStatus.ALLOWED))
{
lockService.unlock(nodeRef, unlockInfo.getIncludeChildren(), unlockInfo.getAllowCheckedOut());
}
else
{
throw new PermissionDeniedException("Current user doesn't have permission to unlock node " + nodeId);
}
}
return getFolderOrDocument(nodeId, parameters);
}
/**
* @author Jamal Kaabi-Mofrad
*/