RM-1559: User with Create Hold capability can't create hold

RM-1561: Edit/Delete Hold actions are not displayed for user with proper capabilities

* editHold and deleteHold specific capabilities added and UI actions wired up accordingly
* capability patch addeded
* freeze, unfreeze and related capabilities deprecated (but still avaialble if required)
* some of the old freeze UI actions removed 



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@74506 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2014-06-24 06:31:43 +00:00
parent 1097aa22e4
commit 7aed13d0fb
15 changed files with 249 additions and 210 deletions

View File

@@ -161,7 +161,7 @@ public class CreateCapability extends DeclarativeCapability
{
return AccessDecisionVoter.ACCESS_GRANTED;
}
if (capabilityService.getCapability(RMPermissionModel.ADD_TO_HOLD).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED)
if (capabilityService.getCapability(RMPermissionModel.CREATE_HOLD).evaluate(destination) == AccessDecisionVoter.ACCESS_GRANTED)
{
return AccessDecisionVoter.ACCESS_GRANTED;
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch.v22;
import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* RM v2.2 patch to add new hold releated capabilities.
*
* @author Roy Wetherall
* @since 2.2
*/
public class RMv22HoldCapabilityPatch extends CapabilityPatch
{
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef)
*/
protected void applyCapabilityPatch(NodeRef filePlan)
{
// add new capability
addCapability(filePlan,
"DeleteHold",
FilePlanRoleService.ROLE_ADMIN,
FilePlanRoleService.ROLE_RECORDS_MANAGER);
addCapability(filePlan,
"EditHold",
FilePlanRoleService.ROLE_ADMIN,
FilePlanRoleService.ROLE_RECORDS_MANAGER);
}
}

View File

@@ -1075,68 +1075,72 @@ public class RecordServiceImpl extends BaseBehaviourBean
String origionalName = (String)properties.get(PROP_ORIGIONAL_NAME);
NodeRef originatingLocation = (NodeRef)properties.get(PROP_RECORD_ORIGINATING_LOCATION);
// first remove the secondary link association
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs)
// we can only reject if the originating location is present
if (originatingLocation != null)
{
if (!childAssociationRef.isPrimary() && childAssociationRef.getParentRef().equals(originatingLocation))
// first remove the secondary link association
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs)
{
nodeService.removeChildAssociation(childAssociationRef);
break;
if (!childAssociationRef.isPrimary() && childAssociationRef.getParentRef().equals(originatingLocation))
{
nodeService.removeChildAssociation(childAssociationRef);
break;
}
}
}
// remove all RM related aspects from the node
Set<QName> aspects = nodeService.getAspects(nodeRef);
for (QName aspect : aspects)
{
if (RM_URI.equals(aspect.getNamespaceURI()))
// remove all RM related aspects from the node
Set<QName> aspects = nodeService.getAspects(nodeRef);
for (QName aspect : aspects)
{
// remove the aspect
nodeService.removeAspect(nodeRef, aspect);
if (RM_URI.equals(aspect.getNamespaceURI()))
{
// remove the aspect
nodeService.removeAspect(nodeRef, aspect);
}
}
}
// get the records primary parent association
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef);
// move the record into the collaboration site
nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// rename to the origional name
if (origionalName != null)
{
fileFolderService.rename(nodeRef, origionalName);
if (logger.isDebugEnabled())
// get the records primary parent association
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef);
// move the record into the collaboration site
nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// rename to the origional name
if (origionalName != null)
{
String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
logger.debug("Rename " + name + " to " + origionalName);
fileFolderService.rename(nodeRef, origionalName);
if (logger.isDebugEnabled())
{
String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
logger.debug("Rename " + name + " to " + origionalName);
}
}
// save the information about the rejection details
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(3);
aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId);
aspectProperties.put(PROP_RECORD_REJECTION_DATE, new Date());
aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason);
nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties);
// Restore the owner of the document
if (StringUtils.isBlank(documentOwner))
{
throw new AlfrescoRuntimeException("Unable to find the creator of document.");
}
ownableService.setOwner(nodeRef, documentOwner);
// clear the existing permissions
permissionService.clearPermission(nodeRef, null);
// restore permission inheritance
permissionService.setInheritParentPermissions(nodeRef, true);
// send an email to the record creator
notificationHelper.recordRejectedEmailNotification(nodeRef, recordId, documentOwner);
}
// save the information about the rejection details
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(3);
aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId);
aspectProperties.put(PROP_RECORD_REJECTION_DATE, new Date());
aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason);
nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties);
// Restore the owner of the document
if (StringUtils.isBlank(documentOwner))
{
throw new AlfrescoRuntimeException("Unable to find the creator of document.");
}
ownableService.setOwner(nodeRef, documentOwner);
// clear the existing permissions
permissionService.clearPermission(nodeRef, null);
// restore permission inheritance
permissionService.setInheritParentPermissions(nodeRef, true);
// send an email to the record creator
notificationHelper.recordRejectedEmailNotification(nodeRef, recordId, documentOwner);
}
finally
{