RM-1429 (The user with read-only permissions on the item can unfreeze it via deleting hold)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@72277 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-05-29 23:05:35 +00:00
parent dd690c6806
commit 1be4399d6b
6 changed files with 130 additions and 7 deletions

View File

@@ -30,6 +30,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -113,6 +114,9 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
/** Record folder service */
protected RecordFolderService recordFolderService;
/** Hold service */
protected HoldService holdService;
/** List of kinds for which this action is applicable */
protected Set<FilePlanComponentKind> applicableKinds = new HashSet<FilePlanComponentKind>();
@@ -204,7 +208,6 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
this.recordsManagementEventService = recordsManagementEventService;
}
/**
* Set the ownable service
* @param ownableSerice
@@ -266,6 +269,14 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
this.recordFolderService = recordFolderService;
}
/**
* @param holdService hold service
*/
public void setHoldService(HoldService holdService)
{
this.holdService = holdService;
}
/**
* @param applicableKinds kinds that this action is applicable for
*/

View File

@@ -0,0 +1,53 @@
/*
* 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.action.impl;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Delete Hold Action
*
* @author Tuna Aksoy
* @since 2.2
* @version 1.0
*/
public class DeleteHoldAction extends RMActionExecuterAbstractBase
{
/** I18N */
private static final String MSG_DELETE_NOT_HOLD_TYPE = "rm.action.delete-not-hold-type";
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
if (holdService.isHold(actionedUponNodeRef))
{
holdService.deleteHold(actionedUponNodeRef);
}
else
{
throw new AlfrescoRuntimeException(MSG_DELETE_NOT_HOLD_TYPE, new Object[]{ TYPE_HOLD.toString(), actionedUponNodeRef.toString() });
}
}
}

View File

@@ -418,6 +418,27 @@ public class HoldServiceImpl extends ServiceBaseImpl
throw new AlfrescoRuntimeException("Can't delete hold, becuase passed node is not a hold. (hold=" + hold.toString() + ")");
}
List<NodeRef> held = getHeld(hold);
List<String> heldNames = new ArrayList<String>();
for (NodeRef nodeRef : held)
{
if (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.ALLOWED)
{
heldNames.add((String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
}
}
if (heldNames.size() > 0)
{
StringBuilder sb = new StringBuilder();
for (String name : heldNames)
{
sb.append("\n ");
sb.append(name);
}
throw new AlfrescoRuntimeException("Can't delete hold, because filing permissions for the following items are needed: " + sb.toString());
}
// delete the hold node
nodeService.deleteNode(hold);
}