RM: RecordsManagementService refactor

* move candiate methods into FilePlanService
  * deprecation of RMService methods
  * remove all deprecation warnings from code
  * update filePlanService unit tests
  * remove all other spurious warnings from RM code
  * a couple of performance enhancements in the bowls of the capability evaluation code
  * first pass at parametising RecordsManagementAuditService with file plan (so capability evaluation had a tangable reference)
  * fix up unit test failures and other fall out from refactors



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@52504 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-07-12 06:12:46 +00:00
parent ba197612d1
commit 87bd9abe53
85 changed files with 2188 additions and 1000 deletions

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -41,66 +42,42 @@ public interface RecordsManagementService
/********** RM Component methods **********/
/**
* Indicates whether the given node is a file plan component or not.
*
* @param nodeRef node reference
* @return boolean true if a file plan component, false otherwise
* @deprecated as of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)}
*/
@Deprecated
boolean isFilePlanComponent(NodeRef nodeRef);
/**
* Returns the 'kind' of file plan component the node reference is.
* <p>
* Returns null if the given node reference is not a
* file plan component.
*
* @param nodeRef node reference
* @return FilePlanComponentKind the kind of file plan component the
* node is
*
* @since 2.0
* @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)}
*/
@Deprecated
FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef);
/**
* Returns the file plan component 'kind' that relates to the passed
* content type.
* <p>
* Returns null if the type does not relate to a file plan component.
*
* @param type qualified name of content type
* @return FilePlanComponentKind the kind relating to the passed type
*
* @since 2.0
* @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)}
*/
@Deprecated
FilePlanComponentKind getFilePlanComponentKindFromType(QName type);
/**
* Indicates whether the given node is a records management container or not.
*
* @param nodeRef node reference
* @return boolean true if node is a record container, false otherwise.
* @deprecated as of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)}
*/
@Deprecated
boolean isRecordsManagementContainer(NodeRef nodeRef);
/**
* Indicates whether the given node is file plan node or not.
*
* @param nodeRef node reference
* @return boolean true if node is a file plan node
*
* @deprecated as of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)}
*/
@Deprecated
boolean isFilePlan(NodeRef nodeRef);
/**
* Indicates whether the given node is a record category or not.
*
* @param nodeRef node reference
* @return boolean true if records category, false otherwise
* @deprecated as of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)}
*/
boolean isRecordCategory(NodeRef nodeRef);
@Deprecated
boolean isRecordCategory(NodeRef nodeRef);
/**
* Indicates whether the given node is a record folder or not.
@@ -108,7 +85,7 @@ public interface RecordsManagementService
* @param nodeRef node reference
* @return boolean true if record folder, false otherwise
*/
boolean isRecordFolder(NodeRef nodeRef);
boolean isRecordFolder(NodeRef nodeRef); // record folder service
/**
* Indicates whether the given node is a transfer (container) or not.
@@ -118,7 +95,7 @@ public interface RecordsManagementService
*
* @since 2.0
*/
boolean isTransfer(NodeRef nodeRef);
boolean isTransfer(NodeRef nodeRef); // transfer service
/**
* Indicates whether the given node (record or record folder) is a metadata stub or not.
@@ -128,7 +105,7 @@ public interface RecordsManagementService
*
* @since 2.0
*/
boolean isMetadataStub(NodeRef nodeRef);
boolean isMetadataStub(NodeRef nodeRef); // record service
/**
* Indicates whether the item is cutoff or not.
@@ -138,24 +115,15 @@ public interface RecordsManagementService
*
* @since 2.0
*/
boolean isCutoff(NodeRef nodeRef);
boolean isCutoff(NodeRef nodeRef); // disposition service ??
/**
* Gets the <b>NodeRef</b> sequence from the {@link #getFilePlan(NodeRef) root}
* down to the fileplan component given. The array will start with the <b>NodeRef</b> of the root
* and end with the name of the fileplan component node given.
*
* @param nodeRef a fileplan component
* @return Returns a <b>NodeRef</b> path starting with the name of the
* records management root
* @deprecated as of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)}
*/
@Deprecated
List<NodeRef> getNodeRefPath(NodeRef nodeRef);
/**
* Gets the file plan the node is in.
*
* @return {@link NodeRef} file node reference, null if none
*
* @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)}
*/
@Deprecated
@@ -164,168 +132,98 @@ public interface RecordsManagementService
/********** File Plan Methods **********/
/**
* Gets all the file plan nodes.
* Searches the SpacesStore by default.
*
* @return List<NodeRef> list of file plan nodes
* @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()}
*/
@Deprecated
List<NodeRef> getFilePlans();
/**
* Creates a file plan as a child of the given parent node, with the name
* provided.
*
* @param parent parent node reference
* @param name name of the root
* @param type type of root created (must be sub-type of rm:filePlan)
* @return NodeRef node reference to the newly create RM root
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)}
*/
@Deprecated
NodeRef createFilePlan(NodeRef parent, String name, QName type);
/**
* @see #createFilePlan(NodeRef, String, QName)
*
* @param parent
* @param name
* @param type
* @param properties
* @return
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)}
*/
@Deprecated
NodeRef createFilePlan(NodeRef parent, String name, QName type, Map<QName, Serializable> properties);
/**
* Creates a file plan with the default type.
*
* @see RecordsManagementService#createFilePlan(NodeRef, String, QName)
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)}
*/
@Deprecated
NodeRef createFilePlan(NodeRef parent, String name);
/**
*
* @param parent
* @param name
* @param properties
* @return
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)}
*/
@Deprecated
NodeRef createFilePlan(NodeRef parent, String name, Map<QName, Serializable> properties);
// TODO void deleteRecordsManagementRoot(NodeRef root);
/********** Record Category Methods **********/
// TODO NodeRef getRecordCategoryByPath(String path);
// TODO NodeRef getRecordCategoryById(String id);
// TODO NodeRef getRecordCategoryByName(NodeRef parent, String id); ??
/**
* Get all the items contained within a container. This will include record folders and other record categories.
*
* @param recordCategory record category node reference
* @param deep if true then return all children including sub-categories and their children in turn, if false then just
* return the immediate children
* @return {@link List}<{@link NodeRef>} list of contained node references
* @deprecated as of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)}
*/
@Deprecated
List<NodeRef> getAllContained(NodeRef recordCategory, boolean deep);
/**
* Only return the immediate children.
*
* @see RecordsManagementService#getAllContained(NodeRef, boolean)
*
* @param recordCategory record category node reference
* @return {@link List}<{@link NodeRef>} list of contained node references
* @deprecated as of 2.1, see {@link FilePlanService#getAllContained(NodeRef)}
*/
@Deprecated
List<NodeRef> getAllContained(NodeRef recordCategory);
/**
* Get all the record categories within a record category.
*
* @param recordCategory record category node reference
* @param deep if true then return all children including sub-categories and their children in turn, if false then just
* return the immediate children
* @return {@link List}<{@link NodeRef>} list of container node references
* @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)}
*/
@Deprecated
List<NodeRef> getContainedRecordCategories(NodeRef recordCategory, boolean deep);
/**
* Only return immediate children.
*
* @see RecordsManagementService#getContainedRecordCategories(NodeRef, boolean)
*
* @param recordCategory container node reference
* @return {@link List}<{@link NodeRef>} list of container node references
* @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)}
*/
@Deprecated
List<NodeRef> getContainedRecordCategories(NodeRef recordCategory);
/**
* Get all the record folders contained within a container
*
* @param container container node reference
* @param deep if true then return all children including sub-containers and their children in turn, if false then just
* return the immediate children
* @return {@link List}<{@link NodeRef>} list of record folder node references
* @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)}
*/
@Deprecated
List<NodeRef> getContainedRecordFolders(NodeRef container, boolean deep);
/**
* Only return immediate children.
*
* @see RecordsManagementService#getContainedRecordFolders(NodeRef, boolean)
*
* @param container container node reference
* @return {@link List}<{@link NodeRef>} list of record folder node references
* @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)}
*/
@Deprecated
List<NodeRef> getContainedRecordFolders(NodeRef container);
// TODO List<NodeRef> getParentRecordCategories(NodeRef container); // also applicable to record folders
/**
* Create a record category.
*
* @param parent parent node reference, must be a record category or file plan.
* @param name name of the new record category
* @param type type of container to create, must be a sub-type of rm:recordCategory
* @return NodeRef node reference of the created record category
* @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)}
*/
@Deprecated
NodeRef createRecordCategory(NodeRef parent, String name, QName type);
/**
*
* @param parent
* @param name
* @param type
* @param properties
* @return
* @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)}
*/
@Deprecated
NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map<QName, Serializable> properties);
/**
* Creates a record category of type rma:recordCategory
*
* @see RecordsManagementService#createRecordCategory(NodeRef, String, QName)
*
* @param parent parent node reference, must be a record category or file plan.
* @param name name of the record category
* @return NodeRef node reference of the created record category
* @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)}
*/
@Deprecated
NodeRef createRecordCategory(NodeRef parent, String name);
/**
*
* @param parent
* @param name
* @param properties
* @return
* @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)}
*/
@Deprecated
NodeRef createRecordCategory(NodeRef parent, String name, Map<QName, Serializable> properties);
// TODO void deleteRecordCategory(NodeRef container);
// TODO move, copy, link ??
/********** Record Folder methods **********/
@@ -421,75 +319,40 @@ public interface RecordsManagementService
/********** Deprecated **********/
/**
* Get a list of all the record meta-data aspects
*
* @return {@link Set}<{@link QName}> list of record meta-data aspects
*
/**
* @deprecated As of 2.1, replaced by {@link RecordService#getRecordMetaDataAspects()}
*/
@Deprecated
Set<QName> getRecordMetaDataAspects();
/**
* Indicates whether the record is declared
*
* @param nodeRef node reference (record)
* @return boolean true if record is declared, false otherwise
*
* @deprecated As of 2.1, replaced by {@link RecordService#isDeclared(NodeRef)}
*/
@Deprecated
boolean isRecordDeclared(NodeRef nodeRef);
/**
* Indicates whether the given node is a hold (container) or not.
*
* @param nodeRef node reference
* @return boolean true if hold, false otherwise
*
* @since 2.0
*
* @deprecated As of 2.1, replaced by {@link FreezeService#isHold(NodeRef)}
*/
@Deprecated
boolean isHold(NodeRef nodeRef);
/**
* Indicates whether the item is frozen or not.
*
* @param nodeRef node reference
* @return boolean true if record is frozen, false otherwise
*
* @since 2.0
*
* @deprecated As of 2.1, replaced by {@link FreezeService#isFrozen(NodeRef)}
*/
@Deprecated
boolean isFrozen(NodeRef nodeRef);
/**
* Indicates whether the item has frozen children or not.
*
* NOTE: this only checks the immediate children and does not check the frozen
* state of the node being passed
*
* @param nodeRef node reference
* @return boolean true if record folder has frozen children, false otherwise
*
* @since 2.0
*
* @deprecated As of 2.1, replaced by {@link FreezeService#hasFrozenChildren(NodeRef)}
*/
@Deprecated
boolean hasFrozenChildren(NodeRef nodeRef);
/**
* Indicates whether the given node is a record or not.
*
* @param nodeRef node reference
* @return boolean true if record, false otherwise
*
* @deprecated As of 2.1, replaced by {@link RecordService#isRecord(NodeRef)}
*/
@Deprecated

View File

