mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4247 Merge release/V2.3 into feature-2.3/RM-4247_UpdateDispositionProperty.
This commit is contained in:
20
pom.xml
20
pom.xml
@@ -4,7 +4,7 @@
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-rm-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.3.1-SNAPSHOT</version>
|
||||
<version>2.3.2-SNAPSHOT</version>
|
||||
<name>Alfresco Records Management</name>
|
||||
|
||||
<url>http://www.alfresco.org/</url>
|
||||
@@ -60,9 +60,27 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-platform-distribution</artifactId>
|
||||
<version>5.0.2</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
<module>rm-server</module>
|
||||
<module>rm-share</module>
|
||||
<module>rm-automation</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
@@ -1,19 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>alfresco-rm-automation</artifactId>
|
||||
<name>Alfresco Records Management Automation</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-rm-parent</artifactId>
|
||||
<version>2.3.1-SNAPSHOT</version>
|
||||
<version>2.3.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>alfresco-rm-automation</artifactId>
|
||||
|
||||
<properties>
|
||||
<selenium.version>2.43.1</selenium.version>
|
||||
<selenium.version>2.45.0</selenium.version>
|
||||
<spring.version>4.0.5.RELEASE</spring.version>
|
||||
<maven.build.sourceVersion>1.8</maven.build.sourceVersion>
|
||||
<suiteXmlFile>testng.xml</suiteXmlFile>
|
||||
<skip.automationtests>true</skip.automationtests>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Additional source folder to be added: source/compatibility -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
@@ -35,23 +42,13 @@
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||
<properties>
|
||||
<property>
|
||||
<name>usedefaultlisteners</name>
|
||||
<value>false</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>listener</name>
|
||||
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
|
||||
</property>
|
||||
</properties>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>${project.build.testOutputDirectory}/testng.xml</suiteXmlFile>
|
||||
<suiteXmlFile>${project.build.testOutputDirectory}/${suiteXmlFile}</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
<skipTests>${skip.automationtests}</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- Configuration triggered by mvn antrun:run, used by Bamboo to stop server -->
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -67,30 +64,72 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<licenseName>alfresco_enterprise</licenseName>
|
||||
<licenseResolver>file:${project.parent.basedir}/license</licenseResolver>
|
||||
<descriptionTemplate>${project.parent.basedir}/license/description.ftl</descriptionTemplate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<versionRange>[1.8,)</versionRange>
|
||||
<goals>
|
||||
<goal>update-file-header</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.test</groupId>
|
||||
<artifactId>dataprep</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.test</groupId>
|
||||
<artifactId>alfresco-testng</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>webdrone</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>${selenium.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-server</artifactId>
|
||||
<version>${selenium.version}</version>
|
||||
<scope>test</scope>
|
||||
<artifactId>selenium-grid</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
@@ -112,18 +151,11 @@
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>6.8.8</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.uncommons</groupId>
|
||||
<artifactId>reportng</artifactId>
|
||||
<version>1.1.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.yandex.qatools.htmlelements</groupId>
|
||||
<artifactId>htmlelements-all</artifactId>
|
||||
<version>1.12</version>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.yandex.qatools.properties</groupId>
|
||||
@@ -131,13 +163,34 @@
|
||||
<version>1.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
<version>1.56</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>1.7.21</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>install-alfresco</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Download and install the latest enterprise alfresco installer -->
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
@@ -152,8 +205,7 @@
|
||||
<echo>Recreating database...</echo>
|
||||
<sql driver="org.postgresql.Driver" url="jdbc:postgresql:template1" userid="alfresco" password="alfresco" autocommit="true">drop database if exists alfresco; create database alfresco</sql>
|
||||
<echo>Downloading Alfresco installer...</echo>
|
||||
<sshexec username="tomcat" host="pbld01.alfresco.com" keyfile="${user.home}/.ssh/id_rsa" outputproperty="installerPath" command="ls -rt ${enterprise.installer.path} | tail -1 | tr ' ' '?' " />
|
||||
<scp remoteFile="tomcat@pbld01.alfresco.com:${installerPath}" localTofile="target/alf-installer.bin" keyfile="${user.home}/.ssh/id_rsa" />
|
||||
<get src="https://releases.alfresco.com/${installer.path}" dest="target/alf-installer.bin" />
|
||||
<chmod file="target/alf-installer.bin" perm="a+x" verbose="true" />
|
||||
<echo>Installing Alfresco...</echo>
|
||||
<exec executable="${basedir}/target/alf-installer.bin" dir="target" failonerror="true">
|
||||
@@ -191,15 +243,15 @@
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-rm-share</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>amp</classifier>
|
||||
<type>amp</type>
|
||||
<classifier>amp</classifier>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-rm-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>amp</classifier>
|
||||
<type>amp</type>
|
||||
<classifier>amp</classifier>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${project.build.directory}/amps</outputDirectory>
|
||||
@@ -223,7 +275,6 @@
|
||||
<backup>true</backup>
|
||||
<ampLocation>${project.build.directory}/amps/alfresco-rm-server-${project.version}-amp.amp</ampLocation>
|
||||
<warLocation>${project.build.directory}/alf-installation/tomcat/webapps/alfresco.war</warLocation>
|
||||
<classifier>amp</classifier>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
@@ -236,7 +287,6 @@
|
||||
<backup>true</backup>
|
||||
<ampLocation>${project.build.directory}/amps/alfresco-rm-share-${project.version}-amp.amp</ampLocation>
|
||||
<warLocation>${project.build.directory}/alf-installation/tomcat/webapps/share.war</warLocation>
|
||||
<classifier>amp</classifier>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -248,11 +298,10 @@
|
||||
<id>run-alfresco</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Fetch JaCoCo agent and set the argLine property accordingly -->
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.6.3.201306030806</version>
|
||||
<version>0.7.5.201505241946</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-jacoco</id>
|
||||
@@ -267,7 +316,6 @@
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Starts/stop the installed Alfresco -->
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
|
@@ -72,6 +72,12 @@ rm.completerecord.mandatorypropertiescheck.enabled=true
|
||||
#
|
||||
rm.patch.v22.convertToStandardFilePlan=false
|
||||
|
||||
# Permission mapping
|
||||
# these take a comma separated string of permissions from org.alfresco.service.cmr.security.PermissionService
|
||||
# read maps to ReadRecords and write to FileRecords
|
||||
rm.haspermissionmap.read=ReadProperties,ReadChildren
|
||||
rm.haspermissionmap.write=WriteProperties,AddChildren
|
||||
|
||||
#
|
||||
# Extended auto-version behaviour. If true and other auto-version properties are satisfied, then
|
||||
# a document will be auto-versioned when its type is changed.
|
||||
|
@@ -138,6 +138,12 @@
|
||||
<property name="filePlanService">
|
||||
<ref bean="filePlanService" />
|
||||
</property>
|
||||
<property name="configuredReadPermissions">
|
||||
<value>${rm.haspermissionmap.read}</value>
|
||||
</property>
|
||||
<property name="configuredFilePermissions">
|
||||
<value>${rm.haspermissionmap.write}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="extendedReaderDynamicAuthority" class="org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority" />
|
||||
|
@@ -392,6 +392,11 @@
|
||||
<type>d:date</type>
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
<property name="rma:manuallySetAsOf">
|
||||
<title>Manually Set Disposition Date Flag</title>
|
||||
<type>d:boolean</type>
|
||||
<default>false</default>
|
||||
</property>
|
||||
<property name="rma:dispositionEventsEligible">
|
||||
<title>Disposition Events Eligible</title>
|
||||
<type>d:boolean</type>
|
||||
|
@@ -39,12 +39,6 @@
|
||||
|
||||
<bean id="RecordsManagementServiceRegistry" class="org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistryImpl" />
|
||||
|
||||
<!-- Disposition selection strategy -->
|
||||
<bean id="org_alfresco_module_rm_dispositionSelectionStrategy"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSelectionStrategy" >
|
||||
<property name="dispositionService" ref="dispositionService"/>
|
||||
</bean>
|
||||
|
||||
<!-- Vital Record Service -->
|
||||
|
||||
<bean id="vitalRecordService" parent="baseService" class="org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl">
|
||||
@@ -96,9 +90,6 @@
|
||||
<property name="recordFolderService" ref="RecordFolderService"/>
|
||||
<property name="recordService" ref="RecordService"/>
|
||||
<property name="freezeService" ref="FreezeService"/>
|
||||
<property name="dispositionSelectionStrategy">
|
||||
<ref local="org_alfresco_module_rm_dispositionSelectionStrategy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="DispositionService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
@@ -139,6 +130,7 @@
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.registerDispositionProperty=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getDispositionProperties=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getDispositionSchedule=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getOriginDispositionSchedule=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getAssociatedDispositionSchedule=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getAssociatedRecordsManagementContainer=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.hasDisposableItems=RM_ALLOW
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-rm-parent</artifactId>
|
||||
<version>2.3.1-SNAPSHOT</version>
|
||||
<version>2.3.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>alfresco-rm-server</artifactId>
|
||||
@@ -20,6 +20,12 @@
|
||||
<resource>
|
||||
<directory>config</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>**/module.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>config</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
@@ -225,7 +231,6 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -185,7 +187,8 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
||||
{
|
||||
// the change does effect the nextAction for this node
|
||||
// so go ahead and determine what needs updating
|
||||
if (changedProps.contains(PROP_DISPOSITION_PERIOD) || changedProps.contains(PROP_DISPOSITION_PERIOD_PROPERTY))
|
||||
if ((changedProps.contains(PROP_DISPOSITION_PERIOD) || changedProps.contains(PROP_DISPOSITION_PERIOD_PROPERTY))
|
||||
&& isNotTrue((Boolean) getNodeService().getProperty(nextAction.getNodeRef(), PROP_MANUALLY_SET_AS_OF)))
|
||||
{
|
||||
persistPeriodChanges(dispositionActionDef, nextAction);
|
||||
}
|
||||
|
@@ -38,6 +38,9 @@ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstrac
|
||||
private static final String MSG_VALID_DATE_DISP_ASOF = "rm.action.valid-date-disp-asof";
|
||||
private static final String MSG_DISP_ASOF_LIFECYCLE_APPLIED = "rm.action.disp-asof-lifecycle-applied";
|
||||
|
||||
/** Action name */
|
||||
public static final String NAME = "editDispositionActionAsOfDate";
|
||||
|
||||
/** Action parameters */
|
||||
public static final String PARAM_AS_OF_DATE = "asOfDate";
|
||||
|
||||
@@ -62,6 +65,7 @@ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstrac
|
||||
if (da != null)
|
||||
{
|
||||
getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate);
|
||||
getNodeService().setProperty(da.getNodeRef(), PROP_MANUALLY_SET_AS_OF, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 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.disposition;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* This class offers the default implementation of a strategy for selection of
|
||||
* disposition schedule for a record when there is more than one which is applicable.
|
||||
* An example of where this strategy might be used would be in the case of a record
|
||||
* which was multiply filed.
|
||||
*
|
||||
* @author neilm
|
||||
*/
|
||||
public class DispositionSelectionStrategy implements RecordsManagementModel
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(DispositionSelectionStrategy.class);
|
||||
|
||||
/** Disposition service */
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/**
|
||||
* Set the disposition service
|
||||
*
|
||||
* @param dispositionService disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the disposition schedule to use given there is more than one
|
||||
*
|
||||
* @param recordFolders
|
||||
* @return
|
||||
*/
|
||||
public NodeRef selectDispositionScheduleFrom(List<NodeRef> recordFolders)
|
||||
{
|
||||
if (recordFolders == null || recordFolders.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 46 CHAPTER 2
|
||||
// Records assigned more than 1 disposition must be retained and linked to the record folder (category) with the longest
|
||||
// retention period.
|
||||
|
||||
// Assumption: an event-based disposition action has a longer retention
|
||||
// period than a time-based one - as we cannot know when an event will occur
|
||||
// TODO Automatic events?
|
||||
|
||||
NodeRef recordFolder = null;
|
||||
if (recordFolders.size() == 1)
|
||||
{
|
||||
recordFolder = recordFolders.get(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
|
||||
sortedFolders.addAll(recordFolders);
|
||||
recordFolder = sortedFolders.first();
|
||||
}
|
||||
|
||||
DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(recordFolder);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Selected disposition schedule: " + dispSchedule);
|
||||
}
|
||||
|
||||
NodeRef result = null;
|
||||
if (dispSchedule != null)
|
||||
{
|
||||
result = dispSchedule.getNodeRef();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class defines a natural comparison order between NodeRefs that have
|
||||
* the dispositionLifecycle aspect applied.
|
||||
* This order has the following meaning: NodeRefs with a 'lesser' value are considered
|
||||
* to have a shorter retention period, although the actual retention period may
|
||||
* not be straightforwardly determined in all cases.
|
||||
*/
|
||||
class DispositionableNodeRefComparator implements Comparator<NodeRef>
|
||||
{
|
||||
public int compare(final NodeRef f1, final NodeRef f2)
|
||||
{
|
||||
// Run as admin user
|
||||
return AuthenticationUtil.runAs(new RunAsWork<Integer>()
|
||||
{
|
||||
public Integer doWork()
|
||||
{
|
||||
return compareImpl(f1, f2);
|
||||
}
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
}
|
||||
|
||||
private int compareImpl(NodeRef f1, NodeRef f2)
|
||||
{
|
||||
// quick check to see if the node references are the same
|
||||
if (f1.equals(f2))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// get the disposition schedules for the folders
|
||||
DispositionSchedule ds1 = dispositionService.getDispositionSchedule(f1);
|
||||
DispositionSchedule ds2 = dispositionService.getDispositionSchedule(f2);
|
||||
|
||||
// make sure each folder has a disposition schedule
|
||||
if (ds1 == null && ds2 != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (ds1 != null && ds2 == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (ds1 == null && ds2 == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO this won't work correctly if we are trying to compare schedules that are record based!!
|
||||
DispositionAction da1 = dispositionService.getNextDispositionAction(f1);
|
||||
DispositionAction da2 = dispositionService.getNextDispositionAction(f2);
|
||||
|
||||
if (da1 != null && da2 != null)
|
||||
{
|
||||
Date asOfDate1 = da1.getAsOfDate();
|
||||
Date asOfDate2 = da2.getAsOfDate();
|
||||
// If both record(Folder)s have asOfDates, then use these to compare
|
||||
if (asOfDate1 != null && asOfDate2 != null)
|
||||
{
|
||||
return asOfDate1.compareTo(asOfDate2);
|
||||
}
|
||||
// If one has a date and the other doesn't, the one with the date is "less".
|
||||
// (Defined date is 'shorter' than undefined date as an undefined date means it may be retained forever - theoretically)
|
||||
else if (asOfDate1 != null || asOfDate2 != null)
|
||||
{
|
||||
return asOfDate1 == null ? +1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither has an asOfDate. (Somewhat arbitrarily) we'll use the number of events to compare now.
|
||||
DispositionActionDefinition dad1 = da1.getDispositionActionDefinition();
|
||||
DispositionActionDefinition dad2 = da2.getDispositionActionDefinition();
|
||||
int eventsCount1 = 0;
|
||||
int eventsCount2 = 0;
|
||||
|
||||
if (dad1 != null)
|
||||
{
|
||||
eventsCount1 = dad1.getEvents().size();
|
||||
}
|
||||
if (dad2 != null)
|
||||
{
|
||||
eventsCount2 = dad2.getEvents().size();
|
||||
}
|
||||
return Integer.valueOf(eventsCount1).compareTo(eventsCount2);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -234,6 +234,17 @@ public interface DispositionService
|
||||
*/
|
||||
void refreshDispositionAction(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Gets date of the disposition action for the given
|
||||
* disposition schedule with the given action name
|
||||
*
|
||||
* @param record
|
||||
* @param dispositionSchedule nodeRef
|
||||
* @param dispositionActionName
|
||||
* @return date
|
||||
*/
|
||||
Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName);
|
||||
|
||||
/**
|
||||
* Compute the "disposition as of" date (if necessary) for a disposition action and a node.
|
||||
*
|
||||
@@ -244,4 +255,13 @@ public interface DispositionService
|
||||
*/
|
||||
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
|
||||
boolean allowContextFromAsOf);
|
||||
|
||||
/**
|
||||
* Gets the origin disposition schedule for the record, not the calculated one
|
||||
* in case of multiple dispositions applied to record
|
||||
*
|
||||
* @param nodeRef record
|
||||
* @return the initial disposition
|
||||
*/
|
||||
DispositionSchedule getOriginDispositionSchedule(NodeRef nodeRef);
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposition;
|
||||
|
||||
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -27,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
|
||||
@@ -38,6 +41,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
import org.alfresco.repo.dictionary.types.period.Immediately;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
@@ -70,15 +74,26 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
/** Logger */
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DispositionServiceImpl.class);
|
||||
|
||||
/** Transaction mode for setting next action */
|
||||
public enum WriteMode
|
||||
{
|
||||
/** Do not update any data. */
|
||||
READ_ONLY,
|
||||
/** Only set the "disposition as of" date. */
|
||||
DATE_ONLY,
|
||||
/**
|
||||
* Set the "disposition as of" date and the name of the next action. This only happens during the creation of a
|
||||
* disposition schedule impl node under a record or folder.
|
||||
*/
|
||||
DATE_AND_NAME
|
||||
};
|
||||
|
||||
/** Behaviour filter */
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
/** Records management service registry */
|
||||
private RecordsManagementServiceRegistry serviceRegistry;
|
||||
|
||||
/** Disposition selection strategy */
|
||||
private DispositionSelectionStrategy dispositionSelectionStrategy;
|
||||
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
@@ -168,16 +183,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
this.freezeService = freezeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dispositionSelectionStrategy bean.
|
||||
*
|
||||
* @param dispositionSelectionStrategy
|
||||
*/
|
||||
public void setDispositionSelectionStrategy(DispositionSelectionStrategy dispositionSelectionStrategy)
|
||||
{
|
||||
this.dispositionSelectionStrategy = dispositionSelectionStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Behavior to initialize the disposition schedule of a newly filed record.
|
||||
*
|
||||
@@ -267,31 +272,76 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public DispositionSchedule getDispositionSchedule(NodeRef nodeRef)
|
||||
public DispositionSchedule getDispositionSchedule(final NodeRef nodeRef)
|
||||
{
|
||||
DispositionSchedule di = null;
|
||||
NodeRef diNodeRef = null;
|
||||
DispositionSchedule ds = null;
|
||||
NodeRef dsNodeRef = null;
|
||||
if (isRecord(nodeRef))
|
||||
{
|
||||
// Get the record folders for the record
|
||||
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(nodeRef);
|
||||
// At this point, we may have disposition instruction objects from 1..n folders.
|
||||
diNodeRef = dispositionSelectionStrategy.selectDispositionScheduleFrom(recordFolders);
|
||||
// calculate disposition schedule without taking into account the user
|
||||
DispositionSchedule originDispositionSchedule = AuthenticationUtil.runAsSystem(new RunAsWork<DispositionSchedule>()
|
||||
{
|
||||
@Override
|
||||
public DispositionSchedule doWork()
|
||||
{
|
||||
return getOriginDispositionSchedule(nodeRef);
|
||||
}
|
||||
});
|
||||
// if the initial disposition schedule of the record is folder based
|
||||
if (originDispositionSchedule == null ||
|
||||
isNotTrue(originDispositionSchedule.isRecordLevelDisposition()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
|
||||
|
||||
if (dsNextAction != null)
|
||||
{
|
||||
final NodeRef action = dsNextAction.getNextActionNodeRef();
|
||||
if (isNotTrue((Boolean)nodeService.getProperty(action, PROP_MANUALLY_SET_AS_OF)))
|
||||
{
|
||||
if (!dsNextAction.getWriteMode().equals(WriteMode.READ_ONLY))
|
||||
{
|
||||
final String dispositionActionName = dsNextAction.getNextActionName();
|
||||
final Date dispositionActionDate = dsNextAction.getNextActionDateAsOf();
|
||||
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
|
||||
if (dsNextAction.getWriteMode().equals(WriteMode.DATE_AND_NAME))
|
||||
{
|
||||
nodeService.setProperty(action, PROP_DISPOSITION_ACTION_NAME, dispositionActionName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
dsNodeRef = dsNextAction.getDispositionNodeRef();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the disposition instructions for the node reference provided
|
||||
diNodeRef = getDispositionScheduleImpl(nodeRef);
|
||||
dsNodeRef = getDispositionScheduleImpl(nodeRef);
|
||||
}
|
||||
|
||||
if (diNodeRef != null)
|
||||
if (dsNodeRef != null)
|
||||
{
|
||||
di = new DispositionScheduleImpl(serviceRegistry, nodeService, diNodeRef);
|
||||
ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef);
|
||||
}
|
||||
|
||||
return di;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This method returns a NodeRef
|
||||
* Gets the disposition instructions
|
||||
@@ -314,6 +364,28 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
return result;
|
||||
}
|
||||
|
||||
public DispositionSchedule getOriginDispositionSchedule(NodeRef nodeRef)
|
||||
{
|
||||
NodeRef parent = this.nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
if (parent != null)
|
||||
{
|
||||
if (filePlanService.isRecordCategory(parent))
|
||||
{
|
||||
NodeRef result = getAssociatedDispositionScheduleImpl(parent);
|
||||
if (result == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new DispositionScheduleImpl(serviceRegistry, nodeService, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getOriginDispositionSchedule(parent);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -620,8 +692,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
* @param dispositionActionDefinition disposition action definition
|
||||
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
|
||||
*/
|
||||
private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
||||
private DispositionAction initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
|
||||
if (childAssocs != null && childAssocs.size() > 0)
|
||||
{
|
||||
return new DispositionActionImpl(serviceRegistry, childAssocs.get(0).getChildRef());
|
||||
}
|
||||
|
||||
// Create the properties
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
||||
|
||||
@@ -651,6 +729,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
// For every event create an entry on the action
|
||||
da.addEventCompletionDetails(event);
|
||||
}
|
||||
return da;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -682,11 +761,18 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (period.getPeriodType().equals(Immediately.PERIOD_TYPE))
|
||||
{
|
||||
contextDate = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_CREATED);
|
||||
}
|
||||
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)
|
||||
@@ -897,6 +983,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID);
|
||||
currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId);
|
||||
|
||||
// When the record has multiple disposition schedules the current disposition action may not be found by id
|
||||
// In this case it will be searched by name
|
||||
if(currentDispositionActionDefinition == null)
|
||||
{
|
||||
String currentADName = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION);
|
||||
currentDispositionActionDefinition = di.getDispositionActionDefinitionByName(currentADName);
|
||||
}
|
||||
|
||||
// Get the next disposition action
|
||||
int index = currentDispositionActionDefinition.getIndex();
|
||||
index++;
|
||||
@@ -983,6 +1077,24 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
}
|
||||
|
||||
public Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName)
|
||||
{
|
||||
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule);
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule);
|
||||
if (assocs != null && assocs.size() > 0)
|
||||
{
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
|
||||
{
|
||||
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
|
||||
return calculateAsOfDate(record, actionDefinition, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to determine if a node is frozen or has frozen children
|
||||
*
|
||||
@@ -1030,4 +1142,169 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate next disposition action for a record
|
||||
*
|
||||
* @param record
|
||||
* @return next disposition action (name, date) and the disposition associated
|
||||
*/
|
||||
|
||||
protected NextActionFromDisposition getDispositionActionByNameForRecord(NodeRef record)
|
||||
{
|
||||
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(record);
|
||||
DispositionAction nextDispositionAction = getNextDispositionAction(record);
|
||||
|
||||
if (nextDispositionAction == null)
|
||||
{
|
||||
DispositionAction lastCompletedDispositionAction = getLastCompletedDispostionAction(record);
|
||||
if (lastCompletedDispositionAction != null)
|
||||
{
|
||||
// all disposition actions upon the given record were completed
|
||||
return null;
|
||||
}
|
||||
|
||||
return getFirstDispositionAction(record, recordFolders);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getNextDispositionAction(record, recordFolders, nextDispositionAction);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next disposition action when the record already has one
|
||||
* @param recordFolders
|
||||
* @param nextDispositionAction
|
||||
* @return next disposition action and the associated disposition schedule
|
||||
*/
|
||||
private NextActionFromDisposition getNextDispositionAction(NodeRef record, List<NodeRef> recordFolders, DispositionAction nextDispositionAction)
|
||||
{
|
||||
String recordNextDispositionActionName = nextDispositionAction.getName();
|
||||
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
|
||||
// We're looking for the latest date, so initially start with a very early one.
|
||||
Date nextDispositionActionDate = new Date(Long.MIN_VALUE);
|
||||
NodeRef dispositionNodeRef = null;
|
||||
|
||||
// Find the latest "disposition as of" date from all the schedules this record is subject to.
|
||||
for (NodeRef folder : recordFolders)
|
||||
{
|
||||
NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
|
||||
if (dsNodeRef != null)
|
||||
{
|
||||
Date dispActionDate = getDispositionActionDate(record, dsNodeRef, recordNextDispositionActionName);
|
||||
if (dispActionDate == null || (nextDispositionActionDate != null
|
||||
&& nextDispositionActionDate.before(dispActionDate)))
|
||||
{
|
||||
nextDispositionActionDate = dispActionDate;
|
||||
dispositionNodeRef = dsNodeRef;
|
||||
if (dispActionDate == null)
|
||||
{
|
||||
// Treat null as the latest date possible (so stop searching further).
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dispositionNodeRef == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
WriteMode mode = determineWriteMode(recordNextDispositionActionDate, nextDispositionActionDate);
|
||||
|
||||
return new NextActionFromDisposition(dispositionNodeRef, nextDispositionAction.getNodeRef(),
|
||||
recordNextDispositionActionName, nextDispositionActionDate, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine what should be updated for an existing disposition schedule impl. We only update the date if the
|
||||
* existing date is earlier than the calculated one.
|
||||
*
|
||||
* @param recordNextDispositionActionDate The next action date found on the record node (or folder node).
|
||||
* @param nextDispositionActionDate The next action date calculated from the current disposition schedule(s)
|
||||
* affecting the node.
|
||||
* @return READ_ONLY if nothing should be updated, or DATE_ONLY if the date needs updating.
|
||||
*/
|
||||
private WriteMode determineWriteMode(Date recordNextDispositionActionDate, Date nextDispositionActionDate)
|
||||
{
|
||||
// Treat null dates as being the latest possible date.
|
||||
Date maxDate = new Date(Long.MAX_VALUE);
|
||||
Date recordDate = (recordNextDispositionActionDate != null ? recordNextDispositionActionDate : maxDate);
|
||||
Date calculatedDate = (nextDispositionActionDate != null ? nextDispositionActionDate : maxDate);
|
||||
|
||||
// We only need to update the date if the current one is too early.
|
||||
if (recordDate.before(calculatedDate))
|
||||
{
|
||||
return WriteMode.DATE_ONLY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return WriteMode.READ_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate first disposition action when the record doesn't have one
|
||||
* @param recordFolders
|
||||
* @return next disposition action and the associated disposition schedule
|
||||
*/
|
||||
private NextActionFromDisposition getFirstDispositionAction(NodeRef record, List<NodeRef> recordFolders)
|
||||
{
|
||||
NodeRef newAction = null;
|
||||
String newDispositionActionName = null;
|
||||
// We're looking for the latest date, so start with a very early one.
|
||||
Date newDispositionActionDateAsOf = new Date(Long.MIN_VALUE);
|
||||
NodeRef dispositionNodeRef = null;
|
||||
for (NodeRef folder : recordFolders)
|
||||
{
|
||||
NodeRef folderDS = getDispositionScheduleImpl(folder);
|
||||
if (folderDS != null)
|
||||
{
|
||||
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, folderDS);
|
||||
List<DispositionActionDefinition> dispositionActionDefinitions = ds.getDispositionActionDefinitions();
|
||||
|
||||
if (dispositionActionDefinitions != null && dispositionActionDefinitions.size() > 0)
|
||||
{
|
||||
DispositionActionDefinition firstDispositionActionDef = dispositionActionDefinitions.get(0);
|
||||
dispositionNodeRef = folderDS;
|
||||
|
||||
if (newAction == null)
|
||||
{
|
||||
NodeRef recordOrFolder = record;
|
||||
if (!ds.isRecordLevelDisposition())
|
||||
{
|
||||
recordOrFolder = folder;
|
||||
}
|
||||
DispositionAction firstDispositionAction = initialiseDispositionAction(recordOrFolder, firstDispositionActionDef, true);
|
||||
newAction = firstDispositionAction.getNodeRef();
|
||||
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
||||
newDispositionActionDateAsOf = firstDispositionAction.getAsOfDate();
|
||||
}
|
||||
else if (firstDispositionActionDef.getPeriod() != null)
|
||||
{
|
||||
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef, true);
|
||||
if (firstActionDate == null || (newDispositionActionDateAsOf != null
|
||||
&& newDispositionActionDateAsOf.before(firstActionDate)))
|
||||
{
|
||||
newDispositionActionName = firstDispositionActionDef.getName();
|
||||
newDispositionActionDateAsOf = firstActionDate;
|
||||
if (firstActionDate == null)
|
||||
{
|
||||
// Treat null as the latest date possible, so there's no point searching further.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newDispositionActionName == null || dispositionNodeRef == null || newAction == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new NextActionFromDisposition(dispositionNodeRef, newAction,
|
||||
newDispositionActionName, newDispositionActionDateAsOf, WriteMode.DATE_AND_NAME);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,80 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposition;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl.WriteMode;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
public class NextActionFromDisposition
|
||||
{
|
||||
public NextActionFromDisposition(NodeRef dispositionNodeRef, NodeRef nextActionNodeRef, String nextActionName, Date nextActionDateAsOf,
|
||||
WriteMode writeMode)
|
||||
{
|
||||
super();
|
||||
this.dispositionNodeRef = dispositionNodeRef;
|
||||
this.nextActionNodeRef = nextActionNodeRef;
|
||||
this.nextActionName = nextActionName;
|
||||
this.nextActionDateAsOf = nextActionDateAsOf;
|
||||
this.writeMode = writeMode;
|
||||
}
|
||||
|
||||
private NodeRef dispositionNodeRef;
|
||||
|
||||
private NodeRef nextActionNodeRef;
|
||||
|
||||
private String nextActionName;
|
||||
|
||||
private Date nextActionDateAsOf;
|
||||
|
||||
private WriteMode writeMode;
|
||||
|
||||
public WriteMode getWriteMode()
|
||||
{
|
||||
return writeMode;
|
||||
}
|
||||
|
||||
public void setWriteMode(WriteMode writeMode)
|
||||
{
|
||||
this.writeMode = writeMode;
|
||||
}
|
||||
|
||||
public NodeRef getNextActionNodeRef()
|
||||
{
|
||||
return nextActionNodeRef;
|
||||
}
|
||||
|
||||
public void setNextActionNodeRef(NodeRef nextActionNodeRef)
|
||||
{
|
||||
this.nextActionNodeRef = nextActionNodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getDispositionNodeRef()
|
||||
{
|
||||
return dispositionNodeRef;
|
||||
}
|
||||
|
||||
public void setDispositionNodeRef(NodeRef dispositionNodeRef)
|
||||
{
|
||||
this.dispositionNodeRef = dispositionNodeRef;
|
||||
}
|
||||
|
||||
public String getNextActionName()
|
||||
{
|
||||
return nextActionName;
|
||||
}
|
||||
|
||||
public void setNextActionName(String nextActionName)
|
||||
{
|
||||
this.nextActionName = nextActionName;
|
||||
}
|
||||
|
||||
public Date getNextActionDateAsOf()
|
||||
{
|
||||
return nextActionDateAsOf;
|
||||
}
|
||||
|
||||
public void setNextActionDateAsOf(Date nextActionDateAsOf)
|
||||
{
|
||||
this.nextActionDateAsOf = nextActionDateAsOf;
|
||||
}
|
||||
}
|
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposition.property;
|
||||
|
||||
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@@ -211,10 +213,14 @@ public class DispositionProperty extends BaseBehaviourBean
|
||||
|
||||
// update asOf date on the disposition action based on the new property value
|
||||
NodeRef daNodeRef = dispositionAction.getNodeRef();
|
||||
// Don't overwrite a manually set "disposition as of" date.
|
||||
if (isNotTrue((Boolean) nodeService.getProperty(daNodeRef, PROP_MANUALLY_SET_AS_OF)))
|
||||
{
|
||||
nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// throw an exception if the property is being 'cleared'
|
||||
|
@@ -149,6 +149,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
QName PROP_DISPOSITION_ACTION_ID = QName.createQName(RM_URI, "dispositionActionId");
|
||||
QName PROP_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction");
|
||||
QName PROP_DISPOSITION_AS_OF = QName.createQName(RM_URI, "dispositionAsOf");
|
||||
/** A flag indicating that the "disposition as of" date has been manually set and shouldn't be changed. */
|
||||
QName PROP_MANUALLY_SET_AS_OF = QName.createQName(RM_URI, "manuallySetAsOf");
|
||||
QName PROP_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "dispositionEventsEligible");
|
||||
QName PROP_DISPOSITION_ACTION_STARTED_AT = QName.createQName(RM_URI, "dispositionActionStartedAt");
|
||||
QName PROP_DISPOSITION_ACTION_STARTED_BY = QName.createQName(RM_URI, "dispositionActionStartedBy");
|
||||
|
@@ -34,12 +34,14 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeFileRecord;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
@@ -1732,7 +1734,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
private void validateLinkConditions(NodeRef record, NodeRef recordFolder)
|
||||
{
|
||||
// ensure that the linking record folders have compatible disposition schedules
|
||||
DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record);
|
||||
|
||||
// get the origin disposition schedule for the record, not the calculated one
|
||||
DispositionSchedule recordDispositionSchedule = dispositionService.getOriginDispositionSchedule(record);
|
||||
|
||||
if (recordDispositionSchedule != null)
|
||||
{
|
||||
DispositionSchedule recordFolderDispositionSchedule = dispositionService.getDispositionSchedule(recordFolder);
|
||||
|
@@ -21,8 +21,10 @@ package org.alfresco.repo.security.permissions.impl;
|
||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
@@ -30,6 +32,7 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
|
||||
import org.alfresco.repo.security.permissions.AccessControlEntry;
|
||||
import org.alfresco.repo.security.permissions.AccessControlList;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -42,6 +45,7 @@ import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Extends the core permission service implementation allowing the consideration of the read records
|
||||
* permission.
|
||||
@@ -56,6 +60,16 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
|
||||
/** Writers simple cache */
|
||||
protected SimpleCache<Serializable, Set<String>> writersCache;
|
||||
|
||||
/**
|
||||
* Configured Permission mapping.
|
||||
*
|
||||
* These strings come from alfresco-global.properties and allow fine tuning of the how permissions are mapped.
|
||||
* This was added as a fix for MNT-16852 to enhance compatibility with our Outlook Integration.
|
||||
*
|
||||
**/
|
||||
protected List<String> configuredReadPermissions;
|
||||
protected List<String> configuredFilePermissions;
|
||||
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
@@ -97,6 +111,28 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
|
||||
this.writersCache = writersCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the string from the properties file (rm.haspermissionmap.read)
|
||||
* to the list used in the hasPermission method
|
||||
*
|
||||
* @param readMapping the mapping of permissions to ReadRecord
|
||||
*/
|
||||
public void setConfiguredReadPermissions(String readMapping)
|
||||
{
|
||||
this.configuredReadPermissions = Arrays.asList(readMapping.split(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the string set in the properties file (rm.haspermissionmap.write)
|
||||
* to the list used in the hasPermission method
|
||||
*
|
||||
* @param fileMapping the mapping of permissions to FileRecord
|
||||
*/
|
||||
public void setConfiguredFilePermissions(String fileMapping)
|
||||
{
|
||||
this.configuredFilePermissions = Arrays.asList(fileMapping.split(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@@ -118,19 +154,19 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
|
||||
public AccessStatus hasPermission(NodeRef nodeRef, String perm)
|
||||
{
|
||||
AccessStatus acs = super.hasPermission(nodeRef, perm);
|
||||
|
||||
if (AccessStatus.DENIED.equals(acs) &&
|
||||
PermissionService.READ.equals(perm) &&
|
||||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
{
|
||||
if (PermissionService.READ.equals(perm) || this.configuredReadPermissions.contains(perm))
|
||||
{
|
||||
return super.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS);
|
||||
}
|
||||
// Added ADD_CHILDREN check in for MNT-16852.
|
||||
else if (AccessStatus.DENIED.equals(acs) &&
|
||||
(PermissionService.WRITE.equals(perm) || PermissionService.ADD_CHILDREN.equals(perm)) &&
|
||||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
else if (PermissionService.WRITE.equals(perm) || this.configuredFilePermissions.contains(perm))
|
||||
{
|
||||
return super.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS);
|
||||
}
|
||||
}
|
||||
|
||||
return acs;
|
||||
}
|
||||
|
@@ -32,7 +32,9 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
@SuiteClasses(
|
||||
{
|
||||
CutOffTest.class,
|
||||
UpdateDispositionScheduleTest.class
|
||||
MultipleSchedulesTest.class,
|
||||
UpdateDispositionScheduleTest.class,
|
||||
UpdateNextDispositionActionTest.class
|
||||
})
|
||||
public class DispositionTestSuite
|
||||
{
|
||||
|
@@ -0,0 +1,176 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
|
||||
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.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class MultipleSchedulesTest extends BaseRMTestCase
|
||||
{
|
||||
/** A unique prefix for the constants in this test. */
|
||||
protected static final String TEST_PREFIX = MultipleSchedulesTest.class.getName() + GUID.generate() + "_";
|
||||
/** The name to use for the first category. */
|
||||
protected static final String CATEGORY_A_NAME = TEST_PREFIX + "CategoryA";
|
||||
/** The name to use for the folder within the first category. */
|
||||
protected static final String FOLDER_A_NAME = TEST_PREFIX + "FolderA";
|
||||
/** The name to use for the second category. */
|
||||
protected static final String CATEGORY_B_NAME = TEST_PREFIX + "CategoryB";
|
||||
/** The name to use for the folder within the second category. */
|
||||
protected static final String FOLDER_B_NAME = TEST_PREFIX + "FolderB";
|
||||
/** The name to use for the record. */
|
||||
protected static final String RECORD_NAME = TEST_PREFIX + "Record";
|
||||
|
||||
/** The internal disposition service is used to avoid permissions issues when updating the record. */
|
||||
private DispositionService internalDispositionService;
|
||||
|
||||
/** The first category node. */
|
||||
private NodeRef categoryA;
|
||||
/** The folder node within the first category. */
|
||||
private NodeRef folderA;
|
||||
/** The second category node. */
|
||||
private NodeRef categoryB;
|
||||
/** The folder node within the second category. */
|
||||
private NodeRef folderB;
|
||||
/** The record node. */
|
||||
private NodeRef record;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
BehaviourTest.initBehaviourTests(retryingTransactionHelper);
|
||||
|
||||
// Get the application context
|
||||
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
||||
internalDispositionService = (DispositionService) applicationContext.getBean("dispositionService");
|
||||
|
||||
// Ensure different records are used for each test.
|
||||
record = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create two categories each containing a folder. Set up a schedule on category A that applies to records (cutoff
|
||||
* immediately, destroy immediately). Set up a schedule on category B that is the same, but with a week delay before
|
||||
* destroy becomes eligible.
|
||||
*/
|
||||
private void setUpFilePlan()
|
||||
{
|
||||
// Only set up the file plan if it hasn't already been done.
|
||||
if (categoryA != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create two categories.
|
||||
categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME);
|
||||
categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME);
|
||||
// Create a disposition schedule for category A (Cut off immediately, then Destroy immediately).
|
||||
DispositionSchedule dispSchedA = utils.createBasicDispositionSchedule(categoryA, "instructions", "authority", true, false);
|
||||
Map<QName, Serializable> cutOffParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedA, cutOffParamsA);
|
||||
Map<QName, Serializable> destroyParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedA, destroyParamsA);
|
||||
// Create a disposition schedule for category B (Cut off immediately, then Destroy one week after cutoff).
|
||||
DispositionSchedule dispSchedB = utils.createBasicDispositionSchedule(categoryB, "instructions", "authority", true, false);
|
||||
Map<QName, Serializable> cutOffParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedB, cutOffParamsB);
|
||||
Map<QName, Serializable> destroyParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_WEEK,
|
||||
PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedB, destroyParamsB);
|
||||
// Create a folder within each category.
|
||||
folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME);
|
||||
folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://issues.alfresco.com/jira/browse/RM-2526">RM-2526</a>
|
||||
* <p><pre>
|
||||
* Given a record subject to a disposition schedule
|
||||
* And it is linked to a disposition schedule with the same step order, but a longer destroy step
|
||||
* When the record is moved onto the destroy step
|
||||
* Then the "as of" date is calculated using the longer period.
|
||||
* </pre>
|
||||
*/
|
||||
public void testLinkedToLongerSchedule()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
test()
|
||||
.given(() -> {
|
||||
setUpFilePlan();
|
||||
// Create a record filed under category A and linked to category B.
|
||||
record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
recordService.link(record, folderB);
|
||||
})
|
||||
.when(() -> {
|
||||
// Cut off the record.
|
||||
dispositionService.cutoffDisposableItem(record);
|
||||
// Ensure the update has been applied to the record.
|
||||
internalDispositionService.updateNextDispositionAction(record);
|
||||
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
|
||||
calendar.add(Calendar.WEEK_OF_YEAR, 1);
|
||||
})
|
||||
.then()
|
||||
.expect(calendar.getTime())
|
||||
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
|
||||
.because("Record should follow largest rentention schedule period, which is one week.");
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://issues.alfresco.com/jira/browse/RM-2526">RM-2526</a>
|
||||
* <p><pre>
|
||||
* Given a record subject to a disposition schedule
|
||||
* And it is linked to a disposition schedule with the same step order, but a shorter destroy step
|
||||
* When the record is moved onto the destroy step
|
||||
* Then the "as of" date is calculated using the longer period.
|
||||
* </pre>
|
||||
*/
|
||||
public void testLinkedToShorterSchedule()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
test()
|
||||
.given(() -> {
|
||||
setUpFilePlan();
|
||||
// Create a record filed under category B and linked to category A.
|
||||
record = fileFolderService.create(folderB, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
recordService.link(record, folderA);
|
||||
})
|
||||
.when(() -> {
|
||||
// Cut off the record.
|
||||
dispositionService.cutoffDisposableItem(record);
|
||||
// Ensure the update has been applied to the record.
|
||||
internalDispositionService.updateNextDispositionAction(record);
|
||||
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
|
||||
calendar.add(Calendar.WEEK_OF_YEAR, 1);
|
||||
})
|
||||
.then()
|
||||
.expect(calendar.getTime())
|
||||
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
|
||||
.because("Record should follow largest rentention schedule period, which is one week.");
|
||||
}
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 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.integration.disposition;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.DEFAULT_EVENT_NAME;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils.PERIOD_ONE_WEEK;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.EditDispositionActionAsOfDateAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Update next disposition step integration tests.
|
||||
*
|
||||
* @author Roxana Lucanu
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public class UpdateNextDispositionActionTest extends BaseRMTestCase
|
||||
{
|
||||
/**
|
||||
* Given a record with multiple dispositions
|
||||
* When updating the next step
|
||||
* Then the action is available
|
||||
* <p>
|
||||
* relates to https://issues.alfresco.com/jira/browse/RM-3060
|
||||
*/
|
||||
public void testUpdateNextDispositionAction_RM3060() throws Exception
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
NodeRef record;
|
||||
NodeRef folder2;
|
||||
|
||||
@Override
|
||||
public void given()
|
||||
{
|
||||
// create category1
|
||||
NodeRef category1 = filePlanService.createRecordCategory(filePlan, generate());
|
||||
|
||||
// create disposition schedule for category1
|
||||
createDispositionSchedule(category1);
|
||||
|
||||
// create category2
|
||||
NodeRef category2 = filePlanService.createRecordCategory(filePlan, generate());
|
||||
|
||||
// create disposition schedule for category2
|
||||
createDispositionSchedule(category2);
|
||||
|
||||
// create folder2 inside category2
|
||||
folder2 = recordFolderService.createRecordFolder(category2, generate());
|
||||
|
||||
// create folder1 inside category1
|
||||
NodeRef folder1 = recordFolderService.createRecordFolder(category1, generate());
|
||||
|
||||
// create record inside folder1
|
||||
record = utils.createRecord(folder1, generate(), generate());
|
||||
|
||||
}
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
// link the record to folder2
|
||||
recordService.link(record, folder2);
|
||||
|
||||
// complete record
|
||||
utils.completeRecord(record);
|
||||
|
||||
// cut off
|
||||
rmActionService.executeRecordsManagementAction(record, CutOffAction.NAME, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
assertTrue("Record " + record + " doesn't have the cutOff aspect.", nodeService.hasAspect(record, ASPECT_CUT_OFF));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createDispositionSchedule(NodeRef category)
|
||||
{
|
||||
DispositionSchedule ds = utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_DESCRIPTION, true, false, false);
|
||||
|
||||
// create the properties for CUTOFF action and add it to the disposition action definition
|
||||
Map<QName, Serializable> cutOff = new HashMap<QName, Serializable>(3);
|
||||
cutOff.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||
cutOff.put(PROP_DISPOSITION_DESCRIPTION, generate());
|
||||
cutOff.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(ds, cutOff);
|
||||
|
||||
// create the properties for TRANSFER action and add it to the disposition action definition
|
||||
Map<QName, Serializable> transfer = new HashMap<QName, Serializable>(3);
|
||||
transfer.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);
|
||||
transfer.put(PROP_DISPOSITION_DESCRIPTION, generate());
|
||||
transfer.put(PROP_DISPOSITION_EVENT, (Serializable)Collections.singletonList(DEFAULT_EVENT_NAME));
|
||||
dispositionService.addDispositionActionDefinition(ds, transfer);
|
||||
|
||||
// create the properties for DESTROY action and add it to the disposition action definition
|
||||
Map<QName, Serializable> destroy = new HashMap<QName, Serializable>(3);
|
||||
destroy.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME);
|
||||
destroy.put(PROP_DISPOSITION_DESCRIPTION, generate());
|
||||
destroy.put(PROP_DISPOSITION_PERIOD, PERIOD_ONE_WEEK);
|
||||
dispositionService.addDispositionActionDefinition(ds, destroy);
|
||||
}
|
||||
}
|
@@ -42,7 +42,6 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
RM452Test.class,
|
||||
RM804Test.class,
|
||||
RM994Test.class,
|
||||
RM1039Test.class,
|
||||
RM1799Test.class,
|
||||
RM1814Test.class,
|
||||
RM978Test.class,
|
||||
|
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.integration.issue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
|
||||
/**
|
||||
* Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RM1039Test extends BaseRMTestCase
|
||||
{
|
||||
@Override
|
||||
protected boolean isRecordTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// try and move a folder from no disposition schedule to a disposition schedule
|
||||
public void testMoveRecordFolderFromNoDisToDis() throws Exception
|
||||
{
|
||||
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create a record category (no disposition schedule)
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
|
||||
|
||||
// create a record folder
|
||||
return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef result) throws Exception
|
||||
{
|
||||
assertNotNull(result);
|
||||
assertNull(dispositionService.getDispositionSchedule(result));
|
||||
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
|
||||
}
|
||||
});
|
||||
|
||||
final NodeRef record = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create a record
|
||||
return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef result) throws Exception
|
||||
{
|
||||
assertNotNull(result);
|
||||
assertNull(dispositionService.getDispositionSchedule(result));
|
||||
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders");
|
||||
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder));
|
||||
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer));
|
||||
|
||||
// take a look at the move capability
|
||||
Capability moveCapability = capabilityService.getCapability("Move");
|
||||
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer));
|
||||
|
||||
// move the node
|
||||
return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef result) throws Exception
|
||||
{
|
||||
assertNotNull(result);
|
||||
assertNotNull(dispositionService.getDispositionSchedule(result));
|
||||
assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
|
||||
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result);
|
||||
assertNotNull(dispositionAction);
|
||||
|
||||
assertNull(dispositionAction.getAsOfDate());
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
assertEquals(1, dispositionAction.getEventCompletionDetails().size());
|
||||
|
||||
// take a look at the record and check things are as we would expect
|
||||
assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// move from a disposition schedule to another .. both record folder level
|
||||
|
||||
// move from a disposition schedule to another .. from record to folder level
|
||||
|
||||
|
||||
// try and move a cutoff folder
|
||||
public void testMoveCutoffRecordFolder() throws Exception
|
||||
{
|
||||
final NodeRef destination = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create a record category (no disposition schedule)
|
||||
return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
|
||||
}
|
||||
});
|
||||
|
||||
final NodeRef testFolder = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create folder
|
||||
NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
|
||||
|
||||
// complete event
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params);
|
||||
|
||||
// cutoff folder
|
||||
rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
|
||||
|
||||
return testFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef result) throws Exception
|
||||
{
|
||||
// take a look at the move capability
|
||||
Capability moveCapability = capabilityService.getCapability("Move");
|
||||
assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(result, destination));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new FailureTest()
|
||||
{
|
||||
@Override
|
||||
public void run() throws Exception
|
||||
{
|
||||
fileFolderService.move(testFolder, destination, null).getNodeRef();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -385,8 +385,11 @@ public class MoveRecordFolderTest extends BaseRMTestCase
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// try and move a cutoff folder
|
||||
/**
|
||||
* Try and move a cutoff folder
|
||||
*
|
||||
* @see https://issues.alfresco.com/jira/browse/RM-1039
|
||||
*/
|
||||
public void testMoveCutoffRecordFolder() throws Exception
|
||||
{
|
||||
final NodeRef destination = doTestInTransaction(new Test<NodeRef>()
|
||||
|
@@ -657,7 +657,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
|
||||
checkDisposableItemChanged(mhRecordFolder42);
|
||||
checkDisposableItemChanged(record43);
|
||||
checkDisposableItemUnchanged(mhRecordFolder44);
|
||||
checkDisposableItemUnchanged(record45);;
|
||||
checkDisposableItemUnchanged(record45);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -76,6 +76,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
public static final String DEFAULT_EVENT_NAME = "case_closed";
|
||||
public static final String PERIOD_NONE = "none|0";
|
||||
public static final String PERIOD_IMMEDIATELY = "immediately|0";
|
||||
public static final String PERIOD_ONE_WEEK = "week|1";
|
||||
public static final String PERIOD_ONE_YEAR = "year|1";
|
||||
public static final String PERIOD_THREE_YEARS = "year|3";
|
||||
|
||||
|
@@ -263,7 +263,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
|
||||
DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class);
|
||||
when(recordDispositionSchedule.isRecordLevelDisposition())
|
||||
.thenReturn(true);
|
||||
when(mockedDispositionService.getDispositionSchedule(record))
|
||||
when(mockedDispositionService.getOriginDispositionSchedule(record))
|
||||
.thenReturn(recordDispositionSchedule);
|
||||
|
||||
DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class);
|
||||
|
Reference in New Issue
Block a user