mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-572 - Refactor: Filling action logic moved to Record Service
* file and setup folder action removed in favour of services * disposition action methods consolidated in disposition service * vital record action methods consolidated in vital record service * unit test updates * other code fallout git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@44783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -175,13 +175,7 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
// Register the association behaviours
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
|
||||
TYPE_RECORD_FOLDER,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
new JavaBehaviour(this, "onFileContent", NotificationFrequency.TRANSACTION_COMMIT));
|
||||
|
||||
// Register the association behaviours
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
|
||||
TYPE_FILE_PLAN,
|
||||
@@ -193,6 +187,7 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
new JavaBehaviour(this, "onAddContentToContainer", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
// TODO move this into the record service
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
|
||||
ASPECT_RECORD,
|
||||
@@ -226,32 +221,6 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
|
||||
new JavaBehaviour(this, "onIdentifierUpdate", NotificationFrequency.TRANSACTION_COMMIT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to file any record created in a record folder
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
public void onFileContent(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
// Ensure that the filed item is cm:content
|
||||
QName type = nodeService.getType(nodeRef);
|
||||
if (ContentModel.TYPE_CONTENT.equals(type) == true ||
|
||||
dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == true)
|
||||
{
|
||||
// File the document
|
||||
rmActionService.executeRecordsManagementAction(childAssocRef.getChildRef(), "file");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Raise an exception since we should only be filling content into a record folder
|
||||
throw new AlfrescoRuntimeException("Unable to complete operation, because only content can be filed within a record folder.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On add content to container
|
||||
*
|
||||
|
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* 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.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* Files a record into a particular record folder
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class FileAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Parameter names */
|
||||
public static final String PARAM_RECORD_METADATA_ASPECTS = "recordMetadataAspects";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// Permissions perform the following checks so this action doesn't need to.
|
||||
//
|
||||
// check the record is within a folder
|
||||
// check that the folder we are filing into is not closed
|
||||
|
||||
// Get the optional list of record meta-data aspects
|
||||
List<QName> recordMetadataAspects = (List<QName>)action.getParameterValue(PARAM_RECORD_METADATA_ASPECTS);
|
||||
|
||||
// Add the record aspect (doesn't matter if it is already present)
|
||||
if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD) == false)
|
||||
{
|
||||
nodeService.addAspect(actionedUponNodeRef, RecordsManagementModel.ASPECT_RECORD, null);
|
||||
}
|
||||
|
||||
// Get the records properties
|
||||
Map<QName, Serializable> recordProperties = this.nodeService.getProperties(actionedUponNodeRef);
|
||||
|
||||
Calendar fileCalendar = Calendar.getInstance();
|
||||
if (recordProperties.get(RecordsManagementModel.PROP_IDENTIFIER) == null)
|
||||
{
|
||||
// Calculate the filed date and record identifier
|
||||
String year = Integer.toString(fileCalendar.get(Calendar.YEAR));
|
||||
QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
|
||||
String recordId = year + "-" + StringUtils.leftPad(recordProperties.get(nodeDbid).toString(), 10, "0");
|
||||
recordProperties.put(RecordsManagementModel.PROP_IDENTIFIER, recordId);
|
||||
}
|
||||
|
||||
// Update/set the date this record was refiled/filed
|
||||
recordProperties.put(RecordsManagementModel.PROP_DATE_FILED, fileCalendar.getTime());
|
||||
|
||||
// Set the record properties
|
||||
this.nodeService.setProperties(actionedUponNodeRef, recordProperties);
|
||||
|
||||
// Apply any record meta-data aspects
|
||||
if (recordMetadataAspects != null && recordMetadataAspects.size() != 0)
|
||||
{
|
||||
for (QName aspect : recordMetadataAspects)
|
||||
{
|
||||
nodeService.addAspect(actionedUponNodeRef, aspect, null);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the review schedule
|
||||
VitalRecordDefinition viDef = vitalRecordService.getVitalRecordDefinition(actionedUponNodeRef);
|
||||
if (viDef != null && viDef.isEnabled() == true)
|
||||
{
|
||||
Date reviewAsOf = viDef.getNextReviewDate();
|
||||
if (reviewAsOf != null)
|
||||
{
|
||||
Map<QName, Serializable> reviewProps = new HashMap<QName, Serializable>(1);
|
||||
reviewProps.put(RecordsManagementModel.PROP_REVIEW_AS_OF, reviewAsOf);
|
||||
|
||||
if (!nodeService.hasAspect(actionedUponNodeRef, ASPECT_VITAL_RECORD))
|
||||
{
|
||||
this.nodeService.addAspect(actionedUponNodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD, reviewProps);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<QName, Serializable> props = nodeService.getProperties(actionedUponNodeRef);
|
||||
props.putAll(reviewProps);
|
||||
nodeService.setProperties(actionedUponNodeRef, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the disposition instructions for the actioned upon record
|
||||
DispositionSchedule di = this.dispositionService.getDispositionSchedule(actionedUponNodeRef);
|
||||
|
||||
// Set up the disposition schedule if the dispositions are being managed at the record level
|
||||
if (di != null && di.isRecordLevelDisposition() == true)
|
||||
{
|
||||
// Setup the next disposition action
|
||||
updateNextDispositionAction(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
// No parameters
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_RECORD_METADATA_ASPECTS, DataTypeDefinition.QNAME, false, "Record Metadata Aspects", true));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Set<QName> getProtectedAspects()
|
||||
// {
|
||||
// HashSet<QName> qnames = new HashSet<QName>();
|
||||
// qnames.add(ASPECT_RECORD);
|
||||
// qnames.add(ASPECT_VITAL_RECORD);
|
||||
// return qnames;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Set<QName> getProtectedProperties()
|
||||
// {
|
||||
// HashSet<QName> qnames = new HashSet<QName>();
|
||||
// qnames.add(PROP_DATE_FILED);
|
||||
// qnames.add(PROP_REVIEW_AS_OF);
|
||||
// return qnames;
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Action to close the records folder
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class SetupRecordFolderAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
|
||||
{
|
||||
// Set up the disposition schedule if the dispositions are being managed at the folder level
|
||||
DispositionSchedule di = this.dispositionService.getDispositionSchedule(actionedUponNodeRef);
|
||||
if (di != null && di.isRecordLevelDisposition() == false)
|
||||
{
|
||||
// Setup the next disposition action
|
||||
updateNextDispositionAction(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -140,7 +140,6 @@ public class RecordsManagementAuditServiceImpl
|
||||
protected static final String AUDIT_TRAIL_FILE_PREFIX = "audit_";
|
||||
protected static final String AUDIT_TRAIL_JSON_FILE_SUFFIX = ".json";
|
||||
protected static final String AUDIT_TRAIL_HTML_FILE_SUFFIX = ".html";
|
||||
protected static final String FILE_ACTION = "file";
|
||||
|
||||
private PolicyComponent policyComponent;
|
||||
private DictionaryService dictionaryService;
|
||||
@@ -268,8 +267,6 @@ public class RecordsManagementAuditServiceImpl
|
||||
this.auditEvents.put(RM_AUDIT_EVENT_LOGIN_FAILURE,
|
||||
new AuditEvent(RM_AUDIT_EVENT_LOGIN_FAILURE, MSG_LOGIN_FAILED));
|
||||
|
||||
this.auditEvents.put("file",
|
||||
new AuditEvent("file", MSG_FILED_RECORD));
|
||||
this.auditEvents.put("reviewed",
|
||||
new AuditEvent("reviewed", MSG_REVIEWED));
|
||||
this.auditEvents.put("cutoff",
|
||||
@@ -282,8 +279,6 @@ public class RecordsManagementAuditServiceImpl
|
||||
new AuditEvent("openRecordFolder", MSG_OPENED_RECORD_FOLDER));
|
||||
this.auditEvents.put("closeRecordFolder",
|
||||
new AuditEvent("closeRecordFolder", MSG_CLOSED_RECORD_FOLDER));
|
||||
this.auditEvents.put("setupRecordFolder",
|
||||
new AuditEvent("setupRecordFolder", MSG_SETUP_RECORD_FOLDER));
|
||||
this.auditEvents.put("declareRecord",
|
||||
new AuditEvent("declareRecord", MSG_DECLARED_RECORD));
|
||||
this.auditEvents.put("undeclareRecord",
|
||||
@@ -994,10 +989,7 @@ public class RecordsManagementAuditServiceImpl
|
||||
ContentWriter writer = this.contentService.getWriter(record, ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype(format == ReportFormat.HTML ? MimetypeMap.MIMETYPE_HTML : MimetypeMap.MIMETYPE_JSON);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(auditTrail);
|
||||
|
||||
// file the node as a record
|
||||
this.rmActionService.executeRecordsManagementAction(record, FILE_ACTION);
|
||||
writer.putContent(auditTrail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ import org.alfresco.model.ContentModel;
|
||||
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.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordFolderServiceImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -38,475 +39,479 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
public class DataSetServiceImpl implements DataSetService, RecordsManagementModel
|
||||
public class DataSetServiceImpl implements DataSetService, RecordsManagementModel, ApplicationContextAware
|
||||
{
|
||||
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(DataSetServiceImpl.class);
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(DataSetServiceImpl.class);
|
||||
|
||||
/** Registered data set implementations */
|
||||
private Map<String, DataSet> dataSets = new HashMap<String, DataSet>();
|
||||
/** Registered data set implementations */
|
||||
private Map<String, DataSet> dataSets = new HashMap<String, DataSet>();
|
||||
|
||||
/** Spaces store */
|
||||
private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
|
||||
"SpacesStore");
|
||||
/** Spaces store */
|
||||
private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||
|
||||
/** Importer service */
|
||||
private ImporterService importerService;
|
||||
/** Importer service */
|
||||
private ImporterService importerService;
|
||||
|
||||
/** Search service */
|
||||
private SearchService searchService;
|
||||
/** Search service */
|
||||
private SearchService searchService;
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Records management service */
|
||||
private RecordsManagementService recordsManagementService;
|
||||
/** Records management service */
|
||||
private RecordsManagementService recordsManagementService;
|
||||
|
||||
/** Records management action service */
|
||||
private RecordsManagementActionService recordsManagementActionService;
|
||||
/** Records management action service */
|
||||
private RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
/** Permission service */
|
||||
private PermissionService permissionService;
|
||||
/** Permission service */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/** Authority service */
|
||||
private AuthorityService authorityService;
|
||||
/** Authority service */
|
||||
private AuthorityService authorityService;
|
||||
|
||||
/** Records management security service */
|
||||
private RecordsManagementSecurityService recordsManagementSecurityService;
|
||||
/** Records management security service */
|
||||
private RecordsManagementSecurityService recordsManagementSecurityService;
|
||||
|
||||
/** Records management search behaviour */
|
||||
private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour;
|
||||
/** Records management search behaviour */
|
||||
private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour;
|
||||
|
||||
/** Disposition service */
|
||||
private DispositionService dispositionService;
|
||||
/** Disposition service */
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/**
|
||||
* Set importer service
|
||||
*
|
||||
* @param importerService the importer service
|
||||
*/
|
||||
public void setImporterService(ImporterService importerService)
|
||||
{
|
||||
this.importerService = importerService;
|
||||
}
|
||||
/** Application context */
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* Set search service
|
||||
*
|
||||
* @param searchService the search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
/**
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set node service
|
||||
*
|
||||
* @param nodeService the node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
/**
|
||||
* Set importer service
|
||||
*
|
||||
* @param importerService the importer service
|
||||
*/
|
||||
public void setImporterService(ImporterService importerService)
|
||||
{
|
||||
this.importerService = importerService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management service
|
||||
*
|
||||
* @param recordsManagementService the records management service
|
||||
*/
|
||||
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
|
||||
{
|
||||
this.recordsManagementService = recordsManagementService;
|
||||
}
|
||||
/**
|
||||
* Set search service
|
||||
*
|
||||
* @param searchService the search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management action service
|
||||
*
|
||||
* @param recordsManagementActionService the records management action
|
||||
* service
|
||||
*/
|
||||
public void setRecordsManagementActionService(
|
||||
RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
/**
|
||||
* Set node service
|
||||
*
|
||||
* @param nodeService the node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set permission service
|
||||
*
|
||||
* @param permissionService the permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
/**
|
||||
* Set records management service
|
||||
*
|
||||
* @param recordsManagementService the records management service
|
||||
*/
|
||||
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
|
||||
{
|
||||
this.recordsManagementService = recordsManagementService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set authority service
|
||||
*
|
||||
* @param authorityService the authority service
|
||||
*/
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
/**
|
||||
* Set records management action service
|
||||
*
|
||||
* @param recordsManagementActionService the records management action
|
||||
* service
|
||||
*/
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management security service
|
||||
*
|
||||
* @param recordsManagementSecurityService the records management security
|
||||
* service
|
||||
*/
|
||||
public void setRecordsManagementSecurityService(
|
||||
RecordsManagementSecurityService recordsManagementSecurityService)
|
||||
{
|
||||
this.recordsManagementSecurityService = recordsManagementSecurityService;
|
||||
}
|
||||
/**
|
||||
* Set permission service
|
||||
*
|
||||
* @param permissionService the permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management search behaviour
|
||||
*
|
||||
* @param recordsManagementSearchBehaviour the records management search
|
||||
* behaviour
|
||||
*/
|
||||
public void setRecordsManagementSearchBehaviour(
|
||||
RecordsManagementSearchBehaviour recordsManagementSearchBehaviour)
|
||||
{
|
||||
this.recordsManagementSearchBehaviour = recordsManagementSearchBehaviour;
|
||||
}
|
||||
/**
|
||||
* Set authority service
|
||||
*
|
||||
* @param authorityService the authority service
|
||||
*/
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set disposition service
|
||||
*
|
||||
* @param dispositionService the disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
/**
|
||||
* Set records management security service
|
||||
*
|
||||
* @param recordsManagementSecurityService the records management security
|
||||
* service
|
||||
*/
|
||||
public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService)
|
||||
{
|
||||
this.recordsManagementSecurityService = recordsManagementSecurityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#register(org.alfresco.module.org_alfresco_module_rm.dataset.DataSet)
|
||||
*/
|
||||
@Override
|
||||
public void register(DataSet dataSet)
|
||||
{
|
||||
ParameterCheck.mandatory("dataSet", dataSet);
|
||||
/**
|
||||
* Set records management search behaviour
|
||||
*
|
||||
* @param recordsManagementSearchBehaviour the records management search
|
||||
* behaviour
|
||||
*/
|
||||
public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour recordsManagementSearchBehaviour)
|
||||
{
|
||||
this.recordsManagementSearchBehaviour = recordsManagementSearchBehaviour;
|
||||
}
|
||||
|
||||
this.dataSets.put(dataSet.getId(), dataSet);
|
||||
}
|
||||
/**
|
||||
* Set disposition service
|
||||
*
|
||||
* @param dispositionService the disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, DataSet> getDataSets()
|
||||
{
|
||||
return this.dataSets;
|
||||
}
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#register(org.alfresco.module.org_alfresco_module_rm.dataset.DataSet)
|
||||
*/
|
||||
@Override
|
||||
public void register(DataSet dataSet)
|
||||
{
|
||||
ParameterCheck.mandatory("dataSet", dataSet);
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets(NodeRef,
|
||||
* boolean)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, DataSet> getDataSets(NodeRef filePlan, boolean excludeLoaded)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
ParameterCheck.mandatory("excludeLoaded", excludeLoaded);
|
||||
this.dataSets.put(dataSet.getId(), dataSet);
|
||||
}
|
||||
|
||||
// Get the list of all available data sets
|
||||
Map<String, DataSet> dataSets = new HashMap<String, DataSet>(getDataSets());
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, DataSet> getDataSets()
|
||||
{
|
||||
return this.dataSets;
|
||||
}
|
||||
|
||||
// Should the list of unloaded data sets be retrieved
|
||||
if (excludeLoaded)
|
||||
{
|
||||
dataSets.keySet().removeAll(getLoadedDataSets(filePlan).keySet());
|
||||
}
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getDataSets(NodeRef,
|
||||
* boolean)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, DataSet> getDataSets(NodeRef filePlan, boolean excludeLoaded)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
ParameterCheck.mandatory("excludeLoaded", excludeLoaded);
|
||||
|
||||
// Return the (filtered) list of data sets
|
||||
return dataSets;
|
||||
}
|
||||
// Get the list of all available data sets
|
||||
Map<String, DataSet> dataSets = new HashMap<String, DataSet>(getDataSets());
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#loadDataSet(java.lang.String,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void loadDataSet(NodeRef filePlan, String dataSetId)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
ParameterCheck.mandatoryString("dataSetId", dataSetId);
|
||||
// Should the list of unloaded data sets be retrieved
|
||||
if (excludeLoaded)
|
||||
{
|
||||
dataSets.keySet().removeAll(getLoadedDataSets(filePlan).keySet());
|
||||
}
|
||||
|
||||
// Get the data set
|
||||
DataSet dataSet = getDataSets().get(dataSetId);
|
||||
// Return the (filtered) list of data sets
|
||||
return dataSets;
|
||||
}
|
||||
|
||||
// Import the RM test data ACP into the the provided file plan node reference
|
||||
InputStream is = null;
|
||||
try
|
||||
{
|
||||
is = getClass().getClassLoader().getResourceAsStream(dataSet.getPath());
|
||||
if (is == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The '" + dataSet.getLabel()
|
||||
+ "' import file could not be found!");
|
||||
}
|
||||
|
||||
// Import view
|
||||
Reader viewReader = new InputStreamReader(is);
|
||||
Location location = new Location(filePlan);
|
||||
importerService.importView(viewReader, location, null, null);
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#loadDataSet(java.lang.String,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void loadDataSet(NodeRef filePlan, String dataSetId)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
ParameterCheck.mandatoryString("dataSetId", dataSetId);
|
||||
|
||||
// Patch data
|
||||
patchLoadedData();
|
||||
// Get the data set
|
||||
DataSet dataSet = getDataSets().get(dataSetId);
|
||||
|
||||
// Set the data set id into the file plan's custom aspect
|
||||
setDataSetIdIntoFilePlan(dataSetId, filePlan);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new RuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
try
|
||||
// Import the RM test data ACP into the the provided file plan node
|
||||
// reference
|
||||
InputStream is = null;
|
||||
try
|
||||
{
|
||||
is = getClass().getClassLoader().getResourceAsStream(dataSet.getPath());
|
||||
if (is == null) { throw new AlfrescoRuntimeException("The '" + dataSet.getLabel()
|
||||
+ "' import file could not be found!"); }
|
||||
|
||||
// Import view
|
||||
Reader viewReader = new InputStreamReader(is);
|
||||
Location location = new Location(filePlan);
|
||||
importerService.importView(viewReader, location, null, null);
|
||||
|
||||
// Patch data
|
||||
patchLoadedData();
|
||||
|
||||
// Set the data set id into the file plan's custom aspect
|
||||
setDataSetIdIntoFilePlan(dataSetId, filePlan);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new RuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
is.close();
|
||||
is = null;
|
||||
try
|
||||
{
|
||||
is.close();
|
||||
is = null;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new RuntimeException("Failed to close the input stream!", ex);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#existsDataSet(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean existsDataSet(String dataSetId)
|
||||
{
|
||||
ParameterCheck.mandatoryString("dataSetId", dataSetId);
|
||||
|
||||
return getDataSets().containsKey(dataSetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getLoadedDataSets(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, DataSet> getLoadedDataSets(NodeRef filePlan)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
|
||||
// Get the list of available data sets
|
||||
Map<String, DataSet> availableDataSets = new HashMap<String, DataSet>(getDataSets());
|
||||
|
||||
// Get the property value of the aspect
|
||||
Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS);
|
||||
// Check if any data has been loaded before
|
||||
if (dataSetIds != null)
|
||||
{
|
||||
// Filter the data sets which have already been loaded
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<String> loadedDataSetIds = (ArrayList<String>) dataSetIds;
|
||||
Iterator<Map.Entry<String, DataSet>> iterator = availableDataSets.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
throw new RuntimeException("Failed to close the input stream!", ex);
|
||||
Entry<String, DataSet> entry = iterator.next();
|
||||
String key = entry.getKey();
|
||||
if (!loadedDataSetIds.contains(key))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return availableDataSets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#existsDataSet(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean existsDataSet(String dataSetId)
|
||||
{
|
||||
ParameterCheck.mandatoryString("dataSetId", dataSetId);
|
||||
return new HashMap<String, DataSet>();
|
||||
}
|
||||
|
||||
return getDataSets().containsKey(dataSetId);
|
||||
}
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#isLoadedDataSet(org.alfresco.service.cmr.repository.NodeRef,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLoadedDataSet(NodeRef filePlan, String dataSetId)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
ParameterCheck.mandatory("dataSetId", dataSetId);
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#getLoadedDataSets(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, DataSet> getLoadedDataSets(NodeRef filePlan)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
return getLoadedDataSets(filePlan).containsKey(dataSetId);
|
||||
}
|
||||
|
||||
// Get the list of available data sets
|
||||
Map<String, DataSet> availableDataSets = new HashMap<String, DataSet>(getDataSets());
|
||||
|
||||
// Get the property value of the aspect
|
||||
Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS);
|
||||
// Check if any data has been loaded before
|
||||
if (dataSetIds != null)
|
||||
{
|
||||
// Filter the data sets which have already been loaded
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<String> loadedDataSetIds = (ArrayList<String>) dataSetIds;
|
||||
Iterator<Map.Entry<String, DataSet>> iterator = availableDataSets.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entry<String, DataSet> entry = iterator.next();
|
||||
String key = entry.getKey();
|
||||
if (!loadedDataSetIds.contains(key))
|
||||
/**
|
||||
* Temp method to patch AMP'ed data
|
||||
*
|
||||
* @param searchService
|
||||
* @param nodeService
|
||||
* @param recordsManagementService
|
||||
* @param recordsManagementActionService
|
||||
*/
|
||||
private void patchLoadedData()
|
||||
{
|
||||
AuthenticationUtil.RunAsWork<Object> runAsWork = new AuthenticationUtil.RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
iterator.remove();
|
||||
java.util.List<NodeRef> rmRoots = recordsManagementService.getFilePlans();
|
||||
logger.info("Bootstraping " + rmRoots.size() + " rm roots ...");
|
||||
for (NodeRef rmRoot : rmRoots)
|
||||
{
|
||||
if (permissionService.getInheritParentPermissions(rmRoot) == true)
|
||||
{
|
||||
logger.info("Updating permissions for rm root: " + rmRoot);
|
||||
permissionService.setInheritParentPermissions(rmRoot, false);
|
||||
}
|
||||
|
||||
String allRoleShortName = "AllRoles" + rmRoot.getId();
|
||||
String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName);
|
||||
|
||||
if (authorityService.authorityExists(allRoleGroupName) == false)
|
||||
{
|
||||
logger.info("Creating all roles group for root node: " + rmRoot.toString());
|
||||
|
||||
// Create "all" role group for root node
|
||||
String allRoles = authorityService.createAuthority(AuthorityType.GROUP, allRoleShortName,
|
||||
"All Roles", null);
|
||||
|
||||
// Put all the role groups in it
|
||||
Set<Role> roles = recordsManagementSecurityService.getRoles(rmRoot);
|
||||
for (Role role : roles)
|
||||
{
|
||||
logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group");
|
||||
authorityService.addAuthority(allRoles, role.getRoleGroupName());
|
||||
}
|
||||
|
||||
// Set the permissions
|
||||
permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure all the containers do not inherit permissions
|
||||
ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE,
|
||||
"TYPE:\"rma:recordsManagementContainer\"");
|
||||
try
|
||||
{
|
||||
logger.info("Bootstraping " + rs.length() + " record containers ...");
|
||||
|
||||
for (NodeRef container : rs.getNodeRefs())
|
||||
{
|
||||
String containerName = (String) nodeService.getProperty(container, ContentModel.PROP_NAME);
|
||||
|
||||
// Set permissions
|
||||
if (permissionService.getInheritParentPermissions(container) == true)
|
||||
{
|
||||
logger.info("Updating permissions for record container: " + containerName);
|
||||
permissionService.setInheritParentPermissions(container, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
|
||||
// fix up the test dataset to fire initial events for
|
||||
// disposition
|
||||
// schedules
|
||||
rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, "TYPE:\"rma:recordFolder\"");
|
||||
try
|
||||
{
|
||||
logger.info("Bootstraping " + rs.length() + " record folders ...");
|
||||
|
||||
for (NodeRef recordFolder : rs.getNodeRefs())
|
||||
{
|
||||
String folderName = (String) nodeService.getProperty(recordFolder, ContentModel.PROP_NAME);
|
||||
|
||||
// Set permissions
|
||||
if (permissionService.getInheritParentPermissions(recordFolder) == true)
|
||||
{
|
||||
logger.info("Updating permissions for record folder: " + folderName);
|
||||
permissionService.setInheritParentPermissions(recordFolder, false);
|
||||
}
|
||||
|
||||
if (nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE) == false)
|
||||
{
|
||||
// See if the folder has a disposition schedule that
|
||||
// needs
|
||||
// to be applied
|
||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder);
|
||||
if (ds != null)
|
||||
{
|
||||
// Fire action to "set-up" the folder correctly
|
||||
logger.info("Setting up bootstraped record folder: " + folderName);
|
||||
RecordFolderServiceImpl recordService = (RecordFolderServiceImpl)applicationContext.getBean("recordFolderService");
|
||||
recordService.initialiseRecordFolder(recordFolder);
|
||||
}
|
||||
}
|
||||
|
||||
// fixup the search behaviour aspect for the record
|
||||
// folder
|
||||
logger.info("Setting up search aspect for record folder: " + folderName);
|
||||
recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return availableDataSets;
|
||||
}
|
||||
};
|
||||
|
||||
return new HashMap<String, DataSet>();
|
||||
}
|
||||
AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName());
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#isLoadedDataSet(org.alfresco.service.cmr.repository.NodeRef,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLoadedDataSet(NodeRef filePlan, String dataSetId)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
ParameterCheck.mandatory("dataSetId", dataSetId);
|
||||
}
|
||||
|
||||
return getLoadedDataSets(filePlan).containsKey(dataSetId);
|
||||
}
|
||||
/**
|
||||
* Helper method for setting the id of the imported data set into the file
|
||||
* plan's aspect
|
||||
*
|
||||
* @param dataSetId The id of the imported data set
|
||||
* @param filePlan The file plan into which the data set has been imported
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setDataSetIdIntoFilePlan(String dataSetId, NodeRef filePlan)
|
||||
{
|
||||
ArrayList<String> loadedDataSetIds;
|
||||
Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS);
|
||||
|
||||
/**
|
||||
* Temp method to patch AMP'ed data
|
||||
*
|
||||
* @param searchService
|
||||
* @param nodeService
|
||||
* @param recordsManagementService
|
||||
* @param recordsManagementActionService
|
||||
*/
|
||||
private void patchLoadedData()
|
||||
{
|
||||
AuthenticationUtil.RunAsWork<Object> runAsWork = new AuthenticationUtil.RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
java.util.List<NodeRef> rmRoots = recordsManagementService.getFilePlans();
|
||||
logger.info("Bootstraping " + rmRoots.size() + " rm roots ...");
|
||||
for (NodeRef rmRoot : rmRoots)
|
||||
{
|
||||
if (permissionService.getInheritParentPermissions(rmRoot) == true)
|
||||
{
|
||||
logger.info("Updating permissions for rm root: " + rmRoot);
|
||||
permissionService.setInheritParentPermissions(rmRoot, false);
|
||||
}
|
||||
// Check if any data set has been imported
|
||||
if (dataSetIds == null)
|
||||
{
|
||||
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
|
||||
aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) new ArrayList<String>());
|
||||
nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties);
|
||||
loadedDataSetIds = (ArrayList<String>) nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadedDataSetIds = (ArrayList<String>) dataSetIds;
|
||||
}
|
||||
|
||||
String allRoleShortName = "AllRoles" + rmRoot.getId();
|
||||
String allRoleGroupName = authorityService.getName(AuthorityType.GROUP,
|
||||
allRoleShortName);
|
||||
|
||||
if (authorityService.authorityExists(allRoleGroupName) == false)
|
||||
{
|
||||
logger.info("Creating all roles group for root node: " + rmRoot.toString());
|
||||
|
||||
// Create "all" role group for root node
|
||||
String allRoles = authorityService.createAuthority(AuthorityType.GROUP,
|
||||
allRoleShortName, "All Roles", null);
|
||||
|
||||
// Put all the role groups in it
|
||||
Set<Role> roles = recordsManagementSecurityService.getRoles(rmRoot);
|
||||
for (Role role : roles)
|
||||
{
|
||||
logger.info(" - adding role group " + role.getRoleGroupName()
|
||||
+ " to all roles group");
|
||||
authorityService.addAuthority(allRoles, role.getRoleGroupName());
|
||||
}
|
||||
|
||||
// Set the permissions
|
||||
permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure all the containers do not inherit permissions
|
||||
ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE,
|
||||
"TYPE:\"rma:recordsManagementContainer\"");
|
||||
try
|
||||
{
|
||||
logger.info("Bootstraping " + rs.length() + " record containers ...");
|
||||
|
||||
for (NodeRef container : rs.getNodeRefs())
|
||||
{
|
||||
String containerName = (String) nodeService.getProperty(container,
|
||||
ContentModel.PROP_NAME);
|
||||
|
||||
// Set permissions
|
||||
if (permissionService.getInheritParentPermissions(container) == true)
|
||||
{
|
||||
logger.info("Updating permissions for record container: " + containerName);
|
||||
permissionService.setInheritParentPermissions(container, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
|
||||
// fix up the test dataset to fire initial events for disposition
|
||||
// schedules
|
||||
rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE,
|
||||
"TYPE:\"rma:recordFolder\"");
|
||||
try
|
||||
{
|
||||
logger.info("Bootstraping " + rs.length() + " record folders ...");
|
||||
|
||||
for (NodeRef recordFolder : rs.getNodeRefs())
|
||||
{
|
||||
String folderName = (String) nodeService.getProperty(recordFolder,
|
||||
ContentModel.PROP_NAME);
|
||||
|
||||
// Set permissions
|
||||
if (permissionService.getInheritParentPermissions(recordFolder) == true)
|
||||
{
|
||||
logger.info("Updating permissions for record folder: " + folderName);
|
||||
permissionService.setInheritParentPermissions(recordFolder, false);
|
||||
}
|
||||
|
||||
if (nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE) == false)
|
||||
{
|
||||
// See if the folder has a disposition schedule that needs
|
||||
// to be applied
|
||||
DispositionSchedule ds = dispositionService
|
||||
.getDispositionSchedule(recordFolder);
|
||||
if (ds != null)
|
||||
{
|
||||
// Fire action to "set-up" the folder correctly
|
||||
logger.info("Setting up bootstraped record folder: " + folderName);
|
||||
recordsManagementActionService.executeRecordsManagementAction(recordFolder,
|
||||
"setupRecordFolder");
|
||||
}
|
||||
}
|
||||
|
||||
// fixup the search behaviour aspect for the record folder
|
||||
logger.info("Setting up search aspect for record folder: " + folderName);
|
||||
recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for setting the id of the imported data set into the file
|
||||
* plan's aspect
|
||||
*
|
||||
* @param dataSetId The id of the imported data set
|
||||
* @param filePlan The file plan into which the data set has been imported
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setDataSetIdIntoFilePlan(String dataSetId, NodeRef filePlan)
|
||||
{
|
||||
ArrayList<String> loadedDataSetIds;
|
||||
Serializable dataSetIds = nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS);
|
||||
|
||||
// Check if any data set has been imported
|
||||
if (dataSetIds == null)
|
||||
{
|
||||
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
|
||||
aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) new ArrayList<String>());
|
||||
nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties);
|
||||
loadedDataSetIds = (ArrayList<String>) nodeService.getProperty(filePlan,
|
||||
PROP_LOADED_DATA_SET_IDS);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadedDataSetIds = (ArrayList<String>) dataSetIds;
|
||||
}
|
||||
|
||||
// Add the new loaded data set id
|
||||
loadedDataSetIds.add(dataSetId);
|
||||
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
|
||||
aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) loadedDataSetIds);
|
||||
nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties);
|
||||
}
|
||||
// Add the new loaded data set id
|
||||
loadedDataSetIds.add(dataSetId);
|
||||
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
|
||||
aspectProperties.put(PROP_LOADED_DATA_SET_IDS, (Serializable) loadedDataSetIds);
|
||||
nodeService.addAspect(filePlan, ASPECT_LOADED_DATA_SET_ID, aspectProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.disposableitem;
|
||||
|
||||
/**
|
||||
* Record folder service interface
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordFolderService
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.disposableitem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* Record Folder Service Implementation
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RecordFolderServiceImpl implements RecordFolderService,
|
||||
RecordsManagementModel,
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||
{
|
||||
/** Policy component */
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Disposition service */
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/** Behaviours */
|
||||
private JavaBehaviour onCreateChildAssociation = new JavaBehaviour(
|
||||
this,
|
||||
"onCreateChildAssociation",
|
||||
NotificationFrequency.FIRST_EVENT);
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispositionService disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
|
||||
TYPE_RECORD_CATEGORY,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
onCreateChildAssociation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
initialiseRecordFolder(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
public void initialiseRecordFolder(NodeRef nodeRef)
|
||||
{
|
||||
// initialise disposition details
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) == false)
|
||||
{
|
||||
DispositionSchedule di = dispositionService.getDispositionSchedule(nodeRef);
|
||||
if (di != null && di.isRecordLevelDisposition() == false)
|
||||
{
|
||||
nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -32,7 +32,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public interface RecordService
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Gets a list of all the record meta-data aspects
|
||||
*
|
||||
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
||||
@@ -55,14 +55,7 @@ public interface RecordService
|
||||
*/
|
||||
boolean isDeclared(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Indicates whether the record is filed or not
|
||||
*
|
||||
* @param nodeRef record
|
||||
* @return boolean true if filed, false otherwise
|
||||
*/
|
||||
boolean isFiled(NodeRef nodeRef);
|
||||
|
||||
// TODO move to filePlan service
|
||||
/**
|
||||
* Gets the unfiled root container for the given file plan
|
||||
*
|
||||
@@ -80,10 +73,10 @@ public interface RecordService
|
||||
void createRecord(NodeRef filePlan, NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Files an unfiled record.
|
||||
* Indicates whether the record is filed or not
|
||||
*
|
||||
* @param record record
|
||||
* @param recordFolder record folder
|
||||
* @param nodeRef record
|
||||
* @return boolean true if filed, false otherwise
|
||||
*/
|
||||
void fileRecord(NodeRef record, NodeRef recordFolder);
|
||||
boolean isFiled(NodeRef record);
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposableitem;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -26,9 +27,16 @@ 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.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
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.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
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;
|
||||
@@ -42,6 +50,9 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
/**
|
||||
* Record service implementation
|
||||
@@ -49,12 +60,18 @@ import org.alfresco.util.ParameterCheck;
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RecordServiceImpl implements RecordService, RecordsManagementModel
|
||||
public class RecordServiceImpl implements RecordService,
|
||||
RecordsManagementModel,
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
ApplicationContextAware
|
||||
{
|
||||
/** Application context */
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/** Node service **/
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Indentiy service */
|
||||
/** Indentity service */
|
||||
private IdentifierService identifierService;
|
||||
|
||||
/** Dictionary service */
|
||||
@@ -68,10 +85,28 @@ public class RecordServiceImpl implements RecordService, RecordsManagementModel
|
||||
|
||||
/** 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",
|
||||
NotificationFrequency.FIRST_EVENT);
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
@@ -120,14 +155,50 @@ public class RecordServiceImpl implements RecordService, RecordsManagementModel
|
||||
this.recordsManagementService = recordsManagementService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispositionService disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
// TODO
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
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
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
// create and file the content as a record
|
||||
file(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects()
|
||||
*/
|
||||
@@ -176,33 +247,7 @@ public class RecordServiceImpl implements RecordService, RecordsManagementModel
|
||||
return nodeService.hasAspect(record, ASPECT_DECLARED_RECORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isFiled(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
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 &&
|
||||
recordsManagementService.isRecordFolder(parent) == true)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getUnfiledRootContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -292,38 +337,7 @@ public class RecordServiceImpl implements RecordService, RecordsManagementModel
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#fileRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void fileRecord(NodeRef record, NodeRef recordFolder)
|
||||
{
|
||||
// check if this is a record
|
||||
if (isRecord(record) == false)
|
||||
{
|
||||
// TODO .. should we make this a record?
|
||||
throw new UnsupportedOperationException("Currently unable to file something that isn't already a record");
|
||||
}
|
||||
|
||||
if (isFiled(record) == false)
|
||||
{
|
||||
// TODO .. refactor the existing code to file a record here ... this will include moving the code that
|
||||
// currently manages the properties of the disposition lifecycle aspect into the disposition service
|
||||
throw new UnsupportedOperationException("Currently unsuported.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO .. figure out how we 'refile' a currently filed record
|
||||
throw new UnsupportedOperationException("Currently unable to file an already filed record.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a record from the given document
|
||||
*
|
||||
@@ -337,4 +351,80 @@ public class RecordServiceImpl implements RecordService, RecordsManagementModel
|
||||
.getParentRef());
|
||||
nodeService.setProperty(document, PROP_IDENTIFIER, recordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService#isFiled(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
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 &&
|
||||
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!)
|
||||
*/
|
||||
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);
|
||||
if (ContentModel.TYPE_CONTENT.equals(type) == true ||
|
||||
dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == true)
|
||||
{
|
||||
// check whether this item is already an item or not
|
||||
if (isRecord(record) == false)
|
||||
{
|
||||
// make the item a record
|
||||
makeRecord(record);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
DispositionSchedule di = dispositionService.getDispositionSchedule(record);
|
||||
if (di != null && di.isRecordLevelDisposition() == true)
|
||||
{
|
||||
nodeService.addAspect(record, ASPECT_DISPOSITION_LIFECYCLE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Disposition service
|
||||
* Disposition service interface.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.0
|
||||
@@ -157,24 +157,28 @@ public interface DispositionService
|
||||
DispositionActionDefinition actionDefinition,
|
||||
Map<QName, Serializable> actionDefinitionParams);
|
||||
|
||||
|
||||
/** ========= Disposition Action Methods ========= */
|
||||
|
||||
/**
|
||||
* TODO MOVE THIS FROM THIS API
|
||||
* Indicates whether the next disposition action is eligible or not.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
* @param nodeRef node reference to disposable item
|
||||
* @return boolean true if next disposition action is eligible, false otherwise
|
||||
*/
|
||||
boolean isNextDispositionActionEligible(NodeRef nodeRef);
|
||||
|
||||
/** ========= Disposition Action Methods ========= */
|
||||
|
||||
/**
|
||||
* Gets the next disposition action for a given node
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
* @param nodeRef node reference to disposable item
|
||||
* @return DispositionAction next disposition action, null if none
|
||||
*/
|
||||
DispositionAction getNextDispositionAction(NodeRef nodeRef);
|
||||
|
||||
// TODO void startNextDispositionAction(NodeRef nodeRef);
|
||||
|
||||
// TODO void completeNextDispositionAction(NodeRef nodeRef);
|
||||
|
||||
|
||||
/** ========= Disposition Action History Methods ========= */
|
||||
|
@@ -30,12 +30,19 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
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.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Period;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
@@ -51,7 +58,11 @@ import org.springframework.context.ApplicationContextAware;
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DispositionServiceImpl implements DispositionService, RecordsManagementModel, ApplicationContextAware
|
||||
public class DispositionServiceImpl implements
|
||||
DispositionService,
|
||||
RecordsManagementModel,
|
||||
ApplicationContextAware,
|
||||
NodeServicePolicies.OnAddAspectPolicy
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(DispositionServiceImpl.class);
|
||||
@@ -77,9 +88,15 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
/** Application context */
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/** Policy component */
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
/** Disposition properties */
|
||||
private Map<QName, DispositionProperty> dispositionProperties = new HashMap<QName, DispositionProperty>(4);
|
||||
|
||||
/** Behaviours */
|
||||
private JavaBehaviour onAddAspect;
|
||||
|
||||
/**
|
||||
* Set node service
|
||||
*
|
||||
@@ -120,6 +137,14 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the records management service
|
||||
* NOTE: have to pull it out of the app context manually to prevent Spring circular dependancy issue
|
||||
@@ -154,6 +179,40 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
this.dispositionSelectionStrategy = dispositionSelectionStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bean initialisation
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
onAddAspect = new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT);
|
||||
policyComponent.bindClassBehaviour(NodeServicePolicies.OnAddAspectPolicy.QNAME, ASPECT_DISPOSITION_LIFECYCLE, onAddAspect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the details of the disposition life cycle
|
||||
*/
|
||||
@Override
|
||||
public void onAddAspect(NodeRef nodeRef, QName aspect)
|
||||
{
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
// get this disposition instructions for the node
|
||||
DispositionSchedule di = getDispositionSchedule(nodeRef);
|
||||
if (di != null)
|
||||
{
|
||||
List<DispositionActionDefinition> dispositionActionDefinitions = di.getDispositionActionDefinitions();
|
||||
if (dispositionActionDefinitions.isEmpty() == false)
|
||||
{
|
||||
// get the first disposition action definition
|
||||
DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0);
|
||||
|
||||
// initialise the details of the next disposition action
|
||||
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** ========= Disposition Property Methods ========= */
|
||||
|
||||
/**
|
||||
@@ -184,6 +243,9 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties()
|
||||
*/
|
||||
@Override
|
||||
public Collection<DispositionProperty> getDispositionProperties()
|
||||
{
|
||||
@@ -199,7 +261,7 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
{
|
||||
DispositionSchedule di = null;
|
||||
NodeRef diNodeRef = null;
|
||||
if (getRmService().isRecord(nodeRef) == true)
|
||||
if (serviceRegistry.getRecordService().isRecord(nodeRef) == true)
|
||||
{
|
||||
// Get the record folders for the record
|
||||
List<NodeRef> recordFolders = getRmService().getRecordFolders(nodeRef);
|
||||
@@ -536,10 +598,106 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
NodeRef ds = this.nodeService.getPrimaryParent(actionDefinition.getNodeRef()).getParentRef();
|
||||
DispositionSchedule updatedSchedule = new DispositionScheduleImpl(serviceRegistry, nodeService, ds);
|
||||
return updatedSchedule.getDispositionActionDefinition(actionDefinition.getId());
|
||||
}
|
||||
|
||||
/** ========= Disposition Action Methods ========= */
|
||||
|
||||
/**
|
||||
* Initialises the details of the next disposition action based on the details of a disposition
|
||||
* action definition.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param dispositionActionDefinition disposition action definition
|
||||
*/
|
||||
private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition)
|
||||
{
|
||||
// Create the properties
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
||||
|
||||
// Calculate the asOf date
|
||||
Date asOfDate = null;
|
||||
Period period = dispositionActionDefinition.getPeriod();
|
||||
if (period != null)
|
||||
{
|
||||
Date contextDate = null;
|
||||
|
||||
// Get the period properties value
|
||||
QName periodProperty = dispositionActionDefinition.getPeriodProperty();
|
||||
if (periodProperty != null)
|
||||
{
|
||||
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
|
||||
// when the value of the period property is set
|
||||
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
// for now use 'NOW' as the default context date
|
||||
// TODO set the default period property ... cut off date or last disposition date depending on context
|
||||
contextDate = new Date();
|
||||
}
|
||||
|
||||
// Calculate the as of date
|
||||
if (contextDate != null)
|
||||
{
|
||||
asOfDate = period.getNextDate(contextDate);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the property values
|
||||
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
|
||||
props.put(PROP_DISPOSITION_ACTION, dispositionActionDefinition.getName());
|
||||
if (asOfDate != null)
|
||||
{
|
||||
props.put(PROP_DISPOSITION_AS_OF, asOfDate);
|
||||
}
|
||||
|
||||
// Create a new disposition action object
|
||||
NodeRef dispositionActionNodeRef = this.nodeService.createNode(
|
||||
nodeRef,
|
||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
||||
TYPE_DISPOSITION_ACTION,
|
||||
props).getChildRef();
|
||||
|
||||
// Create the events
|
||||
List<RecordsManagementEvent> events = dispositionActionDefinition.getEvents();
|
||||
for (RecordsManagementEvent event : events)
|
||||
{
|
||||
// For every event create an entry on the action
|
||||
createEvent(event, dispositionActionNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the given records management event for the given 'next action'.
|
||||
*
|
||||
* @param event The event to create
|
||||
* @param nextActionNodeRef The next action node
|
||||
* @return The created event NodeRef
|
||||
*/
|
||||
private NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef)
|
||||
{
|
||||
NodeRef eventNodeRef = null;
|
||||
|
||||
Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||
eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||
// TODO display label
|
||||
RecordsManagementEventType eventType = serviceRegistry.getRecordsManagementEventService().getEventType(event.getType());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
|
||||
// Create the event execution object
|
||||
this.nodeService.createNode(nextActionNodeRef,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
TYPE_EVENT_EXECUTION,
|
||||
eventProps);
|
||||
|
||||
return eventNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isNextDispositionActionEligible(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public boolean isNextDispositionActionEligible(NodeRef nodeRef)
|
||||
{
|
||||
@@ -609,7 +767,7 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
private NodeRef getNextDispositionActionNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
NodeRef result = null;
|
||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL);
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL);
|
||||
if (assocs.size() != 0)
|
||||
{
|
||||
result = assocs.get(0).getChildRef();
|
||||
@@ -617,10 +775,8 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ========= Disposition Action Methods ========= */
|
||||
|
||||
/**
|
||||
*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getNextDispositionAction(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public DispositionAction getNextDispositionAction(NodeRef nodeRef)
|
||||
{
|
||||
@@ -629,7 +785,7 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
|
||||
if (dispositionActionNodeRef != null)
|
||||
{
|
||||
result = new DispositionActionImpl(this.serviceRegistry, dispositionActionNodeRef);
|
||||
result = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -637,9 +793,10 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
|
||||
/** ========= Disposition Action History Methods ========= */
|
||||
|
||||
|
||||
public List<DispositionAction> getCompletedDispositionActions(NodeRef nodeRef)
|
||||
{
|
||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, RegexQNamePattern.MATCH_ALL);
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, RegexQNamePattern.MATCH_ALL);
|
||||
List<DispositionAction> result = new ArrayList<DispositionAction>(assocs.size());
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
@@ -660,5 +817,4 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -145,13 +145,7 @@ public class RecordContainerType implements RecordsManagementModel,
|
||||
|
||||
// Assume any created folder is a rma:recordFolder
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
if (TYPE_RECORD_FOLDER.equals(nodeService.getType(child)) == true)
|
||||
{
|
||||
// Setup record folder
|
||||
recordsManagementActionService.executeRecordsManagementAction(child, "setupRecordFolder");
|
||||
}
|
||||
}
|
||||
|
||||
// Catch all to generate the rm id (assuming it doesn't already have one!)
|
||||
setIdenifierProperty(child);
|
||||
|
@@ -143,11 +143,12 @@ public class RecordCopyBehaviours implements RecordsManagementModel
|
||||
* @param oldChildAssocRef
|
||||
* @param newChildAssocRef
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void onMoveRecordFolderNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
||||
{
|
||||
final NodeRef newNodeRef = newChildAssocRef.getChildRef();
|
||||
final NodeService nodeService = rmServiceRegistry.getNodeService();
|
||||
final RecordsManagementService rmService = rmServiceRegistry.getRecordsManagementService();
|
||||
final RecordsManagementService rmService = rmServiceRegistry.getRecordsManagementService();
|
||||
final RecordsManagementActionService rmActionService = rmServiceRegistry.getRecordsManagementActionService();
|
||||
|
||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||
@@ -159,15 +160,21 @@ public class RecordCopyBehaviours implements RecordsManagementModel
|
||||
// Remove unwanted aspects
|
||||
removeUnwantedAspects(nodeService, newNodeRef);
|
||||
|
||||
// Trigger folder setup
|
||||
rmActionService.executeRecordsManagementAction(newNodeRef, "setupRecordFolder");
|
||||
// TODO .. this isn't right!!
|
||||
// .. what if the folder is in motion .. do we really want to lose all the disposition information?
|
||||
// .. how do we merge from one disposition schedule to another
|
||||
// .. for now throw unsupportedOperationException and refactor when considered
|
||||
throw new UnsupportedOperationException("Moving a record folder is currently not supported.");
|
||||
|
||||
// Sort out the child records
|
||||
for (NodeRef record : rmService.getRecords(newNodeRef))
|
||||
{
|
||||
removeUnwantedAspects(nodeService, record);
|
||||
rmActionService.executeRecordsManagementAction(record, "file");
|
||||
}
|
||||
// // Trigger folder setup
|
||||
// rmActionService.executeRecordsManagementAction(newNodeRef, "setupRecordFolder");
|
||||
//
|
||||
// // Sort out the child records
|
||||
// for (NodeRef record : rmService.getRecords(newNodeRef))
|
||||
// {
|
||||
// removeUnwantedAspects(nodeService, record);
|
||||
// rmActionService.executeRecordsManagementAction(record, "file");
|
||||
// }
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -399,17 +399,20 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate());
|
||||
props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, this.nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE));
|
||||
|
||||
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
|
||||
Period period = daDefinition.getPeriod();
|
||||
if (period != null)
|
||||
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
|
||||
if (daDefinition != null)
|
||||
{
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
|
||||
}
|
||||
else
|
||||
{
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD, null);
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
|
||||
Period period = daDefinition.getPeriod();
|
||||
if (period != null)
|
||||
{
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
|
||||
}
|
||||
else
|
||||
{
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD, null);
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
|
||||
}
|
||||
}
|
||||
|
||||
nodeService.setProperties(record, props);
|
||||
|
@@ -30,6 +30,7 @@ import org.alfresco.model.ContentModel;
|
||||
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.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordFolderServiceImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -52,6 +53,9 @@ import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
@@ -62,7 +66,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
*/
|
||||
@Deprecated
|
||||
public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
implements RecordsManagementModel
|
||||
implements RecordsManagementModel, ApplicationContextAware
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(BootstrapTestDataGet.class);
|
||||
|
||||
@@ -83,7 +87,14 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
private RecordsManagementSecurityService recordsManagementSecurityService;
|
||||
private AuthorityService authorityService;
|
||||
private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour;
|
||||
private DispositionService dispositionService;
|
||||
private DispositionService dispositionService;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
@@ -184,7 +195,7 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
// Patch data
|
||||
BootstrapTestDataGet.patchLoadedData(searchService, nodeService, recordsManagementService,
|
||||
BootstrapTestDataGet.patchLoadedData(applicationContext, searchService, nodeService, recordsManagementService,
|
||||
recordsManagementActionService, permissionService,
|
||||
authorityService, recordsManagementSecurityService,
|
||||
recordsManagementSearchBehaviour,
|
||||
@@ -204,7 +215,8 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
* @param recordsManagementService
|
||||
* @param recordsManagementActionService
|
||||
*/
|
||||
public static void patchLoadedData( final SearchService searchService,
|
||||
public static void patchLoadedData( final ApplicationContext applicationContext,
|
||||
final SearchService searchService,
|
||||
final NodeService nodeService,
|
||||
final RecordsManagementService recordsManagementService,
|
||||
final RecordsManagementActionService recordsManagementActionService,
|
||||
@@ -302,7 +314,8 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
{
|
||||
// Fire action to "set-up" the folder correctly
|
||||
logger.info("Setting up bootstraped record folder: " + folderName);
|
||||
recordsManagementActionService.executeRecordsManagementAction(recordFolder, "setupRecordFolder");
|
||||
RecordFolderServiceImpl recordService = (RecordFolderServiceImpl)applicationContext.getBean("recordFolderService");
|
||||
recordService.initialiseRecordFolder(recordFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,6 @@ public class TransferReportPost extends BaseTransferWebScript
|
||||
protected static final String RESPONSE_SUCCESS = "success";
|
||||
protected static final String RESPONSE_RECORD = "record";
|
||||
protected static final String RESPONSE_RECORD_NAME = "recordName";
|
||||
protected static final String FILE_ACTION = "file";
|
||||
|
||||
protected DictionaryService ddService;
|
||||
protected RecordsManagementActionService rmActionService;
|
||||
@@ -418,10 +417,7 @@ public class TransferReportPost extends BaseTransferWebScript
|
||||
ContentWriter writer = this.contentService.getWriter(record, ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(report);
|
||||
|
||||
// file the node as a record
|
||||
this.rmActionService.executeRecordsManagementAction(record, FILE_ACTION);
|
||||
writer.putContent(report);
|
||||
|
||||
return record;
|
||||
}
|
||||
|
@@ -29,6 +29,9 @@ import org.alfresco.service.cmr.repository.Period;
|
||||
*/
|
||||
public interface VitalRecordService
|
||||
{
|
||||
/** Period 'none' */
|
||||
static final Period PERIOD_NONE = new Period("none|0");
|
||||
|
||||
/**
|
||||
* Gets the vital record definition details for the node.
|
||||
*
|
||||
@@ -53,6 +56,5 @@ public interface VitalRecordService
|
||||
* @param nodeRef node reference
|
||||
* @return boolean true if this is a vital record, false otherwise
|
||||
*/
|
||||
boolean isVitalRecord(NodeRef nodeRef);
|
||||
|
||||
boolean isVitalRecord(NodeRef nodeRef);
|
||||
}
|
||||
|
@@ -19,8 +19,11 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.vital;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
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;
|
||||
@@ -31,6 +34,7 @@ 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.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Period;
|
||||
@@ -46,10 +50,8 @@ import org.alfresco.util.ParameterCheck;
|
||||
public class VitalRecordServiceImpl implements VitalRecordService,
|
||||
RecordsManagementModel,
|
||||
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.OnAddAspectPolicy
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||
{
|
||||
private static final Period PERIOD_NONE = new Period("none|0");
|
||||
|
||||
/** Services */
|
||||
private NodeService nodeService;
|
||||
private PolicyComponent policyComponent;
|
||||
@@ -58,7 +60,7 @@ public class VitalRecordServiceImpl implements VitalRecordService,
|
||||
|
||||
/** Behaviours */
|
||||
private JavaBehaviour onUpdateProperties;
|
||||
private JavaBehaviour onAddAspect;
|
||||
private JavaBehaviour onCreateChildAssociation;
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
@@ -103,11 +105,17 @@ public class VitalRecordServiceImpl implements VitalRecordService,
|
||||
ASPECT_VITAL_RECORD_DEFINITION,
|
||||
onUpdateProperties);
|
||||
|
||||
onAddAspect = new JavaBehaviour(this, "onAddAspect", NotificationFrequency.TRANSACTION_COMMIT);
|
||||
policyComponent.bindClassBehaviour(
|
||||
NodeServicePolicies.OnAddAspectPolicy.QNAME,
|
||||
ASPECT_VITAL_RECORD_DEFINITION,
|
||||
onAddAspect);
|
||||
onCreateChildAssociation = new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.TRANSACTION_COMMIT);
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
|
||||
TYPE_RECORD_FOLDER,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
onCreateChildAssociation);
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
|
||||
TYPE_RECORD_CATEGORY,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
onCreateChildAssociation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,64 +129,114 @@ public class VitalRecordServiceImpl implements VitalRecordService,
|
||||
rmActionService.executeRecordsManagementAction(nodeRef, "broadcastVitalRecordDefinition");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssociationRef, boolean bNew)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
ParameterCheck.mandatory("aspectTypeQName", aspectTypeQName);
|
||||
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
if (childAssociationRef != null)
|
||||
{
|
||||
onUpdateProperties.disable();
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// get the current review period value
|
||||
Period currentReviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
|
||||
if (currentReviewPeriod == null ||
|
||||
PERIOD_NONE.equals(currentReviewPeriod) == true)
|
||||
{
|
||||
// get the immediate parent
|
||||
NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
|
||||
// is the parent a record category
|
||||
if (parentRef != null &&
|
||||
FilePlanComponentKind.RECORD_CATEGORY.equals(rmService.getFilePlanComponentKind(parentRef)) == true)
|
||||
{
|
||||
// is the child a record category or folder
|
||||
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
|
||||
if (kind.equals(FilePlanComponentKind.RECORD_CATEGORY) == true ||
|
||||
kind.equals(FilePlanComponentKind.RECORD_FOLDER) == true)
|
||||
{
|
||||
// set the vital record definition values to match that of the parent
|
||||
nodeService.setProperty(nodeRef,
|
||||
PROP_VITAL_RECORD_INDICATOR,
|
||||
nodeService.getProperty(parentRef, PROP_VITAL_RECORD_INDICATOR));
|
||||
nodeService.setProperty(nodeRef,
|
||||
PROP_REVIEW_PERIOD,
|
||||
nodeService.getProperty(parentRef, PROP_REVIEW_PERIOD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
onUpdateProperties.enable();
|
||||
}
|
||||
final NodeRef nodeRef = childAssociationRef.getChildRef();
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
onCreateChildAssociation.disable();
|
||||
onUpdateProperties.disable();
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
if (rmService.isRecordCategory(nodeRef) == true ||
|
||||
rmService.isRecordFolder(nodeRef) == true)
|
||||
{
|
||||
inheritVitalRecordDefinition(nodeRef);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
onCreateChildAssociation.enable();
|
||||
onUpdateProperties.enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set the inherited vital record definition details.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
*/
|
||||
private void inheritVitalRecordDefinition(NodeRef nodeRef)
|
||||
{
|
||||
// get the current review period value
|
||||
Period currentReviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
|
||||
if (currentReviewPeriod == null ||
|
||||
PERIOD_NONE.equals(currentReviewPeriod) == true)
|
||||
{
|
||||
// get the immediate parent
|
||||
NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
|
||||
// is the parent a record category
|
||||
if (parentRef != null &&
|
||||
FilePlanComponentKind.RECORD_CATEGORY.equals(rmService.getFilePlanComponentKind(parentRef)) == true)
|
||||
{
|
||||
// is the child a record category or folder
|
||||
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef);
|
||||
if (kind.equals(FilePlanComponentKind.RECORD_CATEGORY) == true ||
|
||||
kind.equals(FilePlanComponentKind.RECORD_FOLDER) == true)
|
||||
{
|
||||
// set the vital record definition values to match that of the parent
|
||||
nodeService.setProperty(nodeRef,
|
||||
PROP_VITAL_RECORD_INDICATOR,
|
||||
nodeService.getProperty(parentRef, PROP_VITAL_RECORD_INDICATOR));
|
||||
nodeService.setProperty(nodeRef,
|
||||
PROP_REVIEW_PERIOD,
|
||||
nodeService.getProperty(parentRef, PROP_REVIEW_PERIOD));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method used by services with access to the private bean to initialise vital record details.
|
||||
*
|
||||
* TODO consider what (if any of this) should be on the public interface
|
||||
*
|
||||
* @param nodeRef node reference to initialise with vital record details
|
||||
*/
|
||||
public void initialiseVitalRecord(NodeRef nodeRef)
|
||||
{
|
||||
// Calculate the review schedule
|
||||
VitalRecordDefinition viDef = getVitalRecordDefinition(nodeRef);
|
||||
if (viDef != null && viDef.isEnabled() == true)
|
||||
{
|
||||
Date reviewAsOf = viDef.getNextReviewDate();
|
||||
if (reviewAsOf != null)
|
||||
{
|
||||
Map<QName, Serializable> reviewProps = new HashMap<QName, Serializable>(1);
|
||||
reviewProps.put(RecordsManagementModel.PROP_REVIEW_AS_OF, reviewAsOf);
|
||||
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD) == false)
|
||||
{
|
||||
nodeService.addAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD, reviewProps);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
|
||||
props.putAll(reviewProps);
|
||||
nodeService.setProperties(nodeRef, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getVitalRecordDefinition(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user