mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1573: Holds the user has read-only permission for are displayed in Remove from Hold dialog
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@75188 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -593,6 +593,7 @@
|
|||||||
<property name="filePlanService" ref="FilePlanService" />
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="holdService" ref="HoldService" />
|
<property name="holdService" ref="HoldService" />
|
||||||
|
<property name="permissionService" ref="PermissionService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Abstract parent bean for many POST and PUT Hold beans -->
|
<!-- Abstract parent bean for many POST and PUT Hold beans -->
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
retrieved which do not include the given node reference.
|
retrieved which do not include the given node reference.
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}&includedInHold={includedInHold?}</url>
|
<url>/api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}&includedInHold={includedInHold?}&fileOnly={fileOnly?}</url>
|
||||||
<url>/api/rma/holds?itemNodeRef={itemNodeRef?}</url>
|
<url>/api/rma/holds?itemNodeRef={itemNodeRef?}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
|
@@ -249,8 +249,6 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
// get the root hold container
|
// get the root hold container
|
||||||
NodeRef holdContainer = filePlanService.getHoldContainer(filePlan);
|
NodeRef holdContainer = filePlanService.getHoldContainer(filePlan);
|
||||||
|
|
||||||
// If you remove the "All Records Management Roles" which means users do not have read permissions on hold container
|
|
||||||
// at all, the hold container will not be found for the logged in user. That's why we need to do a check here.
|
|
||||||
if (holdContainer != null)
|
if (holdContainer != null)
|
||||||
{
|
{
|
||||||
// get the children of the root hold container
|
// get the children of the root hold container
|
||||||
@@ -258,8 +256,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
for (ChildAssociationRef holdAssoc : holdsAssocs)
|
for (ChildAssociationRef holdAssoc : holdsAssocs)
|
||||||
{
|
{
|
||||||
NodeRef hold = holdAssoc.getChildRef();
|
NodeRef hold = holdAssoc.getChildRef();
|
||||||
boolean hasPermissionOnHold = (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.ALLOWED);
|
if (isHold(hold))
|
||||||
if (isHold(hold) && hasPermissionOnHold)
|
|
||||||
{
|
{
|
||||||
// add to list of holds
|
// add to list of holds
|
||||||
holds.add(hold);
|
holds.add(hold);
|
||||||
|
@@ -26,11 +26,14 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
@@ -54,6 +57,9 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
|
|
||||||
/** Hold Service */
|
/** Hold Service */
|
||||||
private HoldService holdService;
|
private HoldService holdService;
|
||||||
|
|
||||||
|
/** permission service */
|
||||||
|
private PermissionService permissionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the file plan service
|
* Set the file plan service
|
||||||
@@ -84,6 +90,16 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.holdService = holdService;
|
this.holdService = holdService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the permission service
|
||||||
|
*
|
||||||
|
* @param permissionService the permission service
|
||||||
|
*/
|
||||||
|
public void setPermissionService(PermissionService permissionService)
|
||||||
|
{
|
||||||
|
this.permissionService = permissionService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||||
@@ -91,6 +107,7 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
|
boolean fileOnly = getFileOnly(req);
|
||||||
NodeRef itemNodeRef = getItemNodeRef(req);
|
NodeRef itemNodeRef = getItemNodeRef(req);
|
||||||
List<NodeRef> holds = new ArrayList<NodeRef>();
|
List<NodeRef> holds = new ArrayList<NodeRef>();
|
||||||
|
|
||||||
@@ -108,8 +125,12 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
List<Hold> holdObjects = new ArrayList<Hold>(holds.size());
|
List<Hold> holdObjects = new ArrayList<Hold>(holds.size());
|
||||||
for (NodeRef nodeRef : holds)
|
for (NodeRef nodeRef : holds)
|
||||||
{
|
{
|
||||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
// only add if user has filling permisson on the hold
|
||||||
holdObjects.add(new Hold(name, nodeRef));
|
if (!fileOnly || permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.ALLOWED)
|
||||||
|
{
|
||||||
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
|
holdObjects.add(new Hold(name, nodeRef));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
@@ -189,6 +210,17 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean getFileOnly(WebScriptRequest req)
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
String fillingOnly = req.getParameter("fileOnly");
|
||||||
|
if (StringUtils.isNotBlank(fillingOnly))
|
||||||
|
{
|
||||||
|
result = Boolean.valueOf(fillingOnly).booleanValue();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to sort the holds by their names
|
* Helper method to sort the holds by their names
|
||||||
|
@@ -27,7 +27,9 @@ import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExce
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -205,6 +207,40 @@ public class HoldsGetUnitTest extends BaseHoldWebScriptUnitTest
|
|||||||
testForBothHolds(json);
|
testForBothHolds(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getFileOnlyHolds() throws Exception
|
||||||
|
{
|
||||||
|
doReturn(AccessStatus.ALLOWED).when(mockedPermissionService).hasPermission(hold1NodeRef, RMPermissionModel.FILING);
|
||||||
|
doReturn(AccessStatus.DENIED).when(mockedPermissionService).hasPermission(hold2NodeRef, RMPermissionModel.FILING);
|
||||||
|
|
||||||
|
// setup web script parameters
|
||||||
|
Map<String, String> parameters = buildParameters
|
||||||
|
(
|
||||||
|
"store_type", filePlan.getStoreRef().getProtocol(),
|
||||||
|
"store_id", filePlan.getStoreRef().getIdentifier(),
|
||||||
|
"id", filePlan.getId(),
|
||||||
|
"itemNodeRef", record.toString(),
|
||||||
|
"includedInHold", "false",
|
||||||
|
"fileOnly", "true"
|
||||||
|
);
|
||||||
|
|
||||||
|
// execute web script
|
||||||
|
JSONObject json = executeJSONWebScript(parameters);
|
||||||
|
assertNotNull(json);
|
||||||
|
|
||||||
|
// check the JSON result
|
||||||
|
assertTrue(json.has("data"));
|
||||||
|
assertTrue(json.getJSONObject("data").has("holds"));
|
||||||
|
|
||||||
|
JSONArray jsonHolds = json.getJSONObject("data").getJSONArray("holds");
|
||||||
|
assertNotNull(jsonHolds);
|
||||||
|
assertEquals(1, jsonHolds.length());
|
||||||
|
|
||||||
|
JSONObject hold1 = jsonHolds.getJSONObject(0);
|
||||||
|
assertNotNull(hold1);
|
||||||
|
assertEquals("hold1", hold1.getString("name"));
|
||||||
|
assertEquals(hold1NodeRef.toString(), hold1.getString("nodeRef"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to test JSON object for the presence of both test holds.
|
* Helper method to test JSON object for the presence of both test holds.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user