Storing the information about the original location of a record

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@45740 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-01-22 21:57:06 +00:00
parent e593bb5cb5
commit 785f6adde3
4 changed files with 180 additions and 157 deletions

View File

@@ -103,10 +103,11 @@ public class HideRecordAction extends ActionExecuterAbstractBase implements Reco
}
else
{
NodeRef originalLocation = (NodeRef) nodeService.getProperty(actionedUponNodeRef, PROP_ORIGINAL_LOCATION);
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(actionedUponNodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs)
{
if (childAssociationRef.isPrimary() == false)
if (childAssociationRef.isPrimary() == false && childAssociationRef.getParentRef().equals(originalLocation))
{
nodeService.removeChildAssociation(childAssociationRef);
}

View File

@@ -22,55 +22,55 @@ import org.alfresco.service.namespace.QName;
/**
* Helper class containing records management qualified names
*
*
* @author Roy Wetherall
*/
public interface RecordsManagementModel extends RecordsManagementCustomModel
{
{
// Namespace details
public static final String RM_URI = "http://www.alfresco.org/model/recordsmanagement/1.0";
public static final String RM_PREFIX = "rma";
// Model
public static final QName RM_MODEL = QName.createQName(RM_URI, "recordsmanagement");
// RM Site
public static final QName TYPE_RM_SITE = QName.createQName(RM_URI, "rmsite");
// Caveat config
public static final QName TYPE_CAVEAT_CONFIG = QName.createQName(RM_URI, "caveatConfig");
public static final QName ASPECT_CAVEAT_CONFIG_ROOT = QName.createQName(RM_URI, "caveatConfigRoot");
public static final QName ASSOC_CAVEAT_CONFIG = QName.createQName(RM_URI, "caveatConfigAssoc");
// Email config
public static final QName TYPE_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfig");
public static final QName TYPE_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfig");
public static final QName ASPECT_EMAIL_CONFIG_ROOT = QName.createQName(RM_URI, "emailConfigRoot");
public static final QName ASSOC_EMAIL_CONFIG = QName.createQName(RM_URI, "emailConfigAssoc");
// Records management container
public static final QName TYPE_RECORDS_MANAGEMENT_CONTAINER = QName.createQName(RM_URI, "recordsManagementContainer");
// Record Category
public static final QName TYPE_RECORD_CATEGORY = QName.createQName(RM_URI, "recordCategory");
// Records management root container
public static final QName TYPE_FILE_PLAN = QName.createQName(RM_URI, "filePlan");
// Unfiled record container
public static final QName TYPE_UNFILED_RECORD_CONTAINER = QName.createQName(RM_URI, "unfiledRecordContainer");
// Disposition instructions aspect
public static final QName ASPECT_SCHEDULED = QName.createQName(RM_URI, "scheduled");
public static final QName ASSOC_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule");
// Disposition definition type
public static final QName TYPE_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule");
public static final QName PROP_DISPOSITION_AUTHORITY = QName.createQName(RM_URI, "dispositionAuthority");
public static final QName PROP_DISPOSITION_INSTRUCTIONS = QName.createQName(RM_URI, "dispositionInstructions");
public static final QName PROP_RECORD_LEVEL_DISPOSITION = QName.createQName(RM_URI, "recordLevelDisposition");
public static final QName ASSOC_DISPOSITION_ACTION_DEFINITIONS = QName.createQName(RM_URI, "dispositionActionDefinitions");
public static final QName ASSOC_DISPOSITION_ACTION_DEFINITIONS = QName.createQName(RM_URI, "dispositionActionDefinitions");
// Disposition action type
public static final QName TYPE_DISPOSITION_ACTION_DEFINITION = QName.createQName(RM_URI, "dispositionActionDefinition");
public static final QName PROP_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "dispositionActionName");
@@ -80,16 +80,16 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName PROP_DISPOSITION_EVENT = QName.createQName(RM_URI, "dispositionEvent");
public static final QName PROP_DISPOSITION_EVENT_COMBINATION = QName.createQName(RM_URI, "dispositionEventCombination");
public static final QName PROP_DISPOSITION_LOCATION = QName.createQName(RM_URI, "dispositionLocation");
// Records folder
public static final QName TYPE_RECORD_FOLDER = QName.createQName(RM_URI, "recordFolder");
public static final QName PROP_IS_CLOSED = QName.createQName(RM_URI, "isClosed");
// Declared record aspect
public static final QName ASPECT_DECLARED_RECORD = QName.createQName(RM_URI, "declaredRecord");
public static final QName PROP_DECLARED_AT = QName.createQName(RM_URI, "declaredAt");
public static final QName PROP_DECLARED_BY = QName.createQName(RM_URI, "declaredBy");
// Record aspect
public static final QName ASPECT_RECORD = QName.createQName(RM_URI, "record");
public static final QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled");
@@ -98,44 +98,44 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName PROP_PUBLICATION_DATE = QName.createQName(RM_URI, "publicationDate");
public static final QName PROP_MEDIA_TYPE = QName.createQName(RM_URI, "mediaType");
public static final QName PROP_FORMAT = QName.createQName(RM_URI, "format");
public static final QName PROP_DATE_RECEIVED = QName.createQName(RM_URI, "dateReceived");
public static final QName PROP_DATE_RECEIVED = QName.createQName(RM_URI, "dateReceived");
// Common record details
public static final QName PROP_LOCATION = QName.createQName(RM_URI, "location");
// Fileable aspect
public static final QName ASPECT_FILABLE = QName.createQName(RM_URI, "fileable");
// Record component identifier aspect
public static final QName ASPECT_RECORD_COMPONENT_ID = QName.createQName(RM_URI, "recordComponentIdentifier");
public static final QName PROP_IDENTIFIER = QName.createQName(RM_URI, "identifier");
public static final QName PROP_DB_UNIQUENESS_ID = QName.createQName(RM_URI, "dbUniquenessId");
// Vital record definition aspect
public static final QName ASPECT_VITAL_RECORD_DEFINITION = QName.createQName(RM_URI, "vitalRecordDefinition");
public static final QName PROP_VITAL_RECORD_INDICATOR = QName.createQName(RM_URI, "vitalRecordIndicator");
public static final QName PROP_REVIEW_PERIOD = QName.createQName(RM_URI, "reviewPeriod");
// Vital record aspect
public static final QName ASPECT_VITAL_RECORD = QName.createQName(RM_URI, "vitalRecord");
public static final QName PROP_REVIEW_AS_OF = QName.createQName(RM_URI, "reviewAsOf");
public static final QName PROP_NOTIFICATION_ISSUED = QName.createQName(RM_URI, "notificationIssued");
// Cut off aspect
public static final QName ASPECT_CUT_OFF = QName.createQName(RM_URI, "cutOff");
public static final QName PROP_CUT_OFF_DATE = QName.createQName(RM_URI, "cutOffDate");
// Transferred aspect
public static final QName ASPECT_TRANSFERRED = QName.createQName(RM_URI, "transferred");
// Ascended aspect
public static final QName ASPECT_ASCENDED = QName.createQName(RM_URI, "ascended");
// Disposition schedule aspect
public static final QName ASPECT_DISPOSITION_LIFECYCLE = QName.createQName(RM_URI, "dispositionLifecycle");
public static final QName ASSOC_NEXT_DISPOSITION_ACTION = QName.createQName(RM_URI, "nextDispositionAction");
public static final QName ASSOC_DISPOSITION_ACTION_HISTORY = QName.createQName(RM_URI, "dispositionActionHistory");
// Disposition action type
public static final QName TYPE_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction");
public static final QName PROP_DISPOSITION_ACTION_ID = QName.createQName(RM_URI, "dispositionActionId");
@@ -147,7 +147,7 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName PROP_DISPOSITION_ACTION_COMPLETED_AT = QName.createQName(RM_URI, "dispositionActionCompletedAt");
public static final QName PROP_DISPOSITION_ACTION_COMPLETED_BY = QName.createQName(RM_URI, "dispositionActionCompletedBy");
public static final QName ASSOC_EVENT_EXECUTIONS = QName.createQName(RM_URI, "eventExecutions");
// Event execution type
public static final QName TYPE_EVENT_EXECUTION = QName.createQName(RM_URI, "eventExecution");
public static final QName PROP_EVENT_EXECUTION_NAME = QName.createQName(RM_URI, "eventExecutionName");
@@ -155,60 +155,60 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName PROP_EVENT_EXECUTION_COMPLETE = QName.createQName(RM_URI, "eventExecutionComplete");
public static final QName PROP_EVENT_EXECUTION_COMPLETED_BY = QName.createQName(RM_URI, "eventExecutionCompletedBy");
public static final QName PROP_EVENT_EXECUTION_COMPLETED_AT = QName.createQName(RM_URI, "eventExecutionCompletedAt");
// Custom RM data aspect
public static final QName ASPECT_CUSTOM_RM_DATA = QName.createQName(RM_URI, "customRMData");
// marker aspect on all RM objercts (except caveat root)
public static final QName ASPECT_FILE_PLAN_COMPONENT = QName.createQName(RM_URI, "filePlanComponent");
public static final QName PROP_ROOT_NODEREF = QName.createQName(RM_URI, "rootNodeRef");
// Non-electronic document
public static final QName TYPE_NON_ELECTRONIC_DOCUMENT = QName.createQName(RM_URI, "nonElectronicDocument");
// Records management root aspect
public static final QName ASPECT_RECORDS_MANAGEMENT_ROOT = QName.createQName(RM_URI, "recordsManagementRoot");
public static final QName ASSOC_HOLDS = QName.createQName(RM_URI, "holds");
public static final QName ASSOC_TRANSFERS = QName.createQName(RM_URI, "transfers");
public static final QName ASSOC_UNFILED_RECORDS = QName.createQName(RM_URI, "unfiledRecords");
// Hold type
public static final QName TYPE_HOLD = QName.createQName(RM_URI, "hold");
public static final QName PROP_HOLD_REASON = QName.createQName(RM_URI, "holdReason");
public static final QName ASSOC_FROZEN_RECORDS = QName.createQName(RM_URI, "frozenRecords");
// Record meta data aspect
public static final QName ASPECT_RECORD_META_DATA = QName.createQName(RM_URI, "recordMetaData");
// Frozen aspect
public static final QName ASPECT_FROZEN = QName.createQName(RM_URI, "frozen");
public static final QName PROP_FROZEN_AT = QName.createQName(RM_URI, "frozenAt");
public static final QName PROP_FROZEN_BY = QName.createQName(RM_URI, "frozenBy");
// Transfer aspect
public static final QName TYPE_TRANSFER = QName.createQName(RM_URI, "transfer");
public static final QName PROP_TRANSFER_ACCESSION_INDICATOR = QName.createQName(RM_URI, "transferAccessionIndicator");
public static final QName PROP_TRANSFER_PDF_INDICATOR = QName.createQName(RM_URI, "transferPDFIndicator");
public static final QName PROP_TRANSFER_LOCATION = QName.createQName(RM_URI, "transferLocation");
public static final QName ASSOC_TRANSFERRED = QName.createQName(RM_URI, "transferred");
// Transferring aspect
public static final QName ASPECT_TRANSFERRING = QName.createQName(RM_URI, "transferring");
// Versioned record aspect
public static final QName ASPECT_VERSIONED_RECORD = QName.createQName(RM_URI, "versionedRecord");
// Unpublished update aspect
public static final QName ASPECT_UNPUBLISHED_UPDATE = QName.createQName(RM_URI, "unpublishedUpdate");
public static final QName PROP_UNPUBLISHED_UPDATE = QName.createQName(RM_URI, "unpublishedUpdate");
public static final QName PROP_UPDATE_TO = QName.createQName(RM_URI, "updateTo");
public static final QName PROP_UPDATED_PROPERTIES = QName.createQName(RM_URI, "updatedProperties");
public static final QName PROP_PUBLISH_IN_PROGRESS = QName.createQName(RM_URI, "publishInProgress");
public static final String UPDATE_TO_DISPOSITION_ACTION_DEFINITION = "dispositionActionDefinition";
public static final String UPDATE_TO_DISPOSITION_ACTION_DEFINITION = "dispositionActionDefinition";
// Ghosted aspect
public static QName ASPECT_GHOSTED = QName.createQName(RM_URI, "ghosted");
// Search rollup aspect
public static final QName ASPECT_RM_SEARCH = QName.createQName(RM_URI, "recordSearch");
public static final QName PROP_RS_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "recordSearchDispositionActionName");
@@ -231,4 +231,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
// Extended readers aspect
public static final QName ASPECT_EXTENDED_READERS = QName.createQName(RM_URI, "extendedReaders");
public static final QName PROP_READERS = QName.createQName(RM_URI, "readers");
// Original location of a record
public static final QName ASPECT_ORIGINAL_LOCATION = QName.createQName(RM_URI, "originalLocation");
public static final QName PROP_ORIGINAL_LOCATION = QName.createQName(RM_URI, "orgLocation");
}

View File

@@ -18,10 +18,13 @@
*/
package org.alfresco.module.org_alfresco_module_rm.record;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -34,9 +37,9 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -56,18 +59,18 @@ import org.springframework.context.ApplicationContextAware;
/**
* Record service implementation
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RecordServiceImpl implements RecordService,
public class RecordServiceImpl implements RecordService,
RecordsManagementModel,
NodeServicePolicies.OnCreateChildAssociationPolicy,
ApplicationContextAware
{
/** Application context */
private ApplicationContext applicationContext;
/** Node service **/
private NodeService nodeService;
@@ -82,23 +85,23 @@ public class RecordServiceImpl implements RecordService,
/** Extended security service */
private ExtendedSecurityService extendedSecurityService;
/** Records management service */
private RecordsManagementService recordsManagementService;
/** Disposition service */
private DispositionService dispositionService;
/** Policy component */
private PolicyComponent policyComponent;
/** List of available record meta-data aspects */
private Set<QName> recordMetaDataAspects;
/** Behaviours */
private JavaBehaviour onCreateChildAssociation = new JavaBehaviour(
this,
"onCreateChildAssociation",
this,
"onCreateChildAssociation",
NotificationFrequency.FIRST_EVENT);
@Override
@@ -106,7 +109,7 @@ public class RecordServiceImpl implements RecordService,
{
this.applicationContext = applicationContext;
}
/**
* @param nodeService node service
*/
@@ -154,7 +157,7 @@ public class RecordServiceImpl implements RecordService,
{
this.recordsManagementService = recordsManagementService;
}
/**
* @param dispositionService disposition service
*/
@@ -162,7 +165,7 @@ public class RecordServiceImpl implements RecordService,
{
this.dispositionService = dispositionService;
}
/**
* @param policyComponent policy component
*/
@@ -170,22 +173,22 @@ public class RecordServiceImpl implements RecordService,
{
this.policyComponent = policyComponent;
}
/**
* Init method
*/
public void init()
{
policyComponent.bindAssociationBehaviour(
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
TYPE_RECORD_FOLDER,
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
TYPE_RECORD_FOLDER,
ContentModel.ASSOC_CONTAINS,
onCreateChildAssociation);
}
/**
* Behaviour executed when a new item is added to a record folder.
*
*
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
*/
@Override
@@ -195,10 +198,10 @@ public class RecordServiceImpl implements RecordService,
if (nodeService.exists(nodeRef) == true)
{
// create and file the content as a record
file(nodeRef);
file(nodeRef);
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects()
*/
@@ -246,8 +249,8 @@ public class RecordServiceImpl implements RecordService,
return nodeService.hasAspect(record, ASPECT_DECLARED_RECORD);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getUnfiledRootContainer(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -255,26 +258,26 @@ public class RecordServiceImpl implements RecordService,
public NodeRef getUnfiledContainer(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
if (recordsManagementService.isFilePlan(filePlan) == false)
{
throw new AlfrescoRuntimeException("Unable to get the unfiled container, because passed node is not a file plan.");
}
NodeRef result = null;
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ASSOC_UNFILED_RECORDS,
RegexQNamePattern.MATCH_ALL);
if (assocs.size() > 1)
{
if (assocs.size() > 1)
{
throw new AlfrescoRuntimeException(
"Unable to get the unfiled container, because the container cannot be indentified.");
"Unable to get the unfiled container, because the container cannot be indentified.");
}
else if (assocs.size() == 1 )
{
{
result = assocs.get(0).getChildRef();
}
return result;
}
@@ -287,60 +290,65 @@ public class RecordServiceImpl implements RecordService,
{
ParameterCheck.mandatory("filePlan", filePlan);
ParameterCheck.mandatory("document", nodeRef);
if (nodeService.hasAspect(nodeRef, ASPECT_RECORD) == false)
{
{
// first we do a sanity check to ensure that the user has at least write permissions on the document
if (permissionService.hasPermission(nodeRef, PermissionService.WRITE) != AccessStatus.ALLOWED)
{
throw new AccessDeniedException("Can not create record from document, because the user " +
throw new AccessDeniedException("Can not create record from document, because the user " +
AuthenticationUtil.getFullyAuthenticatedUser() +
" does not have Write permissions on the doucment " +
nodeRef.toString());
}
// do the work of creating the record as the system user
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
// get the new record container for the file plan
NodeRef newRecordContainer = getUnfiledContainer(filePlan);
if (newRecordContainer == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found.");
if (newRecordContainer == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found.");
}
// get the documents readers
Long aclId = nodeService.getNodeAclId(nodeRef);
Set<String> readers = permissionService.getReaders(aclId);
// get the documents primary parent assoc
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef);
// move the document into the file plan
nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// maintain the original primary location
nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName());
ChildAssociationRef child = nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName());
// Add the information about the original location
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
aspectProperties.put(PROP_ORIGINAL_LOCATION, (Serializable) child.getParentRef());
nodeService.addAspect(nodeRef, ASPECT_ORIGINAL_LOCATION, aspectProperties);
// make the document a record
makeRecord(nodeRef);
// set the readers
extendedSecurityService.setExtendedReaders(nodeRef, readers);
return null;
}
});
}
}
/**
* Creates a record from the given document
*
*
* @param document the document from which a record will be created
*/
private void makeRecord(NodeRef document)
@@ -351,7 +359,7 @@ public class RecordServiceImpl implements RecordService,
.getParentRef());
nodeService.setProperty(document, PROP_IDENTIFIER, recordId);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService#isFiled(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -359,38 +367,38 @@ public class RecordServiceImpl implements RecordService,
public boolean isFiled(NodeRef nodeRef)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
boolean result = false;
if (isRecord(nodeRef) == true)
{
ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(nodeRef);
if (childAssocRef != null)
{
NodeRef parent = childAssocRef.getParentRef();
if (parent != null &&
if (parent != null &&
recordsManagementService.isRecordFolder(parent) == true)
{
result = true;
}
}
}
return result;
}
}
/**
* Helper method to 'file' a new document that arrived in the file plan structure.
*
*
* TODO atm we only 'file' content as a record .. may need to consider other types if we
* are to support the notion of composite records.
*
* @param record node reference to record (or soon to be record!)
*
* @param record node reference to record (or soon to be record!)
*/
private void file(NodeRef record)
{
ParameterCheck.mandatory("item", record);
// we only support filling of content items
// TODO composite record support needs to file containers too
QName type = nodeService.getType(record);
@@ -403,19 +411,19 @@ public class RecordServiceImpl implements RecordService,
// make the item a record
makeRecord(record);
}
// set filed date
// set filed date
if (nodeService.getProperty(record, PROP_DATE_FILED) == null)
{
Calendar fileCalendar = Calendar.getInstance();
nodeService.setProperty(record, PROP_DATE_FILED, fileCalendar.getTime());
}
// initialise vital record details
// TODO .. change this to add the aspect which will trigger the init behaviour
VitalRecordServiceImpl vitalRecordService = (VitalRecordServiceImpl)applicationContext.getBean("vitalRecordService");
vitalRecordService.initialiseVitalRecord(record);
// initialise disposition details
if (nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE) == false)
{