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:
@@ -255,6 +255,7 @@
|
||||
<aspect>rma:recordComponentIdentifier</aspect>
|
||||
<aspect>rma:commonRecordDetails</aspect>
|
||||
<aspect>rma:filePlanComponent</aspect>
|
||||
<!-- <aspect>rma:vitalRecordDefinition</aspect> -->
|
||||
</mandatory-aspects>
|
||||
|
||||
</type>
|
||||
|
@@ -64,34 +64,6 @@
|
||||
|
||||
</bean>
|
||||
|
||||
<!-- file action -->
|
||||
<!-- Bound to policy: allow -->
|
||||
|
||||
|
||||
<bean id="file_proxy" parent="rmProxyAction">
|
||||
<property name="target">
|
||||
<ref bean="file"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="file_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="file_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor" parent="actionSecurity">
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW
|
||||
org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- disable normal registration - the proxy will do it so the proxy is registered -->
|
||||
<bean id="file" class="org.alfresco.module.org_alfresco_module_rm.action.impl.FileAction" parent="rmAction" />
|
||||
|
||||
<!-- Cutoff action -->
|
||||
|
||||
|
||||
@@ -278,32 +250,6 @@
|
||||
|
||||
<bean id="reviewed" class="org.alfresco.module.org_alfresco_module_rm.vital.ReviewedAction" parent="rmAction" depends-on="rmCycleVitalRecordsCapability" />
|
||||
|
||||
<!-- set up record folder -->
|
||||
<!-- bound to policy: allow -->
|
||||
|
||||
<bean id="setupRecordFolder_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="setupRecordFolder"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="setupRecordFolder_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="setupRecordFolder_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor" parent="actionSecurity">
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW
|
||||
org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="setupRecordFolder" class="org.alfresco.module.org_alfresco_module_rm.action.impl.SetupRecordFolderAction" parent="rmAction" />
|
||||
|
||||
<!-- declare record -->
|
||||
<!-- fileable?? -->
|
||||
|
||||
|
@@ -156,11 +156,12 @@
|
||||
|
||||
<!-- Disposition Service -->
|
||||
|
||||
<bean id="dispositionService" class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl">
|
||||
<bean id="dispositionService" class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl" init-method="init">
|
||||
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
||||
<property name="policyComponent" ref="policyComponent" />
|
||||
<property name="dispositionSelectionStrategy">
|
||||
<ref local="org_alfresco_module_rm_dispositionSelectionStrategy" />
|
||||
</property>
|
||||
@@ -967,20 +968,30 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Record Folder Service -->
|
||||
|
||||
<bean id="recordFolderService" class="org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordFolderServiceImpl" init-method="init">
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="policyComponent" ref="policyComponent" />
|
||||
<property name="dispositionService" ref="DispositionService" />
|
||||
</bean>
|
||||
|
||||
<!-- Record Service -->
|
||||
|
||||
<bean id="recordService" class="org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl" init-method="init">
|
||||
<bean id="recordService" class="org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordServiceImpl" init-method="init">
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<property name="identifierService" ref="recordsManagementIdentifierService"/>
|
||||
<property name="permissionService" ref="PermissionService"/>
|
||||
<property name="extendedSecurityService" ref="ExtendedSecurityService" />
|
||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
||||
<property name="policyComponent" ref="policyComponent" />
|
||||
<property name="dispositionService" ref="DispositionService" />
|
||||
</bean>
|
||||
|
||||
<bean id="RecordService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.module.org_alfresco_module_rm.record.RecordService</value>
|
||||
<value>org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="recordService"/>
|
||||
@@ -1018,14 +1029,13 @@
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.getRecordMetaDataAspects=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.isRecord=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.isDeclared=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.isFiled=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.createRecord=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.fileRecord=RM.WRITE.0.1
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.getUnfiledContainer=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.*=RM_DENY
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.getRecordMetaDataAspects=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.isRecord=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.isDeclared=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.isFiled=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.createRecord=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.getUnfiledContainer=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService.*=RM_DENY
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@@ -176,12 +176,6 @@ 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));
|
||||
|
||||
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",
|
||||
@@ -995,9 +990,6 @@ public class RecordsManagementAuditServiceImpl
|
||||
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);
|
||||
}
|
||||
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,8 +39,11 @@ 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 */
|
||||
@@ -49,8 +53,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
private Map<String, DataSet> dataSets = new HashMap<String, DataSet>();
|
||||
|
||||
/** Spaces store */
|
||||
private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
|
||||
"SpacesStore");
|
||||
private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||
|
||||
/** Importer service */
|
||||
private ImporterService importerService;
|
||||
@@ -82,6 +85,18 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
/** Disposition service */
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/** Application context */
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set importer service
|
||||
*
|
||||
@@ -128,8 +143,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
* @param recordsManagementActionService the records management action
|
||||
* service
|
||||
*/
|
||||
public void setRecordsManagementActionService(
|
||||
RecordsManagementActionService recordsManagementActionService)
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
@@ -160,8 +174,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
* @param recordsManagementSecurityService the records management security
|
||||
* service
|
||||
*/
|
||||
public void setRecordsManagementSecurityService(
|
||||
RecordsManagementSecurityService recordsManagementSecurityService)
|
||||
public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService)
|
||||
{
|
||||
this.recordsManagementSecurityService = recordsManagementSecurityService;
|
||||
}
|
||||
@@ -172,8 +185,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
* @param recordsManagementSearchBehaviour the records management search
|
||||
* behaviour
|
||||
*/
|
||||
public void setRecordsManagementSearchBehaviour(
|
||||
RecordsManagementSearchBehaviour recordsManagementSearchBehaviour)
|
||||
public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour recordsManagementSearchBehaviour)
|
||||
{
|
||||
this.recordsManagementSearchBehaviour = recordsManagementSearchBehaviour;
|
||||
}
|
||||
@@ -244,16 +256,14 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
// Get the data set
|
||||
DataSet dataSet = getDataSets().get(dataSetId);
|
||||
|
||||
// Import the RM test data ACP into the the provided file plan node reference
|
||||
// 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!");
|
||||
}
|
||||
if (is == null) { throw new AlfrescoRuntimeException("The '" + dataSet.getLabel()
|
||||
+ "' import file could not be found!"); }
|
||||
|
||||
// Import view
|
||||
Reader viewReader = new InputStreamReader(is);
|
||||
@@ -371,29 +381,26 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
}
|
||||
|
||||
String allRoleShortName = "AllRoles" + rmRoot.getId();
|
||||
String allRoleGroupName = authorityService.getName(AuthorityType.GROUP,
|
||||
allRoleShortName);
|
||||
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);
|
||||
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");
|
||||
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);
|
||||
permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,8 +413,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
|
||||
for (NodeRef container : rs.getNodeRefs())
|
||||
{
|
||||
String containerName = (String) nodeService.getProperty(container,
|
||||
ContentModel.PROP_NAME);
|
||||
String containerName = (String) nodeService.getProperty(container, ContentModel.PROP_NAME);
|
||||
|
||||
// Set permissions
|
||||
if (permissionService.getInheritParentPermissions(container) == true)
|
||||
@@ -422,18 +428,17 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
rs.close();
|
||||
}
|
||||
|
||||
// fix up the test dataset to fire initial events for disposition
|
||||
// fix up the test dataset to fire initial events for
|
||||
// disposition
|
||||
// schedules
|
||||
rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE,
|
||||
"TYPE:\"rma:recordFolder\"");
|
||||
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);
|
||||
String folderName = (String) nodeService.getProperty(recordFolder, ContentModel.PROP_NAME);
|
||||
|
||||
// Set permissions
|
||||
if (permissionService.getInheritParentPermissions(recordFolder) == true)
|
||||
@@ -444,20 +449,21 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
|
||||
if (nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE) == false)
|
||||
{
|
||||
// See if the folder has a disposition schedule that needs
|
||||
// See if the folder has a disposition schedule that
|
||||
// needs
|
||||
// to be applied
|
||||
DispositionSchedule ds = dispositionService
|
||||
.getDispositionSchedule(recordFolder);
|
||||
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");
|
||||
RecordFolderServiceImpl recordService = (RecordFolderServiceImpl)applicationContext.getBean("recordFolderService");
|
||||
recordService.initialiseRecordFolder(recordFolder);
|
||||
}
|
||||
}
|
||||
|
||||
// fixup the search behaviour aspect for the record folder
|
||||
// fixup the search behaviour aspect for the record
|
||||
// folder
|
||||
logger.info("Setting up search aspect for record folder: " + folderName);
|
||||
recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
|
||||
}
|
||||
@@ -494,8 +500,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
|
||||
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);
|
||||
loadedDataSetIds = (ArrayList<String>) nodeService.getProperty(filePlan, PROP_LOADED_DATA_SET_IDS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -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 */
|
||||
@@ -69,9 +86,27 @@ 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,12 +155,48 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,32 +247,6 @@ 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)
|
||||
@@ -293,37 +338,6 @@ 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
|
||||
@@ -158,24 +158,28 @@ public interface DispositionService
|
||||
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);
|
||||
@@ -538,8 +600,104 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -147,12 +147,6 @@ public class RecordContainerType implements RecordsManagementModel,
|
||||
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,6 +143,7 @@ public class RecordCopyBehaviours implements RecordsManagementModel
|
||||
* @param oldChildAssocRef
|
||||
* @param newChildAssocRef
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void onMoveRecordFolderNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
||||
{
|
||||
final NodeRef newNodeRef = newChildAssocRef.getChildRef();
|
||||
@@ -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;
|
||||
|
@@ -400,6 +400,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, this.nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE));
|
||||
|
||||
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
|
||||
if (daDefinition != null)
|
||||
{
|
||||
Period period = daDefinition.getPeriod();
|
||||
if (period != null)
|
||||
{
|
||||
@@ -411,6 +413,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
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);
|
||||
|
||||
@@ -84,6 +88,13 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
|
||||
private AuthorityService authorityService;
|
||||
private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour;
|
||||
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;
|
||||
@@ -420,9 +419,6 @@ public class TransferReportPost extends BaseTransferWebScript
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(report);
|
||||
|
||||
// file the node as a record
|
||||
this.rmActionService.executeRecordsManagementAction(record, FILE_ACTION);
|
||||
|
||||
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.
|
||||
*
|
||||
@@ -54,5 +57,4 @@ public interface VitalRecordService
|
||||
* @return boolean true if this is a vital record, false otherwise
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,22 +131,49 @@ public class VitalRecordServiceImpl implements VitalRecordService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 (childAssociationRef != null)
|
||||
{
|
||||
final NodeRef nodeRef = childAssociationRef.getChildRef();
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
onCreateChildAssociation.disable();
|
||||
onUpdateProperties.disable();
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
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);
|
||||
@@ -167,14 +202,37 @@ public class VitalRecordServiceImpl implements VitalRecordService,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
finally
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
onUpdateProperties.enable();
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.test;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.BootstraptestDataRestApiTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.DataSetRestApiTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.DispositionRestApiTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.EventRestApiTest;
|
||||
@@ -46,7 +45,6 @@ public class WebScriptTestSuite extends TestSuite
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTestSuite(BootstraptestDataRestApiTest.class);
|
||||
suite.addTestSuite(DispositionRestApiTest.class);
|
||||
suite.addTestSuite(EventRestApiTest.class);
|
||||
suite.addTestSuite(RMCaveatConfigScriptTest.class);
|
||||
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.test.action;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
|
||||
/**
|
||||
* Record service implementation unit test.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CreateRecordActionTest extends BaseRMTestCase
|
||||
{
|
||||
/** Services */
|
||||
protected ActionService dmActionService;
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
dmActionService = (ActionService)applicationContext.getBean("ActionService");
|
||||
dmPermissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void testCreateRecordAction()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
assertEquals(AccessStatus.DENIED, dmPermissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS));
|
||||
assertEquals(AccessStatus.DENIED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
|
||||
|
||||
Action action = dmActionService.createAction(CreateRecordAction.NAME);
|
||||
dmActionService.executeAction(action, dmDocument);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test(Void result) throws Exception
|
||||
{
|
||||
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS));
|
||||
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
|
||||
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
};
|
||||
},
|
||||
dmCollaborator);
|
||||
}
|
||||
}
|
@@ -95,9 +95,9 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
Group auditGroup = capabilityService.getGroup("audit");
|
||||
assertNotNull(auditGroup);
|
||||
assertTrue(auditGroup.getIndex() == 1);
|
||||
assertTrue(auditGroup.getTitle().equalsIgnoreCase("Audit"));
|
||||
assertTrue(auditGroup.getId().equalsIgnoreCase("audit"));
|
||||
assertEquals(10, auditGroup.getIndex());
|
||||
assertEquals("Audit", auditGroup.getTitle());
|
||||
assertEquals("audit", auditGroup.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
GroupImpl testGroup = new GroupImpl();
|
||||
testGroup.setId("testGroup");
|
||||
testGroup.setIndex(14);
|
||||
testGroup.setIndex(140);
|
||||
testGroup.setTitle("Test group");
|
||||
capabilityService.addGroup(testGroup);
|
||||
|
||||
@@ -120,7 +120,7 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
assertNotNull(group);
|
||||
assertTrue(group.getId().equalsIgnoreCase("testGroup"));
|
||||
assertTrue(group.getTitle().equalsIgnoreCase("Test group"));
|
||||
assertTrue(group.getIndex() == 14);
|
||||
assertTrue(group.getIndex() == 140);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -152,21 +152,15 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
int size = groups.size();
|
||||
assertTrue(size == 13);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
assertNotNull(groups.get(i));
|
||||
assertTrue(groups.get(i).getIndex() == (i + 1));
|
||||
}
|
||||
|
||||
Group auditGroup = groups.get(0);
|
||||
assertNotNull(auditGroup);
|
||||
assertTrue(auditGroup.getIndex() == 1);
|
||||
assertTrue(auditGroup.getIndex() == 10);
|
||||
assertTrue(auditGroup.getId().equalsIgnoreCase("audit"));
|
||||
assertTrue(auditGroup.getTitle().equalsIgnoreCase("Audit"));
|
||||
|
||||
Group vitalRecords = groups.get(size - 1);
|
||||
assertNotNull(vitalRecords);
|
||||
assertTrue(vitalRecords.getIndex() == 13);
|
||||
assertTrue(vitalRecords.getIndex() == 130);
|
||||
assertTrue(vitalRecords.getId().equalsIgnoreCase("vitalRecords"));
|
||||
assertTrue(vitalRecords.getTitle().equalsIgnoreCase("Vital Records"));
|
||||
|
||||
@@ -194,11 +188,11 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
int vitalRecordCapabilitiesSize = auditCapabilities.size();
|
||||
assertTrue(vitalRecordCapabilitiesSize == 6);
|
||||
|
||||
for (int i = 0; i < vitalRecordCapabilitiesSize; i++)
|
||||
for (int i = 1; i == vitalRecordCapabilitiesSize; i++)
|
||||
{
|
||||
Capability capability = auditCapabilities.get(i);
|
||||
assertNotNull(capability);
|
||||
assertTrue(capability.getIndex() == (i + 1));
|
||||
assertEquals(i * 10, capability.getIndex());
|
||||
}
|
||||
|
||||
Group vitalRecordsGroup = groups.get(groups.size() - 1);
|
||||
@@ -208,14 +202,7 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
assertNotNull(vitalRecordCapabilities);
|
||||
|
||||
vitalRecordCapabilitiesSize = vitalRecordCapabilities.size();
|
||||
assertTrue(vitalRecordCapabilitiesSize == 3);
|
||||
|
||||
for (int i = 0; i < vitalRecordCapabilitiesSize; i++)
|
||||
{
|
||||
Capability capability = vitalRecordCapabilities.get(i);
|
||||
assertNotNull(capability);
|
||||
assertTrue(capability.getIndex() == (i + 1));
|
||||
}
|
||||
assertEquals(3, vitalRecordCapabilitiesSize);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* 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.test.service;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* Record service implementation unit test.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CreateRecordActionTest extends BaseRMTestCase
|
||||
{
|
||||
protected static final String COLLABORATION_SITE_ID = "collab-site-id";
|
||||
|
||||
protected ActionService dmActionService;
|
||||
protected TaggingService taggingService;
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
protected SiteInfo collaborationSite;
|
||||
protected NodeRef documentLibrary;
|
||||
protected NodeRef dmFolder;
|
||||
protected NodeRef dmDocument;
|
||||
|
||||
protected String dmUserName;
|
||||
protected NodeRef dmUserPerson;
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
dmActionService = (ActionService)applicationContext.getBean("ActionService");
|
||||
taggingService = (TaggingService)applicationContext.getBean("TaggingService");
|
||||
dmPermissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTestData()
|
||||
{
|
||||
super.setupTestData();
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
setupCollaborationSiteTestDataImpl();
|
||||
return null;
|
||||
}
|
||||
},
|
||||
AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
protected void setupCollaborationSiteTestDataImpl()
|
||||
{
|
||||
// create collaboration site
|
||||
collaborationSite = siteService.createSite("preset", COLLABORATION_SITE_ID, "title", "description", SiteVisibility.PRIVATE);
|
||||
documentLibrary = SiteServiceImpl.getSiteContainer(
|
||||
COLLABORATION_SITE_ID,
|
||||
SiteService.DOCUMENT_LIBRARY,
|
||||
true,
|
||||
siteService,
|
||||
transactionService,
|
||||
taggingService);
|
||||
|
||||
assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary);
|
||||
|
||||
// create a folder and documents
|
||||
dmFolder = fileFolderService.create(documentLibrary, "collabFolder", ContentModel.TYPE_FOLDER).getNodeRef();
|
||||
dmDocument = fileFolderService.create(dmFolder, "collabDocument.txt", ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTestUsersImpl(NodeRef filePlan)
|
||||
{
|
||||
super.setupTestUsersImpl(filePlan);
|
||||
|
||||
dmUserName = GUID.generate();
|
||||
dmUserPerson = createPerson(dmUserName);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmUserName, SiteModel.SITE_COLLABORATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDownImpl()
|
||||
{
|
||||
super.tearDownImpl();
|
||||
siteService.deleteSite(COLLABORATION_SITE_ID);
|
||||
}
|
||||
|
||||
public void testCreateRecordAction()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
assertEquals(AccessStatus.DENIED, dmPermissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS));
|
||||
assertEquals(AccessStatus.DENIED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
|
||||
|
||||
Action action = dmActionService.createAction(CreateRecordAction.NAME);
|
||||
dmActionService.executeAction(action, dmDocument);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test(Void result) throws Exception
|
||||
{
|
||||
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS));
|
||||
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
|
||||
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
};
|
||||
},
|
||||
dmUserName);
|
||||
}
|
||||
}
|
@@ -22,26 +22,19 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* Records Service Implementation Test
|
||||
@@ -52,35 +45,20 @@ import org.alfresco.util.GUID;
|
||||
*/
|
||||
public class RecordServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
protected static final String COLLABORATION_SITE_ID = "collab-site-id";
|
||||
|
||||
/** Services */
|
||||
protected ActionService dmActionService;
|
||||
|
||||
protected TaggingService taggingService;
|
||||
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
protected ExtendedSecurityService extendedSecurityService;
|
||||
|
||||
// collaboration site artifacts
|
||||
protected SiteInfo collaborationSite;
|
||||
protected NodeRef documentLibrary;
|
||||
protected NodeRef dmFolder;
|
||||
protected NodeRef dmDocument;
|
||||
|
||||
// dm users
|
||||
protected String dmConsumer;
|
||||
protected NodeRef dmConsumerNodeRef;
|
||||
protected String dmCollaborator;
|
||||
protected NodeRef dmCollaboratorNodeRef;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
|
||||
*/
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
dmActionService = (ActionService) applicationContext.getBean("ActionService");
|
||||
taggingService = (TaggingService) applicationContext.getBean("TaggingService");
|
||||
dmPermissionService = (PermissionService) applicationContext.getBean("PermissionService");
|
||||
extendedSecurityService = (ExtendedSecurityService) applicationContext.getBean("ExtendedSecurityService");
|
||||
}
|
||||
@@ -108,62 +86,12 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the collaboration site test data
|
||||
* This is a collaboration site test
|
||||
*/
|
||||
@Override
|
||||
protected void setupTestData()
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
super.setupTestData();
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
setupCollaborationSiteTestDataImpl();
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
protected void setupCollaborationSiteTestDataImpl()
|
||||
{
|
||||
// create collaboration site
|
||||
collaborationSite = siteService.createSite("preset", COLLABORATION_SITE_ID, "title", "description", SiteVisibility.PRIVATE);
|
||||
documentLibrary = SiteServiceImpl.getSiteContainer(
|
||||
COLLABORATION_SITE_ID,
|
||||
SiteService.DOCUMENT_LIBRARY,
|
||||
true,
|
||||
siteService,
|
||||
transactionService,
|
||||
taggingService);
|
||||
|
||||
assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary);
|
||||
|
||||
// create a folder and documents
|
||||
dmFolder = fileFolderService.create(documentLibrary, "collabFolder", ContentModel.TYPE_FOLDER).getNodeRef();
|
||||
dmDocument = fileFolderService.create(dmFolder, "collabDocument.txt", ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTestUsersImpl(NodeRef filePlan)
|
||||
{
|
||||
super.setupTestUsersImpl(filePlan);
|
||||
|
||||
dmConsumer = GUID.generate();
|
||||
dmConsumerNodeRef = createPerson(dmConsumer);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmConsumer, SiteModel.SITE_CONSUMER);
|
||||
|
||||
dmCollaborator = GUID.generate();
|
||||
dmCollaboratorNodeRef = createPerson(dmCollaborator);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmCollaborator, SiteModel.SITE_COLLABORATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDownImpl()
|
||||
{
|
||||
super.tearDownImpl();
|
||||
siteService.deleteSite(COLLABORATION_SITE_ID);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,9 +257,89 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
return null;
|
||||
}
|
||||
}, dmCollaborator);
|
||||
}
|
||||
|
||||
public void testFileNewContent() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
NodeRef record = fileFolderService.create(rmFolder, "test101.txt" , TYPE_CONTENT).getNodeRef();
|
||||
|
||||
ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("hello world this is some test content");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(record));
|
||||
assertTrue(recordService.isFiled(record));
|
||||
|
||||
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testFileUnfiledrecord() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
recordService.createRecord(filePlan, dmDocument);
|
||||
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
assertFalse(recordService.isFiled(dmDocument));
|
||||
|
||||
assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED));
|
||||
|
||||
fileFolderService.move(dmDocument, rmFolder, "record.txt");
|
||||
|
||||
return dmDocument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(record));
|
||||
assertTrue(recordService.isFiled(record));
|
||||
|
||||
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testFileDirectlyFromCollab() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED));
|
||||
|
||||
fileFolderService.move(dmDocument, rmFolder, "record.txt");
|
||||
|
||||
return dmDocument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(record));
|
||||
assertTrue(recordService.isFiled(record));
|
||||
|
||||
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkPermissions(String permission, AccessStatus filePlanExpected,
|
||||
|
@@ -23,8 +23,10 @@ import java.util.Date;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Period;
|
||||
import org.alfresco.util.GUID;
|
||||
@@ -48,6 +50,15 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
|
||||
private NodeRef mhRecord54;
|
||||
private NodeRef mhRecord55;
|
||||
|
||||
/**
|
||||
* Indicate this test uses the collaboration site test data
|
||||
*/
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Indicate this is a multi hierarchy test */
|
||||
@Override
|
||||
protected boolean isMultiHierarchyTest()
|
||||
@@ -212,6 +223,75 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
|
||||
});
|
||||
}
|
||||
|
||||
/** Filling tests */
|
||||
|
||||
public void testFileNewContent() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
NodeRef record = fileFolderService.create(mhRecordFolder41, "test101.txt" , TYPE_CONTENT).getNodeRef();
|
||||
|
||||
ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("hello world this is some test content");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertVitalRecord(record, true, PERIOD_WEEK);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// public void testFileUnfiledrecord() throws Exception
|
||||
// {
|
||||
// doTestInTransaction(new Test<NodeRef>()
|
||||
// {
|
||||
// @Override
|
||||
// public NodeRef run() throws Exception
|
||||
// {
|
||||
// recordService.createRecord(filePlan, dmDocument);
|
||||
// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt");
|
||||
//
|
||||
// return dmDocument;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void test(NodeRef record) throws Exception
|
||||
// {
|
||||
// assertVitalRecord(record, true, PERIOD_WEEK);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public void testFileDirectlyFromCollab() throws Exception
|
||||
// {
|
||||
// doTestInTransaction(new Test<NodeRef>()
|
||||
// {
|
||||
// @Override
|
||||
// public NodeRef run() throws Exception
|
||||
// {
|
||||
// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt");
|
||||
// return dmDocument;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void test(NodeRef record) throws Exception
|
||||
// {
|
||||
// assertVitalRecord(record, true, PERIOD_WEEK);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/** Helper Methods */
|
||||
|
||||
/**
|
||||
* Test to ensure that changes made to vital record definitions are reflected down the hierarchy.
|
||||
*/
|
||||
|
@@ -29,18 +29,20 @@ import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService;
|
||||
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.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RmSiteType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -57,6 +59,7 @@ import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
@@ -81,15 +84,16 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
};
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
/** Test model contants */
|
||||
/** test model constants */
|
||||
protected String URI = "http://www.alfresco.org/model/rmtest/1.0";
|
||||
protected String PREFIX = "rmt";
|
||||
protected QName TYPE_CUSTOM_TYPE = QName.createQName(URI, "customType");
|
||||
protected QName ASPECT_CUSTOM_ASPECT = QName.createQName(URI, "customAspect");
|
||||
protected QName ASPECT_RECORD_META_DATA = QName.createQName(URI, "recordMetaData");
|
||||
|
||||
/** Site id */
|
||||
/** site id's */
|
||||
protected static final String SITE_ID = "mySite";
|
||||
protected static final String COLLABORATION_SITE_ID = "collab-site-id";
|
||||
|
||||
/** Common test utils */
|
||||
protected CommonRMTestUtils utils;
|
||||
@@ -109,6 +113,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected TransactionService transactionService;
|
||||
protected FileFolderService fileFolderService;
|
||||
protected PermissionService permissionService;
|
||||
protected TaggingService taggingService;
|
||||
|
||||
/** RM Services */
|
||||
protected RecordsManagementService rmService;
|
||||
@@ -214,6 +219,18 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected NodeRef recordDeclaredOne;
|
||||
protected NodeRef recordDeclaredTwo;
|
||||
|
||||
/** collaboration site artifacts */
|
||||
protected SiteInfo collaborationSite;
|
||||
protected NodeRef documentLibrary;
|
||||
protected NodeRef dmFolder;
|
||||
protected NodeRef dmDocument;
|
||||
|
||||
/** collaboration site users */
|
||||
protected String dmConsumer;
|
||||
protected NodeRef dmConsumerNodeRef;
|
||||
protected String dmCollaborator;
|
||||
protected NodeRef dmCollaboratorNodeRef;
|
||||
|
||||
/**
|
||||
* Indicates whether this is a multi-hierarchy test or not. If it is then the multi-hierarchy record
|
||||
* taxonomy test data is loaded.
|
||||
@@ -248,6 +265,15 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the test collaboration site should be created
|
||||
* or not.
|
||||
*/
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@@ -263,10 +289,19 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
|
||||
// Setup test data
|
||||
setupTestData();
|
||||
|
||||
// Create multi hierarchy data
|
||||
if (isMultiHierarchyTest() == true)
|
||||
{
|
||||
setupMultiHierarchyTestData();
|
||||
}
|
||||
|
||||
// Create collaboration data
|
||||
if (isCollaborationSiteTest() == true)
|
||||
{
|
||||
setupCollaborationSiteTestData();
|
||||
}
|
||||
|
||||
// Create the users here
|
||||
if (isUserTest() == true)
|
||||
{
|
||||
@@ -294,6 +329,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
transactionService = (TransactionService)applicationContext.getBean("TransactionService");
|
||||
fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService");
|
||||
permissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
taggingService = (TaggingService)applicationContext.getBean("TaggingService");
|
||||
|
||||
// Get RM services
|
||||
rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
|
||||
@@ -342,6 +378,12 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
|
||||
// Delete the site
|
||||
siteService.deleteSite(SITE_ID);
|
||||
|
||||
// delete the collaboration site (if required)
|
||||
if (isCollaborationSiteTest() == true)
|
||||
{
|
||||
siteService.deleteSite(COLLABORATION_SITE_ID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,6 +615,45 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
mhRecordFolder45 = rmService.createRecordFolder(mhContainer35, "mhFolder45");
|
||||
}
|
||||
|
||||
protected void setupCollaborationSiteTestData()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
setupCollaborationSiteTestDataImpl();
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
protected void setupCollaborationSiteTestDataImpl()
|
||||
{
|
||||
// create collaboration site
|
||||
collaborationSite = siteService.createSite("preset", COLLABORATION_SITE_ID, "title", "description", SiteVisibility.PRIVATE);
|
||||
documentLibrary = SiteServiceImpl.getSiteContainer(
|
||||
COLLABORATION_SITE_ID,
|
||||
SiteService.DOCUMENT_LIBRARY,
|
||||
true,
|
||||
siteService,
|
||||
transactionService,
|
||||
taggingService);
|
||||
|
||||
assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary);
|
||||
|
||||
// create a folder and documents
|
||||
dmFolder = fileFolderService.create(documentLibrary, "collabFolder", ContentModel.TYPE_FOLDER).getNodeRef();
|
||||
dmDocument = fileFolderService.create(dmFolder, "collabDocument.txt", ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
|
||||
dmConsumer = GUID.generate();
|
||||
dmConsumerNodeRef = createPerson(dmConsumer);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmConsumer, SiteModel.SITE_CONSUMER);
|
||||
|
||||
dmCollaborator = GUID.generate();
|
||||
dmCollaboratorNodeRef = createPerson(dmCollaborator);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmCollaborator, SiteModel.SITE_COLLABORATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to try and simplify {@link Void} tests.
|
||||
*
|
||||
|
@@ -1,219 +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.test.util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
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.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.BootstrapTestDataGet;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.view.ImporterBinding;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* This class is an initial placeholder for miscellaneous helper methods used in
|
||||
* the testing or test initialisation of the DOD5015 module.
|
||||
*
|
||||
* @author neilm
|
||||
*/
|
||||
public class TestUtilities implements RecordsManagementModel
|
||||
{
|
||||
public static NodeRef loadFilePlanData(ApplicationContext applicationContext)
|
||||
{
|
||||
return TestUtilities.loadFilePlanData(applicationContext, true, false);
|
||||
}
|
||||
|
||||
public static final String TEST_FILE_PLAN_NAME = "testUtilities.filePlan";
|
||||
|
||||
private static NodeRef getFilePlan(NodeService nodeService, NodeRef rootNode)
|
||||
{
|
||||
NodeRef filePlan = null;
|
||||
|
||||
// Try and find a file plan hanging from the root node
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(rootNode, ContentModel.ASSOC_CHILDREN, TYPE_FILE_PLAN);
|
||||
if (assocs.size() != 0)
|
||||
{
|
||||
filePlan = assocs.get(0).getChildRef();
|
||||
}
|
||||
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
public static NodeRef loadFilePlanData(ApplicationContext applicationContext, boolean patchData, boolean alwaysLoad)
|
||||
{
|
||||
NodeService nodeService = (NodeService)applicationContext.getBean("NodeService");
|
||||
AuthorityService authorityService = (AuthorityService)applicationContext.getBean("AuthorityService");
|
||||
PermissionService permissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
SearchService searchService = (SearchService)applicationContext.getBean("SearchService");
|
||||
ImporterService importerService = (ImporterService)applicationContext.getBean("importerComponent");
|
||||
RecordsManagementService recordsManagementService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
|
||||
RecordsManagementActionService recordsManagementActionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService");
|
||||
RecordsManagementSecurityService recordsManagementSecurityService = (RecordsManagementSecurityService)applicationContext.getBean("RecordsManagementSecurityService");
|
||||
RecordsManagementSearchBehaviour recordsManagementSearchBehaviour = (RecordsManagementSearchBehaviour)applicationContext.getBean("recordsManagementSearchBehaviour");
|
||||
DispositionService dispositionService = (DispositionService)applicationContext.getBean("DispositionService");
|
||||
|
||||
NodeRef filePlan = null;
|
||||
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
|
||||
if (alwaysLoad == false && getFilePlan(nodeService, rootNode) != null)
|
||||
{
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
// For now creating the filePlan beneath the
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||
props.put(ContentModel.PROP_NAME, TEST_FILE_PLAN_NAME);
|
||||
filePlan = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN,
|
||||
TYPE_FILE_PLAN,
|
||||
TYPE_FILE_PLAN,
|
||||
props).getChildRef();
|
||||
|
||||
// Do the data load into the the provided filePlan node reference
|
||||
// TODO ...
|
||||
InputStream is = TestUtilities.class.getClassLoader().getResourceAsStream(
|
||||
"alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml");
|
||||
//"alfresco/module/org_alfresco_module_rm/bootstrap/temp.xml");
|
||||
Assert.assertNotNull("The DODExampleFilePlan.xml import file could not be found", is);
|
||||
Reader viewReader = new InputStreamReader(is);
|
||||
Location location = new Location(filePlan);
|
||||
importerService.importView(viewReader, location, REPLACE_BINDING, null);
|
||||
|
||||
if (patchData == true)
|
||||
{
|
||||
// Tempory call out to patch data after AMP
|
||||
BootstrapTestDataGet.patchLoadedData(searchService, nodeService, recordsManagementService,
|
||||
recordsManagementActionService, permissionService,
|
||||
authorityService, recordsManagementSecurityService,
|
||||
recordsManagementSearchBehaviour,
|
||||
dispositionService);
|
||||
}
|
||||
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
public static NodeRef getRecordSeries(RecordsManagementService rmService, NodeService nodeService, String seriesName)
|
||||
{
|
||||
NodeRef result = null;
|
||||
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
NodeRef filePlan = getFilePlan(nodeService, rootNode);
|
||||
|
||||
if (filePlan != null)
|
||||
{
|
||||
result = nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, seriesName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static NodeRef getRecordCategory(RecordsManagementService rmService, NodeService nodeService, String seriesName, String categoryName)
|
||||
{
|
||||
NodeRef seriesNodeRef = getRecordSeries(rmService, nodeService, seriesName);
|
||||
|
||||
NodeRef result = null;
|
||||
if (seriesNodeRef != null)
|
||||
{
|
||||
result = nodeService.getChildByName(seriesNodeRef, ContentModel.ASSOC_CONTAINS, categoryName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static NodeRef getRecordFolder(RecordsManagementService rmService, NodeService nodeService, String seriesName, String categoryName, String folderName)
|
||||
{
|
||||
NodeRef categoryNodeRef = getRecordCategory(rmService, nodeService, seriesName, categoryName);
|
||||
|
||||
NodeRef result = null;
|
||||
if (categoryNodeRef != null)
|
||||
{
|
||||
result = nodeService.getChildByName(categoryNodeRef, ContentModel.ASSOC_CONTAINS, folderName);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO .. do we need to redeclare this here ??
|
||||
private static ImporterBinding REPLACE_BINDING = new ImporterBinding()
|
||||
{
|
||||
|
||||
public UUID_BINDING getUUIDBinding()
|
||||
{
|
||||
return UUID_BINDING.REPLACE_EXISTING;
|
||||
}
|
||||
|
||||
public String getValue(String key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean allowReferenceWithinTransaction()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public QName[] getExcludedClasses()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static void declareRecord(NodeRef recordToDeclare, NodeService nodeService,
|
||||
RecordsManagementActionService rmActionService)
|
||||
{
|
||||
// Declare record
|
||||
Map<QName, Serializable> propValues = nodeService.getProperties(recordToDeclare);
|
||||
propValues.put(RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
|
||||
List<String> smList = new ArrayList<String>(2);
|
||||
// smList.add(DOD5015Test.FOUO);
|
||||
// smList.add(DOD5015Test.NOFORN);
|
||||
propValues.put(RecordsManagementModel.PROP_SUPPLEMENTAL_MARKING_LIST, (Serializable)smList);
|
||||
propValues.put(RecordsManagementModel.PROP_MEDIA_TYPE, "mediaTypeValue");
|
||||
propValues.put(RecordsManagementModel.PROP_FORMAT, "formatValue");
|
||||
propValues.put(RecordsManagementModel.PROP_DATE_RECEIVED, new Date());
|
||||
propValues.put(RecordsManagementModel.PROP_ORIGINATOR, "origValue");
|
||||
propValues.put(RecordsManagementModel.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
||||
propValues.put(ContentModel.PROP_TITLE, "titleValue");
|
||||
nodeService.setProperties(recordToDeclare, propValues);
|
||||
rmActionService.executeRecordsManagementAction(recordToDeclare, "declareRecord");
|
||||
}
|
||||
}
|
@@ -1,79 +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.test.webscript;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.TestUtilities;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||
|
||||
/**
|
||||
* This class tests the Rest API for disposition related operations
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class BootstraptestDataRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel
|
||||
{
|
||||
protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||
protected static final String URL = "/api/rma/bootstraptestdata";
|
||||
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
|
||||
protected static final String APPLICATION_JSON = "application/json";
|
||||
|
||||
protected NodeService nodeService;
|
||||
protected RetryingTransactionHelper transactionHelper;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService");
|
||||
transactionHelper = (RetryingTransactionHelper)getServer().getApplicationContext().getBean("retryingTransactionHelper");
|
||||
}
|
||||
|
||||
public void testBoostrapTestData() throws Exception
|
||||
{
|
||||
final NodeRef filePlan = transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||
return TestUtilities.loadFilePlanData(getServer().getApplicationContext(), false, true);
|
||||
}
|
||||
});
|
||||
|
||||
sendRequest(new GetRequest(URL), 200);
|
||||
|
||||
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||
nodeService.deleteNode(filePlan);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user