@@ -22,7 +22,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -30,6 +29,7 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
@@ -68,14 +68,6 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
private final static String MSG_UPDATE_DISP_ACT_DEF = "rm.service.update-disposition-action-def";
private final static String MSG_SET_ID = "rm.service.set-id";
private final static String MSG_PATH_NODE = "rm.service.path-node";
private final static String MSG_INVALID_RM_NODE = "rm.service.invalid-rm-node";
private final static String MSG_NO_ROOT = "rm.service.no-root";
private final static String MSG_DUP_ROOT = "rm.service.dup-root";
private final static String MSG_ROOT_TYPE = "rm.service.root-type";
private final static String MSG_CONTAINER_PARENT_TYPE= "rm.service.container-parent-type";
private final static String MSG_CONTAINER_TYPE = "rm.service.container-type";
private final static String MSG_CONTAINER_EXPECTED = "rm.service.container-expected";
private final static String MSG_RECORD_FOLDER_EXPECTED = "rm.service.record-folder-expected";
private final static String MSG_PARENT_RECORD_FOLDER_ROOT = "rm.service.parent-record-folder-root";
private final static String MSG_PARENT_RECORD_FOLDER_TYPE = "rm.service.parent-record-folder-type";
@@ -141,6 +133,11 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
{
this.defaultStoreRef = defaultStoreRef;
}
private FilePlanService getFilePlanService()
{
return (FilePlanService)applicationContext.getBean("filePlanService");
}
/**
* Init method. Registered behaviours.
@@ -409,131 +406,49 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
@Deprecated
public boolean isFilePlan(NodeRef nodeRef)
{
return serviceRegistry.getFilePlanService().isFilePlan(nodeRef);
return getFilePlanService().isFilePlan(nodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordsManagementContainer(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)}
*/
@Override
public boolean isRecordsManagementContainer(NodeRef nodeRef)
{
return instanceOf(nodeRef, TYPE_RECORDS_MANAGEMENT_CONTAINER);
return getFilePlanService().isFilePlanContainer(nodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1, see {@link FilePlanService#isFilePlanComponent(NodeRef)}
*/
public boolean isFilePlanComponent(NodeRef nodeRef)
{
boolean result = false;
if (nodeService.exists(nodeRef) == true &&
nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) == true)
{
result = true;
}
return result;
return getFilePlanService().isFilePlan(nodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlanComponentKind(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)}
*/
public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef)
{
FilePlanComponentKind result = null;
if (isFilePlanComponent(nodeRef) == true)
{
result = FilePlanComponentKind.FILE_PLAN_COMPONENT;
if (isFilePlan(nodeRef) == true)
{
result = FilePlanComponentKind.FILE_PLAN;
}
else if (isRecordCategory(nodeRef) == true)
{
result = FilePlanComponentKind.RECORD_CATEGORY;
}
else if (isRecordFolder(nodeRef) == true)
{
result = FilePlanComponentKind.RECORD_FOLDER;
}
else if (isRecord(nodeRef) == true)
{
result = FilePlanComponentKind.RECORD;
}
else if (isHold(nodeRef) == true)
{
result = FilePlanComponentKind.HOLD;
}
else if (isTransfer(nodeRef) == true)
{
result = FilePlanComponentKind.TRANSFER;
}
else if (instanceOf(nodeRef, TYPE_DISPOSITION_SCHEDULE) == true || instanceOf(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION) == true)
{
result = FilePlanComponentKind.DISPOSITION_SCHEDULE;
}
else if (instanceOf(nodeRef, TYPE_UNFILED_RECORD_CONTAINER) == true)
{
result = FilePlanComponentKind.UNFILED_RECORD_CONTAINER;
}
}
return result;
return getFilePlanService().getFilePlanComponentKind(nodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlanComponentKindFromType(org.alfresco.service.namespace.QName)
* @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)}
*/
@Override
public FilePlanComponentKind getFilePlanComponentKindFromType(QName type)
{
FilePlanComponentKind result = null;
if (ASPECT_FILE_PLAN_COMPONENT.equals(type) == true)
{
result = FilePlanComponentKind.FILE_PLAN_COMPONENT;
}
else if (dictionaryService.isSubClass(type, ASPECT_RECORD) == true)
{
result = FilePlanComponentKind.RECORD;
}
else if (dictionaryService.isSubClass(type, TYPE_FILE_PLAN) == true)
{
result = FilePlanComponentKind.FILE_PLAN;
}
else if (dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY) == true)
{
result = FilePlanComponentKind.RECORD_CATEGORY;
}
else if (dictionaryService.isSubClass(type, TYPE_RECORD_FOLDER) == true)
{
result = FilePlanComponentKind.RECORD_FOLDER;
}
else if (dictionaryService.isSubClass(type, TYPE_HOLD) == true)
{
result = FilePlanComponentKind.HOLD;
}
else if (dictionaryService.isSubClass(type, TYPE_TRANSFER) == true)
{
result = FilePlanComponentKind.TRANSFER;
}
else if (dictionaryService.isSubClass(type, TYPE_DISPOSITION_SCHEDULE) == true ||
dictionaryService.isSubClass(type, TYPE_DISPOSITION_ACTION_DEFINITION) == true)
{
result = FilePlanComponentKind.DISPOSITION_SCHEDULE;
}
return result;
return getFilePlanService().getFilePlanComponentKindFromType(type);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordCategory(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)}
*/
public boolean isRecordCategory(NodeRef nodeRef)
{
return instanceOf(nodeRef, TYPE_RECORD_CATEGORY);
return getFilePlanService().isRecordCategory(nodeRef);
}
/**
@@ -577,55 +492,15 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
@Deprecated
public NodeRef getFilePlan(NodeRef nodeRef)
{
FilePlanService filePlanService = (FilePlanService)applicationContext.getBean("filePlanService");
return filePlanService.getFilePlan(nodeRef);
return getFilePlanService().getFilePlan(nodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getNodeRefPath(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)}
*/
public List<NodeRef> getNodeRefPath(NodeRef nodeRef)
{
LinkedList<NodeRef> nodeRefPath = new LinkedList<NodeRef>();
try
{
getNodeRefPathRecursive(nodeRef, nodeRefPath);
}
catch (Throwable e)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PATH_NODE, nodeRef), e);
}
return nodeRefPath;
}
/**
* Helper method to build a <b>NodeRef</b> path from the node to the RM root
*/
private void getNodeRefPathRecursive(NodeRef nodeRef, LinkedList<NodeRef> nodeRefPath)
{
if (isFilePlanComponent(nodeRef) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_INVALID_RM_NODE, ASPECT_FILE_PLAN_COMPONENT.toString()));
}
// Prepend it to the path
nodeRefPath.addFirst(nodeRef);
// Are we at the root
if (isFilePlan(nodeRef) == true)
{
// We're done
}
else
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef);
if (assocRef == null)
{
// We hit the top of the store
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_ROOT));
}
// Recurse
nodeRef = assocRef.getParentRef();
getNodeRefPathRecursive(nodeRef, nodeRefPath);
}
return getFilePlanService().getNodeRefPath(nodeRef);
}
/**
@@ -636,237 +511,126 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
@Deprecated
public List<NodeRef> getFilePlans()
{
return new ArrayList<NodeRef>(serviceRegistry.getFilePlanService().getFilePlans());
return new ArrayList<NodeRef>(getFilePlanService().getFilePlans());
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map)
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)}
*/
public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map<QName, Serializable> properties)
{
ParameterCheck.mandatory("parent", parent);
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("type", type);
// Check the parent is not already an RM component node
// ie: you can't create a rm root in an existing rm hierarchy
if (isFilePlanComponent(parent) == true)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DUP_ROOT));
}
// Check that the passed type is a sub-type of rma:filePlan
if (TYPE_FILE_PLAN.equals(type) == false &&
dictionaryService.isSubClass(type, TYPE_FILE_PLAN) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ROOT_TYPE, type.toString()));
}
// Build map of properties
Map<QName, Serializable> rmRootProps = new HashMap<QName, Serializable>(1);
if (properties != null && properties.size() != 0)
{
rmRootProps.putAll(properties);
}
rmRootProps.put(ContentModel.PROP_NAME, name);
// Create the root
ChildAssociationRef assocRef = nodeService.createNode(
parent,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
type,
rmRootProps);
// TODO do we need to create role and security groups or is this done automatically?
return assocRef.getChildRef();
return getFilePlanService().createFilePlan(parent, name, type, properties);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)}
*/
public NodeRef createFilePlan(NodeRef parent, String name, Map<QName, Serializable> properties)
{
return createFilePlan(parent, name, TYPE_FILE_PLAN, properties);
return getFilePlanService().createFilePlan(parent, name, properties);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)}
*/
public NodeRef createFilePlan(NodeRef parent, String name)
{
return createFilePlan(parent, name, TYPE_FILE_PLAN, null);
return getFilePlanService().createFilePlan(parent, name);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName)
* @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)}
*/
@Override
public NodeRef createFilePlan(NodeRef parent, String name, QName type)
{
return createFilePlan(parent, name, type, null);
return getFilePlanService().createFilePlan(parent, name, type);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map)
* @deprecated as of 2.1
*/
public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map<QName, Serializable> properties)
{
ParameterCheck.mandatory("parent", parent);
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("type", type);
// Check that the parent is a container
QName parentType = nodeService.getType(parent);
if (TYPE_RECORDS_MANAGEMENT_CONTAINER.equals(parentType) == false &&
dictionaryService.isSubClass(parentType, TYPE_RECORDS_MANAGEMENT_CONTAINER) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_PARENT_TYPE, parentType.toString()));
}
// Check that the the provided type is a sub-type of rm:recordCategory
if (TYPE_RECORD_CATEGORY.equals(type) == false &&
dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_TYPE, type.toString()));
}
// Set the properties for the record category
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
if (properties != null && properties.size() != 0)
{
props.putAll(properties);
}
props.put(ContentModel.PROP_NAME, name);
return nodeService.createNode(
parent,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
type,
props).getChildRef();
return getFilePlanService().createRecordCategory(parent, name, type, properties);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
* @deprecated as of 2.1
*/
public NodeRef createRecordCategory(NodeRef parent, String name)
{
return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY);
return getFilePlanService().createRecordCategory(parent, name);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
* @deprecated as of 2.1
*/
public NodeRef createRecordCategory(NodeRef parent, String name, Map<QName, Serializable> properties)
{
return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY, properties);
return getFilePlanService().createRecordCategory(parent, name, properties);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName)
* @deprecated as of 2.1
*/
public NodeRef createRecordCategory(NodeRef parent, String name, QName type)
{
return createRecordCategory(parent, name, type, null);
return getFilePlanService().createRecordCategory(parent, name, type);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getAllContained(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1
*/
@Override
public List<NodeRef> getAllContained(NodeRef container)
{
return getAllContained(container, false);
return getFilePlanService().getAllContained(container);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getAllContained(org.alfresco.service.cmr.repository.NodeRef, boolean)
* @deprecated as of 2.1
*/
@Override
public List<NodeRef> getAllContained(NodeRef container, boolean deep)
{
return getContained(container, null, deep);
return getFilePlanService().getAllContained(container, deep);
}
/**
* Get contained nodes of a particular type. If null return all.
*
* @param container container node reference
* @param typeFilter type filter, null if none
* @return {@link List}<{@link NodeRef> list of contained node references
*/
private List<NodeRef> getContained(NodeRef container, QName typeFilter, boolean deep)
{
// Parameter check
ParameterCheck.mandatory("container", container);
// Check we have a container in our hands
if (isRecordCategory(container) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED));
}
List<NodeRef> result = new ArrayList<NodeRef>(1);
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{
NodeRef child = assoc.getChildRef();
QName childType = nodeService.getType(child);
if (typeFilter == null ||
typeFilter.equals(childType) == true ||
dictionaryService.isSubClass(childType, typeFilter) == true)
{
result.add(child);
}
// Inspect the containers and add children if deep
if (deep == true &&
(TYPE_RECORD_CATEGORY.equals(childType) == true ||
dictionaryService.isSubClass(childType, TYPE_RECORD_CATEGORY) == true))
{
result.addAll(getContained(child, typeFilter, deep));
}
}
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1
*/
@Override
public List<NodeRef> getContainedRecordCategories(NodeRef container)
{
return getContainedRecordCategories(container, false);
return getFilePlanService().getContainedRecordCategories(container);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef, boolean)
* @deprecated as of 2.1
*/
@Override
public List<NodeRef> getContainedRecordCategories(NodeRef container, boolean deep)
{
return getContained(container, TYPE_RECORD_CATEGORY, deep);
return getFilePlanService().getContainedRecordCategories(container, deep);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef)
* @deprecated as of 2.1
*/
@Override
public List<NodeRef> getContainedRecordFolders(NodeRef container)
{
return getContainedRecordFolders(container, false);
return getFilePlanService().getContainedRecordFolders(container);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef, boolean)
* @deprecated as of 2.1
*/
@Override
public List<NodeRef> getContainedRecordFolders(NodeRef container, boolean deep)
{
return getContained(container, TYPE_RECORD_FOLDER, deep);
return getFilePlanService().getContainedRecordFolders(container, deep);
}
/**

View File

@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
@@ -38,6 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
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.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;

View File

@@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.action;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
@@ -40,7 +41,10 @@ public abstract class RecordsManagementActionConditionEvaluatorAbstractBase exte
BeanNameAware
{
/** records management action service */
private RecordsManagementActionService recordsManagementActionService;
protected RecordsManagementActionService recordsManagementActionService;
/** File Plan Service */
protected FilePlanService filePlanService;
/** bean name */
private String name;
@@ -57,6 +61,14 @@ public abstract class RecordsManagementActionConditionEvaluatorAbstractBase exte
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @param retryingTransactionHelper

View File

@@ -20,7 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.action;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.service.cmr.action.ActionDefinition;
/**

View File

@@ -20,7 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.action;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.repo.action.ActionDefinitionImpl;
/**

View File

@@ -29,7 +29,7 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPoliciesUtil;
import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -134,7 +134,7 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
protected void invokeBeforeRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
{
// get qnames to invoke against
Set<QName> qnames = RecordsManagementPoliciesUtil.getTypeAndAspectQNames(nodeService, nodeRef);
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, nodeRef);
// execute policy for node type and aspects
BeforeRMActionExecution policy = beforeRMActionExecutionDelegate.get(qnames);
policy.beforeRMActionExecution(nodeRef, name, parameters);
@@ -150,7 +150,7 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
protected void invokeOnRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
{
// get qnames to invoke against
Set<QName> qnames = RecordsManagementPoliciesUtil.getTypeAndAspectQNames(nodeService, nodeRef);
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, nodeRef);
// execute policy for node type and aspects
OnRMActionExecution policy = onRMActionExecutionDelegate.get(qnames);
policy.onRMActionExecution(nodeRef, name, parameters);

View File

@@ -25,6 +25,7 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
import org.alfresco.repo.i18n.StaticMessageLookup;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.namespace.QName;
@@ -68,7 +69,7 @@ public class RecordTypeParameterConstraint extends BaseParameterConstraint
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
if (aspectDefinition != null)
{
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle());
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup()));
}
}
return result;

View File

@@ -16,7 +16,7 @@
* 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;
package org.alfresco.module.org_alfresco_module_rm.action.evaluator;
/**
* Disposition action relative position enumeration class. <br>

View File

@@ -20,7 +20,6 @@ package org.alfresco.module.org_alfresco_module_rm.action.evaluator;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.DispositionActionRelativePositions;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
@@ -128,5 +127,4 @@ public class HasDispositionActionEvaluator extends RecordsManagementActionCondit
"rm-ac-disposition-actions"));
}
}

View File

@@ -20,9 +20,8 @@ package org.alfresco.module.org_alfresco_module_rm.action.evaluator;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ParameterDefinition;
@@ -50,23 +49,13 @@ public class IsKindEvaluator extends RecordsManagementActionConditionEvaluatorAb
public static final String NAME = "isKind";
public static final String PARAM_KIND = "kind";
private RecordsManagementService rmService;
/**
* @param rmService
*/
public void setRecordsManagementService(RecordsManagementService rmService)
{
this.rmService = rmService;
}
@Override
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
{
boolean result = false;
String kind = ((QName) actionCondition.getParameterValue(PARAM_KIND)).getLocalName();
FilePlanComponentKind filePlanComponentKind = rmService.getFilePlanComponentKind(actionedUponNodeRef);
FilePlanComponentKind filePlanComponentKind = filePlanService.getFilePlanComponentKind(actionedUponNodeRef);
if (filePlanComponentKind.toString().equals(kind))
{

View File

@@ -20,6 +20,7 @@ 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.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
@@ -35,6 +36,17 @@ public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBas
/** Logger */
@SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(CreateDispositionScheduleAction.class);
/** file plan service */
private FilePlanService filePlanService;
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
@@ -42,7 +54,7 @@ public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBas
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
if (recordsManagementService.isRecordCategory(actionedUponNodeRef) == true)
if (filePlanService.isRecordCategory(actionedUponNodeRef) == true)
{
// Create the disposition schedule
dispositionService.createDispositionSchedule(actionedUponNodeRef, null);

View File

@@ -167,7 +167,7 @@ public class FileToAction extends RMActionExecuterAbstractBase
}
// ensure we are trying to create a record folder in a record category
if (recordsManagementService.isRecordCategory(parent) == false)
if (filePlanService.isRecordCategory(parent) == false)
{
throw new AlfrescoRuntimeException("Unable to create nre record folder, beacuse the parent is not a record category.");
}

View File

@@ -33,7 +33,6 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPoliciesUtil;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeCreateReference;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRemoveReference;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference;
@@ -43,6 +42,7 @@ import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstrain
import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.dictionary.DictionaryRepositoryBootstrap;
import org.alfresco.repo.dictionary.IndexTokenisationMode;
@@ -225,7 +225,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
protected void invokeBeforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
{
// get qnames to invoke against
Set<QName> qnames = RecordsManagementPoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
// execute policy for node type and aspects
BeforeCreateReference policy = beforeCreateReferenceDelegate.get(qnames);
policy.beforeCreateReference(fromNodeRef, toNodeRef, reference);
@@ -234,7 +234,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
protected void invokeOnCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
{
// get qnames to invoke against
Set<QName> qnames = RecordsManagementPoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
// execute policy for node type and aspects
OnCreateReference policy = onCreateReferenceDelegate.get(qnames);
policy.onCreateReference(fromNodeRef, toNodeRef, reference);
@@ -243,7 +243,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
protected void invokeBeforeRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
{
// get qnames to invoke against
Set<QName> qnames = RecordsManagementPoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
// execute policy for node type and aspects
BeforeRemoveReference policy = beforeRemoveReferenceDelegate.get(qnames);
policy.beforeRemoveReference(fromNodeRef, toNodeRef, reference);
@@ -258,7 +258,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
protected void invokeOnRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
{
// get qnames to invoke against
Set<QName> qnames = RecordsManagementPoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, fromNodeRef);
// execute policy for node type and aspects
OnRemoveReference policy = onRemoveReferenceDelegate.get(qnames);
policy.onRemoveReference(fromNodeRef, toNodeRef, reference);

View File

@@ -23,6 +23,7 @@ import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -41,7 +42,7 @@ import org.alfresco.service.cmr.repository.NodeService;
public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor
{
private NodeService nodeService;
private RecordsManagementService rmService;
private FilePlanService filePlanService;
/**
* Used to check that the node in the context is a fileplan component
@@ -52,12 +53,12 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor
}
/**
* Used to find the RM root
* @param filePlanService file plan service
*/
public void setRmService(RecordsManagementService rmService)
public void setFilePlanService(FilePlanService filePlanService)
{
this.rmService = rmService;
}
this.filePlanService = filePlanService;
}
/**
* @return Returns <tt>true</tt> if the data is a NodeRef and it represents
@@ -72,12 +73,15 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor
return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
}
/**
* @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable)
*/
public Serializable extractData(Serializable value) throws Throwable
{
NodeRef nodeRef = (NodeRef) value;
// Get path from the RM root
List<NodeRef> nodeRefPath = rmService.getNodeRefPath(nodeRef);
List<NodeRef> nodeRefPath = filePlanService.getNodeRefPath(nodeRef);
StringBuilder sb = new StringBuilder(128);
for (NodeRef pathNodeRef : nodeRefPath)

View File

@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -35,12 +36,12 @@ import org.alfresco.service.cmr.repository.NodeService;
* @see RecordsManagementService#getNodeRefPath(NodeRef)
*
* @author Derek Hulley
* @since 3.2
* @since 1.0
*/
public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtractor
{
private NodeService nodeService;
private RecordsManagementService rmService;
private FilePlanService filePlanService;
/**
* Used to check that the node in the context is a fileplan component
@@ -50,13 +51,10 @@ public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtracto
this.nodeService = nodeService;
}
/**
* Used to find the RM root
*/
public void setRmService(RecordsManagementService rmService)
public void setFilePlanService(FilePlanService filePlanService)
{
this.rmService = rmService;
}
this.filePlanService = filePlanService;
}
/**
* @return Returns <tt>true</tt> if the data is a NodeRef and it represents
@@ -76,7 +74,7 @@ public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtracto
NodeRef nodeRef = (NodeRef) value;
// Get path from the RM root
List<NodeRef> nodeRefPath = rmService.getNodeRefPath(nodeRef);
List<NodeRef> nodeRefPath = filePlanService.getNodeRefPath(nodeRef);
// Done
return (Serializable) nodeRefPath;

View File

@@ -68,40 +68,83 @@ public interface RecordsManagementAuditService
public static final String RM_AUDIT_DATA_LOGIN_ERROR = "/RM/login/error/value";
/**
* Starts RM auditing.
* @deprecated as of 2.1, see {@link #start(NodeRef)}
*/
@Deprecated
void start();
/**
* Stops RM auditing.
* Start RM auditing.
*
* @param filePlan file plan
*/
void startAuditLog(NodeRef filePlan);
/**
* @deprecated as of 2.1, see {@link #stop(NodeRef)}
*/
@Deprecated
void stop();
/**
* Clears the RM audit trail.
* Stop RM auditing.
*
* @param filePlan file plan
*/
void stopAuditLog(NodeRef filePlan);
/**
* @deprecated as of 2.1, see {@link #clear(NodeRef)}
*/
@Deprecated
void clear();
/**
* Clears the RM audit.
*
* @param filePlan file plan
*/
void clearAuditLog(NodeRef filePlan);
/**
* @deprecated as of 2.1, see {@link #isEnabled(NodeRef)}
*/
@Deprecated
boolean isEnabled();
/**
* Determines whether the RM audit log is currently enabled.
*
* @param filePlan file plan
* @return true if RM auditing is active false otherwise
*/
boolean isEnabled();
boolean isAuditLogEnabled(NodeRef filePlan);
/**
* @deprecated as of 2.1, see {@link #getDateLastStarted(NodeRef)}
*/
@Deprecated
Date getDateLastStarted();
/**
* Returns the date the RM audit was last started.
*
* @return Date the audit was last started
* @param filePlan file plan
* @return Date the audit was last started
*/
Date getDateLastStarted();
Date getDateAuditLogLastStarted(NodeRef filePlan);
/**
* @deprecated as of 2.1, see {@link #getDateLastStopped(NodeRef)}
*/
Date getDateLastStopped();
/**
* Returns the date the RM audit was last stopped.
*
* @return Date the audit was last stopped
*/
Date getDateLastStopped();
Date getDateAuditLogLastStopped(NodeRef filePlan);
/**
* An explicit call that RM actions can make to have the events logged.
@@ -157,8 +200,7 @@ public interface RecordsManagementAuditService
* @param format The format the report should be produced in
* @return NodeRef of the undeclared record filed
*/
NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params,
NodeRef destination, ReportFormat format);
NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params, NodeRef destination, ReportFormat format);
/**
* Retrieves a list of audit events.

View File

@@ -36,6 +36,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.audit.AuditComponent;
import org.alfresco.repo.audit.model.AuditApplication;
@@ -88,11 +89,11 @@ import org.springframework.extensions.surf.util.ParameterCheck;
* @since 3.2
*/
public class RecordsManagementAuditServiceImpl
extends AbstractLifecycleBean
implements RecordsManagementAuditService,
NodeServicePolicies.OnCreateNodePolicy,
NodeServicePolicies.BeforeDeleteNodePolicy,
NodeServicePolicies.OnUpdatePropertiesPolicy
extends AbstractLifecycleBean
implements RecordsManagementAuditService,
NodeServicePolicies.OnCreateNodePolicy,
NodeServicePolicies.BeforeDeleteNodePolicy,
NodeServicePolicies.OnUpdatePropertiesPolicy
{
/** I18N */
private static final String MSG_UPDATED_METADATA = "rm.audit.updated-metadata";
@@ -149,16 +150,13 @@ public class RecordsManagementAuditServiceImpl
private AuditService auditService;
private RecordsManagementService rmService;
private RecordsManagementActionService rmActionService;
private FilePlanService filePlanService;
private boolean shutdown = false;
private RMAuditTxnListener txnListener;
private Map<String, AuditEvent> auditEvents;
public RecordsManagementAuditServiceImpl()
{
}
/**
* Set the component used to bind to behaviour callbacks
*/
@@ -230,6 +228,14 @@ public class RecordsManagementAuditServiceImpl
{
this.rmActionService = rmActionService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* Checks that all necessary properties have been set.
@@ -245,6 +251,7 @@ public class RecordsManagementAuditServiceImpl
PropertyCheck.mandatory(this, "rmService", rmService);
PropertyCheck.mandatory(this, "rmActionService", rmActionService);
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
PropertyCheck.mandatory(this, "filePlanService", filePlanService);
// setup the audit events map
initAuditEvents();
@@ -357,12 +364,44 @@ public class RecordsManagementAuditServiceImpl
{
shutdown = true;
}
/*** TODO remove this when we support multiple file plans ****/
private NodeRef defaultFilePlan;
private NodeRef getDefaultFilePlan()
{
if (defaultFilePlan == null)
{
defaultFilePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (defaultFilePlan == null)
{
throw new AlfrescoRuntimeException("Default file plan could not be found.");
}
}
return defaultFilePlan;
}
/*** TODO end ***/
/**
* {@inheritDoc}
*/
public boolean isEnabled()
@Override
@Deprecated
public boolean isEnabled()
{
return isAuditLogEnabled(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
public boolean isAuditLogEnabled(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log
return auditService.isAuditEnabled(
RecordsManagementAuditService.RM_AUDIT_APPLICATION_NAME,
RecordsManagementAuditService.RM_AUDIT_PATH_ROOT);
@@ -371,32 +410,71 @@ public class RecordsManagementAuditServiceImpl
/**
* {@inheritDoc}
*/
@Deprecated
public void start()
{
startAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
public void startAuditLog(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log
auditService.enableAudit(
RecordsManagementAuditService.RM_AUDIT_APPLICATION_NAME,
RecordsManagementAuditService.RM_AUDIT_PATH_ROOT);
if (logger.isInfoEnabled())
{
logger.info("Started Records Management auditing");
}
}
/**
* {@inheritDoc}
*/
@Deprecated
public void stop()
{
stopAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
public void stopAuditLog(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log
auditService.disableAudit(
RecordsManagementAuditService.RM_AUDIT_APPLICATION_NAME,
RecordsManagementAuditService.RM_AUDIT_PATH_ROOT);
if (logger.isInfoEnabled())
logger.info("Stopped Records Management auditing");
}
/**
* {@inheritDoc}
*/
@Deprecated
public void clear()
{
clearAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
public void clear()
public void clearAuditLog(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log
auditService.clearAudit(RecordsManagementAuditService.RM_AUDIT_APPLICATION_NAME, null, null);
if (logger.isInfoEnabled())
logger.debug("Records Management audit log has been cleared");
@@ -405,17 +483,41 @@ public class RecordsManagementAuditServiceImpl
/**
* {@inheritDoc}
*/
@Deprecated
public Date getDateLastStarted()
{
return getDateAuditLogLastStarted(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
public Date getDateAuditLogLastStarted(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log
// TODO: return proper date, for now it's today's date
return new Date();
}
/**
* {@inheritDoc}
*/
@Deprecated
public Date getDateLastStopped()
{
return getDateAuditLogLastStopped(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
public Date getDateLastStopped()
public Date getDateAuditLogLastStopped(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log
// TODO: return proper date, for now it's today's date
return new Date();
}
@@ -432,10 +534,6 @@ public class RecordsManagementAuditServiceImpl
private Map<QName, Serializable> nodePropertiesBefore;
private Map<QName, Serializable> nodePropertiesAfter;
private RMAuditNode()
{
}
public String getEventName()
{
return eventName;

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2005-2011 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.capability;
import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy;
/**
* @author Roy Wetherall
*/
public interface PolicyRegister
{
void registerPolicy(Policy policy);
}

View File

@@ -31,6 +31,8 @@ import net.sf.acegisecurity.vote.AccessDecisionVoter;
import org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition;
import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionalResourceHelper;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.OwnableService;
@@ -43,35 +45,38 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Records managment entry voter.
*
* @author Roy Wetherall, Andy Hind
*/
public class RMEntryVoter extends RMSecurityCommon
implements AccessDecisionVoter, InitializingBean, ApplicationContextAware
implements AccessDecisionVoter, InitializingBean, ApplicationContextAware, PolicyRegister
{
/** Logger */
private static Log logger = LogFactory.getLog(RMEntryVoter.class);
private NamespacePrefixResolver nspr;
private SearchService searchService;
/** Namespace resolver */
private NamespacePrefixResolver nspr;
/** Search service */
private SearchService searchService;
/** Ownable service */
private OwnableService ownableService;
/** Capability Service */
private CapabilityService capabilityService;
/** Policy map */
private HashMap<String, Policy> policies = new HashMap<String, Policy>();
// static
// {
// policies.put("Read", new ReadPolicy());
// policies.put("Create", new CreatePolicy());
// policies.put("Move", new MovePolicy());
// policies.put("Update", new UpdatePolicy());
// policies.put("Delete", new DeletePolicy());
// policies.put("UpdateProperties", new UpdatePropertiesPolicy());
// policies.put("Assoc", new AssocPolicy());
// policies.put("WriteContent", new WriteContentPolicy());
// policies.put("Capability", new CapabilityPolicy());
// policies.put("Declare", new DeclarePolicy());
// policies.put("ReadProperty", new ReadPropertyPolicy());
// }
/** Application context */
private ApplicationContext applicationContext;
/**
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
@@ -87,7 +92,6 @@ public class RMEntryVoter extends RMSecurityCommon
}
/**
* Get the search service
* @return search service
*/
public SearchService getSearchService()
@@ -100,8 +104,7 @@ public class RMEntryVoter extends RMSecurityCommon
}
/**
*
* @return
* @return ownable service
*/
public OwnableService getOwnableService()
{
@@ -113,9 +116,7 @@ public class RMEntryVoter extends RMSecurityCommon
}
/**
* Set the name space prefix resolver
*
* @param nspr
* @param nspr namespace prefix resolver
*/
public void setNamespacePrefixResolver(NamespacePrefixResolver nspr)
{
@@ -138,10 +139,13 @@ public class RMEntryVoter extends RMSecurityCommon
@Override
public boolean supports(ConfigAttribute attribute)
{
if ((attribute.getAttribute() != null)
&& (attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ABSTAIN)
|| attribute.getAttribute().equals(ConfigAttributeDefinition.RM_QUERY) || attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ALLOW) || attribute.getAttribute().equals(ConfigAttributeDefinition.RM_DENY)
|| attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM_CAP) || attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM)))
if ((attribute.getAttribute() != null) &&
(attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ABSTAIN) ||
attribute.getAttribute().equals(ConfigAttributeDefinition.RM_QUERY) ||
attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ALLOW) ||
attribute.getAttribute().equals(ConfigAttributeDefinition.RM_DENY) ||
attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM_CAP) ||
attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM)))
{
return true;
}
@@ -151,132 +155,174 @@ public class RMEntryVoter extends RMSecurityCommon
}
}
/**
* @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(java.lang.Class)
*/
@SuppressWarnings("unchecked")
public boolean supports(Class clazz)
{
return (MethodInvocation.class.isAssignableFrom(clazz));
}
/**
* @see net.sf.acegisecurity.vote.AccessDecisionVoter#vote(net.sf.acegisecurity.Authentication, java.lang.Object, net.sf.acegisecurity.ConfigAttributeDefinition)
*/
@SuppressWarnings("unchecked")
public int vote(Authentication authentication, Object object, net.sf.acegisecurity.ConfigAttributeDefinition config)
{
if (logger.isDebugEnabled())
{
MethodInvocation mi = (MethodInvocation) object;
logger.debug("Method: " + mi.getMethod().toString());
}
// The system user can do anything
if (AuthenticationUtil.isRunAsUserTheSystemUser())
{
if (logger.isDebugEnabled())
{
logger.debug("Access granted for the system user");
}
return AccessDecisionVoter.ACCESS_GRANTED;
}
List<ConfigAttributeDefinition> supportedDefinitions = extractSupportedDefinitions(config);
// No RM definitions so we do not vote
if (supportedDefinitions.size() == 0)
{
return AccessDecisionVoter.ACCESS_ABSTAIN;
}
MethodInvocation invocation = (MethodInvocation) object;
Method method = invocation.getMethod();
Class[] params = method.getParameterTypes();
// If there are only capability (RM_CAP) and policy (RM) entries non must deny
// If any abstain we deny
// All present must vote to allow unless an explicit direction comes first (e.g. RM_ALLOW)
for (ConfigAttributeDefinition cad : supportedDefinitions)
{
// Whatever is found first takes precedence
if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_DENY))
{
return AccessDecisionVoter.ACCESS_DENIED;
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ABSTAIN))
{
return AccessDecisionVoter.ACCESS_ABSTAIN;
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ALLOW))
{
return AccessDecisionVoter.ACCESS_GRANTED;
}
// RM_QUERY is a special case - the entry is allowed and filtering sorts out the results
// It is distinguished from RM_ALLOW so query may have additional behaviour in the future
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_QUERY))
{
return AccessDecisionVoter.ACCESS_GRANTED;
}
// Ignore config that references method arguments that do not exist
// Arguably we should deny here but that requires a full impact analysis
// These entries effectively abstain
else if (((cad.getParameters().get(0) != null) && (cad.getParameters().get(0) >= invocation.getArguments().length)) ||
((cad.getParameters().get(1) != null) && (cad.getParameters().get(1) >= invocation.getArguments().length)))
{
continue;
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_CAP))
{
switch(checkCapability(invocation, params, cad))
{
case AccessDecisionVoter.ACCESS_DENIED:
return AccessDecisionVoter.ACCESS_DENIED;
case AccessDecisionVoter.ACCESS_ABSTAIN:
if(logger.isDebugEnabled())
{
if(logger.isTraceEnabled())
{
logger.trace("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod(), new IllegalStateException());
}
else
{
logger.debug("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod());
}
}
// abstain denies
return AccessDecisionVoter.ACCESS_DENIED;
case AccessDecisionVoter.ACCESS_GRANTED:
break;
}
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM))
{
switch(checkPolicy(invocation, params, cad))
{
case AccessDecisionVoter.ACCESS_DENIED:
return AccessDecisionVoter.ACCESS_DENIED;
case AccessDecisionVoter.ACCESS_ABSTAIN:
if(logger.isDebugEnabled())
{
if(logger.isTraceEnabled())
{
logger.trace("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod(), new IllegalStateException());
}
else
{
logger.debug("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod());
}
}
// abstain denies
return AccessDecisionVoter.ACCESS_DENIED;
case AccessDecisionVoter.ACCESS_GRANTED:
break;
}
}
MethodInvocation mi = (MethodInvocation)object;
if (TransactionalResourceHelper.isResourcePresent("voting") == true)
{
if (logger.isDebugEnabled())
{
logger.debug(" .. grant access already voting: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName());
}
return AccessDecisionVoter.ACCESS_GRANTED;
}
if (logger.isDebugEnabled())
{
logger.debug("Method: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName());
}
AlfrescoTransactionSupport.bindResource("voting", true);
try
{
// The system user can do anything
if (AuthenticationUtil.isRunAsUserTheSystemUser())
{
if (logger.isDebugEnabled())
{
logger.debug("Access granted for the system user");
}
return AccessDecisionVoter.ACCESS_GRANTED;
}
List<ConfigAttributeDefinition> supportedDefinitions = extractSupportedDefinitions(config);
// No RM definitions so we do not vote
if (supportedDefinitions.size() == 0)
{
return AccessDecisionVoter.ACCESS_ABSTAIN;
}
MethodInvocation invocation = (MethodInvocation) object;
Method method = invocation.getMethod();
Class[] params = method.getParameterTypes();
// If there are only capability (RM_CAP) and policy (RM) entries non must deny
// If any abstain we deny
// All present must vote to allow unless an explicit direction comes first (e.g. RM_ALLOW)
for (ConfigAttributeDefinition cad : supportedDefinitions)
{
// Whatever is found first takes precedence
if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_DENY))
{
return AccessDecisionVoter.ACCESS_DENIED;
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ABSTAIN))
{
return AccessDecisionVoter.ACCESS_ABSTAIN;
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ALLOW))
{
return AccessDecisionVoter.ACCESS_GRANTED;
}
// RM_QUERY is a special case - the entry is allowed and filtering sorts out the results
// It is distinguished from RM_ALLOW so query may have additional behaviour in the future
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_QUERY))
{
return AccessDecisionVoter.ACCESS_GRANTED;
}
// Ignore config that references method arguments that do not exist
// Arguably we should deny here but that requires a full impact analysis
// These entries effectively abstain
else if (((cad.getParameters().get(0) != null) && (cad.getParameters().get(0) >= invocation.getArguments().length)) ||
((cad.getParameters().get(1) != null) && (cad.getParameters().get(1) >= invocation.getArguments().length)))
{
continue;
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_CAP))
{
switch(checkCapability(invocation, params, cad))
{
case AccessDecisionVoter.ACCESS_DENIED:
{
return AccessDecisionVoter.ACCESS_DENIED;
}
case AccessDecisionVoter.ACCESS_ABSTAIN:
{
if(logger.isDebugEnabled())
{
if(logger.isTraceEnabled())
{
logger.trace("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod(), new IllegalStateException());
}
else
{
logger.debug("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod());
}
}
// abstain denies
return AccessDecisionVoter.ACCESS_DENIED;
}
case AccessDecisionVoter.ACCESS_GRANTED:
{
break;
}
}
}
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM))
{
switch(checkPolicy(invocation, params, cad))
{
case AccessDecisionVoter.ACCESS_DENIED:
{
return AccessDecisionVoter.ACCESS_DENIED;
}
case AccessDecisionVoter.ACCESS_ABSTAIN:
{
if(logger.isDebugEnabled())
{
if(logger.isTraceEnabled())
{
logger.trace("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod(), new IllegalStateException());
}
else
{
logger.debug("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod());
}
}
// abstain denies
return AccessDecisionVoter.ACCESS_DENIED;
}
case AccessDecisionVoter.ACCESS_GRANTED:
{
break;
}
}
}
}
}
finally
{
AlfrescoTransactionSupport.unbindResource("voting");
}
// all voted to allow
return AccessDecisionVoter.ACCESS_GRANTED;
}
/**
*
* @param invocation
* @param params
* @param cad
* @return
*/
@SuppressWarnings("unchecked")
private int checkCapability(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad)
{
@@ -294,6 +340,13 @@ public class RMEntryVoter extends RMSecurityCommon
}
/**
*
* @param invocation
* @param params
* @param cad
* @return
*/
@SuppressWarnings("unchecked")
private int checkPolicy(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad)
{
@@ -308,12 +361,18 @@ public class RMEntryVoter extends RMSecurityCommon
}
}
/**
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception
{
// TODO Auto-generated method stub
{
}
/**
*
* @param config
* @return
*/
@SuppressWarnings("unchecked")
private List<ConfigAttributeDefinition> extractSupportedDefinitions(net.sf.acegisecurity.ConfigAttributeDefinition config)
{
@@ -331,6 +390,5 @@ public class RMEntryVoter extends RMSecurityCommon
}
return definitions;
}
}
}

View File

@@ -18,10 +18,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.capability;
import java.util.List;
import net.sf.acegisecurity.vote.AccessDecisionVoter;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigComponent;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
@@ -143,7 +142,7 @@ public class RMSecurityCommon
{
int result = AccessDecisionVoter.ACCESS_ABSTAIN;
if (rmService.isFilePlanComponent(nodeRef) == true)
if (filePlanService.isFilePlanComponent(nodeRef) == true)
{
result = checkRmRead(nodeRef);
}
@@ -230,18 +229,16 @@ public class RMSecurityCommon
NodeRef testNodeRef = null;
if (position < 0)
{
// Test against the fileplan root node
List<NodeRef> rmRoots = rmService.getFilePlans();
if (rmRoots.size() != 0)
testNodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (testNodeRef == null)
{
throw new AlfrescoRuntimeException("Unable to find default file plan node.");
}
if (logger.isDebugEnabled())
{
// TODO for now we can take the first one as we only support a single rm site
testNodeRef = rmRoots.get(0);
if (logger.isDebugEnabled())
{
logger.debug("\tPermission test against the rm root node " + nodeService.getPath(testNodeRef));
}
}
logger.debug("\tPermission test against the file plan node " + nodeService.getPath(testNodeRef));
}
}
else if (StoreRef.class.isAssignableFrom(params[position]))
{

View File

@@ -19,6 +19,7 @@
package org.alfresco.module.org_alfresco_module_rm.capability.declarative;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -44,6 +45,7 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition
protected PermissionService permissionService;
protected NodeService nodeService;
protected FreezeService freezeService;
protected FilePlanService filePlanService;
/**
* @param rmService records management service
@@ -85,6 +87,14 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition
this.freezeService = freezeService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#getName()
*/

View File

@@ -26,9 +26,9 @@ import java.util.Map;
import net.sf.acegisecurity.vote.AccessDecisionVoter;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.apache.commons.logging.Log;
@@ -255,7 +255,7 @@ public class DeclarativeCapability extends AbstractCapability
{
boolean result = false;
FilePlanComponentKind actualKind = rmService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind actualKind = filePlanService.getFilePlanComponentKind(nodeRef);
if (actualKind != null)
{
@@ -292,7 +292,7 @@ public class DeclarativeCapability extends AbstractCapability
int result = AccessDecisionVoter.ACCESS_ABSTAIN;
// Check we are dealing with a file plan component
if (rmService.isFilePlanComponent(nodeRef) == true)
if (filePlanService.isFilePlanComponent(nodeRef) == true)
{
// Check the kind of the object, the permissions and the conditions
if (checkKinds(nodeRef) == true && checkPermissions(nodeRef) == true && checkConditions(nodeRef) == true)

View File

@@ -18,8 +18,8 @@
*/
package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -31,7 +31,7 @@ public class DeclaredCapabilityCondition extends AbstractCapabilityCondition
public boolean evaluate(NodeRef nodeRef)
{
boolean result = false;
if (FilePlanComponentKind.RECORD.equals(rmService.getFilePlanComponentKind(nodeRef)) == true)
if (FilePlanComponentKind.RECORD.equals(filePlanService.getFilePlanComponentKind(nodeRef)) == true)
{
result = recordService.isDeclared(nodeRef);
}

View File

@@ -18,8 +18,8 @@
*/
package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -35,7 +35,7 @@ public class FrozenOrHoldCondition extends AbstractCapabilityCondition
@Override
public boolean evaluate(NodeRef nodeRef)
{
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
return (freezeService.isFrozen(nodeRef) ||
(kind != null && kind.equals(FilePlanComponentKind.HOLD)));
}

View File

@@ -38,7 +38,7 @@ public class IsRecordCategoryCondition extends AbstractCapabilityCondition
{
ParameterCheck.mandatory("nodeRef", nodeRef);
return rmService.isRecordCategory(nodeRef);
return filePlanService.isRecordCategory(nodeRef);
}
}

View File

@@ -18,8 +18,8 @@
*/
package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -35,7 +35,7 @@ public class IsTransferAccessionCapabilityCondition extends AbstractCapabilityCo
{
boolean result = false;
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
if (FilePlanComponentKind.TRANSFER.equals(kind) == true)
{
Boolean value = (Boolean)nodeService.getProperty(nodeRef, PROP_TRANSFER_ACCESSION_INDICATOR);

View File

@@ -45,11 +45,11 @@ public class ChangeOrDeleteReferencesCapability extends DeclarativeCapability
*/
public int evaluate(NodeRef source, NodeRef target)
{
if (rmService.isFilePlanComponent(source))
if (filePlanService.isFilePlanComponent(source))
{
if (target != null)
{
if (rmService.isFilePlanComponent(target) == true)
if (filePlanService.isFilePlanComponent(target) == true)
{
if (checkConditions(source) == true && checkConditions(target) == true)
{

View File

@@ -72,7 +72,7 @@ public class CreateCapability extends DeclarativeCapability
return AccessDecisionVoter.ACCESS_DENIED;
}
}
if (rmService.isFilePlanComponent(destination))
if (filePlanService.isFilePlanComponent(destination))
{
if ((assocType == null) || assocType.equals(ContentModel.ASSOC_CONTAINS) == false)
{

View File

@@ -45,8 +45,8 @@ public class DeleteLinksCapability extends DeclarativeCapability
*/
public int evaluate(NodeRef source, NodeRef target)
{
if (rmService.isFilePlanComponent(source) == true &&
rmService.isFilePlanComponent(target) == true)
if (filePlanService.isFilePlanComponent(source) == true &&
filePlanService.isFilePlanComponent(target) == true)
{
if (checkConditions(source) == true && checkConditions(target) == true)
{

View File

@@ -32,7 +32,7 @@ public final class ViewRecordsCapability extends DeclarativeCapability
{
if (nodeRef != null)
{
if (rmService.isFilePlanComponent(nodeRef) == true)
if (filePlanService.isFilePlanComponent(nodeRef) == true)
{
return checkRmRead(nodeRef);
}

View File

@@ -22,7 +22,7 @@ import java.io.Serializable;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter;
import org.alfresco.module.org_alfresco_module_rm.capability.PolicyRegister;
import org.alfresco.module.org_alfresco_module_rm.capability.RMSecurityCommon;
import org.alfresco.repo.security.permissions.impl.acegi.ACLEntryVoterException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -46,8 +46,8 @@ public abstract class AbstractBasePolicy extends RMSecurityCommon
/** Capability service */
protected CapabilityService capabilityService;
/** RM entry */
protected RMEntryVoter rmEntryVoter;
/** Policy register */
protected PolicyRegister policyRegister;
/** Policy name */
protected String name;
@@ -78,19 +78,19 @@ public abstract class AbstractBasePolicy extends RMSecurityCommon
}
/**
* @param rmEntryVoter rm entry voter
* @param policyRegister policy register
*/
public void setRmEntryVoter(RMEntryVoter rmEntryVoter)
public void setPolicyRegister(PolicyRegister policyRegister)
{
this.rmEntryVoter = rmEntryVoter;
}
this.policyRegister = policyRegister;
}
/**
* Init method
*/
public void init()
{
rmEntryVoter.registerPolicy(this);
policyRegister.registerPolicy(this);
}
/**

View File

@@ -22,6 +22,10 @@ import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.aopalliance.intercept.MethodInvocation;
/**
* @author Roy Wethearll
* @since 2.1
*/
public class ReadPolicy extends AbstractBasePolicy
{

View File

@@ -25,7 +25,7 @@ import java.util.SortedSet;
import java.util.TreeSet;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
@@ -47,6 +47,9 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
/** Disposition service */
private DispositionService dispositionService;
/** File plan authentication service */
private FilePlanAuthenticationService filePlanAuthenticationService;
/**
* Set the disposition service
*
@@ -57,6 +60,14 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
this.dispositionService = dispositionService;
}
/**
* @param filePlanAuthenticationService file plan authentication service
*/
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
{
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
/**
* Select the disposition schedule to use given there is more than one
*
@@ -79,12 +90,22 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
// period than a time-based one - as we cannot know when an event will occur
// TODO Automatic events?
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
for (NodeRef f : recordFolders)
{
sortedFolders.add(f);
}
DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(sortedFolders.first());
NodeRef recordFolder = null;
if (recordFolders.size() == 1)
{
recordFolder = recordFolders.get(0);
}
else
{
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
for (NodeRef f : recordFolders)
{
sortedFolders.add(f);
}
recordFolder = sortedFolders.first();
}
DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(recordFolder);
if (logger.isDebugEnabled())
{
@@ -112,14 +133,14 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
public int compare(final NodeRef f1, final NodeRef f2)
{
// Run as admin user
return AuthenticationUtil.runAs(new RunAsWork<Integer>()
return filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<Integer>()
{
public Integer doWork() throws Exception
{
return new Integer(compareImpl(f1, f2));
}
}, AuthenticationUtil.getAdminUserName()).intValue();
}).intValue();
}
private int compareImpl(NodeRef f1, NodeRef f2)

View File

@@ -32,6 +32,7 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegist
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.BehaviourFilter;
@@ -85,6 +86,9 @@ public class DispositionServiceImpl implements
/** Disposition selection strategy */
private DispositionSelectionStrategy dispositionSelectionStrategy;
/** File plan service */
private FilePlanService filePlanService;
/** Application context */
private ApplicationContext applicationContext;
@@ -145,6 +149,14 @@ public class DispositionServiceImpl implements
this.policyComponent = policyComponent;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* Get the records management service
* NOTE: have to pull it out of the app context manually to prevent Spring circular dependancy issue
@@ -296,7 +308,7 @@ public class DispositionServiceImpl implements
if (result == null)
{
NodeRef parent = this.nodeService.getPrimaryParent(nodeRef).getParentRef();
if (parent != null && getRmService().isRecordCategory(parent) == true)
if (parent != null && filePlanService.isRecordCategory(parent) == true)
{
result = getDispositionScheduleImpl(parent);
}
@@ -339,7 +351,7 @@ public class DispositionServiceImpl implements
ParameterCheck.mandatory("nodeRef", nodeRef);
// Make sure we are dealing with an RM node
if (getRmService().isFilePlanComponent(nodeRef) == false)
if (filePlanService.isFilePlanComponent(nodeRef) == false)
{
throw new AlfrescoRuntimeException("Can not find the associated disposition schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")");
}
@@ -434,7 +446,7 @@ public class DispositionServiceImpl implements
*/
private List<NodeRef> getDisposableItemsImpl(boolean isRecordLevelDisposition, NodeRef rmContainer)
{
List<NodeRef> items = getRmService().getAllContained(rmContainer);
List<NodeRef> items = filePlanService.getAllContained(rmContainer);
List<NodeRef> result = new ArrayList<NodeRef>(items.size());
for (NodeRef item : items)
{
@@ -449,7 +461,7 @@ public class DispositionServiceImpl implements
result.add(item);
}
}
else if (getRmService().isRecordCategory(item) == true)
else if (filePlanService.isRecordCategory(item) == true)
{
if (getAssociatedDispositionScheduleImpl(item) == null)
{

View File

@@ -16,7 +16,7 @@
* 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;
package org.alfresco.module.org_alfresco_module_rm.fileplan;
/**
* File plan component kind enumeration class.

View File

@@ -18,10 +18,15 @@
*/
package org.alfresco.module.org_alfresco_module_rm.fileplan;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import com.hazelcast.impl.Node;
@@ -33,9 +38,42 @@ import com.hazelcast.impl.Node;
*/
public interface FilePlanService
{
/** Default RM site id. Can be used with {@link FilePlanService#getFilePlanBySiteId(String)} to get the file plan node. */
/**
* Default RM site id.
* Can be used with {@link FilePlanService#getFilePlanBySiteId(String)} to get the file plan node.
* */
public static final String DEFAULT_RM_SITE_ID = "rm";
/**
* Indicates whether the given node is a file plan component or not.
*
* @param nodeRef node reference
* @return boolean true if a file plan component, false otherwise
*/
boolean isFilePlanComponent(NodeRef nodeRef);
/**
* Returns the 'kind' of file plan component the node reference is.
* <p>
* Returns null if the given node reference is not a
* file plan component.
*
* @param nodeRef node reference
* @return FilePlanComponentKind the kind of file plan component the node is
*/
FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef);
/**
* Returns the file plan component 'kind' that relates to the passed
* content type.
* <p>
* Returns null if the type does not relate to a file plan component.
*
* @param type qualified name of content type
* @return FilePlanComponentKind the kind relating to the passed type
*/
FilePlanComponentKind getFilePlanComponentKindFromType(QName type);
/**
* Indicates whether the given node is file plan node or not.
*
@@ -100,5 +138,182 @@ public interface FilePlanService
* @return {@link Node} unfiled container
*/
NodeRef createUnfiledContainer(NodeRef filePlan);
/**
* Creates a file plan as a child of the given parent node, with the name
* provided.
*
* @param parent parent node reference
* @param name file plan name
* @param type type, must be rma:filePlan or sub-type of
* @return NodeRef file plan node reference
*/
NodeRef createFilePlan(NodeRef parent, String name, QName type);
/**
* Specifies the properties to be set on the created file plan.
*
* @see #createFilePlan(NodeRef, String, QName)
*
* @param parent parent node reference
* @param name file plan name
* @param type type, must be rma:filePlan or sub-type of
* @param properties file plan properties
* @return NodeRef file plan node reference
*/
NodeRef createFilePlan(NodeRef parent, String name, QName type, Map<QName, Serializable> properties);
/**
* Creates a file plan with the default type.
*
* @see #createFilePlan(NodeRef, String, QName)
*
* @param parent parent node reference
* @param name file plan name
* @return NodeRef file plan node reference
*/
NodeRef createFilePlan(NodeRef parent, String name);
/**
* Creates a file plan with the default type, specifying properties.
*
* @see #createFilePlan(NodeRef, String, QName)
*
* @param parent parent node reference
* @param name file plan name
* @param properties file plan properties
* @return NodeRef file plan node reference
*/
NodeRef createFilePlan(NodeRef parent, String name, Map<QName, Serializable> properties);
// TODO deleteFilePlan
/**
* Gets the <b>NodeRef</b> sequence from the {@link #getFilePlan(NodeRef) root}
* down to the fileplan component given. The array will start with the <b>NodeRef</b> of the root
* and end with the name of the fileplan component node given.
*
* @param nodeRef a fileplan component
* @return Returns a <b>NodeRef</b> path starting with the file plan
*/
List<NodeRef> getNodeRefPath(NodeRef nodeRef);
/**
* Indicates whether the given node is a file plan container or not.
* <p>
* This includes file plan and record category nodes.
*
* @param nodeRef node reference
* @return boolean true if node is a file plan container, false otherwise.
*/
boolean isFilePlanContainer(NodeRef nodeRef);
/**
* Indicates whether the given node is a record category or not.
*
* @param nodeRef node reference
* @return boolean true if records category, false otherwise
*/
boolean isRecordCategory(NodeRef nodeRef);
/**
* Get all the items contained within a container. This will include record folders and other record categories.
*
* @param recordCategory record category node reference
* @param deep if true then return all children including sub-categories and their children in turn, if false then just
* return the immediate children
* @return {@link List}<{@link NodeRef>} list of contained node references
*/
List<NodeRef> getAllContained(NodeRef recordCategory, boolean deep);
/**
* Only return the immediate children.
*
* @see RecordsManagementService#getAllContained(NodeRef, boolean)
*
* @param recordCategory record category node reference
* @return {@link List}<{@link NodeRef>} list of contained node references
*/
List<NodeRef> getAllContained(NodeRef recordCategory);
/**
* Get all the record categories within a record category.
*
* @param recordCategory record category node reference
* @param deep if true then return all children including sub-categories and their children in turn, if false then just
* return the immediate children
* @return {@link List}<{@link NodeRef>} list of container node references
*/
List<NodeRef> getContainedRecordCategories(NodeRef recordCategory, boolean deep);
/**
* Only return immediate children.
*
* @see RecordsManagementService#getContainedRecordCategories(NodeRef, boolean)
*
* @param recordCategory container node reference
* @return {@link List}<{@link NodeRef>} list of container node references
*/
List<NodeRef> getContainedRecordCategories(NodeRef recordCategory);
/**
* Get all the record folders contained within a container
*
* @param container container node reference
* @param deep if true then return all children including sub-containers and their children in turn, if false then just
* return the immediate children
* @return {@link List}<{@link NodeRef>} list of record folder node references
*/
List<NodeRef> getContainedRecordFolders(NodeRef container, boolean deep);
/**
* Only return immediate children.
*
* @see RecordsManagementService#getContainedRecordFolders(NodeRef, boolean)
*
* @param container container node reference
* @return {@link List}<{@link NodeRef>} list of record folder node references
*/
List<NodeRef> getContainedRecordFolders(NodeRef container);
/**
* Create a record category.
*
* @param parent parent node reference, must be a record category or file plan.
* @param name name of the new record category
* @param type type of container to create, must be a sub-type of rm:recordCategory
* @return NodeRef node reference of the created record category
*/
NodeRef createRecordCategory(NodeRef parent, String name, QName type);
/**
*
* @param parent
* @param name
* @param type
* @param properties
* @return
*/
NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map<QName, Serializable> properties);
/**
* Creates a record category of type rma:recordCategory
*
* @see RecordsManagementService#createRecordCategory(NodeRef, String, QName)
*
* @param parent parent node reference, must be a record category or file plan.
* @param name name of the record category
* @return NodeRef node reference of the created record category
*/
NodeRef createRecordCategory(NodeRef parent, String name);
/**
*
* @param parent
* @param name
* @param properties
* @return
*/
NodeRef createRecordCategory(NodeRef parent, String name, Map<QName, Serializable> properties);
}

View File

@@ -19,16 +19,22 @@
package org.alfresco.module.org_alfresco_module_rm.fileplan;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
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.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority;
@@ -38,15 +44,19 @@ 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.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* File plan service implementation.
@@ -59,6 +69,16 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
RecordsManagementModel,
ApplicationContextAware
{
/** I18N */
private final static String MSG_DUP_ROOT = "rm.service.dup-root";
private final static String MSG_ROOT_TYPE = "rm.service.root-type";
private final static String MSG_PATH_NODE = "rm.service.path-node";
private final static String MSG_INVALID_RM_NODE = "rm.service.invalid-rm-node";
private final static String MSG_NO_ROOT = "rm.service.no-root";
private final static String MSG_CONTAINER_PARENT_TYPE= "rm.service.container-parent-type";
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 */
private static final String NAME_UNFILED_CONTAINER = "Unfiled Records";
private static final QName QNAME_UNFILED_CONTAINER = QName.createQName(RM_URI, NAME_UNFILED_CONTAINER);
@@ -121,6 +141,145 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
return (SiteService)applicationContext.getBean("SiteService");
}
/**
* @return record service
*/
protected RecordService getRecordService()
{
return (RecordService)applicationContext.getBean("RecordService");
}
/**
* @return record folder service
*/
protected RecordFolderService getRecordFolderService()
{
return (RecordFolderService)applicationContext.getBean("RecordFolderService");
}
/**
* @return freeze service
*/
protected FreezeService getFreezeService()
{
return (FreezeService)applicationContext.getBean("FreezeService");
}
/**
* @return records management service
*/
protected RecordsManagementService getRecordsManagementService()
{
return (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean isFilePlanComponent(NodeRef nodeRef)
{
boolean result = false;
if (nodeService.exists(nodeRef) == true &&
nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) == true)
{
result = true;
}
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanComponentKind(org.alfresco.service.cmr.repository.NodeRef)
*/
public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef)
{
FilePlanComponentKind result = null;
if (isFilePlanComponent(nodeRef) == true)
{
result = FilePlanComponentKind.FILE_PLAN_COMPONENT;
if (isFilePlan(nodeRef) == true)
{
result = FilePlanComponentKind.FILE_PLAN;
}
else if (isRecordCategory(nodeRef) == true)
{
result = FilePlanComponentKind.RECORD_CATEGORY;
}
else if (getRecordsManagementService().isRecordFolder(nodeRef) == true)
{
result = FilePlanComponentKind.RECORD_FOLDER;
}
else if (getRecordService().isRecord(nodeRef) == true)
{
result = FilePlanComponentKind.RECORD;
}
else if (getFreezeService().isHold(nodeRef) == true)
{
result = FilePlanComponentKind.HOLD;
}
else if (getRecordsManagementService().isTransfer(nodeRef) == true)
{
result = FilePlanComponentKind.TRANSFER;
}
else if (instanceOf(nodeRef, TYPE_DISPOSITION_SCHEDULE) == true || instanceOf(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION) == true)
{
result = FilePlanComponentKind.DISPOSITION_SCHEDULE;
}
else if (instanceOf(nodeRef, TYPE_UNFILED_RECORD_CONTAINER) == true)
{
result = FilePlanComponentKind.UNFILED_RECORD_CONTAINER;
}
}
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlanComponentKindFromType(org.alfresco.service.namespace.QName)
*/
@Override
public FilePlanComponentKind getFilePlanComponentKindFromType(QName type)
{
FilePlanComponentKind result = null;
if (ASPECT_FILE_PLAN_COMPONENT.equals(type) == true)
{
result = FilePlanComponentKind.FILE_PLAN_COMPONENT;
}
else if (dictionaryService.isSubClass(type, ASPECT_RECORD) == true)
{
result = FilePlanComponentKind.RECORD;
}
else if (dictionaryService.isSubClass(type, TYPE_FILE_PLAN) == true)
{
result = FilePlanComponentKind.FILE_PLAN;
}
else if (dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY) == true)
{
result = FilePlanComponentKind.RECORD_CATEGORY;
}
else if (dictionaryService.isSubClass(type, TYPE_RECORD_FOLDER) == true)
{
result = FilePlanComponentKind.RECORD_FOLDER;
}
else if (dictionaryService.isSubClass(type, TYPE_HOLD) == true)
{
result = FilePlanComponentKind.HOLD;
}
else if (dictionaryService.isSubClass(type, TYPE_TRANSFER) == true)
{
result = FilePlanComponentKind.TRANSFER;
}
else if (dictionaryService.isSubClass(type, TYPE_DISPOSITION_SCHEDULE) == true ||
dictionaryService.isSubClass(type, TYPE_DISPOSITION_ACTION_DEFINITION) == true)
{
result = FilePlanComponentKind.DISPOSITION_SCHEDULE;
}
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -294,5 +453,297 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
return container;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map)
*/
public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map<QName, Serializable> properties)
{
ParameterCheck.mandatory("parent", parent);
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("type", type);
// Check the parent is not already an RM component node
// ie: you can't create a rm root in an existing rm hierarchy
if (isFilePlanComponent(parent) == true)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DUP_ROOT));
}
// Check that the passed type is a sub-type of rma:filePlan
if (TYPE_FILE_PLAN.equals(type) == false &&
dictionaryService.isSubClass(type, TYPE_FILE_PLAN) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ROOT_TYPE, type.toString()));
}
// Build map of properties
Map<QName, Serializable> rmRootProps = new HashMap<QName, Serializable>(1);
if (properties != null && properties.size() != 0)
{
rmRootProps.putAll(properties);
}
rmRootProps.put(ContentModel.PROP_NAME, name);
// Create the root
ChildAssociationRef assocRef = nodeService.createNode(
parent,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
type,
rmRootProps);
// TODO do we need to create role and security groups or is this done automatically?
return assocRef.getChildRef();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
*/
public NodeRef createFilePlan(NodeRef parent, String name, Map<QName, Serializable> properties)
{
return createFilePlan(parent, name, TYPE_FILE_PLAN, properties);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
*/
public NodeRef createFilePlan(NodeRef parent, String name)
{
return createFilePlan(parent, name, TYPE_FILE_PLAN, null);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName)
*/
@Override
public NodeRef createFilePlan(NodeRef parent, String name, QName type)
{
return createFilePlan(parent, name, type, null);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getNodeRefPath(org.alfresco.service.cmr.repository.NodeRef)
*/
public List<NodeRef> getNodeRefPath(NodeRef nodeRef)
{
LinkedList<NodeRef> nodeRefPath = new LinkedList<NodeRef>();
try
{
getNodeRefPathRecursive(nodeRef, nodeRefPath);
}
catch (Throwable e)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PATH_NODE, nodeRef), e);
}
return nodeRefPath;
}
/**
* Helper method to build a <b>NodeRef</b> path from the node to the RM root
*/
private void getNodeRefPathRecursive(NodeRef nodeRef, LinkedList<NodeRef> nodeRefPath)
{
if (isFilePlanComponent(nodeRef) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_INVALID_RM_NODE, ASPECT_FILE_PLAN_COMPONENT.toString()));
}
// Prepend it to the path
nodeRefPath.addFirst(nodeRef);
// Are we at the root
if (isFilePlan(nodeRef) == true)
{
// We're done
}
else
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef);
if (assocRef == null)
{
// We hit the top of the store
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_ROOT));
}
// Recurse
nodeRef = assocRef.getParentRef();
getNodeRefPathRecursive(nodeRef, nodeRefPath);
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlanContainer(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public boolean isFilePlanContainer(NodeRef nodeRef)
{
return instanceOf(nodeRef, TYPE_RECORDS_MANAGEMENT_CONTAINER);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isRecordCategory(org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean isRecordCategory(NodeRef nodeRef)
{
return instanceOf(nodeRef, TYPE_RECORD_CATEGORY);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map)
*/
public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map<QName, Serializable> properties)
{
ParameterCheck.mandatory("parent", parent);
ParameterCheck.mandatory("name", name);
ParameterCheck.mandatory("type", type);
// Check that the parent is a container
QName parentType = nodeService.getType(parent);
if (TYPE_RECORDS_MANAGEMENT_CONTAINER.equals(parentType) == false &&
dictionaryService.isSubClass(parentType, TYPE_RECORDS_MANAGEMENT_CONTAINER) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_PARENT_TYPE, parentType.toString()));
}
// Check that the the provided type is a sub-type of rm:recordCategory
if (TYPE_RECORD_CATEGORY.equals(type) == false &&
dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_TYPE, type.toString()));
}
// Set the properties for the record category
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
if (properties != null && properties.size() != 0)
{
props.putAll(properties);
}
props.put(ContentModel.PROP_NAME, name);
return nodeService.createNode(
parent,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
type,
props).getChildRef();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
*/
public NodeRef createRecordCategory(NodeRef parent, String name)
{
return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
*/
public NodeRef createRecordCategory(NodeRef parent, String name, Map<QName, Serializable> properties)
{
return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY, properties);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName)
*/
public NodeRef createRecordCategory(NodeRef parent, String name, QName type)
{
return createRecordCategory(parent, name, type, null);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public List<NodeRef> getAllContained(NodeRef container)
{
return getAllContained(container, false);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
@Override
public List<NodeRef> getAllContained(NodeRef container, boolean deep)
{
return getContained(container, null, deep);
}
/**
* Get contained nodes of a particular type. If null return all.
*
* @param container container node reference
* @param typeFilter type filter, null if none
* @return {@link List}<{@link NodeRef> list of contained node references
*/
private List<NodeRef> getContained(NodeRef container, QName typeFilter, boolean deep)
{
// Parameter check
ParameterCheck.mandatory("container", container);
// Check we have a container in our hands
if (isRecordCategory(container) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED));
}
List<NodeRef> result = new ArrayList<NodeRef>(1);
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{
NodeRef child = assoc.getChildRef();
QName childType = nodeService.getType(child);
if (typeFilter == null ||
typeFilter.equals(childType) == true ||
dictionaryService.isSubClass(childType, typeFilter) == true)
{
result.add(child);
}
// Inspect the containers and add children if deep
if (deep == true &&
(TYPE_RECORD_CATEGORY.equals(childType) == true ||
dictionaryService.isSubClass(childType, TYPE_RECORD_CATEGORY) == true))
{
result.addAll(getContained(child, typeFilter, deep));
}
}
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public List<NodeRef> getContainedRecordCategories(NodeRef container)
{
return getContainedRecordCategories(container, false);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
@Override
public List<NodeRef> getContainedRecordCategories(NodeRef container, boolean deep)
{
return getContained(container, TYPE_RECORD_CATEGORY, deep);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public List<NodeRef> getContainedRecordFolders(NodeRef container)
{
return getContainedRecordFolders(container, false);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
@Override
public List<NodeRef> getContainedRecordFolders(NodeRef container, boolean deep)
{
return getContained(container, TYPE_RECORD_FOLDER, deep);
}
}

View File

@@ -24,12 +24,13 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.model.ImapModel;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.compatibility.CompatibilityModel;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.forms.Field;
@@ -71,6 +72,9 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
/** Disposition service */
protected DispositionService dispositionService;
/** File Plan Service */
protected FilePlanService filePlanService;
/**
* Sets the data dictionary service
@@ -91,6 +95,14 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
{
this.dispositionService = dispositionService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, java.util.List, java.util.List, org.alfresco.repo.forms.Form, java.util.Map)
@@ -103,12 +115,12 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
Form form,
Map<String, Object> context)
{
if (rmService.isFilePlanComponent(nodeRef) == true)
if (filePlanService.isFilePlanComponent(nodeRef) == true)
{
// add all the custom properties
addCustomPropertyFieldsToGroup(form, nodeRef);
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
if (FilePlanComponentKind.RECORD.equals(kind) == true)
{
// add all the record meta-data aspect properties

View File

@@ -160,8 +160,8 @@ public class FreezeServiceImpl implements FreezeService,
@Override
public Void doWork() throws Exception
{
if (nodeService.exists(nodeRef) == true
&& recordsManagementService.isFilePlanComponent(nodeRef) == true)
if (nodeService.exists(nodeRef) == true &&
filePlanService.isFilePlanComponent(nodeRef) == true)
{
if (isFrozen(nodeRef) == true)
{

View File

@@ -23,10 +23,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -72,6 +73,9 @@ public abstract class BaseEvaluator implements RecordsManagementModel
/** Capabilities */
protected List<String> capabilities;
/** File plan service */
protected FilePlanService filePlanService;
/**
* @param jsonConversionComponent json conversion component
*/
@@ -128,6 +132,14 @@ public abstract class BaseEvaluator implements RecordsManagementModel
this.freezeService = freezeService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @param name
*/
@@ -219,7 +231,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel
*/
private boolean checkKinds(NodeRef nodeRef)
{
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
return kinds.contains(kind);
}

View File

@@ -21,10 +21,10 @@ package org.alfresco.module.org_alfresco_module_rm.jscript.app;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.model.FileInfo;
@@ -125,7 +125,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
RMPermissionModel.VIEW_RECORDS)) == true)
{
// Indicate whether the node is a RM object or not
boolean isFilePlanComponent = recordsManagementService.isFilePlanComponent(nodeInfo.getNodeRef());
boolean isFilePlanComponent = filePlanService.isFilePlanComponent(nodeInfo.getNodeRef());
rootJSONObject.put("isRmNode", isFilePlanComponent);
if (isFilePlanComponent == true)
@@ -150,7 +150,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
rmNodeValues.put("uiType", getUIType(nodeRef));
// Get the 'kind' of the file plan component
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
rmNodeValues.put("kind", kind.toString());
// File plan node reference
@@ -221,7 +221,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
{
String result = "unknown";
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
if (kind != null)
{
switch (kind)

View File

@@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
@@ -56,9 +55,6 @@ public class RecordContainerType implements RecordsManagementModel,
/** Identity service */
private IdentifierService recordsManagementIdentifierService;
/** File plan authentication service */
private FilePlanAuthenticationService filePlanAuthenticationService;
/**
* Set the policy component
* @param policyComponent policy component
@@ -88,14 +84,6 @@ public class RecordContainerType implements RecordsManagementModel,
this.dictionaryService = dictionaryService;
}
/**
* @param filePlanAuthenticationService file plan authentication service
*/
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
{
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
/**
* Set the identity service
*

View File

@@ -21,13 +21,13 @@ package org.alfresco.module.org_alfresco_module_rm.patch;
import java.io.Serializable;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
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.security.RecordsManagementSecurityService;
import org.alfresco.module.org_alfresco_module_rm.security.Role;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.domain.qname.QNameDAO;
@@ -55,24 +55,19 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
private static Log logger = LogFactory.getLog(RMv2FilePlanNodeRefPatch.class);
private NodeService nodeService;
private RecordsManagementService recordsManagementService;
private BehaviourFilter behaviourFilter;
private PatchDAO patchDAO;
private NodeDAO nodeDAO;
private QNameDAO qnameDAO;
private PermissionService permissionService;
private RecordsManagementSecurityService recordsManagementSecurityService;
private FilePlanService filePlanService;
private FilePlanRoleService filePlanRoleService;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
this.behaviourFilter = behaviourFilter;
@@ -93,14 +88,6 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
this.qnameDAO = qnameDAO;
}
/**
* @param recordsManagementSecurityService records management security service
*/
public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService)
{
this.recordsManagementSecurityService = recordsManagementSecurityService;
}
/**
* @param permissionService permission service
*/
@@ -109,6 +96,22 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
this.permissionService = permissionService;
}
/**
* @param filePlanRoleService file plan role service
*/
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
{
this.filePlanRoleService = filePlanRoleService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/
@@ -138,7 +141,7 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(filePlanComponent);
NodeRef filePlanComponentNodeRef = recordPair.getSecond();
NodeRef filePlan = recordsManagementService.getFilePlan(filePlanComponentNodeRef);
NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef);
// set the file plan node reference
if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null)
@@ -147,13 +150,13 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
}
// only set the rmadmin permissions on record categories, record folders and records
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(filePlanComponentNodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) == true ||
FilePlanComponentKind.RECORD_FOLDER.equals(kind) == true ||
FilePlanComponentKind.RECORD.equals(kind) == true )
{
// ensure the that the records management role has read and file on the node
Role adminRole = recordsManagementSecurityService.getRole(filePlan, "Administrator");
Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator");
if (adminRole != null)
{
permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true);

View File

@@ -39,7 +39,7 @@ public class AuditLogDelete extends BaseAuditAdminWebScript
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
this.rmAuditService.clear();
this.rmAuditService.clearAuditLog(getDefaultFilePlan());
// create model object with the audit status model
Map<String, Object> model = new HashMap<String, Object>(1);

View File

@@ -61,11 +61,11 @@ public class AuditLogPut extends BaseAuditAdminWebScript
boolean enabled = json.getBoolean(PARAM_ENABLED);
if (enabled)
{
this.rmAuditService.start();
this.rmAuditService.startAuditLog(getDefaultFilePlan());
}
else
{
this.rmAuditService.stop();
this.rmAuditService.stopAuditLog(getDefaultFilePlan());
}
// create model object with the audit status model

View File

@@ -21,7 +21,10 @@ package org.alfresco.module.org_alfresco_module_rm.script;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
@@ -37,6 +40,9 @@ public class AuditLogStatusGet extends DeclarativeWebScript
/** Records management audit service */
protected RecordsManagementAuditService rmAuditService;
/** File plan service */
protected FilePlanService filePlanService;
/**
* Sets the RecordsManagementAuditService instance
*
@@ -47,6 +53,14 @@ public class AuditLogStatusGet extends DeclarativeWebScript
this.rmAuditService = rmAuditService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@@ -54,7 +68,22 @@ public class AuditLogStatusGet extends DeclarativeWebScript
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("enabled", Boolean.valueOf(rmAuditService.isEnabled()));
model.put("enabled", Boolean.valueOf(rmAuditService.isAuditLogEnabled(getDefaultFilePlan())));
return model;
}
/**
* Helper method to get default file plan.
*
* @return NodeRef default file plan
*/
protected NodeRef getDefaultFilePlan()
{
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan == null)
{
throw new AlfrescoRuntimeException("Default file plan not found.");
}
return filePlan;
}
}

View File

@@ -21,7 +21,10 @@ package org.alfresco.module.org_alfresco_module_rm.script;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.ISO8601DateFormat;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
@@ -32,8 +35,12 @@ import org.springframework.extensions.webscripts.DeclarativeWebScript;
*/
public class BaseAuditAdminWebScript extends DeclarativeWebScript
{
/** Records management audit service */
protected RecordsManagementAuditService rmAuditService;
/** File plan service */
protected FilePlanService filePlanService;
/**
* Sets the RecordsManagementAuditService instance
*
@@ -44,6 +51,14 @@ public class BaseAuditAdminWebScript extends DeclarativeWebScript
this.rmAuditService = rmAuditService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* Creates a model to represent the current status of the RM audit log.
*
@@ -53,10 +68,25 @@ public class BaseAuditAdminWebScript extends DeclarativeWebScript
{
Map<String, Object> auditStatus = new HashMap<String, Object>(3);
auditStatus.put("started", ISO8601DateFormat.format(rmAuditService.getDateLastStarted()));
auditStatus.put("stopped", ISO8601DateFormat.format(rmAuditService.getDateLastStopped()));
auditStatus.put("enabled", Boolean.valueOf(rmAuditService.isEnabled()));
auditStatus.put("started", ISO8601DateFormat.format(rmAuditService.getDateAuditLogLastStarted(getDefaultFilePlan())));
auditStatus.put("stopped", ISO8601DateFormat.format(rmAuditService.getDateAuditLogLastStopped(getDefaultFilePlan())));
auditStatus.put("enabled", Boolean.valueOf(rmAuditService.isAuditLogEnabled(getDefaultFilePlan())));
return auditStatus;
}
/**
* Helper method to get default file plan.
*
* @return NodeRef default file plan
*/
protected NodeRef getDefaultFilePlan()
{
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan == null)
{
throw new AlfrescoRuntimeException("Default file plan not found.");
}
return filePlan;
}
}

View File

@@ -20,7 +20,6 @@ package org.alfresco.module.org_alfresco_module_rm.script;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -28,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -52,6 +52,7 @@ public class UserRightsReportGet extends DeclarativeWebScript
protected NodeService nodeService;
protected RecordsManagementService rmService;
protected FilePlanRoleService filePlanRoleService;
protected FilePlanService filePlanService;
/**
* Sets the AuthorityService instance
@@ -99,19 +100,26 @@ public class UserRightsReportGet extends DeclarativeWebScript
this.filePlanRoleService = filePlanRoleService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/*
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
// get the RM root nodes in the system
List<NodeRef> rmRoots = this.rmService.getFilePlans();
NodeRef filePlanNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (rmRoots == null || rmRoots.size() == 0)
if (filePlanNode == null)
{
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
"There are no Records Management root nodes in the system");
"The default RM site could not be found.");
return null;
}
@@ -120,11 +128,8 @@ public class UserRightsReportGet extends DeclarativeWebScript
Map<String, RoleModel> rolesMap = new HashMap<String, RoleModel>(8);
Map<String, GroupModel> groupsMap = new HashMap<String, GroupModel>(8);
// TODO: deal with presence of more than one root, for now we know it's only 1
NodeRef rmRootNode = rmRoots.get(0);
// iterate over all the roles for the file plan and construct models
Set<Role> roles = this.filePlanRoleService.getRoles(rmRootNode);
Set<Role> roles = filePlanRoleService.getRoles(filePlanNode);
for (Role role : roles)
{
// get or create the RoleModel object for current role
@@ -138,7 +143,7 @@ public class UserRightsReportGet extends DeclarativeWebScript
// get the users for the current RM role
String group = role.getRoleGroupName();
Set<String> users = this.authorityService.getContainedAuthorities(AuthorityType.USER, group, true);
Set<String> users = authorityService.getContainedAuthorities(AuthorityType.USER, group, true);
roleModel.setUsers(users);
// setup a user model object for each user
@@ -158,7 +163,7 @@ public class UserRightsReportGet extends DeclarativeWebScript
}
// get the groups for the cuurent RM role
Set<String> groups = this.authorityService.getContainedAuthorities(AuthorityType.GROUP, group, false);
Set<String> groups = authorityService.getContainedAuthorities(AuthorityType.GROUP, group, false);
roleModel.setGroups(groups);
// setup a user model object for each user in each group
@@ -168,7 +173,7 @@ public class UserRightsReportGet extends DeclarativeWebScript
if (groupModel == null)
{
groupModel = new GroupModel(groupName,
this.authorityService.getAuthorityDisplayName(groupName));
authorityService.getAuthorityDisplayName(groupName));
groupsMap.put(groupName, groupModel);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -25,10 +25,10 @@ import java.util.TreeMap;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.Group;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus;
@@ -39,22 +39,33 @@ import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Capabilities GET web service implementation.
*/
public class CapabilitiesGet extends DeclarativeWebScript
{
private RecordsManagementService recordsManagementService;
/** File plan service */
private FilePlanService filePlanService;
/** Capability service */
private CapabilityService capabilityService;
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
/**
* @param capabilityService capability service
*/
public void setCapabilityService(CapabilityService capabilityService)
{
this.capabilityService = capabilityService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@@ -75,16 +86,11 @@ public class CapabilitiesGet extends DeclarativeWebScript
{
// we are talking about the file plan node
// TODO we are making the assumption there is only one file plan here!
List<NodeRef> filePlans = recordsManagementService.getFilePlans();
if (filePlans.isEmpty() == true)
nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (nodeRef == null)
{
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file plan node has been found.");
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The default file plan node could not be found.");
}
else if (filePlans.size() != 1)
{
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "More than one file plan has been found.");
}
nodeRef = filePlans.get(0);
}
boolean grouped = false;

View File

@@ -27,8 +27,8 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
@@ -56,22 +56,14 @@ public class RMMetaDataGet extends DeclarativeWebScript
/** QName pattern */
private static final Pattern qnamePattern = Pattern.compile(".+:[^=,]+");
/** Records management service */
private RecordsManagementService rmService;
/** Namespace service */
private NamespaceService namespaceService;
/** Node service */
private NodeService nodeService;
/**
* @param rmService records management service
*/
public void setRecordsManagementService(RecordsManagementService rmService)
{
this.rmService = rmService;
}
/** File Plan Service */
private FilePlanService filePlanService;
/**
* @param namespaceService namespace service
@@ -81,6 +73,14 @@ public class RMMetaDataGet extends DeclarativeWebScript
this.namespaceService = namespaceService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @param nodeService node service
*/
@@ -112,7 +112,7 @@ public class RMMetaDataGet extends DeclarativeWebScript
if (m.matches() == true)
{
QName qname = QName.createQName(type, namespaceService);
FilePlanComponentKind kind = rmService.getFilePlanComponentKindFromType(qname);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKindFromType(qname);
if (kind != null)
{
result = kind.toString();
@@ -130,7 +130,7 @@ public class RMMetaDataGet extends DeclarativeWebScript
{
NodeRef nodeRefObj = new NodeRef(nodeRef);
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRefObj);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRefObj);
if (kind != null)
{
result = kind.toString();

View File

@@ -30,6 +30,11 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public interface ExtendedSecurityService
{
/**
*
* @param nodeRef
* @return
*/
boolean hasExtendedSecurity(NodeRef nodeRef);
/**

View File

@@ -25,7 +25,6 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.model.RenditionModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
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;
@@ -62,9 +61,6 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
/** Policy component */
private PolicyComponent policyComponent;
/** Records management service */
private RecordsManagementService recordsManagementService;
/** Record service */
private RecordService recordService;
@@ -90,14 +86,6 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
this.recordService = recordService;
}
/**
* @param recordsManagementService records management service
*/
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
/**
* @param filePlanService file plan service
*/
@@ -244,7 +232,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
// apply the extended readers up the file plan primary hierarchy
NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
if (parent != null &&
recordsManagementService.isFilePlanComponent(parent) == true)
filePlanService.isFilePlanComponent(parent) == true)
{
addExtendedSecurityImpl(parent, readers, null, applyToParents);
addExtendedSecurityImpl(parent, writers, null, applyToParents);
@@ -407,7 +395,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
// apply the extended readers up the file plan primary hierarchy
NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
if (parent != null &&
recordsManagementService.isFilePlanComponent(parent) == true)
filePlanService.isFilePlanComponent(parent) == true)
{
removeExtendedSecurity(parent, readers, null, applyToParents);
removeExtendedSecurity(parent, writers, null, applyToParents);

View File

@@ -393,7 +393,7 @@ public class FilePlanPermissionServiceImpl implements FilePlanPermissionService,
{
setPermissionDown(nodeRef, authority, permission);
}
else if (recordsManagementService.isRecordsManagementContainer(nodeRef) == true ||
else if (filePlanService.isFilePlanContainer(nodeRef) == true ||
recordsManagementService.isRecordFolder(nodeRef) == true ||
recordService.isRecord(nodeRef) == true)
{
@@ -440,14 +440,14 @@ public class FilePlanPermissionServiceImpl implements FilePlanPermissionService,
private void setPermissionDown(NodeRef nodeRef, String authority, String permission)
{
setPermissionImpl(nodeRef, authority, permission);
if (recordsManagementService.isRecordsManagementContainer(nodeRef) == true ||
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)
{
NodeRef child = assoc.getChildRef();
if (recordsManagementService.isRecordsManagementContainer(child) == true ||
if (filePlanService.isFilePlanContainer(child) == true ||
recordsManagementService.isRecordFolder(child) == true ||
recordService.isRecord(child) == true)
{
@@ -487,14 +487,14 @@ public class FilePlanPermissionServiceImpl implements FilePlanPermissionService,
// Delete permission on this node
permissionService.deletePermission(nodeRef, authority, permission);
if (recordsManagementService.isRecordsManagementContainer(nodeRef) == true ||
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)
{
NodeRef child = assoc.getChildRef();
if (recordsManagementService.isRecordsManagementContainer(child) == true ||
if (filePlanService.isFilePlanContainer(child) == true ||
recordsManagementService.isRecordFolder(child) == true ||
recordService.isRecord(child) == true)
{

View File

@@ -16,7 +16,7 @@
* 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;
package org.alfresco.module.org_alfresco_module_rm.util;
import java.util.Collections;
import java.util.HashSet;
@@ -29,9 +29,11 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
/**
* Utility class with policy helper methods.
*
* @author Roy Wetherall
*/
public class RecordsManagementPoliciesUtil
public class PoliciesUtil
{
/**
* Get all aspect and node type qualified names
@@ -67,5 +69,4 @@ public class RecordsManagementPoliciesUtil
}
}, AuthenticationUtil.getAdminUserName());
}
}

View File

@@ -25,6 +25,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
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.security.FilePlanAuthenticationService;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
@@ -45,7 +46,14 @@ import org.alfresco.service.namespace.RegexQNamePattern;
*/
public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstractBase
{
private FilePlanAuthenticationService filePlanAuthenticationService;
protected FilePlanService filePlanService;
protected FilePlanAuthenticationService filePlanAuthenticationService;
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
{
@@ -94,7 +102,7 @@ public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstra
{
NodeRef nextChild = nextAssoc.getChildRef();
if (recordsManagementService.isFilePlanComponent(nextChild) == true)
if (filePlanService.isFilePlanComponent(nextChild) == true)
{
// If the child is a record, then the VitalRecord aspect needs to be applied or updated
if (recordService.isRecord(nextChild))

View File

@@ -24,9 +24,10 @@ import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
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.security.FilePlanAuthenticationService;
import org.alfresco.repo.node.NodeServicePolicies;
@@ -59,6 +60,7 @@ public class VitalRecordServiceImpl implements VitalRecordService,
private RecordsManagementService rmService;
private RecordsManagementActionService rmActionService;
private FilePlanAuthenticationService filePlanAuthenticationService;
private FilePlanService filePlanService;
/** Behaviours */
private JavaBehaviour onUpdateProperties;
@@ -101,6 +103,14 @@ public class VitalRecordServiceImpl implements VitalRecordService,
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* Init method.
*/
@@ -164,7 +174,7 @@ public class VitalRecordServiceImpl implements VitalRecordService,
@Override
public Void doWork() throws Exception
{
if (rmService.isRecordCategory(nodeRef) == true ||
if (filePlanService.isRecordCategory(nodeRef) == true ||
rmService.isRecordFolder(nodeRef) == true)
{
inheritVitalRecordDefinition(nodeRef);
@@ -200,10 +210,10 @@ public class VitalRecordServiceImpl implements VitalRecordService,
// is the parent a record category
if (parentRef != null &&
FilePlanComponentKind.RECORD_CATEGORY.equals(rmService.getFilePlanComponentKind(parentRef)) == true)
FilePlanComponentKind.RECORD_CATEGORY.equals(filePlanService.getFilePlanComponentKind(parentRef)) == true)
{
// is the child a record category or folder
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
if (kind.equals(FilePlanComponentKind.RECORD_CATEGORY) == true ||
kind.equals(FilePlanComponentKind.RECORD_FOLDER) == true)
{
@@ -259,7 +269,7 @@ public class VitalRecordServiceImpl implements VitalRecordService,
{
VitalRecordDefinition result = null;
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
if (FilePlanComponentKind.RECORD.equals(kind) == true)
{
result = resolveVitalRecordDefinition(nodeRef);

View File

@@ -22,9 +22,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionDefinition;
@@ -40,25 +40,32 @@ import org.springframework.context.ApplicationContextAware;
*/
public class ExtendedActionServiceImpl extends ActionServiceImpl implements ApplicationContextAware
{
/** Records management service */
private RecordsManagementService recordsManagementService;
/** File plan service */
private FilePlanService filePlanService;
/** Application context */
private ApplicationContext extendedApplicationContext;
/**
* @see org.alfresco.repo.action.ActionServiceImpl#setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext)
{
super.setApplicationContext(applicationContext);
extendedApplicationContext = applicationContext;
}
/**
* @param recordsManagementService records management service
*/
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String)
*/
public ActionConditionDefinition getActionConditionDefinition(String name)
{
// get direct access to action condition definition (i.e. ignoring public flag of executer)
@@ -91,7 +98,7 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
else
{
// get the file component kind of the node reference
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
result = new ArrayList<ActionDefinition>(actionDefinitions.size());
// check each action definition

View File

@@ -20,7 +20,7 @@ package org.alfresco.repo.rule;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
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.security.FilePlanAuthenticationService;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -39,13 +39,13 @@ import org.alfresco.service.namespace.QName;
public class ExtendedRuleServiceImpl extends RuleServiceImpl
{
private boolean runAsRmAdmin = true;
private FilePlanService filePlanService;
private FilePlanAuthenticationService filePlanAuthenticationService;
protected NodeService nodeService;
private RecordsManagementService recordsManagementService;
public void setRunAsRmAdmin(boolean runAsRmAdmin)
{
this.runAsRmAdmin = runAsRmAdmin;
@@ -56,20 +56,20 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
public void setNodeService2(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
@Override
public void saveRule(final NodeRef nodeRef, final Rule rule)
{
if (recordsManagementService.isFilePlanComponent(nodeRef) == true && runAsRmAdmin == true)
if (filePlanService.isFilePlanComponent(nodeRef) == true && runAsRmAdmin == true)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@@ -91,7 +91,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
@Override
public void removeRule(final NodeRef nodeRef, final Rule rule)
{
if (recordsManagementService.isFilePlanComponent(nodeRef) == true && runAsRmAdmin == true)
if (filePlanService.isFilePlanComponent(nodeRef) == true && runAsRmAdmin == true)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@@ -116,7 +116,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
QName typeQName = nodeService.getType(nodeRef);
// The dispositionSchedule node will not be executed by rules
if (recordsManagementService.isFilePlanComponent(nodeRef) == true
if (filePlanService.isFilePlanComponent(nodeRef) == true
&& typeQName.equals(RecordsManagementModel.TYPE_DISPOSITION_SCHEDULE) == false
&& isFilePlanComponentRule(rule) == true && runAsRmAdmin == true)
{
@@ -141,6 +141,6 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
private boolean isFilePlanComponentRule(Rule rule)
{
NodeRef nodeRef = getOwningNodeRef(rule);
return recordsManagementService.isFilePlanComponent(nodeRef);
return filePlanService.isFilePlanComponent(nodeRef);
}
}

View File

@@ -90,7 +90,8 @@ public class RequestInfoNotifier implements TaskListener
* @param recordName The name of the record
* @return Returns the email subject
*/
private String getEmailSubject(String recordName)
@SuppressWarnings("unused")
private String getEmailSubject(String recordName)
{
StringBuilder sb = new StringBuilder();
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.subject"));
@@ -106,7 +107,8 @@ public class RequestInfoNotifier implements TaskListener
* @param recordName The name of the record
* @return Returns the email body
*/
private String getEmailBody(String recordName)
@SuppressWarnings("unused")
private String getEmailBody(String recordName)
{
StringBuilder sb = new StringBuilder();
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body1"));