mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge branch 'feature/RM-4559_relativePathSupport' into 'master'
Feature/rm 4559 relative path support The relativePath specifies the container structure to create relative to the node nodeId. Containers in the relativePath that do not exist are created before the node is created. The container type is decided considering the type of the parent container and the type of the node to be created. See merge request !701
This commit is contained in:
@@ -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.ALLOWABLE_OPERATIONS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
|
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.PROPERTIES;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.RELATIVE_PATH;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ public class FilePlanComponent
|
|||||||
@JsonProperty (required = false)
|
@JsonProperty (required = false)
|
||||||
private FilePlanComponentContent content;
|
private FilePlanComponentContent content;
|
||||||
|
|
||||||
|
@JsonProperty (value = PATH)
|
||||||
private FilePlanComponentPath path;
|
private FilePlanComponentPath path;
|
||||||
|
|
||||||
@JsonProperty (required = true)
|
@JsonProperty (required = true)
|
||||||
@@ -108,4 +111,7 @@ public class FilePlanComponent
|
|||||||
@JsonProperty (required = true)
|
@JsonProperty (required = true)
|
||||||
private FilePlanComponentUserInfo modifiedByUser;
|
private FilePlanComponentUserInfo modifiedByUser;
|
||||||
|
|
||||||
|
@JsonProperty (value = RELATIVE_PATH)
|
||||||
|
private String relativePath;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -58,4 +58,7 @@ public class FilePlanComponentFields
|
|||||||
public static final String PROPERTIES_SHELF = "rma:shelf";
|
public static final String PROPERTIES_SHELF = "rma:shelf";
|
||||||
public static final String PROPERTIES_STORAGE_LOCATION = "rma:storageLocation";
|
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";
|
||||||
}
|
}
|
||||||
|
@@ -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.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.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.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.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
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.Assert.fail;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.NoSuchElementException;
|
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)
|
@AfterClass (alwaysRun = true)
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user