mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Story: RM-1206 (As a records user I want to be able to add records to a hold(s) I have permission to see so that I can freeze a record)
Sub-task: RM-1325 (Implement Hold Service) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63732 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1637,4 +1637,45 @@
|
||||
</bean>
|
||||
-->
|
||||
|
||||
<!-- Hold Service -->
|
||||
|
||||
<bean id="holdService"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldServiceImpl">
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
</bean>
|
||||
|
||||
<bean id="HoldService"
|
||||
class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="holdService"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="HoldService_transaction"/>
|
||||
<idref bean="exceptionTranslator"/>
|
||||
<idref local="HoldService_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="HoldService_transaction" parent="baseTransaction" />
|
||||
|
||||
<bean id="HoldService_security" parent="baseSecurity">
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.getHolds=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.addToHoldContainer=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.addToHoldContainers=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.removeFromHoldContainer=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.removeFromHoldContainers=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.*=RM_DENY
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.fileplan.hold;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Hold service interface.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public interface HoldService
|
||||
{
|
||||
/**
|
||||
* Gets the list of the holds within the holds container for the given file plan
|
||||
*
|
||||
* @param filePlan The {@link NodeRef} of the file plan
|
||||
* @return List of hold node references
|
||||
*/
|
||||
List<NodeRef> getHolds(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Adds the record to the given hold
|
||||
*
|
||||
* @param hold The {@link NodeRef} of the hold
|
||||
* @param record The {@link NodeRef} of the record which will be added to the given hold
|
||||
*/
|
||||
void addToHoldContainer(NodeRef hold, NodeRef record);
|
||||
|
||||
/**
|
||||
* Adds the record to the given list of holds
|
||||
*
|
||||
* @param holds The list of {@link NodeRef}s of the holds
|
||||
* @param record The {@link NodeRef} of the record which will be added to the given holds
|
||||
*/
|
||||
void addToHoldContainers(List<NodeRef> holds, NodeRef record);
|
||||
|
||||
/**
|
||||
* Removes the record from the given hold
|
||||
*
|
||||
* @param hold The {@link NodeRef} of the hold
|
||||
* @param record The {@link NodeRef} of the record which will be removed from the given hold
|
||||
*/
|
||||
void removeFromHoldContainer(NodeRef hold, NodeRef record);
|
||||
|
||||
/**
|
||||
* Removes the record from the given list of hold
|
||||
*
|
||||
* @param holds The list {@link NodeRef}s of the holds
|
||||
* @param record The {@link NodeRef} of the record which will be removed from the given holds
|
||||
*/
|
||||
void removeFromHoldContainers(List<NodeRef> holds, NodeRef record);
|
||||
}
|
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.fileplan.hold;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Hold service implementation
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public class HoldServiceImpl implements HoldService
|
||||
{
|
||||
/** File Plan Service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/** Node Service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Set the file plan service
|
||||
*
|
||||
* @param filePlanService the file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the node service
|
||||
*
|
||||
* @param nodeService the node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHolds(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public List<NodeRef> getHolds(NodeRef filePlan)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
|
||||
NodeRef holdContainer = filePlanService.getHoldContainer(filePlan);
|
||||
List<ChildAssociationRef> holdsAssocs = nodeService.getChildAssocs(holdContainer);
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>(holdsAssocs.size());
|
||||
for (ChildAssociationRef holdAssoc : holdsAssocs)
|
||||
{
|
||||
holds.add(holdAssoc.getChildRef());
|
||||
}
|
||||
|
||||
return holds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#addToHoldContainer(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void addToHoldContainer(NodeRef hold, NodeRef record)
|
||||
{
|
||||
ParameterCheck.mandatory("hold", hold);
|
||||
ParameterCheck.mandatory("record", record);
|
||||
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>(1);
|
||||
holds.add(hold);
|
||||
addToHoldContainers(Collections.unmodifiableList(holds), record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#addToHoldContainers(java.util.List, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void addToHoldContainers(List<NodeRef> holds, NodeRef record)
|
||||
{
|
||||
ParameterCheck.mandatoryCollection("holds", holds);
|
||||
ParameterCheck.mandatory("record", record);
|
||||
|
||||
String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
|
||||
String validLocalName = QName.createValidLocalName(recordName);
|
||||
QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, validLocalName);
|
||||
|
||||
for (NodeRef hold : holds)
|
||||
{
|
||||
nodeService.addChild(hold, record, ContentModel.ASSOC_CONTAINS, name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#removeFromHoldContainer(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void removeFromHoldContainer(NodeRef hold, NodeRef record)
|
||||
{
|
||||
ParameterCheck.mandatory("hold", hold);
|
||||
ParameterCheck.mandatory("record", record);
|
||||
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>(1);
|
||||
holds.add(hold);
|
||||
removeFromHoldContainers(Collections.unmodifiableList(holds), record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#removeFromHoldContainers(java.util.List, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void removeFromHoldContainers(List<NodeRef> holds, NodeRef record)
|
||||
{
|
||||
ParameterCheck.mandatory("holds", holds);
|
||||
ParameterCheck.mandatory("record", record);
|
||||
|
||||
for (NodeRef hold : holds)
|
||||
{
|
||||
nodeService.removeChild(hold, record);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user