diff --git a/pom.xml b/pom.xml
index 4ea36d3b7d..4eff6fbd7f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -297,6 +297,11 @@
maven-failsafe-plugin
2.19
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.8
+
org.codehaus.mojo
build-helper-maven-plugin
diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml
index 78c62c3a3b..1e6d3439db 100644
--- a/rm-automation/pom.xml
+++ b/rm-automation/pom.xml
@@ -24,7 +24,6 @@
- releases
1.8
1.8
testng.xml
@@ -109,22 +108,18 @@
Recreating database...
drop database if exists alfresco; create database alfresco
Downloading Alfresco installer...
-
+
Installing Alfresco...
+
-
- org.apache.ant
- ant-jsch
- 1.8.2
-
postgresql
postgresql
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java
index d821768829..b9edeb4002 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java
@@ -28,7 +28,9 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.RELATIVE_PATH;
import java.util.List;
@@ -96,7 +98,8 @@ public class FilePlanComponent
@JsonProperty (required = false)
private FilePlanComponentContent content;
-
+
+ @JsonProperty (value = PATH)
private FilePlanComponentPath path;
@JsonProperty (required = true)
@@ -108,4 +111,7 @@ public class FilePlanComponent
@JsonProperty (required = true)
private FilePlanComponentUserInfo modifiedByUser;
+ @JsonProperty (value = RELATIVE_PATH)
+ private String relativePath;
+
}
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
index 11b14c1906..130cb388f5 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
@@ -49,7 +49,7 @@ public class FilePlanComponentFields
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
public static final String PROPERTIES_LOCATION = "rma:location";
public static final String PROPERTIES_IS_CLOSED = "rma:isClosed"; // not to be confused with IS_CLOSED!
-
+
// for non-electronic records
public static final String PROPERTIES_BOX = "rma:box";
public static final String PROPERTIES_FILE = "rma:file";
@@ -57,5 +57,8 @@ public class FilePlanComponentFields
public static final String PROPERTIES_PHYSICAL_SIZE = "rma:physicalSize";
public static final String PROPERTIES_SHELF = "rma:shelf";
public static final String PROPERTIES_STORAGE_LOCATION = "rma:storageLocation";
-
+
+ //RelativePath specifies the container structure to create relative to the node nodeId.
+ public static final String RELATIVE_PATH = "relativePath";
+ public static final String PATH = "path";
}
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java
index 4c7d836a43..bab76aec0c 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java
@@ -31,6 +31,7 @@ import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME;
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.springframework.http.HttpStatus.CREATED;
@@ -44,6 +45,7 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import static org.testng.AssertJUnit.assertTrue;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.NoSuchElementException;
@@ -358,6 +360,97 @@ public class RecordFolderTests extends BaseRestTest
);
}
+
+ /**
+ * Given that I want to create a record folder
+ * When I use the API with the relativePath
+ * Then the categories specified in the relativePath that don't exist are created within the record folder
+ *
+ * Containers in the relativePath that do not exist are created before the node is created
+ */
+ @Test
+ (
+ description = "Create a folder based on the relativePath. " +
+ "Containers in the relativePath that do not exist are created before the node is created"
+ )
+ public void createFolderWithRelativePath() throws Exception
+ {
+ //RelativePath specify the container structure to create relative to the record folder to be created
+ String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth();
+
+ // Authenticate with admin user
+ filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
+ //The record folder to be created
+ FilePlanComponent recordFolder = FilePlanComponent.builder()
+ .name(FOLDER_NAME)
+ .nodeType(RECORD_FOLDER_TYPE.toString())
+ .relativePath(RELATIVE_PATH)
+ .build();
+
+ // Create the record folder
+ FilePlanComponent folder = filePlanComponentAPI.withParams("include="+ PATH).createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString());
+ //Check the API response code
+ filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
+
+ // Verify the returned properties for the file plan component - record folder
+ assertFalse(folder.getIsCategory());
+ assertFalse(folder.getIsFile());
+ assertTrue(folder.getIsRecordFolder());
+
+ //Check the path return contains the RELATIVE_PATH
+ assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
+ //check the parent is a category
+ assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
+
+ //check the created folder from the server
+ folder=filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder.getId());
+ //Check the API response code
+ filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
+ // Verify the returned properties for the file plan component - record folder
+ assertFalse(folder.getIsCategory());
+ assertFalse(folder.getIsFile());
+ assertTrue(folder.getIsRecordFolder());
+
+ //Check the path return contains the RELATIVE_PATH
+ assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
+
+ //New Relative Path only a part of containers need to be created before the record folder
+ String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1);
+ //The record folder to be created
+ FilePlanComponent recordFolder2 = FilePlanComponent.builder()
+ .name(FOLDER_NAME)
+ .nodeType(RECORD_FOLDER_TYPE.toString())
+ .relativePath(NEW_RELATIVE_PATH)
+ .build();
+
+ // Create the record folder
+ FilePlanComponent folder2 = filePlanComponentAPI.withParams("include=" + PATH).createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS.toString());
+ //Check the API response code
+ filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
+
+ // Verify the returned properties for the file plan component - record folder
+ assertFalse(folder2.getIsCategory());
+ assertFalse(folder2.getIsFile());
+ assertTrue(folder2.getIsRecordFolder());
+ //Check the path return contains the NEW_RELATIVE_PATH
+ assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH));
+
+ //check the parent is a category
+ assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
+
+ // Check the folder created on the server
+ folder2 = filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder2.getId());
+ //Check the API response code
+ filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
+
+ // Verify the returned properties for the file plan component - record folder
+ assertFalse(folder2.getIsCategory());
+ assertFalse(folder2.getIsFile());
+ assertTrue(folder2.getIsRecordFolder());
+ //Check the path return contains the NEW_RELATIVE_PATH
+ assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH));
+ }
+
@AfterClass (alwaysRun = true)
public void tearDown() throws Exception
{