mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-926: File plan filters (Hold, Transfer, Unfiled) may not show up to date results when Rm configured for SOLR
* transfer and hold containers created under file plan * holds and transfers now contained within these containers * holds named using folder level counter to avoid name clash in container * hold and transfer filters now API driven .. so canned query driven .. so *live* * unit test updates * UI tested git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@55091 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -142,8 +142,9 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
transferNodeRef = this.nodeService.createNode(root,
|
||||
ASSOC_TRANSFERS,
|
||||
NodeRef transferContainer = filePlanService.getTransferContainer(root);
|
||||
transferNodeRef = this.nodeService.createNode(transferContainer,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(RM_URI, transferName),
|
||||
TYPE_TRANSFER,
|
||||
transferProps).getChildRef();
|
||||
|
@@ -139,6 +139,34 @@ public interface FilePlanService
|
||||
*/
|
||||
NodeRef createUnfiledContainer(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filePlan
|
||||
* @return
|
||||
*/
|
||||
NodeRef getHoldContainer(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filePlan
|
||||
* @return
|
||||
*/
|
||||
NodeRef createHoldContainer(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filePlan
|
||||
* @return
|
||||
*/
|
||||
NodeRef getTransferContainer(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filePlan
|
||||
* @return
|
||||
*/
|
||||
NodeRef createTransferContainer(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Creates a file plan as a child of the given parent node, with the name
|
||||
* provided.
|
||||
|
@@ -78,9 +78,10 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
private final static String MSG_CONTAINER_TYPE = "rm.service.container-type";
|
||||
private final static String MSG_CONTAINER_EXPECTED = "rm.service.container-expected";
|
||||
|
||||
/** Unfiled record container name */
|
||||
/** File plan containers */
|
||||
private static final String NAME_UNFILED_CONTAINER = "Unfiled Records";
|
||||
private static final QName QNAME_UNFILED_CONTAINER = QName.createQName(RM_URI, NAME_UNFILED_CONTAINER);
|
||||
private static final String NAME_HOLD_CONTAINER = "Holds";
|
||||
private static final String NAME_TRANSFER_CONTAINER = "Transfers";
|
||||
|
||||
/** RM site file plan container */
|
||||
private static final String FILE_PLAN_CONTAINER = "documentLibrary";
|
||||
@@ -392,20 +393,49 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getUnfiledContainer(NodeRef filePlan)
|
||||
{
|
||||
return getFilePlanRootContainer(filePlan, NAME_UNFILED_CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getHoldContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getHoldContainer(NodeRef filePlan)
|
||||
{
|
||||
return getFilePlanRootContainer(filePlan, NAME_HOLD_CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getTransferContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getTransferContainer(NodeRef filePlan)
|
||||
{
|
||||
return getFilePlanRootContainer(filePlan, NAME_TRANSFER_CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filePlan
|
||||
* @param containerName
|
||||
* @return
|
||||
*/
|
||||
private NodeRef getFilePlanRootContainer(NodeRef filePlan, String containerName)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
if (isFilePlan(filePlan) == false)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get the unfiled container, because passed node is not a file plan.");
|
||||
throw new AlfrescoRuntimeException("Unable to get the container " + containerName + ", because passed node is not a file plan.");
|
||||
}
|
||||
|
||||
NodeRef result = null;
|
||||
|
||||
// try and get the unfiled record container
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ContentModel.ASSOC_CONTAINS, QNAME_UNFILED_CONTAINER);
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, containerName));
|
||||
if (assocs.size() > 1)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get unfiled conatiner.");
|
||||
throw new AlfrescoRuntimeException("Unable to get unfiled conatiner " + containerName + ".");
|
||||
}
|
||||
else if (assocs.size() == 1)
|
||||
{
|
||||
@@ -419,35 +449,76 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public NodeRef createUnfiledContainer(NodeRef filePlan)
|
||||
{
|
||||
return createFilePlanRootContainer(filePlan, TYPE_UNFILED_RECORD_CONTAINER, NAME_UNFILED_CONTAINER, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createHoldContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef createHoldContainer(NodeRef filePlan)
|
||||
{
|
||||
return createFilePlanRootContainer(filePlan, TYPE_HOLD_CONTAINER, NAME_HOLD_CONTAINER, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createTransferContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef createTransferContainer(NodeRef filePlan)
|
||||
{
|
||||
return createFilePlanRootContainer(filePlan, TYPE_TRANSFER_CONTAINER, NAME_TRANSFER_CONTAINER, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filePlan
|
||||
* @param containerType
|
||||
* @param containerName
|
||||
* @param inheritPermissions
|
||||
* @return
|
||||
*/
|
||||
private NodeRef createFilePlanRootContainer(NodeRef filePlan, QName containerType, String containerName, boolean inheritPermissions)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
if (isFilePlan(filePlan) == false)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to create unfiled container, because passed node is not a file plan.");
|
||||
throw new AlfrescoRuntimeException("Unable to create file plan root container, because passed node is not a file plan.");
|
||||
}
|
||||
|
||||
String allRoles = getFilePlanRoleService().getAllRolesContainerGroup(filePlan);
|
||||
|
||||
// create the properties map
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
|
||||
properties.put(ContentModel.PROP_NAME, NAME_UNFILED_CONTAINER);
|
||||
properties.put(ContentModel.PROP_NAME, containerName);
|
||||
|
||||
// create the unfiled container
|
||||
NodeRef container = nodeService.createNode(
|
||||
filePlan,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QNAME_UNFILED_CONTAINER,
|
||||
TYPE_UNFILED_RECORD_CONTAINER,
|
||||
QName.createQName(RM_URI, containerName),
|
||||
containerType,
|
||||
properties).getChildRef();
|
||||
|
||||
// set inheritance to false
|
||||
getPermissionService().setInheritParentPermissions(container, false);
|
||||
getPermissionService().setPermission(container, allRoles, RMPermissionModel.READ_RECORDS, true);
|
||||
getPermissionService().setPermission(container, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS, true);
|
||||
getPermissionService().setPermission(container, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING, true);
|
||||
|
||||
// TODO set the admin users to have filing permissions on the unfiled container!!!
|
||||
// TODO we will need to be able to get a list of the admin roles from the service
|
||||
if (inheritPermissions == false)
|
||||
{
|
||||
// set inheritance to false
|
||||
getPermissionService().setInheritParentPermissions(container, false);
|
||||
getPermissionService().setPermission(container, allRoles, RMPermissionModel.READ_RECORDS, true);
|
||||
getPermissionService().setPermission(container, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS, true);
|
||||
getPermissionService().setPermission(container, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING, true);
|
||||
|
||||
// TODO set the admin users to have filing permissions on the unfiled container!!!
|
||||
// TODO we will need to be able to get a list of the admin roles from the service
|
||||
}
|
||||
else
|
||||
{
|
||||
// just inherit eveything
|
||||
// TODO will change this when we are able to set permissions on holds and transfers!
|
||||
getPermissionService().setInheritParentPermissions(container, true);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ 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.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
@@ -42,12 +43,9 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
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.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
@@ -63,7 +61,8 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class FreezeServiceImpl implements FreezeService,
|
||||
public class FreezeServiceImpl extends ServiceBaseImpl
|
||||
implements FreezeService,
|
||||
RecordsManagementModel,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy
|
||||
{
|
||||
@@ -72,33 +71,28 @@ public class FreezeServiceImpl implements FreezeService,
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_FREEZE_ONLY_RECORDS_FOLDERS = "rm.action.freeze-only-records-folders";
|
||||
private static final String MSG_HOLD_NAME = "rm.hold.name";
|
||||
|
||||
/** Hold node reference key */
|
||||
private static final String KEY_HOLD_NODEREF = "holdNodeRef";
|
||||
|
||||
/** Policy Component */
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
/** Node Service */
|
||||
private NodeService nodeService;
|
||||
protected PolicyComponent policyComponent;
|
||||
|
||||
/** Records Management Service */
|
||||
private RecordsManagementService recordsManagementService;
|
||||
|
||||
/** Dictionary Service */
|
||||
private DictionaryService dictionaryService;
|
||||
protected RecordsManagementService recordsManagementService;
|
||||
|
||||
/** Record service */
|
||||
private RecordService recordService;
|
||||
protected RecordService recordService;
|
||||
|
||||
/** File Plan Service */
|
||||
private FilePlanService filePlanService;
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
/** Permission service */
|
||||
private PermissionService permissionService;
|
||||
protected PermissionService permissionService;
|
||||
|
||||
/** file plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
protected FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
@@ -108,14 +102,6 @@ public class FreezeServiceImpl implements FreezeService,
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordsManagementService records management service
|
||||
*/
|
||||
@@ -124,14 +110,6 @@ public class FreezeServiceImpl implements FreezeService,
|
||||
this.recordsManagementService = recordsManagementService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
@@ -534,9 +512,8 @@ public class FreezeServiceImpl implements FreezeService,
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
|
||||
Set<NodeRef> holds = new HashSet<NodeRef>();
|
||||
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(filePlan, ASSOC_HOLDS,
|
||||
RegexQNamePattern.MATCH_ALL);
|
||||
NodeRef holdContainer = filePlanService.getHoldContainer(filePlan);
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(holdContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
if (childAssocs != null && !childAssocs.isEmpty())
|
||||
{
|
||||
for (ChildAssociationRef childAssoc : childAssocs)
|
||||
@@ -617,27 +594,28 @@ public class FreezeServiceImpl implements FreezeService,
|
||||
private NodeRef createHold(NodeRef nodeRef, String reason)
|
||||
{
|
||||
NodeRef holdNodeRef = null;
|
||||
|
||||
// get the hold container
|
||||
NodeRef root = filePlanService.getFilePlan(nodeRef);
|
||||
NodeRef holdContainer = filePlanService.getHoldContainer(root);
|
||||
|
||||
// Calculate a transfer name
|
||||
QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
|
||||
Long dbId = (Long) nodeService.getProperty(nodeRef, nodeDbid);
|
||||
String transferName = StringUtils.leftPad(dbId.toString(), 10, "0");
|
||||
// calculate the hold name
|
||||
int nextCount = getNextCount(holdContainer);
|
||||
String holdName = I18NUtil.getMessage(MSG_HOLD_NAME) + " " + StringUtils.leftPad(Integer.toString(nextCount), 10, "0");
|
||||
|
||||
// Create the properties for the hold object
|
||||
Map<QName, Serializable> holdProps = new HashMap<QName, Serializable>(2);
|
||||
holdProps.put(ContentModel.PROP_NAME, transferName);
|
||||
holdProps.put(ContentModel.PROP_NAME, holdName);
|
||||
holdProps.put(PROP_HOLD_REASON, reason);
|
||||
|
||||
// Get the root rm node and create the hold object
|
||||
NodeRef root = filePlanService.getFilePlan(nodeRef);
|
||||
QName transferQName = QName.createQName(RM_URI, transferName);
|
||||
holdNodeRef = nodeService.createNode(root, ASSOC_HOLDS, transferQName, TYPE_HOLD, holdProps).getChildRef();
|
||||
// create the hold object
|
||||
QName holdQName = QName.createQName(RM_URI, holdName);
|
||||
holdNodeRef = nodeService.createNode(holdContainer, ContentModel.ASSOC_CONTAINS, holdQName, TYPE_HOLD, holdProps).getChildRef();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Created hold object '").append(holdNodeRef).append("' with transfer name '").append(
|
||||
transferQName).append("'.");
|
||||
msg.append("Created hold object '").append(holdNodeRef).append("' with name '").append(holdQName).append("'.");
|
||||
logger.debug(msg.toString());
|
||||
}
|
||||
|
||||
|
@@ -59,6 +59,12 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
|
||||
// Unfiled record container
|
||||
public static final QName TYPE_UNFILED_RECORD_CONTAINER = QName.createQName(RM_URI, "unfiledRecordContainer");
|
||||
|
||||
// Hold container
|
||||
public static final QName TYPE_HOLD_CONTAINER = QName.createQName(RM_URI, "holdContainer");
|
||||
|
||||
// Transfer container
|
||||
public static final QName TYPE_TRANSFER_CONTAINER = QName.createQName(RM_URI, "transferContainer");
|
||||
|
||||
// Disposition instructions aspect
|
||||
public static final QName ASPECT_SCHEDULED = QName.createQName(RM_URI, "scheduled");
|
||||
@@ -169,7 +175,9 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
|
||||
// Records management root aspect
|
||||
public static final QName ASPECT_RECORDS_MANAGEMENT_ROOT = QName.createQName(RM_URI, "recordsManagementRoot");
|
||||
public static final QName ASSOC_HOLDS = QName.createQName(RM_URI, "holds");
|
||||
@Deprecated // since 2.1
|
||||
public static final QName ASSOC_HOLDS = QName.createQName(RM_URI, "holds");
|
||||
@Deprecated // since 2.1
|
||||
public static final QName ASSOC_TRANSFERS = QName.createQName(RM_URI, "transfers");
|
||||
|
||||
// Hold type
|
||||
@@ -244,4 +252,9 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
public static final QName PROP_RECORD_REJECTION_USER_ID = QName.createQName(RM_URI, "recordRejectionUserId");
|
||||
public static final QName PROP_RECORD_REJECTION_DATE = QName.createQName(RM_URI, "recordRejectionDate");
|
||||
public static final QName PROP_RECORD_REJECTION_REASON = QName.createQName(RM_URI, "recordRejectionReason");
|
||||
|
||||
// Countable aspect
|
||||
public static final QName ASPECT_COUNTABLE = QName.createQName(RM_URI, "countable");
|
||||
public static final QName PROP_COUNT = QName.createQName(RM_URI, "count");
|
||||
|
||||
}
|
||||
|
@@ -123,31 +123,34 @@ public class RecordContainerType implements RecordsManagementModel,
|
||||
{
|
||||
// Get the elements of the created association
|
||||
final NodeRef child = childAssocRef.getChildRef();
|
||||
QName childType = nodeService.getType(child);
|
||||
|
||||
// We only care about "folder" or sub-types
|
||||
if (dictionaryService.isSubClass(childType, ContentModel.TYPE_FOLDER) == true)
|
||||
{
|
||||
if (dictionaryService.isSubClass(childType, ContentModel.TYPE_SYSTEM_FOLDER) == true)
|
||||
{
|
||||
// this is a rule container, make sure it is an file plan component
|
||||
nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to automatically cast the created folder to RM type if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
if (nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT) == false)
|
||||
if (nodeService.exists(child) == true)
|
||||
{
|
||||
QName childType = nodeService.getType(child);
|
||||
|
||||
// We only care about "folder" or sub-types
|
||||
if (dictionaryService.isSubClass(childType, ContentModel.TYPE_FOLDER) == true)
|
||||
{
|
||||
if (dictionaryService.isSubClass(childType, ContentModel.TYPE_SYSTEM_FOLDER) == true)
|
||||
{
|
||||
// this is a rule container, make sure it is an file plan component
|
||||
nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO it may not always be a record folder ... perhaps if the current user is a admin it would be a record category??
|
||||
|
||||
// Assume any created folder is a rma:recordFolder
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
// Catch all to generate the rm id (assuming it doesn't already have one!)
|
||||
setIdenifierProperty(child);
|
||||
}
|
||||
// We need to automatically cast the created folder to RM type if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
if (nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT) == false)
|
||||
{
|
||||
// TODO it may not always be a record folder ... perhaps if the current user is a admin it would be a record category??
|
||||
|
||||
// Assume any created folder is a rma:recordFolder
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
// Catch all to generate the rm id (assuming it doesn't already have one!)
|
||||
setIdenifierProperty(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -148,9 +148,17 @@ public class RMv21InPlacePatch extends ModulePatchComponent
|
||||
filePlanPermissionService.setPermission(filePlan, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS);
|
||||
filePlanPermissionService.setPermission(filePlan, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING);
|
||||
|
||||
// create unfiled container
|
||||
// create fileplan containers
|
||||
filePlanService.createHoldContainer(filePlan);
|
||||
filePlanService.createTransferContainer(filePlan);
|
||||
filePlanService.createUnfiledContainer(filePlan);
|
||||
|
||||
// move any existing holds to new container
|
||||
// TODO
|
||||
|
||||
// move any existing transfers to new container
|
||||
// TODO
|
||||
|
||||
// add the inplace roles
|
||||
filePlanRoleService.createRole(filePlan, ROLE_READERS, ROLE_READERS_LABEL, getCapabilities(ROLE_READERS_CAPABILITIES));
|
||||
filePlanRoleService.createRole(filePlan, ROLE_WRITERS, ROLE_WRITERS_LABEL, getCapabilities(ROLE_WRITERS_CAPABILITIES));
|
||||
|
@@ -253,6 +253,11 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
||||
permissionService.setPermission(rmRootNode, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS, true);
|
||||
permissionService.setPermission(rmRootNode, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING, true);
|
||||
|
||||
// Create the transfer and hold containers
|
||||
// NOTE: don't need to worry about the admin permissions as for now we just inherit all
|
||||
filePlanService.createHoldContainer(rmRootNode);
|
||||
filePlanService.createTransferContainer(rmRootNode);
|
||||
|
||||
// Create the unfiled record container
|
||||
return filePlanService.createUnfiledContainer(rmRootNode);
|
||||
}
|
||||
@@ -310,7 +315,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
||||
* @param rmRootNode
|
||||
* @param unfiledContainer
|
||||
*/
|
||||
private void bootstrapDefaultRoles(final NodeRef rmRootNode, final NodeRef unfiledContainer)
|
||||
private void bootstrapDefaultRoles(final NodeRef filePlan, final NodeRef unfiledContainer)
|
||||
{
|
||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||
{
|
||||
@@ -344,9 +349,9 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
||||
if (object.has("name") == true)
|
||||
{
|
||||
name = object.getString("name");
|
||||
if (existsRole(rmRootNode, name) == true)
|
||||
if (existsRole(filePlan, name) == true)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The bootstrap role " + name + " already exists on the rm root node " + rmRootNode.toString());
|
||||
throw new AlfrescoRuntimeException("The bootstrap role " + name + " already exists on the rm root node " + filePlan.toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -387,13 +392,13 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
||||
}
|
||||
|
||||
// Create the role
|
||||
Role role = createRole(rmRootNode, name, displayLabel, capabilities);
|
||||
Role role = createRole(filePlan, name, displayLabel, capabilities);
|
||||
|
||||
// Add any additional admin permissions
|
||||
if (isAdmin == true)
|
||||
{
|
||||
// Admin has filing
|
||||
permissionService.setPermission(rmRootNode, role.getRoleGroupName(), RMPermissionModel.FILING, true);
|
||||
permissionService.setPermission(filePlan, role.getRoleGroupName(), RMPermissionModel.FILING, true);
|
||||
if (unfiledContainer != null)
|
||||
{
|
||||
permissionService.setPermission(unfiledContainer, role.getRoleGroupName(), RMPermissionModel.FILING, true);
|
||||
|
@@ -26,6 +26,8 @@ import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.web.scripts.content.StreamACP;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -50,6 +52,13 @@ public abstract class BaseTransferWebScript extends StreamACP
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(BaseTransferWebScript.class);
|
||||
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
@@ -167,8 +176,10 @@ public abstract class BaseTransferWebScript extends StreamACP
|
||||
NodeRef transferNode = null;
|
||||
|
||||
// get all the transfer nodes and find the one we need
|
||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(filePlan,
|
||||
RecordsManagementModel.ASSOC_TRANSFERS, RegexQNamePattern.MATCH_ALL);
|
||||
NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
|
||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(transferContainer,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef child : assocs)
|
||||
{
|
||||
if (child.getChildRef().getId().equals(transferId))
|
||||
|
@@ -454,19 +454,25 @@ public class FilePlanPermissionServiceImpl implements FilePlanPermissionService,
|
||||
*/
|
||||
private void setPermissionDown(NodeRef nodeRef, String authority, String permission)
|
||||
{
|
||||
setPermissionImpl(nodeRef, authority, permission);
|
||||
if (filePlanService.isFilePlanContainer(nodeRef) == true ||
|
||||
recordsManagementService.isRecordFolder(nodeRef) == true)
|
||||
// skip out node's that inherit (for example hold and transfer)
|
||||
if (permissionService.getInheritParentPermissions(nodeRef) == false)
|
||||
{
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
NodeRef child = assoc.getChildRef();
|
||||
if (filePlanService.isFilePlanContainer(child) == true ||
|
||||
recordsManagementService.isRecordFolder(child) == true ||
|
||||
recordService.isRecord(child) == true)
|
||||
// set permissions
|
||||
setPermissionImpl(nodeRef, authority, permission);
|
||||
|
||||
if (filePlanService.isFilePlanContainer(nodeRef) == true ||
|
||||
recordsManagementService.isRecordFolder(nodeRef) == true)
|
||||
{
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
setPermissionDown(child, authority, permission);
|
||||
NodeRef child = assoc.getChildRef();
|
||||
if (filePlanService.isFilePlanContainer(child) == true ||
|
||||
recordsManagementService.isRecordFolder(child) == true ||
|
||||
recordService.isRecord(child) == true)
|
||||
{
|
||||
setPermissionDown(child, authority, permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,21 +505,25 @@ public class FilePlanPermissionServiceImpl implements FilePlanPermissionService,
|
||||
{
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
// Delete permission on this node
|
||||
permissionService.deletePermission(nodeRef, authority, permission);
|
||||
|
||||
if (filePlanService.isFilePlanContainer(nodeRef) == true ||
|
||||
recordsManagementService.isRecordFolder(nodeRef) == true)
|
||||
// can't delete permissions if inherited (eg hold and transfer containers)
|
||||
if (permissionService.getInheritParentPermissions(nodeRef) == false)
|
||||
{
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
// Delete permission on this node
|
||||
permissionService.deletePermission(nodeRef, authority, permission);
|
||||
|
||||
if (filePlanService.isFilePlanContainer(nodeRef) == true ||
|
||||
recordsManagementService.isRecordFolder(nodeRef) == true)
|
||||
{
|
||||
NodeRef child = assoc.getChildRef();
|
||||
if (filePlanService.isFilePlanContainer(child) == true ||
|
||||
recordsManagementService.isRecordFolder(child) == true ||
|
||||
recordService.isRecord(child) == true)
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
deletePermission(child, authority, permission);
|
||||
NodeRef child = assoc.getChildRef();
|
||||
if (filePlanService.isFilePlanContainer(child) == true ||
|
||||
recordsManagementService.isRecordFolder(child) == true ||
|
||||
recordService.isRecord(child) == true)
|
||||
{
|
||||
deletePermission(child, authority, permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,13 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.util;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
|
||||
/**
|
||||
* Helper base class for service implementations.
|
||||
@@ -30,7 +32,7 @@ import org.alfresco.util.ParameterCheck;
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ServiceBaseImpl
|
||||
public class ServiceBaseImpl implements RecordsManagementModel
|
||||
{
|
||||
/** Node service */
|
||||
protected NodeService nodeService;
|
||||
@@ -73,5 +75,40 @@ public class ServiceBaseImpl
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to get the next counter for a node.
|
||||
* <p>
|
||||
* If the node is not already countable, then rma:countable is added and 0 returned.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return int next counter value
|
||||
*/
|
||||
protected int getNextCount(NodeRef nodeRef)
|
||||
{
|
||||
int counter = 0;
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_COUNTABLE) == false)
|
||||
{
|
||||
PropertyMap props = new PropertyMap(1);
|
||||
props.put(PROP_COUNT, 1);
|
||||
nodeService.addAspect(nodeRef, ASPECT_COUNTABLE, props);
|
||||
counter = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Integer value = (Integer)this.nodeService.getProperty(nodeRef, PROP_COUNT);
|
||||
if (value != null)
|
||||
{
|
||||
counter = value.intValue() + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter = 1;
|
||||
}
|
||||
nodeService.setProperty(nodeRef, PROP_COUNT, counter);
|
||||
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user