mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
RM-4326: allow creation under hold type only from HoldServiceImpl
This commit is contained in:
@@ -44,6 +44,7 @@ import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent;
|
||||
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.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.rma.type.HoldType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
@@ -102,6 +103,8 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
/** records management audit service */
|
||||
private RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
private HoldType holdType;
|
||||
|
||||
/**
|
||||
* Set the file plan service
|
||||
*
|
||||
@@ -160,6 +163,11 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||
}
|
||||
|
||||
public void setHoldType(HoldType holdType)
|
||||
{
|
||||
this.holdType = holdType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise hold service
|
||||
*/
|
||||
@@ -594,7 +602,15 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
|
||||
// Link the record to the hold
|
||||
nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
|
||||
holdType.disable();
|
||||
try
|
||||
{
|
||||
nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
|
||||
}
|
||||
finally
|
||||
{
|
||||
holdType.enable();
|
||||
}
|
||||
|
||||
// audit item being added to the hold
|
||||
recordsManagementAuditService.auditEvent(nodeRef, AUDIT_ADD_TO_HOLD);
|
||||
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
|
||||
/**
|
||||
* rma:transferContainer behaviour bean
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@BehaviourBean(defaultType = "rma:hold")
|
||||
public class HoldType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||
{
|
||||
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForHoldType";
|
||||
|
||||
/**
|
||||
* Disable the behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
name = BEHAVIOUR_NAME
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
{
|
||||
throw new InvalidParameterException("Operation failed. Creation is not allowed in Hold Folders");
|
||||
}
|
||||
|
||||
}
|
@@ -407,22 +407,14 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
public void checkPostPermission(String nodeId)
|
||||
{
|
||||
NodeRef parentNodeRef = validateOrLookupNode(nodeId, null);
|
||||
QName parentNodeRefType = nodeService.getType(parentNodeRef);
|
||||
|
||||
if(RecordsManagementModel.TYPE_HOLD.equals(parentNodeRefType))
|
||||
SiteInfo siteInfo = siteService.getSite(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if(siteInfo !=null)
|
||||
{
|
||||
throw new PermissionDeniedException("POST request not allowed in Hold Folder.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SiteInfo siteInfo = siteService.getSite(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if(siteInfo !=null)
|
||||
NodeRef rmNodeRef = siteInfo.getNodeRef();
|
||||
if(rmNodeRef.equals(parentNodeRef))
|
||||
{
|
||||
NodeRef rmNodeRef = siteInfo.getNodeRef();
|
||||
if(rmNodeRef.equals(parentNodeRef))
|
||||
{
|
||||
throw new PermissionDeniedException("POST request not allowed in RM site.");
|
||||
}
|
||||
throw new PermissionDeniedException("POST request not allowed in RM site.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
|
Reference in New Issue
Block a user