Merge master into feature/RM-4362_UpdateAPI_ImplAndDoc

This commit is contained in:
Ana Bozianu
2016-12-16 15:56:34 +02:00
5 changed files with 112 additions and 10 deletions

View File

@@ -297,6 +297,11 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>

View File

@@ -24,7 +24,6 @@
</modules>
<properties>
<alfresco.installer.host>releases</alfresco.installer.host>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<suiteXmlFile>testng.xml</suiteXmlFile>
@@ -109,22 +108,18 @@
<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>
<get src="https://${alfresco.installer.host}.alfresco.com/${installer.path}" dest="target/alf-installer.bin" />
<get src="${installer.url}" 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">
<arg line="--mode unattended --alfresco_admin_password admin --disable-components postgres,alfrescowcmqs --jdbc_username alfresco --jdbc_password alfresco --prefix ${basedir}/target/alf-installation" />
</exec>
<delete file="target/alf-installer.bin" verbose="true" />
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>

View File

@@ -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;
}

View File

@@ -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";
}

View File

@@ -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
{