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="nodeService" ref="NodeService" />
|
||||
<property name="holdService" ref="HoldService" />
|
||||
<property name="permissionService" ref="PermissionService" />
|
||||
</bean>
|
||||
|
||||
<!-- Abstract parent bean for many POST and PUT Hold beans -->
|
||||
|
@@ -11,7 +11,7 @@
|
||||
retrieved which do not include the given node reference.
|
||||
]]>
|
||||
</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>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
|
@@ -249,8 +249,6 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
// get the root hold container
|
||||
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)
|
||||
{
|
||||
// get the children of the root hold container
|
||||
@@ -258,8 +256,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
for (ChildAssociationRef holdAssoc : holdsAssocs)
|
||||
{
|
||||
NodeRef hold = holdAssoc.getChildRef();
|
||||
boolean hasPermissionOnHold = (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.ALLOWED);
|
||||
if (isHold(hold) && hasPermissionOnHold)
|
||||
if (isHold(hold))
|
||||
{
|
||||
// add to list of holds
|
||||
holds.add(hold);
|
||||
|
@@ -26,11 +26,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.hold.HoldService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
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.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
@@ -55,6 +58,9 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
/** Hold Service */
|
||||
private HoldService holdService;
|
||||
|
||||
/** permission service */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* Set the file plan service
|
||||
*
|
||||
@@ -85,12 +91,23 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
boolean fileOnly = getFileOnly(req);
|
||||
NodeRef itemNodeRef = getItemNodeRef(req);
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>();
|
||||
|
||||
@@ -108,8 +125,12 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
List<Hold> holdObjects = new ArrayList<Hold>(holds.size());
|
||||
for (NodeRef nodeRef : holds)
|
||||
{
|
||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
holdObjects.add(new Hold(name, nodeRef));
|
||||
// only add if user has filling permisson on the hold
|
||||
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);
|
||||
@@ -190,6 +211,17 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
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
|
||||
*
|
||||
|
@@ -27,7 +27,9 @@ import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExce
|
||||
import java.util.Collections;
|
||||
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.service.cmr.security.AccessStatus;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
@@ -205,6 +207,40 @@ public class HoldsGetUnitTest extends BaseHoldWebScriptUnitTest
|
||||
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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user