mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'master' into feature/Update_Alfresco_Dependencies_5_2_d
Conflicts: pom.xml
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<maven.build.sourceVersion>1.8</maven.build.sourceVersion>
|
||||
<alfresco.rm.share>alfresco-rm-community-share</alfresco.rm.share>
|
||||
<alfresco.rm.repo>alfresco-rm-community-repo</alfresco.rm.repo>
|
||||
<tas.restapi.version>5.2.0-2</tas.restapi.version>
|
||||
<tas.restapi.version>5.2.0-7</tas.restapi.version>
|
||||
<fluent.json.version>2.0.0</fluent.json.version>
|
||||
</properties>
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi-test</artifactId>
|
||||
|
@@ -26,6 +26,8 @@
|
||||
*/
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilesAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||
@@ -33,6 +35,7 @@ import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RecordsAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.RepoTestModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -68,6 +71,22 @@ public class RestAPIFactory
|
||||
return getRmRestWrapper().withIGCoreAPI();
|
||||
}
|
||||
|
||||
private RestCoreAPI getRestCoreAPI(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser());
|
||||
return getRmRestWrapper().withCoreAPI();
|
||||
}
|
||||
|
||||
public Node getNodeAPI(RepoTestModel model) throws Exception
|
||||
{
|
||||
return getRestCoreAPI(null).usingNode(model);
|
||||
}
|
||||
|
||||
public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws Exception
|
||||
{
|
||||
return getRestCoreAPI(userModel).usingNode(model);
|
||||
}
|
||||
|
||||
public RMSiteAPI getRMSiteAPI()
|
||||
{
|
||||
return getRestIGCoreAPI(null).usingRMSite();
|
||||
@@ -97,7 +116,7 @@ public class RestAPIFactory
|
||||
{
|
||||
return getRestIGCoreAPI(userModel).usingRecords();
|
||||
}
|
||||
|
||||
|
||||
public FilesAPI getFilesAPI()
|
||||
{
|
||||
return getRestIGCoreAPI(null).usingFiles();
|
||||
@@ -107,12 +126,12 @@ public class RestAPIFactory
|
||||
{
|
||||
return getRestIGCoreAPI(userModel).usingFiles();
|
||||
}
|
||||
|
||||
|
||||
public RMUserAPI getRMUserAPI()
|
||||
{
|
||||
return getRestIGCoreAPI(null).usingRMUser();
|
||||
}
|
||||
|
||||
|
||||
public RMUserAPI getRMUserAPI(UserModel userModel)
|
||||
{
|
||||
return getRestIGCoreAPI(userModel).usingRMUser();
|
||||
|
@@ -107,7 +107,7 @@ public class FilePlanComponentProperties
|
||||
|
||||
@JsonProperty(value = PROPERTIES_PHYSICAL_SIZE, required = false)
|
||||
private Integer physicalSize;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_RECORD_ID, required = false)
|
||||
private String recordId;
|
||||
private String rmIdentifier;
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJsonElectronicRecord;
|
||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
||||
import static org.springframework.http.HttpMethod.DELETE;
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
@@ -231,7 +232,7 @@ public class FilePlanComponentAPI extends RMModelRequest
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
*
|
||||
*
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param recordContent {@link File} pointing to the content of the electronic record to be created
|
||||
* @param parentId parent container id
|
||||
@@ -253,8 +254,7 @@ public class FilePlanComponentAPI extends RMModelRequest
|
||||
* to the request.
|
||||
*/
|
||||
RequestSpecBuilder builder = getRMRestWrapper().configureRequestSpec();
|
||||
JsonNode root = new ObjectMapper().readTree(toJson(electronicRecordModel));
|
||||
|
||||
JsonNode root = new ObjectMapper().readTree(toJsonElectronicRecord(electronicRecordModel));
|
||||
// add request fields
|
||||
Iterator<String> fieldNames = root.fieldNames();
|
||||
while (fieldNames.hasNext())
|
||||
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 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.rest.rm.community.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
|
||||
/**
|
||||
* Mix class for FilePlanComponent POJO class
|
||||
* Mix-in annotations are: a way to associate annotations with classes
|
||||
* without modifying (target) classes themselves.
|
||||
*
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class FilePlanComponentMixIn
|
||||
{
|
||||
/**
|
||||
* Annotation used to indicate that a property should be serialized "unwrapped"
|
||||
* Its properties are instead included as properties of its containing Object
|
||||
*/
|
||||
@JsonUnwrapped
|
||||
abstract FilePlanComponentProperties getProperties();
|
||||
|
||||
}
|
@@ -34,6 +34,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
|
||||
/**
|
||||
* Utility class for creating the json object
|
||||
*
|
||||
@@ -71,4 +73,42 @@ public class PojoUtility
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converting object to JSON string for electronic records
|
||||
*
|
||||
* @param model The java object model to convert
|
||||
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
|
||||
*/
|
||||
public static String toJsonElectronicRecord(Object model) throws JsonProcessingException
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
//inject the "mix-in" annotations from FilePlanComponentMix to
|
||||
// FilePlanComponent POJO class when converting to json
|
||||
mapper.addMixIn(FilePlanComponent.class, FilePlanComponentMixIn.class);
|
||||
|
||||
//include only values that differ from default settings to be included
|
||||
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
||||
try
|
||||
{
|
||||
|
||||
//return the json object
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||
|
||||
}
|
||||
catch (JsonGenerationException e)
|
||||
{
|
||||
return e.toString();
|
||||
}
|
||||
catch (JsonMappingException e)
|
||||
{
|
||||
return e.toString();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
|
||||
@@ -123,12 +125,12 @@ public interface TestData
|
||||
* The default electronic record name used when creating electronic records
|
||||
*/
|
||||
public static String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||
|
||||
|
||||
/**
|
||||
* The default Non electronic record name used when creating non-electronic records
|
||||
*/
|
||||
public static String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||
|
||||
|
||||
/**
|
||||
* Data Provider with:
|
||||
* with the object types not allowed as children for a record category
|
||||
@@ -146,8 +148,39 @@ public interface TestData
|
||||
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||
{ HOLD_TYPE },
|
||||
{ TRANSFER_TYPE },
|
||||
{ FOLDER_TYPE },
|
||||
{ CONTENT_TYPE }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Data Provider with:
|
||||
* with the object types for creating a Record Folder
|
||||
*
|
||||
* @return file plan component alias
|
||||
*/
|
||||
@DataProvider
|
||||
public static Object[][] folderTypes()
|
||||
{
|
||||
return new Object[][] {
|
||||
{ RECORD_FOLDER_TYPE },
|
||||
{ FOLDER_TYPE }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Data Provider with:
|
||||
* with the object types for creating a Record Category
|
||||
*
|
||||
* @return file plan component alias
|
||||
*/
|
||||
@DataProvider
|
||||
public static Object[][] categoryTypes()
|
||||
{
|
||||
return new Object[][] {
|
||||
{ FOLDER_TYPE },
|
||||
{ RECORD_CATEGORY_TYPE }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -49,6 +49,7 @@ import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -220,6 +221,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// created record will have record identifier inserted in its name but will be prefixed with
|
||||
// the name it was created as
|
||||
assertTrue(electronicRecord.getName().startsWith(record.getName()));
|
||||
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getRmIdentifier()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,6 +253,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// record will have record identifier inserted in its name but will for sure start with file name
|
||||
// and end with its extension
|
||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
||||
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getRmIdentifier()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -272,6 +275,11 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
.mimeType("text/plain")
|
||||
.build()
|
||||
)
|
||||
.properties(FilePlanComponentProperties
|
||||
.builder()
|
||||
.description(ELECTRONIC_RECORD_NAME)
|
||||
.build()
|
||||
)
|
||||
.relativePath(RELATIVE_PATH)
|
||||
.build();
|
||||
|
||||
@@ -283,6 +291,8 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getProperties().getDescription().equals(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId())
|
||||
.getName().equals(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
|
@@ -44,6 +44,7 @@ import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -142,6 +143,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
||||
String file = "File " + getRandomAlphanumeric();
|
||||
String shelf = "Shelf " + getRandomAlphanumeric();
|
||||
String location = "Location " + getRandomAlphanumeric();
|
||||
String name = "Record " + getRandomAlphanumeric();
|
||||
|
||||
Random random = new Random();
|
||||
Integer copies = random.nextInt(Integer.MAX_VALUE);
|
||||
@@ -149,7 +151,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
||||
|
||||
// set values of all available properties for the non electronic records
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.name(name)
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(title)
|
||||
@@ -183,6 +185,8 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
||||
assertEquals(location, nonElectronicRecord.getProperties().getLocation());
|
||||
assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
|
||||
assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
|
||||
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getRmIdentifier()));
|
||||
assertTrue(nonElectronicRecord.getName().contains(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -85,7 +85,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
||||
.build();
|
||||
|
||||
|
||||
private FilePlanComponent nonelectronicRecord = FilePlanComponent.builder()
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.description(NONELECTRONIC_RECORD_NAME)
|
||||
@@ -178,6 +178,8 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
assertNotNull(recordWithContent.getContent().getEncoding());
|
||||
assertNotNull(recordWithContent.getContent().getMimeType());
|
||||
assertNotNull(recordWithContent.getAspectNames());
|
||||
assertFalse(recordWithContent.getName().equals(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(recordWithContent.getName().contains(recordWithContent.getProperties().getRmIdentifier()));
|
||||
assertStatusCode(OK);
|
||||
|
||||
//create non-electronic record
|
||||
@@ -196,6 +198,8 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
assertNotNull(nonElectronicRecord.getContent().getMimeType());
|
||||
assertNotNull(nonElectronicRecord.getAspectNames());
|
||||
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
|
||||
assertFalse(nonElectronicRecord.getName().equals(NONELECTRONIC_RECORD_NAME));
|
||||
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getRmIdentifier()));
|
||||
assertStatusCode(OK);
|
||||
}
|
||||
|
||||
@@ -209,11 +213,11 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
{
|
||||
FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
|
||||
|
||||
String RECORD_ELECTRONIC = "Record " + getRandomAlphanumeric();
|
||||
String RECORD_ELECTRONIC_BINARY = "Binary Record" + getRandomAlphanumeric();
|
||||
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
||||
|
||||
|
||||
// create the containers from the relativePath
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
.name(FOLDER_NAME)
|
||||
@@ -221,7 +225,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
.relativePath(RELATIVE_PATH)
|
||||
.build();
|
||||
String folderId = filePlanComponentAPI.createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS).getId();
|
||||
|
||||
|
||||
// text file as an electronic record
|
||||
FilePlanComponent recordText = FilePlanComponent.builder()
|
||||
.name(RECORD_ELECTRONIC)
|
||||
@@ -237,19 +241,19 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
.name(RECORD_ELECTRONIC_BINARY)
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
|
||||
|
||||
String binaryRecordId = filePlanComponentAPI.createElectronicRecord(recordBinary, IMAGE_FILE, folderId).getId();
|
||||
// binary content, therefore compare respective SHA1 checksums in order to verify this is identical content
|
||||
try
|
||||
(
|
||||
InputStream recordContentStream = recordsAPI.getRecordContent(binaryRecordId).asInputStream();
|
||||
FileInputStream localFileStream = new FileInputStream(new File(Resources.getResource(IMAGE_FILE).getFile()));
|
||||
)
|
||||
)
|
||||
{
|
||||
assertEquals(DigestUtils.sha1(recordContentStream), DigestUtils.sha1(localFileStream));
|
||||
}
|
||||
assertStatusCode(OK);
|
||||
|
||||
|
||||
// electronic record with no content
|
||||
FilePlanComponent recordNoContent = FilePlanComponent.builder()
|
||||
.name(RECORD_ELECTRONIC)
|
||||
@@ -390,8 +394,9 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
|
||||
//assertEquals(createdComponent.getName(), filePlanComponent.getName());
|
||||
assertTrue(filePlanComponent.getName().startsWith(createdComponent.getName()));
|
||||
//check the record name
|
||||
assertTrue(filePlanComponent.getName().equals(createdComponent.getName()));
|
||||
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getRmIdentifier()));
|
||||
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
|
||||
|
||||
}
|
||||
|
@@ -70,12 +70,21 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
* Given that a file plan exists
|
||||
* When I ask the API to create a root record category
|
||||
* Then it is created as a root record category
|
||||
*
|
||||
*
|
||||
* Given that a file plan exists
|
||||
* When I use the API to create a folder (cm:folder type) into the fileplan
|
||||
* Then the folder is converted to rma:recordCategory
|
||||
* (see RM-4572 comments)
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
(
|
||||
description = "Create root category"
|
||||
description = "Create root category",
|
||||
dataProviderClass= TestData.class,
|
||||
dataProvider = "categoryTypes"
|
||||
)
|
||||
public void createCategoryTest() throws Exception
|
||||
public void createCategoryTest(String nodeType) throws Exception
|
||||
{
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
@@ -83,7 +92,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE)
|
||||
.nodeType(nodeType)
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
@@ -109,7 +118,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
// Verify the returned file plan component properties
|
||||
FilePlanComponentProperties filePlanComponentProperties = filePlanComponent.getProperties();
|
||||
assertEquals(filePlanComponentProperties.getTitle(), categoryTitle);
|
||||
|
||||
assertNotNull(filePlanComponentProperties.getRmIdentifier());
|
||||
logger.info("Aspects: " + filePlanComponent.getAspectNames());
|
||||
}
|
||||
|
||||
@@ -316,6 +325,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
|
||||
// Verify properties
|
||||
// FIXME: Verify properties
|
||||
assertNotNull(createdComponent.getProperties().getRmIdentifier());
|
||||
}
|
||||
catch (NoSuchElementException e)
|
||||
{
|
||||
@@ -336,7 +346,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
dataProvider = "childrenNotAllowedForCategory"
|
||||
|
||||
)
|
||||
@Bug (id="RM-4367")
|
||||
@Bug (id="RM-4367, RM-4572")
|
||||
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
||||
{
|
||||
String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
|
||||
|
@@ -74,12 +74,21 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
* Given that a record category exists
|
||||
* When I use the API to create a new record folder
|
||||
* Then it is created within the record category
|
||||
*
|
||||
* Given that a record category exists
|
||||
* When I use the API to create a folder (cm:folder type)
|
||||
* Then the folder is converted to rma:recordFolder within the record category
|
||||
* (see RM-4572 comments)
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
(
|
||||
description = "Create a folder into a record category"
|
||||
description = "Create a folder into a record category.",
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "folderTypes"
|
||||
)
|
||||
public void createFolderTest() throws Exception
|
||||
@Bug (id = "RM-4572")
|
||||
public void createFolderTest(String folderType) throws Exception
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
@@ -88,7 +97,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.nodeType(folderType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FOLDER_TITLE)
|
||||
.build())
|
||||
@@ -113,6 +122,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
// Verify the returned file plan component properties
|
||||
FilePlanComponentProperties folderProperties = folder.getProperties();
|
||||
assertEquals(folderProperties.getTitle(), FOLDER_TITLE);
|
||||
assertNotNull(folderProperties.getRmIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -39,6 +39,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentEntry;
|
||||
@@ -79,15 +80,15 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
// create test user and test collaboration site to store documents in
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
testUserReadOnly = dataUser.createRandomTestUser();
|
||||
|
||||
|
||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
dataUser.addUserToSite(testUserReadOnly, testSite, UserRole.SiteConsumer);
|
||||
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a document that is not a record
|
||||
@@ -103,17 +104,17 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
@Test(description = "User with correct permissions can declare document as a record")
|
||||
@AlfrescoTest(jira = "RM-4429")
|
||||
public void userWithPrivilegesCanDeclareDocumentAsRecord() throws Exception
|
||||
{
|
||||
// create document in a folder in a collaboration site
|
||||
{
|
||||
// create document in a folder in a collaboration site
|
||||
FileModel document = dataContent.usingSite(testSite)
|
||||
.usingUser(testUser)
|
||||
.usingResource(testFolder)
|
||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
|
||||
// declare document as record
|
||||
FilePlanComponent record = getRestAPIFactory().getFilesAPI(testUser).declareAsRecord(document.getNodeRefWithoutVersion());
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
// verify the declared record is in Unfiled Records folder
|
||||
FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
List<FilePlanComponentEntry> matchingRecords = filePlanComponentAPI.listChildComponents(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
@@ -125,23 +126,23 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
assertEquals(matchingRecords.size(), 1, "More than one record matching document name");
|
||||
|
||||
// verify the original file in collaboration site has been renamed to reflect the record identifier
|
||||
// FIXME: this call uses the FilePlanComponentAPI due to no TAS support for Node API in TAS restapi v 5.2.0-0. See RM-4585 for details.
|
||||
List<FilePlanComponentEntry> filesAfterRename = filePlanComponentAPI.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
List<RestNodeModel> filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder)
|
||||
.listChildren()
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(filesAfterRename.size(), 1, "There should be only one file in folder " + testFolder.getName());
|
||||
|
||||
// verify the new name has the form of "<original name> (<record Id>).<original extension>"
|
||||
assertEquals(filesAfterRename.get(0).getFilePlanComponentModel().getName(),
|
||||
document.getName().replace(".", String.format(" (%s).", record.getProperties().getRecordId())));
|
||||
String recordName = filesAfterRename.get(0).onModel().getName();
|
||||
assertEquals(recordName, document.getName().replace(".", String.format(" (%s).", record.getProperties().getRmIdentifier())));
|
||||
|
||||
// verify the document in collaboration site is now a record, note the file is now renamed hence folder + doc. name concatenation
|
||||
// this also verifies the document is still in the initial folder
|
||||
Document documentPostFiling = dataContent.usingSite(testSite)
|
||||
.usingUser(testUser)
|
||||
.getCMISDocument(testFolder.getCmisLocation() + "/" + filesAfterRename.get(0).getFilePlanComponentModel().getName());
|
||||
.getCMISDocument(testFolder.getCmisLocation() + "/" + recordName);
|
||||
|
||||
// a document is a record if "Record" is one of its secondary types
|
||||
List<SecondaryType> documentSecondary = documentPostFiling.getSecondaryTypes()
|
||||
@@ -151,7 +152,7 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
assertFalse(documentSecondary.isEmpty(), "Document is not a record");
|
||||
|
||||
// verify the document is readable and has same content as corresponding record
|
||||
try
|
||||
try
|
||||
(
|
||||
InputStream recordInputStream = getRestAPIFactory().getRecordsAPI().getRecordContent(record.getId()).asInputStream();
|
||||
InputStream documentInputStream = documentPostFiling.getContentStream().getStream();
|
||||
@@ -160,7 +161,7 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
assertEquals(DigestUtils.sha1(recordInputStream), DigestUtils.sha1(documentInputStream));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a document that is not a record
|
||||
@@ -172,26 +173,25 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
*/
|
||||
@Test(description = "User with read-only permissions can't declare document a record")
|
||||
@AlfrescoTest(jira = "RM-4429")
|
||||
public void userWithReadPermissionsCantDeclare() throws Exception
|
||||
public void userWithReadPermissionsCantDeclare() throws Exception
|
||||
{
|
||||
// create document in a folder in a collaboration site
|
||||
FileModel document = dataContent.usingSite(testSite)
|
||||
.usingUser(testUser)
|
||||
.usingResource(testFolder)
|
||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
|
||||
// declare document as record as testUserReadOnly
|
||||
getRestAPIFactory().getFilesAPI(testUserReadOnly).declareAsRecord(document.getNodeRefWithoutVersion());
|
||||
assertStatusCode(FORBIDDEN);
|
||||
|
||||
|
||||
// verify the document is still in the original folder
|
||||
// FIXME: this call uses the FilePlanComponentAPI due to no TAS support for Node API in TAS restapi v 5.2.0-0. See RM-4585 for details.
|
||||
List<FilePlanComponentEntry> filesAfterRename = getRestAPIFactory().getFilePlanComponentsAPI()
|
||||
.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
List<RestNodeModel> filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder)
|
||||
.listChildren()
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(filesAfterRename.size(), 1, "Declare as record failed but original document is missing");
|
||||
}
|
||||
|
||||
@@ -219,15 +219,15 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
FilePlanComponent record = getRestAPIFactory().getFilePlanComponentsAPI()
|
||||
.createFilePlanComponent(nonelectronicRecord, createCategoryFolderInFilePlan().getId());
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
// try to declare it as a record
|
||||
getRestAPIFactory().getFilesAPI().declareAsRecord(record.getId());
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a node that is NOT a document
|
||||
* Given a node that is NOT a document
|
||||
* When I declare the node as a record
|
||||
* Then I get a invalid operation exception
|
||||
* </pre>
|
||||
@@ -238,7 +238,7 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
public void nonDocumentCantBeDeclaredARecord() throws Exception
|
||||
{
|
||||
FolderModel otherTestFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
|
||||
// try to declare otherTestFolder as a record
|
||||
getRestAPIFactory().getFilesAPI().declareAsRecord(otherTestFolder.getNodeRefWithoutVersion());
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
|
Reference in New Issue
Block a user