Added check for Remove From Hold capability

This commit is contained in:
cagache
2019-08-19 09:32:33 +03:00
parent 21f341f40a
commit 055ccfd968
2 changed files with 27 additions and 4 deletions

View File

@@ -712,13 +712,20 @@ public class HoldServiceImpl extends ServiceBaseImpl
ParameterCheck.mandatory("holds", holds);
ParameterCheck.mandatory("nodeRef", nodeRef);
if (holds != null && !holds.isEmpty())
if (!holds.isEmpty())
{
for (final NodeRef hold : holds)
{
if (!instanceOf(hold, TYPE_HOLD))
if (!isHold(hold))
{
throw new AlfrescoRuntimeException("Can't remove from hold, because it isn't a hold. (hold=" + hold + ")");
final String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME);
throw new IntegrityException(I18NUtil.getMessage("rm.hold.not-hold", holdName), null);
}
if (!AccessStatus.ALLOWED.equals(
capabilityService.getCapabilityAccessState(hold, RMPermissionModel.REMOVE_FROM_HOLD)))
{
throw new AccessDeniedException(I18NUtil.getMessage(MSG_ERR_ACCESS_DENIED));
}
if (getHeld(hold).contains(nodeRef))