mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-11-05 15:32:21 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83c863cb6e | ||
|
|
705f05636f | ||
|
|
2ec36e2e85 | ||
|
|
8d35483a17 | ||
|
|
6e49b8ccb9 | ||
|
|
842e879970 | ||
|
|
b687453ccb |
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -166,6 +166,7 @@
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
|
||||
<property name="dispositionService" ref="DispositionService"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.recordfolders.RecordFolderEntityResource">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -32,6 +32,7 @@ import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -42,6 +43,8 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegist
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
|
||||
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.disposition.property.DispositionProperty;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
@@ -73,6 +76,7 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
protected NodeService nodeService;
|
||||
private RecordsManagementServiceRegistry service;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private DispositionService dispositionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -94,6 +98,11 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Create a retention schedule step for the particular retention schedule using the 'retentionScheduleId'")
|
||||
public List<RetentionScheduleActionDefinition> create(String retentionScheduleId, List<RetentionScheduleActionDefinition> nodeInfos, Parameters parameters)
|
||||
@@ -102,19 +111,28 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
mandatory("entity", nodeInfos);
|
||||
mandatory("parameters", parameters);
|
||||
NodeRef retentionScheduleNodeRef = apiUtils.lookupAndValidateNodeType(retentionScheduleId, RecordsManagementModel.TYPE_DISPOSITION_SCHEDULE);
|
||||
|
||||
RetentionScheduleActionDefinition retentionScheduleActionDefinition = nodeInfos.get(0);
|
||||
|
||||
// validation for the order of the step
|
||||
retentionScheduleStepValidation(retentionScheduleNodeRef, nodeInfos.get(0));
|
||||
retentionScheduleStepValidation(retentionScheduleNodeRef, retentionScheduleActionDefinition);
|
||||
|
||||
DispositionSchedule dispositionSchedule = new DispositionScheduleImpl(service, nodeService, retentionScheduleNodeRef);
|
||||
boolean isRecordLevel = dispositionSchedule.isRecordLevelDisposition();
|
||||
|
||||
// request property validation
|
||||
retentionScheduleRequestValidation(nodeInfos.get(0));
|
||||
retentionScheduleRequestValidation(retentionScheduleActionDefinition, isRecordLevel);
|
||||
|
||||
// create the parameters for the action definition
|
||||
Map<QName, Serializable> actionDefinitionParams = nodesModelFactory.createRetentionActionDefinitionParams(nodeInfos.get(0));
|
||||
Map<QName, Serializable> actionDefinitionParams = nodesModelFactory.createRetentionActionDefinitionParams(retentionScheduleActionDefinition);
|
||||
|
||||
// create the child association from the schedule to the action definition
|
||||
NodeRef actionNodeRef = this.nodeService.createNode(retentionScheduleNodeRef,
|
||||
RecordsManagementModel.ASSOC_DISPOSITION_ACTION_DEFINITIONS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
|
||||
QName.createValidLocalName(nodeInfos.get(0).getName())),
|
||||
QName.createValidLocalName(retentionScheduleActionDefinition.getName())),
|
||||
RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION, actionDefinitionParams).getChildRef();
|
||||
DispositionSchedule dispositionSchedule = new DispositionScheduleImpl(service, nodeService, retentionScheduleNodeRef);
|
||||
|
||||
DispositionActionDefinition dispositionActionDefinition = dispositionSchedule.getDispositionActionDefinition(actionNodeRef.getId());
|
||||
List<RetentionScheduleActionDefinition> responseActions = new ArrayList<>();
|
||||
if (dispositionActionDefinition != null)
|
||||
@@ -195,7 +213,7 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
* @param retentionScheduleActionDefinition
|
||||
* retention schedule action definition
|
||||
*/
|
||||
private void retentionScheduleRequestValidation(RetentionScheduleActionDefinition retentionScheduleActionDefinition)
|
||||
private void retentionScheduleRequestValidation(RetentionScheduleActionDefinition retentionScheduleActionDefinition, boolean isRecordLevel)
|
||||
{
|
||||
// step name validation
|
||||
if (invalidStepNameCheck(retentionScheduleActionDefinition.getName()))
|
||||
@@ -203,7 +221,7 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
throw new InvalidArgumentException("name value is invalid : " + retentionScheduleActionDefinition.getName());
|
||||
}
|
||||
|
||||
validatePeriodAndPeriodProperty(retentionScheduleActionDefinition);
|
||||
validatePeriodAndPeriodProperty(retentionScheduleActionDefinition, isRecordLevel);
|
||||
|
||||
// event name validation
|
||||
if (invalidEventNameCheck(retentionScheduleActionDefinition.getEvents()))
|
||||
@@ -222,7 +240,7 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePeriodAndPeriodProperty(RetentionScheduleActionDefinition retentionScheduleActionDefinition)
|
||||
private void validatePeriodAndPeriodProperty(RetentionScheduleActionDefinition retentionScheduleActionDefinition, boolean isRecordLevel)
|
||||
{
|
||||
// period value validation
|
||||
if (invalidPeriodCheck(retentionScheduleActionDefinition.getPeriod()))
|
||||
@@ -231,8 +249,8 @@ public class RetentionScheduleActionRelation implements RelationshipResourceActi
|
||||
}
|
||||
|
||||
// periodProperty validation
|
||||
List<String> validPeriodProperties = Arrays.asList("cm:created", "rma:cutOffDate", "rma:dispositionAsOf");
|
||||
if (validPeriodProperties.stream().noneMatch(retentionScheduleActionDefinition.getPeriodProperty()::equals))
|
||||
Collection<DispositionProperty> validPeriodProperties = dispositionService.getDispositionProperties(isRecordLevel, retentionScheduleActionDefinition.getName());
|
||||
if (validPeriodProperties.stream().map(dp -> dp.getQName().toPrefixString()).noneMatch(retentionScheduleActionDefinition.getPeriodProperty()::equals))
|
||||
{
|
||||
throw new InvalidArgumentException("periodProperty value is invalid: " + retentionScheduleActionDefinition.getPeriodProperty());
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
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.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||
@@ -148,6 +149,7 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
|
||||
@Mock(name="alfrescoTransactionSupport") protected AlfrescoTransactionSupport mockedAlfrescoTransactionSupport;
|
||||
@Mock(name="freezeService") protected FreezeService mockedFreezeService;
|
||||
@Mock(name="dispositionService") protected DispositionService mockedDispositionService;
|
||||
@Mock(name="recordsManagementEventService") protected RecordsManagementEventService mockedRecordsManagementEventService;
|
||||
|
||||
/** application context mock */
|
||||
@Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext;
|
||||
|
||||
@@ -0,0 +1,397 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rm.rest.api.retentionschedule;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinitionImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.RetentionScheduleActionDefinition;
|
||||
import org.alfresco.rm.rest.api.model.RetentionSteps;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/**
|
||||
* Unit tests for RetentionScheduleActionRelation
|
||||
*/
|
||||
public class RetentionScheduleActionRelationUnitTest extends BaseUnitTest {
|
||||
|
||||
@Mock
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
|
||||
@Mock
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
@Mock
|
||||
private Parameters parameters;
|
||||
|
||||
private RetentionScheduleActionRelation retentionScheduleActionRelation;
|
||||
|
||||
private NodeRef rsRecordLevelNodeRef = new NodeRef("workspace://SpacesStore/recordLevel");
|
||||
private NodeRef rsRecordFolderLevelNodeRef = new NodeRef("workspace://SpacesStore/recordFolderLevel");
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
// Disposition Service
|
||||
DispositionService dispositionService = new DispositionServiceImpl();
|
||||
|
||||
// Disposition Properties
|
||||
DispositionProperty publicationDate = createDispositionProperty("dod:publicationDate", false, true, Set.of());
|
||||
DispositionProperty cutoffDate = createDispositionProperty("rma:cutOffDate", true, true, Set.of("cutoff"));
|
||||
DispositionProperty dispositionAsOf = createDispositionProperty("rma:dispositionAsOf", true, true, Set.of());
|
||||
DispositionProperty dateFiled = createDispositionProperty("rma:dateFiled", false, true, Set.of());
|
||||
DispositionProperty created = createDispositionProperty("cm:created", true, true, Set.of());
|
||||
|
||||
// Register Disposition Properties
|
||||
dispositionService.registerDispositionProperty(publicationDate);
|
||||
dispositionService.registerDispositionProperty(cutoffDate);
|
||||
dispositionService.registerDispositionProperty(dispositionAsOf);
|
||||
dispositionService.registerDispositionProperty(dateFiled);
|
||||
dispositionService.registerDispositionProperty(created);
|
||||
|
||||
// Retention Schedule Action Relation
|
||||
retentionScheduleActionRelation = new RetentionScheduleActionRelation();
|
||||
retentionScheduleActionRelation.setApiUtils(apiUtils);
|
||||
retentionScheduleActionRelation.setNodeService(mockedNodeService);
|
||||
retentionScheduleActionRelation.setNodesModelFactory(nodesModelFactory);
|
||||
retentionScheduleActionRelation.setDispositionService(dispositionService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "cutoff" retention step for a retention schedule with "record" level
|
||||
* disposition supplying only VALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Valid: dod:publicationDate, rma:dispositionAsOf, rma:dateField and cm:created
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordLevel_Cutoff_Valid() throws Exception {
|
||||
|
||||
// Retention schedule with "record" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(true, false);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.CUTOFF.stepName;
|
||||
|
||||
// Cutoff - dod:publicationDate
|
||||
executeValidStep(retentionScheduleId, actionName, "dod:publicationDate");
|
||||
|
||||
// Cutoff - rma:dispositionAsOf
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:dispositionAsOf");
|
||||
|
||||
// Cutoff - rma:dateFiled
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:dateFiled");
|
||||
|
||||
// Cutoff - cm:created
|
||||
executeValidStep(retentionScheduleId, actionName, "cm:created");
|
||||
|
||||
verify(mockedNodeService, times(4)).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "cutoff" retention step for a retention schedule with "record" level
|
||||
* disposition supplying only INVALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Invalid: rma:cutOffDate
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordLevel_Cutoff_Invalid() throws Exception {
|
||||
|
||||
// Retention schedule with "record" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(true, false);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.CUTOFF.stepName;
|
||||
|
||||
// Cutoff - rma:cutOffDate
|
||||
executeInvalidStep(retentionScheduleId, actionName, "rma:cutOffDate");
|
||||
|
||||
verify(mockedNodeService, never()).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "cutoff" retention step for a retention schedule with "record folder"
|
||||
* level disposition supplying only VALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Valid: rma:dispositionAsOf and cm:created
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordFolderLevel_Cutoff_Valid() throws Exception {
|
||||
|
||||
// Retention schedule with "record folder" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(false, false);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.CUTOFF.stepName;
|
||||
|
||||
// Cutoff - rma:dispositionAsOf
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:dispositionAsOf");
|
||||
|
||||
// Cutoff - cm:created
|
||||
executeValidStep(retentionScheduleId, actionName, "cm:created");
|
||||
|
||||
verify(mockedNodeService, times(2)).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "cutoff" retention step for a retention schedule with "record folder"
|
||||
* level disposition supplying only INVALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Invalid: dod:publicationDate, rma:cutOffDate and rma:dateFiled
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordFolderLevel_Cutoff_Invalid() throws Exception {
|
||||
|
||||
// Retention schedule with "record folder" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(false, false);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.CUTOFF.stepName;
|
||||
|
||||
// Cutoff - dod:publicationDate
|
||||
executeInvalidStep(retentionScheduleId, actionName, "dod:publicationDate");
|
||||
|
||||
// Cutoff - rma:cutOffDate
|
||||
executeInvalidStep(retentionScheduleId, actionName, "rma:cutOffDate");
|
||||
|
||||
// Cutoff - rma:dateFiled
|
||||
executeInvalidStep(retentionScheduleId, actionName, "rma:dateFiled");
|
||||
|
||||
verify(mockedNodeService, never()).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "transfer" retention step for a retention schedule with "record" level
|
||||
* disposition supplying only VALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Valid: dod:publicationDate, rma:cutOffDate, rma:dispositionAsOf,
|
||||
* rma:dateField and cm:created
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordLevel_Transfer_Valid() throws Exception {
|
||||
|
||||
// Retention schedule with "record" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(true, true);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.TRANSFER.stepName;
|
||||
|
||||
// Transfer - dod:publicationDate
|
||||
executeValidStep(retentionScheduleId, actionName, "dod:publicationDate");
|
||||
|
||||
// Transfer - rma:cutOffDate
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:cutOffDate");
|
||||
|
||||
// Transfer - rma:dispositionAsOf
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:dispositionAsOf");
|
||||
|
||||
// Transfer - rma:dateFiled
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:dateFiled");
|
||||
|
||||
// Transfer - cm:created
|
||||
executeValidStep(retentionScheduleId, actionName, "cm:created");
|
||||
|
||||
verify(mockedNodeService, times(5)).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "transfer" retention step for a retention schedule with "record" level
|
||||
* disposition supplying only INVALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Invalid: any other property that is not dod:publicationDate, rma:cutOffDate,
|
||||
* rma:dispositionAsOf, rma:dateField and cm:created.
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordLevel_Transfer_Invalid() throws Exception {
|
||||
|
||||
// Retention schedule with "record" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(true, true);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.TRANSFER.stepName;
|
||||
|
||||
// Transfer - bad:property
|
||||
executeInvalidStep(retentionScheduleId, actionName, "bad:property");
|
||||
|
||||
verify(mockedNodeService, never()).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "transfer" retention step for a retention schedule with "record
|
||||
* folder" level disposition supplying only VALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Valid: rma:cutOffDate, rma:dispositionAsOf and cm:created
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordFolderLevel_Transfer_Valid() throws Exception {
|
||||
|
||||
// Retention schedule with "record" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(false, true);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.TRANSFER.stepName;
|
||||
|
||||
// Transfer - rma:cutOffDate
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:cutOffDate");
|
||||
|
||||
// Transfer - rma:dispositionAsOf
|
||||
executeValidStep(retentionScheduleId, actionName, "rma:dispositionAsOf");
|
||||
|
||||
// Transfer - cm:created
|
||||
executeValidStep(retentionScheduleId, actionName, "cm:created");
|
||||
|
||||
verify(mockedNodeService, times(3)).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create "transfer" retention step for a retention schedule with "record
|
||||
* folder" level disposition supplying only INVALID disposition properties.
|
||||
*
|
||||
* <p>
|
||||
* Invalid: dod:publicationDate and rma:dateFiled
|
||||
* </p>
|
||||
*/
|
||||
@Test
|
||||
public void testCreate_RetentionScheduleRecordFolderLevel_Transfer_Invalid() throws Exception {
|
||||
|
||||
// Retention schedule with "record" level disposition
|
||||
String retentionScheduleId = useRetentionScheduleWithRecordLevel(false, true);
|
||||
|
||||
// Retention step action
|
||||
String actionName = RetentionSteps.TRANSFER.stepName;
|
||||
|
||||
// Transfer - dod:publicationDate
|
||||
executeInvalidStep(retentionScheduleId, actionName, "dod:publicationDate");
|
||||
|
||||
// Transfer - rma:dateFiled
|
||||
executeInvalidStep(retentionScheduleId, actionName, "rma:dateFiled");
|
||||
|
||||
verify(mockedNodeService, never()).createNode(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
private void executeValidStep(String retentionScheduleId, String actionName, String periodProperty) {
|
||||
RetentionScheduleActionDefinition actionDef = createAction(actionName, periodProperty);
|
||||
retentionScheduleActionRelation.create(retentionScheduleId, Arrays.asList(actionDef), parameters);
|
||||
}
|
||||
|
||||
private void executeInvalidStep(String retentionScheduleId, String actionName, String periodProperty) {
|
||||
RetentionScheduleActionDefinition actionDef = createAction(actionName, periodProperty);
|
||||
try {
|
||||
retentionScheduleActionRelation.create(retentionScheduleId, Arrays.asList(actionDef), parameters);
|
||||
} catch (InvalidArgumentException e) {
|
||||
assertTrue(e.getMessage().contains("periodProperty value is invalid: " + periodProperty));
|
||||
}
|
||||
}
|
||||
|
||||
private String useRetentionScheduleWithRecordLevel(Boolean withRecordLevel, boolean hasCompletedActions) {
|
||||
|
||||
NodeRef retentionScheduleNodeRef = withRecordLevel ? rsRecordLevelNodeRef : rsRecordFolderLevelNodeRef;
|
||||
|
||||
String retentionScheduleId = retentionScheduleNodeRef.getId();
|
||||
|
||||
ChildAssociationRef retentionScheduleAssocRef = mock(ChildAssociationRef.class);
|
||||
|
||||
NodeRef cutOffActionNodeRef = mock(NodeRef.class);
|
||||
|
||||
DispositionActionDefinition cutoffAction = new DispositionActionDefinitionImpl(
|
||||
mockedRecordsManagementEventService, mockedRecordsManagementActionService, mockedNodeService,
|
||||
cutOffActionNodeRef, 0);
|
||||
|
||||
List<DispositionActionDefinition> completedActions = hasCompletedActions ? Arrays.asList(cutoffAction)
|
||||
: Collections.emptyList();
|
||||
|
||||
when(retentionScheduleAssocRef.getChildRef()).thenReturn(new NodeRef("workspace://SpacesStore/123"));
|
||||
when(apiUtils.lookupAndValidateNodeType(eq(retentionScheduleId), any(QName.class))).thenReturn(retentionScheduleNodeRef);
|
||||
when(mockedNodeService.getProperty(retentionScheduleNodeRef, RecordsManagementModel.PROP_RECORD_LEVEL_DISPOSITION)).thenReturn(withRecordLevel);
|
||||
when(nodesModelFactory.getRetentionActions(retentionScheduleNodeRef)).thenReturn(completedActions);
|
||||
when(mockedNodeService.createNode(any(), any(), any(), any(), any())).thenReturn(retentionScheduleAssocRef);
|
||||
|
||||
return retentionScheduleId;
|
||||
}
|
||||
|
||||
private RetentionScheduleActionDefinition createAction(String name, String periodProperty) {
|
||||
RetentionScheduleActionDefinition actionDef = mock(RetentionScheduleActionDefinition.class);
|
||||
when(actionDef.getName()).thenReturn(name);
|
||||
when(actionDef.getPeriodProperty()).thenReturn(periodProperty);
|
||||
when(actionDef.getPeriodAmount()).thenReturn(2);
|
||||
when(actionDef.getPeriod()).thenReturn("day");
|
||||
when(actionDef.getEvents()).thenReturn(Collections.singletonList("versioned"));
|
||||
when(actionDef.isCombineRetentionStepConditions()).thenReturn(false);
|
||||
return actionDef;
|
||||
}
|
||||
|
||||
private DispositionProperty createDispositionProperty(String name, Boolean appliesToFolderLevel,
|
||||
Boolean appliesToRecordLevel, Set<String> excludedActions) {
|
||||
when(mockedNamespaceService.getNamespaceURI(any())).thenReturn(name.split(":")[0]);
|
||||
DispositionProperty dp = new DispositionProperty();
|
||||
dp.setNamespaceService(mockedNamespaceService);
|
||||
dp.setName(name);
|
||||
dp.setAppliesToRecordLevel(appliesToRecordLevel);
|
||||
dp.setAppliesToFolderLevel(appliesToFolderLevel);
|
||||
dp.setExcludedDispositionActions(excludedActions);
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -2,7 +2,7 @@
|
||||
<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-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
<dependency.json-smart.version>2.5.2</dependency.json-smart.version>
|
||||
<alfresco.googledrive.version>4.1.0</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>3.4.0</alfresco.aos-module.version>
|
||||
<alfresco.api-explorer.version>25.3.0-A.1</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
|
||||
<alfresco.api-explorer.version>25.3.0-A.2</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
|
||||
|
||||
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
|
||||
<license-maven-plugin.version>2.4.0</license-maven-plugin.version>
|
||||
@@ -154,7 +154,7 @@
|
||||
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
|
||||
<url>https://github.com/Alfresco/alfresco-community-repo</url>
|
||||
<tag>25.3.0.69</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.3.0.69</version>
|
||||
<version>25.3.0.72-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
Reference in New Issue
Block a user