mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge 'feature/RM-4921_ExceptionsDoneOnTransactionCommit' into feature/RM-5012_recordIdentifier
This commit is contained in:
@@ -28,8 +28,10 @@ package org.alfresco.rest.rm.community.model.fileplan;
|
|||||||
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_COMPONENT_ID;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_COMPONENT_ID;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_COUNT;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_COUNT;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
@@ -71,4 +73,10 @@ public class FilePlanProperties extends TestModel
|
|||||||
/************************/
|
/************************/
|
||||||
@JsonProperty (PROPERTIES_COUNT)
|
@JsonProperty (PROPERTIES_COUNT)
|
||||||
private Integer count;
|
private Integer count;
|
||||||
|
|
||||||
|
@JsonProperty (PROPERTIES_TITLE)
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@JsonProperty (PROPERTIES_DESCRIPTION)
|
||||||
|
private String description;
|
||||||
}
|
}
|
||||||
|
@@ -96,9 +96,6 @@ public class UnfiledContainerChild extends TestModel
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private List<String> aspectNames;
|
private List<String> aspectNames;
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
private Boolean hasRetentionSchedule;
|
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private Boolean isClosed;
|
private Boolean isClosed;
|
||||||
|
|
||||||
|
@@ -45,8 +45,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PHYSICAL_SIZE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PHYSICAL_SIZE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PIXEL_X_DIMENSION;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PIXEL_X_DIMENSION;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PIXEL_Y_DIMENSION;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PIXEL_Y_DIMENSION;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RESOLUTION_UNIT;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RESOLUTION_UNIT;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SHELF;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SHELF;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SOFTWARE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SOFTWARE;
|
||||||
@@ -54,7 +54,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VERSION_LABEL;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VERSION_LABEL;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VERSION_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VERSION_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION;
|
||||||
|
|
||||||
@@ -64,7 +63,6 @@ import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
|
|||||||
import org.alfresco.utility.model.TestModel;
|
import org.alfresco.utility.model.TestModel;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -92,22 +90,18 @@ public class UnfiledContainerChildProperties extends TestModel
|
|||||||
@JsonProperty (required = true, value = PROPERTIES_TITLE)
|
@JsonProperty (required = true, value = PROPERTIES_TITLE)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@JsonProperty (required = true, value = PROPERTIES_VITAL_RECORD_INDICATOR)
|
|
||||||
private Boolean vitalRecordIndicator;
|
|
||||||
|
|
||||||
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
|
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
|
||||||
private String rootNodeRef;
|
private String rootNodeRef;
|
||||||
|
|
||||||
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
|
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
|
||||||
private String identifier;
|
private String identifier;
|
||||||
|
|
||||||
@JsonProperty (required = true, value = PROPERTIES_REVIEW_PERIOD)
|
|
||||||
@JsonSerialize (using = ReviewPeriodSerializer.class)
|
|
||||||
private ReviewPeriod reviewPeriod;
|
|
||||||
|
|
||||||
@JsonProperty (required = true, value = PROPERTIES_DESCRIPTION)
|
@JsonProperty (required = true, value = PROPERTIES_DESCRIPTION)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@JsonProperty (value = PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
|
||||||
|
private Boolean recordSearchHasDispositionSchedule;
|
||||||
|
|
||||||
/*********************************/
|
/*********************************/
|
||||||
/** Electronic record parameters */
|
/** Electronic record parameters */
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
@@ -34,6 +34,7 @@ import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
|||||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
||||||
import static org.springframework.http.HttpMethod.GET;
|
import static org.springframework.http.HttpMethod.GET;
|
||||||
import static org.springframework.http.HttpMethod.POST;
|
import static org.springframework.http.HttpMethod.POST;
|
||||||
|
import static org.springframework.http.HttpMethod.PUT;
|
||||||
|
|
||||||
import org.alfresco.rest.core.RMRestWrapper;
|
import org.alfresco.rest.core.RMRestWrapper;
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||||
@@ -172,4 +173,44 @@ public class FilePlanAPI extends RMModelRequest
|
|||||||
parameters
|
parameters
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* see {@link #updateFilePlan(FilePlan, String, String)
|
||||||
|
*/
|
||||||
|
public FilePlan updateFilePlan(FilePlan filePlanModel, String filePlanId) throws Exception
|
||||||
|
{
|
||||||
|
mandatoryObject("filePlanModel", filePlanModel);
|
||||||
|
mandatoryString("filePlanId", filePlanId);
|
||||||
|
|
||||||
|
return updateFilePlan(filePlanModel, filePlanId, EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a file plan.
|
||||||
|
*
|
||||||
|
* @param filePlanModel The file plan model which holds the information
|
||||||
|
* @param filePlanId The identifier of the file plan
|
||||||
|
* @param parameters The URL parameters to add
|
||||||
|
* @throws Exception for the following cases:
|
||||||
|
* <ul>
|
||||||
|
* <li>the update request is invalid or {@code filePlanId} is not a valid format or {@code filePlanModel} is invalid</li>
|
||||||
|
* <li>authentication fails</li>
|
||||||
|
* <li>current user does not have permission to update {@code filePlanId}</li>
|
||||||
|
* <li>{@code filePlanId} does not exist</li>
|
||||||
|
* <li>model integrity exception, including file name with invalid characters</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public FilePlan updateFilePlan(FilePlan filePlanModel, String filePlanId, String parameters) throws Exception
|
||||||
|
{
|
||||||
|
mandatoryObject("filePlanModel", filePlanModel);
|
||||||
|
mandatoryString("filePlanId", filePlanId);
|
||||||
|
|
||||||
|
return getRmRestWrapper().processModel(FilePlan.class, requestWithBody(
|
||||||
|
PUT,
|
||||||
|
toJson(filePlanModel),
|
||||||
|
"file-plans/{filePlanId}?{parameters}",
|
||||||
|
filePlanId,
|
||||||
|
parameters));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -263,7 +263,7 @@ public class RecordFolderAPI extends RMModelRequest
|
|||||||
* Creates a record in a record folder child, i.e. a record.
|
* Creates a record in a record folder child, i.e. a record.
|
||||||
*
|
*
|
||||||
* @param recordModel The record model which holds the information
|
* @param recordModel The record model which holds the information
|
||||||
* @param recordfolderId The identifier of a record folder
|
* @param recordFolderId The identifier of a record folder
|
||||||
* @param parameters The URL parameters to add
|
* @param parameters The URL parameters to add
|
||||||
* @return The created {@link Record}
|
* @return The created {@link Record}
|
||||||
* @throws Exception for the following cases:
|
* @throws Exception for the following cases:
|
||||||
|
@@ -108,7 +108,7 @@ public class UnfiledContainerAPI extends RMModelRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* see {@link #getRootRecordCategories(String, String)}
|
* see {@link #getUnfiledContainerChildren(String)} (String, String)}
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChildCollection getUnfiledContainerChildren(String unfiledContainerId)
|
public UnfiledContainerChildCollection getUnfiledContainerChildren(String unfiledContainerId)
|
||||||
{
|
{
|
||||||
|
@@ -80,22 +80,6 @@ public interface TestData
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Data Provider with:
|
|
||||||
* the special file plan components alias
|
|
||||||
* file plan component node type
|
|
||||||
* @return file plan component alias
|
|
||||||
*/
|
|
||||||
@DataProvider
|
|
||||||
public static String[][] getContainersAndTypes()
|
|
||||||
{
|
|
||||||
return new String[][] {
|
|
||||||
{ FILE_PLAN_ALIAS, FILE_PLAN_TYPE },
|
|
||||||
{ TRANSFERS_ALIAS, TRANSFER_CONTAINER_TYPE },
|
|
||||||
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default record category name used when creating categories
|
* The default record category name used when creating categories
|
||||||
*/
|
*/
|
||||||
@@ -174,4 +158,20 @@ public interface TestData
|
|||||||
{ RECORD_CATEGORY_TYPE }
|
{ RECORD_CATEGORY_TYPE }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid root level types, at unfiled record folder/unfiled containers container level that shouldn't be possible to create
|
||||||
|
*/
|
||||||
|
@DataProvider (name = "invalidRootTypes")
|
||||||
|
public static Object[][] getInvalidRootTypes()
|
||||||
|
{
|
||||||
|
return new String[][]
|
||||||
|
{
|
||||||
|
{ FILE_PLAN_TYPE },
|
||||||
|
{ RECORD_CATEGORY_TYPE },
|
||||||
|
{ RECORD_FOLDER_TYPE },
|
||||||
|
{ TRANSFER_CONTAINER_TYPE },
|
||||||
|
{ UNFILED_CONTAINER_TYPE }
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,258 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%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.fileplancomponents;
|
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
import static org.alfresco.rest.rm.community.base.AllowableOperations.CREATE;
|
|
||||||
import static org.alfresco.rest.rm.community.base.AllowableOperations.DELETE;
|
|
||||||
import static org.alfresco.rest.rm.community.base.AllowableOperations.UPDATE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.base.TestData;
|
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
|
||||||
import org.alfresco.rest.rm.community.model.transfercontainer.TransferContainer;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the tests for the File Plan CRUD API
|
|
||||||
*
|
|
||||||
* @author Rodica Sutu
|
|
||||||
* @since 2.6
|
|
||||||
*/
|
|
||||||
public class FilePlanTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that the RM site doesn't exist
|
|
||||||
* When I use the API to get the File Plan/Holds/Unfiled Records Container/Transfers
|
|
||||||
* Then I get the 404 response code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Check the GET response for the special contianers when the RM site doesn't exist",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "getContainers"
|
|
||||||
)
|
|
||||||
public void getContainersWhenRMIsNotCreated(String containerAlias) throws Exception
|
|
||||||
{
|
|
||||||
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
|
||||||
|
|
||||||
// Check RM Site Exist
|
|
||||||
if (rmSiteAPI.existsRMSite())
|
|
||||||
{
|
|
||||||
// Delete RM Site
|
|
||||||
rmSiteAPI.deleteRMSite();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getFilePlansAPI().getFilePlan(containerAlias);
|
|
||||||
}
|
|
||||||
else if(TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getTransferContainerAPI().getTransferContainer(containerAlias);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(containerAlias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the response code is NOT_FOUND
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a file plan exists
|
|
||||||
* When I ask the API for the details of the file plan
|
|
||||||
* Then I am given the details of the file plan
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Check the GET response for the special containers when the RM site exit",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "getContainersAndTypes"
|
|
||||||
)
|
|
||||||
public void getContainersWhenRMIsCreated(String containerAlias, String containerType) throws Exception
|
|
||||||
{
|
|
||||||
// Create RM Site if doesn't exist
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
// Get the file plan special container
|
|
||||||
FilePlan filePlan = null;
|
|
||||||
TransferContainer transferContainer = null;
|
|
||||||
UnfiledContainer unfiledContainer = null;
|
|
||||||
|
|
||||||
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(containerAlias);
|
|
||||||
}
|
|
||||||
else if(TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
transferContainer = getRestAPIFactory().getTransferContainerAPI().getTransferContainer(containerAlias);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unfiledContainer = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(containerAlias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the response code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Check the response contains the right node type
|
|
||||||
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
assertEquals(filePlan.getNodeType(), containerType);
|
|
||||||
}
|
|
||||||
else if(TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
assertEquals(transferContainer.getNodeType(), containerType);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assertEquals(unfiledContainer.getNodeType(), containerType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a file plan exists
|
|
||||||
* When I ask the API for the details of the file plan to include the allowableOperations property
|
|
||||||
* Then I am given the allowableOperations property with the update and create operations.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Check the allowableOperations list returned",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "getContainers"
|
|
||||||
)
|
|
||||||
public void includeAllowableOperations(String containerAlias) throws Exception
|
|
||||||
{
|
|
||||||
// Create RM Site if doesn't exist
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
// Get the file plan special containers with the optional parameter allowableOperations
|
|
||||||
FilePlan filePlan = null;
|
|
||||||
TransferContainer transferContainer = null;
|
|
||||||
UnfiledContainer unfiledContainer = null;
|
|
||||||
|
|
||||||
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
// Check the list of allowableOperations returned
|
|
||||||
filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(containerAlias, "include=" + ALLOWABLE_OPERATIONS);
|
|
||||||
|
|
||||||
assertTrue(filePlan.getAllowableOperations().containsAll(asList(UPDATE, CREATE)),
|
|
||||||
"Wrong list of the allowable operations is return" + filePlan.getAllowableOperations().toString());
|
|
||||||
|
|
||||||
// Check the list of allowableOperations doesn't contain DELETE operation
|
|
||||||
assertFalse(filePlan.getAllowableOperations().contains(DELETE),
|
|
||||||
"The list of allowable operations contains delete option" + filePlan.getAllowableOperations().toString());
|
|
||||||
}
|
|
||||||
else if (TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
// Check the list of allowableOperations returned
|
|
||||||
transferContainer = getRestAPIFactory().getTransferContainerAPI().getTransferContainer(containerAlias, "include=" + ALLOWABLE_OPERATIONS);
|
|
||||||
|
|
||||||
assertTrue(transferContainer.getAllowableOperations().containsAll(asList(UPDATE)),
|
|
||||||
"Wrong list of the allowable operations is return" + transferContainer.getAllowableOperations().toString());
|
|
||||||
|
|
||||||
// Check the list of allowableOperations doesn't contain DELETE operation
|
|
||||||
assertFalse(transferContainer.getAllowableOperations().contains(DELETE),
|
|
||||||
"The list of allowable operations contains delete option" + transferContainer.getAllowableOperations().toString());
|
|
||||||
|
|
||||||
// Check the list of allowableOperations doesn't contain DELETE operation
|
|
||||||
assertFalse(transferContainer.getAllowableOperations().contains(CREATE),
|
|
||||||
"The list of allowable operations contains delete option" + transferContainer.getAllowableOperations().toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unfiledContainer = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(containerAlias, "include=" + ALLOWABLE_OPERATIONS);
|
|
||||||
|
|
||||||
// Check the list of allowableOperations returned
|
|
||||||
assertTrue(unfiledContainer.getAllowableOperations().containsAll(asList(UPDATE, CREATE)),
|
|
||||||
"Wrong list of the allowable operations is return" + unfiledContainer.getAllowableOperations().toString());
|
|
||||||
|
|
||||||
// Check the list of allowableOperations doesn't contain DELETE operation
|
|
||||||
assertFalse(unfiledContainer.getAllowableOperations().contains(DELETE),
|
|
||||||
"The list of allowable operations contains delete option" + unfiledContainer.getAllowableOperations().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that RM site exists
|
|
||||||
* When a non-RM user asks the API for the details of the file plan
|
|
||||||
* Then the status code 403 (Permission denied) is return
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Check the response code when the RM site containers are get with non-RM users",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "getContainers"
|
|
||||||
)
|
|
||||||
public void getContainersWithNonRMuser(String containerAlias) throws Exception
|
|
||||||
{
|
|
||||||
// Create RM Site if doesn't exist
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
// Create a random user
|
|
||||||
UserModel nonRMuser = getDataUser().createRandomTestUser("testUser");
|
|
||||||
|
|
||||||
// Get the special file plan components
|
|
||||||
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getFilePlansAPI(nonRMuser).getFilePlan(containerAlias);
|
|
||||||
}
|
|
||||||
else if(TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getTransferContainerAPI(nonRMuser).getTransferContainer(containerAlias);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getUnfiledContainersAPI(nonRMuser).getUnfiledContainer(containerAlias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the response status code is FORBIDDEN
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,331 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%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.fileplancomponents;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
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.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
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.assertNotNull;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.base.TestData;
|
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryProperties;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
|
||||||
import org.alfresco.utility.report.Bug;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Record category related API tests
|
|
||||||
*
|
|
||||||
* @author Kristijan Conkas
|
|
||||||
* @author Tuna Aksoy
|
|
||||||
* @since 2.6
|
|
||||||
*/
|
|
||||||
public class RecordCategoryTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
/** Number of children (for children creation test) */
|
|
||||||
private static final int NUMBER_OF_CHILDREN = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 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
|
|
||||||
* </pre>
|
|
||||||
* <pre>
|
|
||||||
* 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)
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Create root category",
|
|
||||||
dataProviderClass= TestData.class,
|
|
||||||
dataProvider = "categoryTypes"
|
|
||||||
)
|
|
||||||
public void createCategoryTest(String nodeType) throws Exception
|
|
||||||
{
|
|
||||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
|
||||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the root record category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(categoryName, categoryTitle);
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
assertEquals(rootRecordCategory.getName(), categoryName);
|
|
||||||
assertEquals(rootRecordCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
|
||||||
|
|
||||||
assertEquals(rootRecordCategory.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
// Verify the returned root record category properties
|
|
||||||
RecordCategoryProperties rootRecordCategoryProperties = rootRecordCategory.getProperties();
|
|
||||||
assertEquals(rootRecordCategoryProperties.getTitle(), categoryTitle);
|
|
||||||
assertNotNull(rootRecordCategoryProperties.getIdentifier());
|
|
||||||
logger.info("Aspects: " + rootRecordCategory.getAspectNames());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to update the details of the record category
|
|
||||||
* Then the details of the record category are updated
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Rename root category"
|
|
||||||
)
|
|
||||||
public void renameCategory() throws Exception
|
|
||||||
{
|
|
||||||
// Create record category first
|
|
||||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
|
||||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the root record category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(categoryName, categoryTitle);
|
|
||||||
|
|
||||||
String newCategoryName = "Rename " + categoryName;
|
|
||||||
|
|
||||||
// Build the properties which will be updated
|
|
||||||
RecordCategory recordCategoryUpdated = RecordCategory.builder().name(newCategoryName).build();
|
|
||||||
|
|
||||||
// Update the record category
|
|
||||||
RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated, rootRecordCategory.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Verify the returned file plan component
|
|
||||||
assertEquals(renamedRecordCategory.getName(), newCategoryName);
|
|
||||||
|
|
||||||
// Get actual FILE_PLAN_ALIAS id
|
|
||||||
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
// verify renamed component still has this parent
|
|
||||||
assertEquals(renamedRecordCategory.getParentId(), filePlan.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to delete the record category
|
|
||||||
* Then the record category and all its contents are deleted
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Delete category"
|
|
||||||
)
|
|
||||||
public void deleteCategory() throws Exception
|
|
||||||
{
|
|
||||||
// Create record category first
|
|
||||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
|
||||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the root record category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(categoryName, categoryTitle);
|
|
||||||
|
|
||||||
// Delete the record category
|
|
||||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
|
||||||
String recordCategoryId = rootRecordCategory.getId();
|
|
||||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NO_CONTENT);
|
|
||||||
|
|
||||||
// Deleted component should no longer be retrievable
|
|
||||||
recordCategoryAPI.getRecordCategory(recordCategoryId);
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to create a record category
|
|
||||||
* Then it is created within the record category
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Create child category"
|
|
||||||
)
|
|
||||||
public void createSubcategory() throws Exception
|
|
||||||
{
|
|
||||||
// Create root level category
|
|
||||||
RecordCategory rootCategory = createRootCategory(getRandomAlphanumeric());
|
|
||||||
assertNotNull(rootCategory.getId());
|
|
||||||
|
|
||||||
// Create sub-category as a child of rootCategory
|
|
||||||
RecordCategoryChild recordCategory = createRecordCategoryChild(rootCategory.getId(), RECORD_CATEGORY_NAME, RECORD_CATEGORY_TYPE);
|
|
||||||
|
|
||||||
// Child category created?
|
|
||||||
assertNotNull(recordCategory.getId());
|
|
||||||
|
|
||||||
// Verify child category
|
|
||||||
assertEquals(recordCategory.getParentId(), rootCategory.getId());
|
|
||||||
assertTrue(recordCategory.getIsRecordCategory());
|
|
||||||
assertFalse(recordCategory.getIsRecordFolder());
|
|
||||||
assertEquals(recordCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* And contains a number of record categories and record folders
|
|
||||||
* When I ask the API to get me the children of the record category
|
|
||||||
* Then I am returned the contained record categories and record folders and their details
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Get children of a record category"
|
|
||||||
)
|
|
||||||
public void getRecordCategoryChildren() throws Exception
|
|
||||||
{
|
|
||||||
// Create root level category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric());
|
|
||||||
assertNotNull(rootRecordCategory.getId());
|
|
||||||
|
|
||||||
// Add record category children
|
|
||||||
List<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>();
|
|
||||||
for (int i=0; i < NUMBER_OF_CHILDREN; i++)
|
|
||||||
{
|
|
||||||
// Create a record category child
|
|
||||||
RecordCategoryChild child = createRecordCategoryChild(rootRecordCategory.getId(),
|
|
||||||
getRandomAlphanumeric(),
|
|
||||||
// half of the children should be sub-categories, the other sub-folders
|
|
||||||
(i <= NUMBER_OF_CHILDREN / 2) ? RECORD_CATEGORY_TYPE : RECORD_FOLDER_TYPE);
|
|
||||||
assertNotNull(child.getId());
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get children from API
|
|
||||||
RecordCategoryChildCollection recordCategoryChildren = getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(rootRecordCategory.getId(),"include=isRecordCategory,isRecordFolder");
|
|
||||||
|
|
||||||
// Check status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
logger.info("Parent: " + rootRecordCategory.getId());
|
|
||||||
|
|
||||||
// Check listed children against created list
|
|
||||||
recordCategoryChildren.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
RecordCategoryChild recordCategoryChild = c.getEntry();
|
|
||||||
String recordCategoryChildId = recordCategoryChild.getId();
|
|
||||||
|
|
||||||
assertNotNull(recordCategoryChildId);
|
|
||||||
logger.info("Checking child " + recordCategoryChildId);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Find this child in created children list
|
|
||||||
RecordCategoryChild createdComponent = children.stream()
|
|
||||||
.filter(child -> child.getId().equals(recordCategoryChildId))
|
|
||||||
.findFirst()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
// Is parent id set correctly?
|
|
||||||
assertEquals(recordCategoryChild.getParentId(), rootRecordCategory.getId());
|
|
||||||
|
|
||||||
// Boolean properties related to node type
|
|
||||||
// Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created
|
|
||||||
if (recordCategoryChild.getNodeType().equals(RECORD_CATEGORY_TYPE))
|
|
||||||
{
|
|
||||||
assertTrue(recordCategoryChild.getIsRecordCategory());
|
|
||||||
assertFalse(recordCategoryChild.getIsRecordFolder());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assertTrue(recordCategoryChild.getIsRecordFolder());
|
|
||||||
assertFalse(recordCategoryChild.getIsRecordCategory());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Does returned object have the same contents as the created one?
|
|
||||||
assertEquals(createdComponent.getName(), recordCategoryChild.getName());
|
|
||||||
assertEquals(createdComponent.getNodeType(), recordCategoryChild.getNodeType());
|
|
||||||
|
|
||||||
// FIXME: Verify properties
|
|
||||||
assertNotNull(createdComponent.getProperties().getIdentifier());
|
|
||||||
}
|
|
||||||
catch (NoSuchElementException e)
|
|
||||||
{
|
|
||||||
fail("No child element for " + recordCategoryChildId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask to create an object type which is not a record category or a record folder as a child
|
|
||||||
* Then the children are not created and the 422 response code is returned
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Create node types not allowed inside a category",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "childrenNotAllowedForCategory"
|
|
||||||
)
|
|
||||||
@Bug (id="RM-4367, RM-4572")
|
|
||||||
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
|
||||||
{
|
|
||||||
String componentName = "Component" + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(componentName);
|
|
||||||
|
|
||||||
// Create the invalid node type
|
|
||||||
createRecordCategoryChild(rootRecordCategory.getId(), componentName, nodeType);
|
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,530 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%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.fileplancomponents;
|
|
||||||
|
|
||||||
import static java.time.LocalDateTime.now;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_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_CATEGORY_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.base.TestData;
|
|
||||||
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildProperties;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
|
||||||
import org.alfresco.utility.report.Bug;
|
|
||||||
import org.testng.AssertJUnit;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.AfterMethod;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the tests for the Record Folder CRUD API
|
|
||||||
*
|
|
||||||
* @author Rodica Sutu
|
|
||||||
* @since 2.6
|
|
||||||
*/
|
|
||||||
public class RecordFolderTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private static final int NUMBER_OF_FOLDERS = 5;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 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
|
|
||||||
* </pre>
|
|
||||||
* <pre>
|
|
||||||
* 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)
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Create a record folder into a record category.",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "folderTypes"
|
|
||||||
)
|
|
||||||
@Bug (id = "RM-4572")
|
|
||||||
public void createFolderTest(String folderType) throws Exception
|
|
||||||
{
|
|
||||||
// Authenticate with admin user
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Create the record folder
|
|
||||||
RecordCategoryChild recordFolder = createRecordCategoryChild(rootRecordCategory.getId(), RECORD_FOLDER_NAME, folderType);
|
|
||||||
|
|
||||||
// Assert status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
// Check record folder has been created within the record category
|
|
||||||
AssertJUnit.assertEquals(rootRecordCategory.getId(), recordFolder.getParentId());
|
|
||||||
|
|
||||||
// Verify the returned values for the record folder
|
|
||||||
assertFalse(recordFolder.getIsRecordCategory());
|
|
||||||
assertTrue(recordFolder.getIsRecordFolder());
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
// Verify the returned record folder properties
|
|
||||||
RecordCategoryChildProperties folderProperties = recordFolder.getProperties();
|
|
||||||
AssertJUnit.assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
|
|
||||||
assertNotNull(folderProperties.getIdentifier());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that RM site is created
|
|
||||||
* When I use the API to create a new record folder into transfers/holds/unfiled containers
|
|
||||||
* Then the operation fails
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Create a record folder into transfers/unfiled/file plan container",
|
|
||||||
dataProviderClass = TestData.class,
|
|
||||||
dataProvider = "getContainers"
|
|
||||||
)
|
|
||||||
@Bug(id="RM-4327")
|
|
||||||
public void createRecordFolderIntoSpecialContainers(String containerAlias) throws Exception
|
|
||||||
{
|
|
||||||
String containerId;
|
|
||||||
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
containerId = getRestAPIFactory().getFilePlansAPI().getFilePlan(containerAlias).getId();
|
|
||||||
}
|
|
||||||
else if(TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
|
||||||
{
|
|
||||||
containerId = getRestAPIFactory().getTransferContainerAPI().getTransferContainer(containerAlias).getId();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//is unfiled container
|
|
||||||
containerId = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(containerAlias).getId();;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a record folder
|
|
||||||
createRecordFolder(containerId, RECORD_FOLDER_NAME);
|
|
||||||
|
|
||||||
// Check the API Response code
|
|
||||||
assertStatusCode(BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record folder exists
|
|
||||||
* When I ask for the details of a record folder
|
|
||||||
* Then I am given the details of a record folder
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Check the details of a record folder"
|
|
||||||
)
|
|
||||||
public void checkRecordFolderDetails() throws Exception
|
|
||||||
{
|
|
||||||
// Create a category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Create a folder
|
|
||||||
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME);
|
|
||||||
|
|
||||||
// Get the folder including extra information
|
|
||||||
RecordFolder recordFolder = getRestAPIFactory().getRecordFolderAPI().getRecordFolder(recordCategoryChild.getId(), "include=" + IS_CLOSED);
|
|
||||||
|
|
||||||
// Verify the returned record folder details
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
|
|
||||||
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getModifiedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
AssertJUnit.assertEquals(recordFolder.getProperties().getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record folder exists
|
|
||||||
* When I use the API to update its details
|
|
||||||
* Then the details of the record folder are updated
|
|
||||||
* The above test does treat any custom metadata
|
|
||||||
* Note: The details of the record folder includes any custom meta-data
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Update the details of a record folder"
|
|
||||||
)
|
|
||||||
public void updateRecordFolderDetails() throws Exception
|
|
||||||
{
|
|
||||||
// Create a record category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Create a record folder
|
|
||||||
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME);
|
|
||||||
|
|
||||||
// Create record category first
|
|
||||||
String folderDescription = "The folder description is updated" + getRandomAlphanumeric();
|
|
||||||
String folderName = "The folder name is updated" + getRandomAlphanumeric();
|
|
||||||
String folderTitle = "Update title " + getRandomAlphanumeric();
|
|
||||||
String location = "Location "+ getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the record folder properties to update
|
|
||||||
RecordFolder recordFolder = RecordFolder.builder()
|
|
||||||
.name(folderName)
|
|
||||||
.properties(RecordFolderProperties.builder()
|
|
||||||
.title(folderTitle)
|
|
||||||
.description(folderDescription)
|
|
||||||
.vitalRecordIndicator(true)
|
|
||||||
.reviewPeriod(new ReviewPeriod("month","1"))
|
|
||||||
.location(location)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Update the record folder
|
|
||||||
RecordFolder updatedRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordCategoryChild.getId());
|
|
||||||
|
|
||||||
// Check the Response Status Code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Verify the returned details for the record folder
|
|
||||||
AssertJUnit.assertEquals(updatedRecordFolder.getName(), folderName);
|
|
||||||
RecordFolderProperties recordFolderProperties = updatedRecordFolder.getProperties();
|
|
||||||
AssertJUnit.assertEquals(recordFolderProperties.getDescription(), folderDescription);
|
|
||||||
AssertJUnit.assertEquals(recordFolderProperties.getTitle(), folderTitle);
|
|
||||||
assertTrue(recordFolderProperties.getVitalRecordIndicator());
|
|
||||||
AssertJUnit.assertEquals(recordFolderProperties.getLocation(), location);
|
|
||||||
assertNotNull(recordFolderProperties.getReviewPeriod().getPeriodType());
|
|
||||||
assertNotNull(recordFolderProperties.getReviewPeriod().getExpression());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record folder exists
|
|
||||||
* When I use the API to delete the record folder
|
|
||||||
* Then it is deleted according to the normal rules governing the deletion of record folders
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Delete record folder"
|
|
||||||
)
|
|
||||||
public void deleteRecordFolder() throws Exception
|
|
||||||
{
|
|
||||||
// Create the record category
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Create the record folder
|
|
||||||
RecordCategoryChild recordFolder = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME);
|
|
||||||
|
|
||||||
// Delete the record folder
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
String recordFolderId = recordFolder.getId();
|
|
||||||
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
|
||||||
|
|
||||||
// Check the response status code
|
|
||||||
assertStatusCode(NO_CONTENT);
|
|
||||||
|
|
||||||
// Check the record folder is not found
|
|
||||||
recordFolderAPI.getRecordFolder(recordFolderId);
|
|
||||||
|
|
||||||
// Check the response status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* And contains several record folders
|
|
||||||
* When I use the API to get the record category children for an existing record category
|
|
||||||
* Then I am provided with a list of the contained record category children and their details
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Get children of a record category"
|
|
||||||
)
|
|
||||||
public void getFolders() throws Exception
|
|
||||||
{
|
|
||||||
// Authenticate with admin user
|
|
||||||
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Add child folders
|
|
||||||
ArrayList<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>();
|
|
||||||
for (int i = 0; i < NUMBER_OF_FOLDERS; i++)
|
|
||||||
{
|
|
||||||
// Create a record folder
|
|
||||||
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), getRandomAlphanumeric());
|
|
||||||
assertNotNull(recordCategoryChild.getId());
|
|
||||||
children.add(recordCategoryChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get record category children from API
|
|
||||||
RecordCategoryChildCollection recordCategoryChildren = getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(rootRecordCategory.getId(), "include=isRecordCategory,isRecordFolder");
|
|
||||||
|
|
||||||
// Check status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Check children against created list
|
|
||||||
recordCategoryChildren.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
RecordCategoryChild recordCategoryChild = c.getEntry();
|
|
||||||
String recordCategoryChildId = recordCategoryChild.getId();
|
|
||||||
assertNotNull(recordCategoryChildId);
|
|
||||||
logger.info("Checking child " + recordCategoryChildId);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Find this child in created children list
|
|
||||||
RecordCategoryChild createdComponent = children.stream()
|
|
||||||
.filter(child -> child.getId().equals(recordCategoryChildId))
|
|
||||||
.findFirst()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
// Is parent id set correctly
|
|
||||||
assertEquals(recordCategoryChild.getParentId(), rootRecordCategory.getId());
|
|
||||||
|
|
||||||
// Boolean properties related to node type
|
|
||||||
assertTrue(recordCategoryChild.getIsRecordFolder());
|
|
||||||
assertFalse(recordCategoryChild.getIsRecordCategory());
|
|
||||||
|
|
||||||
assertEquals(createdComponent.getName(), recordCategoryChild.getName());
|
|
||||||
assertEquals(createdComponent.getNodeType(), recordCategoryChild.getNodeType());
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (NoSuchElementException e)
|
|
||||||
{
|
|
||||||
fail("No child element for " + recordCategoryChildId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 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
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "Create a folder using record-categories endpoint, based on the relativePath. " +
|
|
||||||
"Containers in the relativePath that do not exist are created before the node is created"
|
|
||||||
)
|
|
||||||
public void createRecordFolderWithRelativePath() throws Exception
|
|
||||||
{
|
|
||||||
// The record category to be created
|
|
||||||
RecordCategory recordCategoryModel = RecordCategory.builder()
|
|
||||||
.name(RECORD_CATEGORY_NAME)
|
|
||||||
.nodeType(RECORD_CATEGORY_TYPE)
|
|
||||||
.build();
|
|
||||||
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI();
|
|
||||||
RecordCategory createRootRecordCategory = filePlansAPI.createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS, "include=" + PATH);
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
String recordCategoryId = createRootRecordCategory.getId();
|
|
||||||
|
|
||||||
// relativePath specify the container structure to create relative to the record folder to be created
|
|
||||||
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth();
|
|
||||||
|
|
||||||
// The record folder to be created
|
|
||||||
RecordCategoryChild recordFolderModel = RecordCategoryChild.builder()
|
|
||||||
.name(RECORD_FOLDER_NAME)
|
|
||||||
.nodeType(RECORD_FOLDER_TYPE)
|
|
||||||
.relativePath(relativePath)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Create the record folder
|
|
||||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
|
||||||
RecordCategoryChild recordCategoryChild = recordCategoryAPI.createRecordCategoryChild(recordFolderModel, recordCategoryId, "include=" + PATH);
|
|
||||||
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
// Verify the returned details for the record folder
|
|
||||||
assertFalse(recordCategoryChild.getIsRecordCategory());
|
|
||||||
assertTrue(recordCategoryChild.getIsRecordFolder());
|
|
||||||
|
|
||||||
// Check the path return contains the relativePath
|
|
||||||
AssertJUnit.assertTrue(recordCategoryChild.getPath().getName().contains(relativePath));
|
|
||||||
|
|
||||||
// Check the parent is a category
|
|
||||||
assertNotNull(recordCategoryAPI.getRecordCategory(recordCategoryChild.getParentId()).getId());
|
|
||||||
|
|
||||||
// Check the created folder from the server
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
RecordFolder recordFolder = recordFolderAPI.getRecordFolder(recordCategoryChild.getId(), "include=" + PATH);
|
|
||||||
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Verify the returned details for the record folder
|
|
||||||
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
|
|
||||||
|
|
||||||
// Check the path return contains the relativePath
|
|
||||||
AssertJUnit.assertTrue(recordFolder.getPath().getName().contains(relativePath));
|
|
||||||
|
|
||||||
// New relative path only a part of containers need to be created before the record folder
|
|
||||||
String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1);
|
|
||||||
|
|
||||||
// The record folder to be created
|
|
||||||
RecordCategoryChild newRecordFolderModel = RecordCategoryChild.builder()
|
|
||||||
.name(RECORD_FOLDER_NAME)
|
|
||||||
.nodeType(RECORD_FOLDER_TYPE)
|
|
||||||
.relativePath(newRelativePath)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Create the record folder
|
|
||||||
RecordCategoryChild newRecordCategoryChild = recordCategoryAPI.createRecordCategoryChild(newRecordFolderModel, recordCategoryId, "include=" + PATH);
|
|
||||||
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
// Verify the returned properties for the file plan component - record folder
|
|
||||||
assertFalse(newRecordCategoryChild.getIsRecordCategory());
|
|
||||||
assertTrue(newRecordCategoryChild.getIsRecordFolder());
|
|
||||||
|
|
||||||
// Check the path return contains the newRelativePath
|
|
||||||
AssertJUnit.assertTrue(newRecordCategoryChild.getPath().getName().contains(newRelativePath));
|
|
||||||
|
|
||||||
// Check the parent is a category
|
|
||||||
assertNotNull(recordCategoryAPI.getRecordCategory(newRecordCategoryChild.getParentId()).getId());
|
|
||||||
|
|
||||||
// Check the folder created on the server
|
|
||||||
RecordFolder newRecordFolder = recordFolderAPI.getRecordFolder(newRecordCategoryChild.getId(), "include=" + PATH);
|
|
||||||
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Verify the returned details for the record folder
|
|
||||||
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
|
|
||||||
|
|
||||||
// Check the path return contains the newRelativePath
|
|
||||||
AssertJUnit.assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given that a record folder exists
|
|
||||||
* When the record folder is closed
|
|
||||||
* Then a request can be made to reopen it
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
(
|
|
||||||
description = "A closed record folder can be reopened"
|
|
||||||
)
|
|
||||||
@Bug(id="RM-4808")
|
|
||||||
public void openClosedRecordFolder() throws Exception
|
|
||||||
{
|
|
||||||
// Create a record folder
|
|
||||||
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
|
|
||||||
// Assert that the record folder is not closed
|
|
||||||
assertFalse(recordFolder.getProperties().getIsClosed());
|
|
||||||
|
|
||||||
// Get the record folder API
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
|
|
||||||
// Create a record folder model to close it
|
|
||||||
RecordFolder recordFolderModel = RecordFolder.builder()
|
|
||||||
.properties(RecordFolderProperties.builder()
|
|
||||||
.isClosed(true)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Make a request to close the record folder
|
|
||||||
RecordFolder updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
|
|
||||||
|
|
||||||
//FIXME - remove this workaround after RM-4921 is fixed.
|
|
||||||
updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
|
|
||||||
|
|
||||||
// Verify that the record folder is closed now
|
|
||||||
assertTrue(updatedRecordFolder.getProperties().getIsClosed());
|
|
||||||
|
|
||||||
// Create a record folder model to reopen it
|
|
||||||
recordFolderModel = RecordFolder.builder()
|
|
||||||
.properties(RecordFolderProperties.builder()
|
|
||||||
.isClosed(false)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Make a request to reopen the record folder
|
|
||||||
updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
|
|
||||||
|
|
||||||
//FIXME - remove this workaround after RM-4921 is fixed.
|
|
||||||
updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
|
|
||||||
|
|
||||||
// Verify that the record folder is open now
|
|
||||||
assertFalse(updatedRecordFolder.getProperties().getIsClosed());
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterMethod
|
|
||||||
@AfterClass (alwaysRun = true)
|
|
||||||
public void tearDown() throws Exception
|
|
||||||
{
|
|
||||||
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI();
|
|
||||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
|
||||||
|
|
||||||
filePlansAPI.getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
|
||||||
{
|
|
||||||
recordCategoryAPI.deleteRecordCategory(recordCategoryEntry.getEntry().getId());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,485 @@
|
|||||||
|
/*
|
||||||
|
* #%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.fileplans;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.base.AllowableOperations.CREATE;
|
||||||
|
import static org.alfresco.rest.rm.community.base.AllowableOperations.DELETE;
|
||||||
|
import static org.alfresco.rest.rm.community.base.AllowableOperations.UPDATE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_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;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
||||||
|
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;
|
||||||
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
|
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||||
|
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.base.TestData;
|
||||||
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||||
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlanProperties;
|
||||||
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryProperties;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
||||||
|
import org.alfresco.utility.constants.ContainerName;
|
||||||
|
import org.alfresco.utility.model.UserModel;
|
||||||
|
import org.alfresco.utility.report.Bug;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains the tests for the File Plan CRUD API
|
||||||
|
*
|
||||||
|
* @author Rodica Sutu
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
public class FilePlanTests extends BaseRMRestTest
|
||||||
|
{
|
||||||
|
//** Number of children (for children creation test) */
|
||||||
|
private static final int NUMBER_OF_CHILDREN = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Provider with:
|
||||||
|
* with the object types not allowed as children for a record category
|
||||||
|
*
|
||||||
|
* @return file plan component alias
|
||||||
|
*/
|
||||||
|
@DataProvider
|
||||||
|
public static Object[][] childrenNotAllowedForFilePlan()
|
||||||
|
{
|
||||||
|
return new String[][] {
|
||||||
|
{ FILE_PLAN_TYPE },
|
||||||
|
{ TRANSFER_CONTAINER_TYPE },
|
||||||
|
{ UNFILED_CONTAINER_TYPE },
|
||||||
|
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||||
|
{ TRANSFER_TYPE },
|
||||||
|
{ CONTENT_TYPE },
|
||||||
|
{ NON_ELECTRONIC_RECORD_TYPE},
|
||||||
|
{ RECORD_FOLDER_TYPE}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that the RM site doesn't exist
|
||||||
|
* When I use the API to get the File Plan
|
||||||
|
* Then I get the 404 response code
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getFilePlanWhenRMIsNotCreated() throws Exception
|
||||||
|
{
|
||||||
|
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
||||||
|
|
||||||
|
// Check RM Site Exist
|
||||||
|
if (rmSiteAPI.existsRMSite())
|
||||||
|
{
|
||||||
|
// Delete RM Site
|
||||||
|
rmSiteAPI.deleteRMSite();
|
||||||
|
}
|
||||||
|
//get file plan
|
||||||
|
getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// Check the response code is NOT_FOUND
|
||||||
|
assertStatusCode(NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a file plan exists
|
||||||
|
* When I ask the API for the details of the file plan
|
||||||
|
* Then I am given the details of the file plan
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getFilePlanWhenRMIsCreated() throws Exception
|
||||||
|
{
|
||||||
|
// Create RM Site if doesn't exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
|
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// Check the response code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
//check file plan details
|
||||||
|
assertTrue(filePlan.getNodeType().equals(FilePlanComponentType.FILE_PLAN_TYPE));
|
||||||
|
assertTrue(filePlan.getName().equals(ContainerName.documentLibrary.toString()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a file plan exists
|
||||||
|
* When I ask the API for the details of the file plan to include the allowableOperations property
|
||||||
|
* Then I am given the allowableOperations property with the update and create operations.
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void includeAllowableOperations() throws Exception
|
||||||
|
{
|
||||||
|
// Create RM Site if doesn't exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
|
// Check the list of allowableOperations returned
|
||||||
|
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS, "include=" + ALLOWABLE_OPERATIONS);
|
||||||
|
|
||||||
|
assertTrue(filePlan.getAllowableOperations().containsAll(asList(UPDATE, CREATE)),
|
||||||
|
"Wrong list of the allowable operations is return" + filePlan.getAllowableOperations().toString());
|
||||||
|
|
||||||
|
// Check the list of allowableOperations doesn't contain DELETE operation
|
||||||
|
assertFalse(filePlan.getAllowableOperations().contains(DELETE),
|
||||||
|
"The list of allowable operations contains delete option" + filePlan.getAllowableOperations().toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that RM site exists
|
||||||
|
* When a non-RM user asks the API for the details of the file plan
|
||||||
|
* Then the status code 403 (Permission denied) is return
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getFilePlanWithNonRMuser() throws Exception
|
||||||
|
{
|
||||||
|
// Create RM Site if doesn't exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
|
// Create a random user
|
||||||
|
UserModel nonRMuser = getDataUser().createRandomTestUser("testUser");
|
||||||
|
|
||||||
|
// Get the special file plan components
|
||||||
|
getRestAPIFactory().getFilePlansAPI(nonRMuser).getFilePlan(FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// Check the response status code is FORBIDDEN
|
||||||
|
assertStatusCode(FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that a file plan exists
|
||||||
|
* When I ask the API to modify the details of the file plan
|
||||||
|
* Then the details of the file are modified
|
||||||
|
* Note: the details of the file plan are limited to title and description.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Bug (id = "RM-4295")
|
||||||
|
public void updateFilePlan() throws Exception
|
||||||
|
{
|
||||||
|
String FILE_PLAN_DESCRIPTION = "Description updated " + getRandomAlphanumeric();
|
||||||
|
String FILE_PLAN_TITLE = "Title updated " + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create RM Site if doesn't exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
|
// Build object for updating the filePlan
|
||||||
|
FilePlan filePlanComponent = FilePlan.builder()
|
||||||
|
.properties(FilePlanProperties.builder()
|
||||||
|
.title(FILE_PLAN_TITLE)
|
||||||
|
.description(FILE_PLAN_DESCRIPTION)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
// Create a random user
|
||||||
|
UserModel nonRMuser = getDataUser().createRandomTestUser("testUser");
|
||||||
|
|
||||||
|
// Update the file plan
|
||||||
|
getRestAPIFactory().getFilePlansAPI(nonRMuser).updateFilePlan(filePlanComponent, FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
//Check the response status code is FORBIDDEN
|
||||||
|
assertStatusCode(FORBIDDEN);
|
||||||
|
|
||||||
|
// Update the file plan
|
||||||
|
FilePlan renamedFilePlan = getRestAPIFactory().getFilePlansAPI().updateFilePlan(filePlanComponent, FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// Verify the response status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned description field for the file plan component
|
||||||
|
assertEquals(renamedFilePlan.getProperties().getDescription(), FILE_PLAN_DESCRIPTION);
|
||||||
|
|
||||||
|
// Verify the returned title field for the file plan component
|
||||||
|
assertEquals(renamedFilePlan.getProperties().getTitle(), FILE_PLAN_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that a file plan exists
|
||||||
|
* When I ask the API to modify the name of the file plan
|
||||||
|
* Then a error is returned (422 response code)
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Bug (id = "RM-4295")
|
||||||
|
public void updateFilePlanName() throws Exception
|
||||||
|
{
|
||||||
|
String FILE_PLAN_NAME = "File Plan name updated " + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create RM Site if doesn't exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
|
// Build object for updating the filePlan
|
||||||
|
FilePlan filePlanComponent = FilePlan.builder()
|
||||||
|
.name(FILE_PLAN_NAME)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Update the file plan
|
||||||
|
getRestAPIFactory().getFilePlansAPI().updateFilePlan(filePlanComponent, FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// Verify the response status code
|
||||||
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 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
|
||||||
|
* </pre>
|
||||||
|
* <pre>
|
||||||
|
* 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)
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create root category",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
dataProvider = "categoryTypes"
|
||||||
|
)
|
||||||
|
public void createFilePlanChildren(String nodeType) throws Exception
|
||||||
|
{
|
||||||
|
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||||
|
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create the root record category
|
||||||
|
RecordCategory recordCategory = RecordCategory.builder()
|
||||||
|
.name(categoryName)
|
||||||
|
.properties(RecordCategoryProperties.builder()
|
||||||
|
.title(categoryTitle)
|
||||||
|
.build())
|
||||||
|
.nodeType(nodeType)
|
||||||
|
.build();
|
||||||
|
RecordCategory rootRecordCategory = getRestAPIFactory().getFilePlansAPI()
|
||||||
|
.createRootRecordCategory(recordCategory,FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// Verify the status code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
assertEquals(rootRecordCategory.getName(), categoryName);
|
||||||
|
assertEquals(rootRecordCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
||||||
|
|
||||||
|
assertEquals(rootRecordCategory.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Verify the returned root record category properties
|
||||||
|
RecordCategoryProperties rootRecordCategoryProperties = rootRecordCategory.getProperties();
|
||||||
|
assertEquals(rootRecordCategoryProperties.getTitle(), categoryTitle);
|
||||||
|
assertNotNull(rootRecordCategoryProperties.getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void listFilePlanChildren() throws Exception
|
||||||
|
{
|
||||||
|
//delete all the root categories
|
||||||
|
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||||
|
{
|
||||||
|
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordCategoryEntry.getEntry().getId());
|
||||||
|
});
|
||||||
|
// Add child folders
|
||||||
|
ArrayList<RecordCategory> children = new ArrayList<RecordCategory>();
|
||||||
|
for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
|
||||||
|
{
|
||||||
|
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||||
|
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||||
|
// Create a record folder
|
||||||
|
RecordCategory recordCategory = createRootCategory(categoryName, categoryTitle);
|
||||||
|
assertNotNull(recordCategory.getId());
|
||||||
|
children.add(recordCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get record category children from API
|
||||||
|
RecordCategoryCollection recordCategoryChildren = getRestAPIFactory().getFilePlansAPI()
|
||||||
|
.getRootRecordCategories(FILE_PLAN_ALIAS, "include=aspects,properties");
|
||||||
|
|
||||||
|
// Check status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Check children against created list
|
||||||
|
recordCategoryChildren.getEntries().forEach(c ->
|
||||||
|
{
|
||||||
|
RecordCategory recordCategoryChild = c.getEntry();
|
||||||
|
String recordCategoryChildId = recordCategoryChild.getId();
|
||||||
|
assertNotNull(recordCategoryChildId);
|
||||||
|
logger.info("Checking child " + recordCategoryChildId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Find this child in created children list
|
||||||
|
RecordCategory createdComponent = children.stream()
|
||||||
|
.filter(child -> child.getId().equals(recordCategoryChildId))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
assertEquals(createdComponent.getName(), recordCategoryChild.getName());
|
||||||
|
assertEquals(createdComponent.getNodeType(), recordCategoryChild.getNodeType());
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException e)
|
||||||
|
{
|
||||||
|
fail("No child element for " + recordCategoryChildId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that RM site is created
|
||||||
|
* When I use the API to create invalid types inside a file plan
|
||||||
|
* Then the node type provided is converted to a record category
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create a record folder/unfiled container/unfiled folder/record/file plan container",
|
||||||
|
dataProvider = "childrenNotAllowedForFilePlan"
|
||||||
|
)
|
||||||
|
public void createChildrenNotAllowedInFilePlan(String nodeType) throws Exception
|
||||||
|
{
|
||||||
|
String componentName = "Component" + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create the root record category
|
||||||
|
RecordCategory component = RecordCategory.builder()
|
||||||
|
.name(componentName)
|
||||||
|
.nodeType(nodeType)
|
||||||
|
.build();
|
||||||
|
// Create the invalid node type
|
||||||
|
RecordCategory rootRecordCategory = getRestAPIFactory().getFilePlansAPI()
|
||||||
|
.createRootRecordCategory(component, FILE_PLAN_ALIAS);
|
||||||
|
//check the response status code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
assertEquals(rootRecordCategory.getName(), componentName);
|
||||||
|
assertEquals(rootRecordCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
||||||
|
|
||||||
|
assertEquals(rootRecordCategory.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Verify the returned root record category properties
|
||||||
|
assertNotNull(rootRecordCategory.getProperties().getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void listChildrenUserPermission() throws Exception
|
||||||
|
{
|
||||||
|
// Create RM Site if doesn't exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
|
// Create a random user
|
||||||
|
UserModel managerUser = getDataUser().createRandomTestUser("managerUser");
|
||||||
|
|
||||||
|
// Add child folders
|
||||||
|
ArrayList<RecordCategory> children = new ArrayList<RecordCategory>();
|
||||||
|
for (int i = 0; i < NUMBER_OF_CHILDREN/2; i++)
|
||||||
|
{
|
||||||
|
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||||
|
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||||
|
// Create a record folder
|
||||||
|
RecordCategory recordCategory = createRootCategory(categoryName, categoryTitle);
|
||||||
|
assertNotNull(recordCategory.getId());
|
||||||
|
children.add(recordCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
getRestAPIFactory().getRMUserAPI().assignRoleToUser(managerUser.getUsername(), ROLE_RM_MANAGER);
|
||||||
|
// Get record category children from API
|
||||||
|
getRestAPIFactory().getFilePlansAPI(managerUser).getRootRecordCategories(FILE_PLAN_ALIAS)
|
||||||
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
|
|
||||||
|
ArrayList<RecordCategory> childrenManager = new ArrayList<RecordCategory>();
|
||||||
|
for (int i = 0; i < NUMBER_OF_CHILDREN / 2; i++)
|
||||||
|
{
|
||||||
|
String categoryName = "Category for manager " + getRandomAlphanumeric();
|
||||||
|
String categoryTitle = "Category for manager " + getRandomAlphanumeric();
|
||||||
|
// Create a record folder
|
||||||
|
RecordCategory recordCategory = createRootCategory(categoryName, categoryTitle);
|
||||||
|
assertNotNull(recordCategory.getId());
|
||||||
|
getRestAPIFactory().getRMUserAPI().addUserPermission(recordCategory.getId(), managerUser, PERMISSION_FILING);
|
||||||
|
childrenManager.add(recordCategory);
|
||||||
|
}
|
||||||
|
// Get record category children from API
|
||||||
|
RecordCategoryCollection recordCategoryChildren = getRestAPIFactory().getFilePlansAPI(managerUser).getRootRecordCategories(FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
//Check children against created list
|
||||||
|
recordCategoryChildren.getEntries().forEach(c ->
|
||||||
|
{
|
||||||
|
RecordCategory recordCategoryChild = c.getEntry();
|
||||||
|
String recordCategoryChildId = recordCategoryChild.getId();
|
||||||
|
assertNotNull(recordCategoryChildId);
|
||||||
|
logger.info("Checking child " + recordCategoryChildId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Find this child in created children list
|
||||||
|
assertTrue(childrenManager.stream()
|
||||||
|
.anyMatch(child -> child.getId().equals(recordCategoryChildId))
|
||||||
|
);
|
||||||
|
assertFalse(children.stream()
|
||||||
|
.anyMatch(child -> child.getId().equals(recordCategoryChildId))
|
||||||
|
|
||||||
|
);
|
||||||
|
} catch (NoSuchElementException e)
|
||||||
|
{
|
||||||
|
fail("No child element for " + recordCategoryChildId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,719 @@
|
|||||||
|
/*
|
||||||
|
* #%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.recordcategories;
|
||||||
|
|
||||||
|
import static java.time.LocalDateTime.now;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
|
||||||
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
||||||
|
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.UNFILED_RECORD_FOLDER_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX;
|
||||||
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
|
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||||
|
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
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.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.base.TestData;
|
||||||
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildProperties;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||||
|
import org.alfresco.utility.report.Bug;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record category related API tests
|
||||||
|
*
|
||||||
|
* @author Kristijan Conkas
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
public class RecordCategoryTests extends BaseRMRestTest
|
||||||
|
{
|
||||||
|
/** Number of children (for children creation test) */
|
||||||
|
private static final int NUMBER_OF_CHILDREN = 10;
|
||||||
|
private static final int NUMBER_OF_FOLDERS = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid containers that cannot be deleted with record category end-point
|
||||||
|
*/
|
||||||
|
@DataProvider (name = "invalidContainersToDelete")
|
||||||
|
public Object[][] getNodesToDelete() throws Exception
|
||||||
|
{
|
||||||
|
return new String[][] {
|
||||||
|
{ FILE_PLAN_ALIAS },
|
||||||
|
{ UNFILED_RECORDS_CONTAINER_ALIAS },
|
||||||
|
{ TRANSFERS_ALIAS },
|
||||||
|
// an arbitrary record category
|
||||||
|
{ createCategoryFolderInFilePlan(getAdminUser()).getId() },
|
||||||
|
// an arbitrary unfiled records folder
|
||||||
|
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId() }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I ask the API to update the details of the record category
|
||||||
|
* Then the details of the record category are updated
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Rename root category"
|
||||||
|
)
|
||||||
|
public void renameCategory() throws Exception
|
||||||
|
{
|
||||||
|
// Create record category first
|
||||||
|
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||||
|
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create the root record category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(categoryName, categoryTitle);
|
||||||
|
|
||||||
|
String newCategoryName = "Rename " + categoryName;
|
||||||
|
|
||||||
|
// Build the properties which will be updated
|
||||||
|
RecordCategory recordCategoryUpdated = RecordCategory.builder().name(newCategoryName).build();
|
||||||
|
|
||||||
|
// Update the record category
|
||||||
|
RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated, rootRecordCategory.getId());
|
||||||
|
|
||||||
|
// Verify the status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned file plan component
|
||||||
|
assertEquals(renamedRecordCategory.getName(), newCategoryName);
|
||||||
|
|
||||||
|
// Get actual FILE_PLAN_ALIAS id
|
||||||
|
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
|
// verify renamed component still has this parent
|
||||||
|
assertEquals(renamedRecordCategory.getParentId(), filePlan.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I ask the API to delete the record category
|
||||||
|
* Then the record category and all its contents are deleted
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Delete category"
|
||||||
|
)
|
||||||
|
public void deleteCategory() throws Exception
|
||||||
|
{
|
||||||
|
// Create record category first
|
||||||
|
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||||
|
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create the root record category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(categoryName, categoryTitle);
|
||||||
|
|
||||||
|
int totalEntries= getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getPagination().getTotalItems();
|
||||||
|
// Delete the record category
|
||||||
|
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||||
|
String recordCategoryId = rootRecordCategory.getId();
|
||||||
|
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||||
|
|
||||||
|
// Verify the status code
|
||||||
|
assertStatusCode(NO_CONTENT);
|
||||||
|
|
||||||
|
// Deleted component should no longer be retrievable
|
||||||
|
recordCategoryAPI.getRecordCategory(recordCategoryId);
|
||||||
|
assertStatusCode(NOT_FOUND);
|
||||||
|
//check the number of entries after delete
|
||||||
|
int totalEntriesAfterDelete = getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getPagination().getTotalItems();
|
||||||
|
assertEquals(totalEntriesAfterDelete,(totalEntries-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that nodes that are not record category
|
||||||
|
* When I ask to delete the nodes with the delete request from the record-categories endpoint
|
||||||
|
* Then the request fails
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Delete invalid nodes with delete category endpoint",
|
||||||
|
dataProvider = "invalidContainersToDelete"
|
||||||
|
)
|
||||||
|
public void deleteInvalidNodes(String nodeId) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
// Delete the record category
|
||||||
|
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||||
|
recordCategoryAPI.deleteRecordCategory(nodeId);
|
||||||
|
|
||||||
|
// Verify the status code
|
||||||
|
assertStatusCode(BAD_REQUEST);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I ask the API to create a record category
|
||||||
|
* Then it is created within the record category
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create child category"
|
||||||
|
)
|
||||||
|
public void createSubcategory() throws Exception
|
||||||
|
{
|
||||||
|
// Create root level category
|
||||||
|
RecordCategory rootCategory = createRootCategory(getRandomAlphanumeric());
|
||||||
|
assertNotNull(rootCategory.getId());
|
||||||
|
|
||||||
|
// Create sub-category as a child of rootCategory
|
||||||
|
RecordCategoryChild recordCategory = createRecordCategoryChild(rootCategory.getId(), RECORD_CATEGORY_NAME, RECORD_CATEGORY_TYPE);
|
||||||
|
|
||||||
|
// Child category created?
|
||||||
|
assertNotNull(recordCategory.getId());
|
||||||
|
|
||||||
|
// Verify child category
|
||||||
|
assertEquals(recordCategory.getParentId(), rootCategory.getId());
|
||||||
|
assertTrue(recordCategory.getIsRecordCategory());
|
||||||
|
assertFalse(recordCategory.getIsRecordFolder());
|
||||||
|
assertEquals(recordCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
||||||
|
|
||||||
|
|
||||||
|
//get the sub-category
|
||||||
|
RecordCategory subCategory = getRestAPIFactory().getRecordCategoryAPI().getRecordCategory(recordCategory.getId(),"include=isRecordCategory,isRecordFolder");
|
||||||
|
// Verify child category
|
||||||
|
assertEquals(subCategory.getParentId(), rootCategory.getId());
|
||||||
|
assertEquals(subCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
||||||
|
assertFalse(subCategory.getAspectNames().isEmpty());
|
||||||
|
assertNotNull(subCategory.getProperties().getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I use the API to create children of type record folder
|
||||||
|
* Then a record folder it is created within the record category
|
||||||
|
* </pre>
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I use the API to create children of type folder (cm:folder type)
|
||||||
|
* Then the folder is converted to rma:recordFolder within the record category
|
||||||
|
* (see RM-4572 comments)
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create a record folder into a record category.",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
dataProvider = "folderTypes"
|
||||||
|
)
|
||||||
|
@Bug (id = "RM-4572")
|
||||||
|
public void createFolderTest(String folderType) throws Exception
|
||||||
|
{
|
||||||
|
// Authenticate with admin user
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
|
RecordCategoryChild recordFolder = createRecordCategoryChild(rootRecordCategory.getId(), RECORD_FOLDER_NAME, folderType);
|
||||||
|
|
||||||
|
// Assert status code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
// Check record folder has been created within the record category
|
||||||
|
assertEquals(rootRecordCategory.getId(), recordFolder.getParentId());
|
||||||
|
|
||||||
|
// Verify the returned values for the record folder
|
||||||
|
assertFalse(recordFolder.getIsRecordCategory());
|
||||||
|
assertTrue(recordFolder.getIsRecordFolder());
|
||||||
|
assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
|
||||||
|
assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
|
||||||
|
assertEquals(recordFolder.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Verify the returned record folder properties
|
||||||
|
RecordCategoryChildProperties folderProperties = recordFolder.getProperties();
|
||||||
|
assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
|
||||||
|
assertNotNull(folderProperties.getIdentifier());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* And contains a number of record categories and record folders
|
||||||
|
* When I ask the API to get me the children of the record category
|
||||||
|
* Then I am returned the contained record categories and record folders and their details
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Get children of a record category"
|
||||||
|
)
|
||||||
|
public void getRecordCategoryChildren() throws Exception
|
||||||
|
{
|
||||||
|
// Create root level category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric());
|
||||||
|
assertNotNull(rootRecordCategory.getId());
|
||||||
|
|
||||||
|
// Add record category children
|
||||||
|
List<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>();
|
||||||
|
for (int i=0; i < NUMBER_OF_CHILDREN; i++)
|
||||||
|
{
|
||||||
|
// Create a record category child
|
||||||
|
RecordCategoryChild child = createRecordCategoryChild(rootRecordCategory.getId(),
|
||||||
|
getRandomAlphanumeric(),
|
||||||
|
// half of the children should be sub-categories, the other sub-folders
|
||||||
|
(i <= NUMBER_OF_CHILDREN / 2) ? RECORD_CATEGORY_TYPE : RECORD_FOLDER_TYPE);
|
||||||
|
assertNotNull(child.getId());
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get children from API
|
||||||
|
RecordCategoryChildCollection recordCategoryChildren = getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(rootRecordCategory.getId(),"include=isRecordCategory,isRecordFolder");
|
||||||
|
|
||||||
|
// Check status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
logger.info("Parent: " + rootRecordCategory.getId());
|
||||||
|
|
||||||
|
// Check listed children against created list
|
||||||
|
recordCategoryChildren.getEntries().forEach(c ->
|
||||||
|
{
|
||||||
|
RecordCategoryChild recordCategoryChild = c.getEntry();
|
||||||
|
String recordCategoryChildId = recordCategoryChild.getId();
|
||||||
|
|
||||||
|
assertNotNull(recordCategoryChildId);
|
||||||
|
logger.info("Checking child " + recordCategoryChildId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Find this child in created children list
|
||||||
|
RecordCategoryChild createdComponent = children.stream()
|
||||||
|
.filter(child -> child.getId().equals(recordCategoryChildId))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Is parent id set correctly?
|
||||||
|
assertEquals(recordCategoryChild.getParentId(), rootRecordCategory.getId());
|
||||||
|
|
||||||
|
// Boolean properties related to node type
|
||||||
|
// Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created
|
||||||
|
if (recordCategoryChild.getNodeType().equals(RECORD_CATEGORY_TYPE))
|
||||||
|
{
|
||||||
|
assertTrue(recordCategoryChild.getIsRecordCategory());
|
||||||
|
assertFalse(recordCategoryChild.getIsRecordFolder());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assertTrue(recordCategoryChild.getIsRecordFolder());
|
||||||
|
assertFalse(recordCategoryChild.getIsRecordCategory());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Does returned object have the same contents as the created one?
|
||||||
|
assertEquals(createdComponent.getName(), recordCategoryChild.getName());
|
||||||
|
assertEquals(createdComponent.getNodeType(), recordCategoryChild.getNodeType());
|
||||||
|
|
||||||
|
// verify the record categories children identifier
|
||||||
|
assertNotNull(createdComponent.getProperties().getIdentifier());
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException e)
|
||||||
|
{
|
||||||
|
fail("No child element for " + recordCategoryChildId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I ask to create an object type which is not a record category or a record folder as a child
|
||||||
|
* Then the children are not created and the 422 response code is returned
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create node types not allowed inside a category",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
dataProvider = "childrenNotAllowedForCategory"
|
||||||
|
)
|
||||||
|
@Bug (id="RM-4367, RM-4572")
|
||||||
|
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
||||||
|
{
|
||||||
|
String componentName = "Component" + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create the category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(componentName);
|
||||||
|
|
||||||
|
// Create the invalid node type
|
||||||
|
createRecordCategoryChild(rootRecordCategory.getId(), componentName, nodeType);
|
||||||
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record category exists
|
||||||
|
* And contains several record folders
|
||||||
|
* When I use the API to get the record category children for an existing record category
|
||||||
|
* Then I am provided with a list of the contained record category children and their details
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Get children of a record category"
|
||||||
|
)
|
||||||
|
public void getFolders() throws Exception
|
||||||
|
{
|
||||||
|
// Authenticate with admin user
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
||||||
|
|
||||||
|
// Add child folders
|
||||||
|
ArrayList<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>();
|
||||||
|
for (int i = 0; i < NUMBER_OF_FOLDERS; i++)
|
||||||
|
{
|
||||||
|
// Create a record folder
|
||||||
|
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), getRandomAlphanumeric());
|
||||||
|
assertNotNull(recordCategoryChild.getId());
|
||||||
|
children.add(recordCategoryChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get record category children from API
|
||||||
|
RecordCategoryChildCollection recordCategoryChildren = getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(rootRecordCategory.getId(), "include=isRecordCategory,isRecordFolder");
|
||||||
|
|
||||||
|
// Check status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Check children against created list
|
||||||
|
recordCategoryChildren.getEntries().forEach(c ->
|
||||||
|
{
|
||||||
|
RecordCategoryChild recordCategoryChild = c.getEntry();
|
||||||
|
String recordCategoryChildId = recordCategoryChild.getId();
|
||||||
|
assertNotNull(recordCategoryChildId);
|
||||||
|
logger.info("Checking child " + recordCategoryChildId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Find this child in created children list
|
||||||
|
RecordCategoryChild createdComponent = children.stream()
|
||||||
|
.filter(child -> child.getId().equals(recordCategoryChildId))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Is parent id set correctly
|
||||||
|
assertEquals(recordCategoryChild.getParentId(), rootRecordCategory.getId());
|
||||||
|
|
||||||
|
// Boolean properties related to node type
|
||||||
|
assertTrue(recordCategoryChild.getIsRecordFolder());
|
||||||
|
assertFalse(recordCategoryChild.getIsRecordCategory());
|
||||||
|
|
||||||
|
assertEquals(createdComponent.getName(), recordCategoryChild.getName());
|
||||||
|
assertEquals(createdComponent.getNodeType(), recordCategoryChild.getNodeType());
|
||||||
|
|
||||||
|
} catch (NoSuchElementException e)
|
||||||
|
{
|
||||||
|
fail("No child element for " + recordCategoryChildId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 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
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create a folder using record-categories endpoint, based on the relativePath. " +
|
||||||
|
"Containers in the relativePath that do not exist are created before the node is created"
|
||||||
|
)
|
||||||
|
public void createRecordFolderWithRelativePath() throws Exception
|
||||||
|
{
|
||||||
|
// The record category to be created
|
||||||
|
RecordCategory recordCategoryModel = RecordCategory.builder()
|
||||||
|
.name(RECORD_CATEGORY_NAME)
|
||||||
|
.nodeType(RECORD_CATEGORY_TYPE)
|
||||||
|
.build();
|
||||||
|
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI();
|
||||||
|
RecordCategory createRootRecordCategory = filePlansAPI.createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
String recordCategoryId = createRootRecordCategory.getId();
|
||||||
|
|
||||||
|
// relativePath specify the container structure to create relative to the record folder to be created
|
||||||
|
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth();
|
||||||
|
|
||||||
|
// The record folder to be created
|
||||||
|
RecordCategoryChild recordFolderModel = RecordCategoryChild.builder()
|
||||||
|
.name(RECORD_FOLDER_NAME)
|
||||||
|
.nodeType(RECORD_FOLDER_TYPE)
|
||||||
|
.relativePath(relativePath)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
|
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||||
|
RecordCategoryChild recordCategoryChild = recordCategoryAPI.createRecordCategoryChild(recordFolderModel, recordCategoryId, "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
// Verify the returned details for the record folder
|
||||||
|
assertFalse(recordCategoryChild.getIsRecordCategory());
|
||||||
|
assertTrue(recordCategoryChild.getIsRecordFolder());
|
||||||
|
|
||||||
|
// Check the path return contains the relativePath
|
||||||
|
assertTrue(recordCategoryChild.getPath().getName().contains(relativePath));
|
||||||
|
|
||||||
|
// Check the parent is a category
|
||||||
|
assertNotNull(recordCategoryAPI.getRecordCategory(recordCategoryChild.getParentId()).getId());
|
||||||
|
|
||||||
|
// Check the created folder from the server
|
||||||
|
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||||
|
RecordFolder recordFolder = recordFolderAPI.getRecordFolder(recordCategoryChild.getId(), "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned details for the record folder
|
||||||
|
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
|
||||||
|
|
||||||
|
// Check the path return contains the relativePath
|
||||||
|
assertTrue(recordFolder.getPath().getName().contains(relativePath));
|
||||||
|
|
||||||
|
// New relative path only a part of containers need to be created before the record folder
|
||||||
|
String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1);
|
||||||
|
|
||||||
|
// The record folder to be created
|
||||||
|
RecordCategoryChild newRecordFolderModel = RecordCategoryChild.builder()
|
||||||
|
.name(RECORD_FOLDER_NAME)
|
||||||
|
.nodeType(RECORD_FOLDER_TYPE)
|
||||||
|
.relativePath(newRelativePath)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
|
RecordCategoryChild newRecordCategoryChild = recordCategoryAPI.createRecordCategoryChild(newRecordFolderModel, recordCategoryId, "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
// Verify the returned properties for the file plan component - record folder
|
||||||
|
assertFalse(newRecordCategoryChild.getIsRecordCategory());
|
||||||
|
assertTrue(newRecordCategoryChild.getIsRecordFolder());
|
||||||
|
|
||||||
|
// Check the path return contains the newRelativePath
|
||||||
|
assertTrue(newRecordCategoryChild.getPath().getName().contains(newRelativePath));
|
||||||
|
|
||||||
|
// Check the parent is a category
|
||||||
|
assertNotNull(recordCategoryAPI.getRecordCategory(newRecordCategoryChild.getParentId()).getId());
|
||||||
|
|
||||||
|
// Check the folder created on the server
|
||||||
|
RecordFolder newRecordFolder = recordFolderAPI.getRecordFolder(newRecordCategoryChild.getId(), "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned details for the record folder
|
||||||
|
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
|
||||||
|
|
||||||
|
// Check the path return contains the newRelativePath
|
||||||
|
assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that I want to create a record sub-category
|
||||||
|
* When I use the API with the relativePath
|
||||||
|
* Then the categories specified in the relativePath that don't exist are created
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create a sub-category using record-categories endpoint, based on the relativePath. " +
|
||||||
|
"Containers in the relativePath that do not exist are created before the node is created"
|
||||||
|
)
|
||||||
|
public void createRecordSubCategoryWithRelativePath() throws Exception
|
||||||
|
{
|
||||||
|
// The record category to be created
|
||||||
|
RecordCategory recordCategoryModel = RecordCategory.builder()
|
||||||
|
.name(RECORD_CATEGORY_NAME+getRandomAlphanumeric())
|
||||||
|
.nodeType(RECORD_CATEGORY_TYPE)
|
||||||
|
.build();
|
||||||
|
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI();
|
||||||
|
RecordCategory createRootRecordCategory = filePlansAPI.createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
String recordCategoryId = createRootRecordCategory.getId();
|
||||||
|
|
||||||
|
// relativePath specify the container structure to create relative to the record folder to be created
|
||||||
|
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth()+ "/"+getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// The record folder to be created
|
||||||
|
RecordCategoryChild recordFolderModel = RecordCategoryChild.builder()
|
||||||
|
.name(RECORD_CATEGORY_NAME)
|
||||||
|
.nodeType(RECORD_CATEGORY_TYPE)
|
||||||
|
.relativePath(relativePath)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
|
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||||
|
RecordCategoryChild recordCategoryChild = recordCategoryAPI.createRecordCategoryChild(recordFolderModel, recordCategoryId, "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
// Verify the returned details for the record sub-category
|
||||||
|
assertTrue(recordCategoryChild.getIsRecordCategory());
|
||||||
|
assertFalse(recordCategoryChild.getIsRecordFolder());
|
||||||
|
|
||||||
|
// Check the path return contains the relativePath
|
||||||
|
assertTrue(recordCategoryChild.getPath().getName().contains(relativePath));
|
||||||
|
|
||||||
|
// Check the parent is a category
|
||||||
|
assertNotNull(recordCategoryAPI.getRecordCategory(recordCategoryChild.getParentId()).getId());
|
||||||
|
|
||||||
|
// Check the created folder from the server
|
||||||
|
RecordCategory recordSubCategory = recordCategoryAPI.getRecordCategory(recordCategoryChild.getId(), "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned details for the record folder
|
||||||
|
assertTrue(RECORD_CATEGORY_TYPE.equals(recordSubCategory.getNodeType()));
|
||||||
|
|
||||||
|
// Check the path return contains the relativePath
|
||||||
|
assertTrue(recordSubCategory.getPath().getName().contains(relativePath));
|
||||||
|
|
||||||
|
// New relative path only a part of containers need to be created before the record folder
|
||||||
|
String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1) +"/"+getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// The record folder to be created
|
||||||
|
RecordCategoryChild newRecordFolderModel = RecordCategoryChild.builder()
|
||||||
|
.name(RECORD_CATEGORY_NAME)
|
||||||
|
.nodeType(RECORD_CATEGORY_TYPE)
|
||||||
|
.relativePath(newRelativePath)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
|
RecordCategoryChild newRecordCategoryChild = recordCategoryAPI.createRecordCategoryChild(newRecordFolderModel, recordCategoryId, "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
// Verify the returned properties for the file plan component - record folder
|
||||||
|
assertTrue(newRecordCategoryChild.getIsRecordCategory());
|
||||||
|
assertFalse(newRecordCategoryChild.getIsRecordFolder());
|
||||||
|
|
||||||
|
// Check the path return contains the newRelativePath
|
||||||
|
assertTrue(newRecordCategoryChild.getPath().getName().contains(newRelativePath));
|
||||||
|
|
||||||
|
// Check the parent is a category
|
||||||
|
assertNotNull(recordCategoryAPI.getRecordCategory(newRecordCategoryChild.getParentId()).getId());
|
||||||
|
|
||||||
|
// Check the folder created on the server
|
||||||
|
RecordCategory newRecordFolder = recordCategoryAPI.getRecordCategory(newRecordCategoryChild.getId(), "include=" + PATH);
|
||||||
|
|
||||||
|
// Check the API response code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned details for the record folder
|
||||||
|
assertTrue(RECORD_CATEGORY_TYPE.equals(recordSubCategory.getNodeType()));
|
||||||
|
|
||||||
|
// Check the path return contains the newRelativePath
|
||||||
|
assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that RM site is created
|
||||||
|
* When I use the API to create a new record folder into transfers/holds/unfiled containers
|
||||||
|
* Then the operation fails
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create a record folder into transfers/unfiled/file plan container",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
dataProvider = "getContainers"
|
||||||
|
)
|
||||||
|
@Bug (id = "RM-4327")
|
||||||
|
public void createRecordFolderIntoSpecialContainers(String containerAlias) throws Exception
|
||||||
|
{
|
||||||
|
String containerId;
|
||||||
|
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))
|
||||||
|
{
|
||||||
|
containerId = getRestAPIFactory().getFilePlansAPI().getFilePlan(containerAlias).getId();
|
||||||
|
} else if (TRANSFERS_ALIAS.equalsIgnoreCase(containerAlias))
|
||||||
|
{
|
||||||
|
containerId = getRestAPIFactory().getTransferContainerAPI().getTransferContainer(containerAlias).getId();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//is unfiled container
|
||||||
|
containerId = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(containerAlias).getId();
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a record folder
|
||||||
|
createRecordFolder(containerId, RECORD_FOLDER_NAME);
|
||||||
|
|
||||||
|
// Check the API Response code
|
||||||
|
assertStatusCode(BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
@@ -24,7 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.recordfolders;
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||||
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;
|
||||||
@@ -72,7 +72,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
|
|
||||||
/** Invalid parent containers where electronic records can't be created */
|
/** Invalid parent containers where electronic records can't be created */
|
||||||
@DataProvider(name = "invalidParentContainers")
|
@DataProvider(name = "invalidParentContainers")
|
||||||
public String[][] invalidParentContainers() throws Exception
|
public Object[][] invalidParentContainers() throws Exception
|
||||||
{
|
{
|
||||||
return new String[][]
|
return new String[][]
|
||||||
{
|
{
|
||||||
@@ -326,8 +326,6 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getIdentifier()));
|
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getIdentifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Bug (id = "RM-4568")
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* Given that I want to create an electronic record in one unfiled record folder
|
* Given that I want to create an electronic record in one unfiled record folder
|
||||||
@@ -335,6 +333,8 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
* Then the containers in the relativePath that don't exist are created before creating the electronic record
|
* Then the containers in the relativePath that don't exist are created before creating the electronic record
|
||||||
* <pre>
|
* <pre>
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
|
@Bug (id = "RM-4568")
|
||||||
public void createElectronicRecordWithRelativePath() throws Exception
|
public void createElectronicRecordWithRelativePath() throws Exception
|
||||||
{
|
{
|
||||||
// The containers specified on the relativePath parameter don't exist on server
|
// The containers specified on the relativePath parameter don't exist on server
|
@@ -24,7 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.recordfolders;
|
||||||
|
|
||||||
import static java.lang.Integer.MAX_VALUE;
|
import static java.lang.Integer.MAX_VALUE;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
@@ -0,0 +1,492 @@
|
|||||||
|
/*
|
||||||
|
* #%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.recordfolders;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
|
||||||
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_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;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
||||||
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||||
|
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
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.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
||||||
|
import org.alfresco.rest.rm.community.model.record.Record;
|
||||||
|
import org.alfresco.rest.rm.community.model.record.RecordProperties;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||||
|
import org.alfresco.utility.report.Bug;
|
||||||
|
import org.testng.AssertJUnit;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains the tests for the Record Folder CRUD API
|
||||||
|
*
|
||||||
|
* @author Rodica Sutu
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
public class RecordFolderTests extends BaseRMRestTest
|
||||||
|
{
|
||||||
|
public static final String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||||
|
public static final String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Provider with:
|
||||||
|
* with the object types not allowed as children for a record folder
|
||||||
|
*
|
||||||
|
* @return node type to be created
|
||||||
|
*/
|
||||||
|
@DataProvider
|
||||||
|
public static Object[][] childrenNotAllowedForFolder()
|
||||||
|
{
|
||||||
|
return new String[][] {
|
||||||
|
{ FILE_PLAN_TYPE },
|
||||||
|
{ TRANSFER_CONTAINER_TYPE },
|
||||||
|
{ UNFILED_CONTAINER_TYPE },
|
||||||
|
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||||
|
{ TRANSFER_TYPE },
|
||||||
|
{ RECORD_CATEGORY_TYPE }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid containers that cannot be updated/deleted with record folder endpoint
|
||||||
|
*/
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] getInvalidNodesForRecordFolders() throws Exception
|
||||||
|
{
|
||||||
|
return new String[][] {
|
||||||
|
{ getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId()},
|
||||||
|
{ getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
|
||||||
|
{ getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
|
||||||
|
// an arbitrary record category
|
||||||
|
{ createRootCategory(RECORD_CATEGORY_NAME+getRandomAlphanumeric()).getId()},
|
||||||
|
// an arbitrary unfiled records folder
|
||||||
|
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId() },
|
||||||
|
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Record " + getRandomAlphanumeric(), CONTENT_TYPE).getId()}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that RM site is created
|
||||||
|
* When I use the API to create a children inside a record folder with wron types
|
||||||
|
* Then the operation fails
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create invalid types as children for a record folder",
|
||||||
|
dataProvider = "childrenNotAllowedForFolder"
|
||||||
|
)
|
||||||
|
|
||||||
|
public void createRecordFolderIntoSpecialContainers(String nodeType) throws Exception
|
||||||
|
{
|
||||||
|
//create a record folder
|
||||||
|
RecordCategoryChild folder = createCategoryFolderInFilePlan();
|
||||||
|
Record record = Record.builder()
|
||||||
|
.name(ELECTRONIC_RECORD_NAME)
|
||||||
|
.nodeType(nodeType)
|
||||||
|
.build();
|
||||||
|
//create invalid child typefor the record folder
|
||||||
|
getRestAPIFactory().getRecordFolderAPI().createRecord(record,folder.getId());
|
||||||
|
// Check the API Response code
|
||||||
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record folder exists
|
||||||
|
* When I ask for the details of a record folder
|
||||||
|
* Then I am given the details of a record folder
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Check the details of a record folder"
|
||||||
|
)
|
||||||
|
public void checkRecordFolderDetails() throws Exception
|
||||||
|
{
|
||||||
|
// Create a category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
||||||
|
|
||||||
|
// Create a folder
|
||||||
|
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME);
|
||||||
|
|
||||||
|
// Get the folder including extra information
|
||||||
|
RecordFolder recordFolder = getRestAPIFactory().getRecordFolderAPI().getRecordFolder(recordCategoryChild.getId(), "include=" + IS_CLOSED);
|
||||||
|
|
||||||
|
// Verify the returned record folder details
|
||||||
|
assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
|
||||||
|
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
|
||||||
|
assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
|
||||||
|
assertEquals(recordFolder.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
assertEquals(recordFolder.getModifiedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
assertEquals(recordFolder.getProperties().getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
|
||||||
|
assertNotNull(recordFolder.getProperties().getIdentifier(),"The record folder doesn't have a identifier");
|
||||||
|
assertFalse(recordFolder.getProperties().getVitalRecordIndicator(), "The record folder has the vital record identifier");
|
||||||
|
assertFalse(recordFolder.getProperties().getIsClosed(), "The record folder is closed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record folder exists
|
||||||
|
* When I use the API to update its details
|
||||||
|
* Then the details of the record folder are updated
|
||||||
|
* The above test does treat any custom metadata
|
||||||
|
* Note: The details of the record folder includes any custom meta-data
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Update the details of a record folder"
|
||||||
|
)
|
||||||
|
public void updateRecordFolderDetails() throws Exception
|
||||||
|
{
|
||||||
|
// Create a record category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
||||||
|
|
||||||
|
// Create a record folder
|
||||||
|
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME);
|
||||||
|
|
||||||
|
// Create record category first
|
||||||
|
String folderDescription = "The folder description is updated" + getRandomAlphanumeric();
|
||||||
|
String folderName = "The folder name is updated" + getRandomAlphanumeric();
|
||||||
|
String folderTitle = "Update title " + getRandomAlphanumeric();
|
||||||
|
String location = "Location "+ getRandomAlphanumeric();
|
||||||
|
|
||||||
|
// Create the record folder properties to update
|
||||||
|
RecordFolder recordFolder = RecordFolder.builder()
|
||||||
|
.name(folderName)
|
||||||
|
.properties(RecordFolderProperties.builder()
|
||||||
|
.title(folderTitle)
|
||||||
|
.description(folderDescription)
|
||||||
|
.vitalRecordIndicator(true)
|
||||||
|
.reviewPeriod(new ReviewPeriod("month","1"))
|
||||||
|
.location(location)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Update the record folder
|
||||||
|
RecordFolder updatedRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordCategoryChild.getId());
|
||||||
|
|
||||||
|
// Check the Response Status Code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
// Verify the returned details for the record folder
|
||||||
|
AssertJUnit.assertEquals(updatedRecordFolder.getName(), folderName);
|
||||||
|
RecordFolderProperties recordFolderProperties = updatedRecordFolder.getProperties();
|
||||||
|
AssertJUnit.assertEquals(recordFolderProperties.getDescription(), folderDescription);
|
||||||
|
AssertJUnit.assertEquals(recordFolderProperties.getTitle(), folderTitle);
|
||||||
|
assertTrue(recordFolderProperties.getVitalRecordIndicator());
|
||||||
|
AssertJUnit.assertEquals(recordFolderProperties.getLocation(), location);
|
||||||
|
assertNotNull(recordFolderProperties.getReviewPeriod().getPeriodType());
|
||||||
|
assertNotNull(recordFolderProperties.getReviewPeriod().getExpression());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given other nodes type than record folders exists
|
||||||
|
* When I use the API to update its details
|
||||||
|
* Then the request fails
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Update the details for other nodes than record folder with the request used for record-folders ",
|
||||||
|
dataProvider = "getInvalidNodesForRecordFolders"
|
||||||
|
)
|
||||||
|
public void updateOtherNodeTypesDetails(String nodeId) throws Exception
|
||||||
|
{
|
||||||
|
// Create record category first
|
||||||
|
String nodeDescription = "The folder description is updated" + getRandomAlphanumeric();
|
||||||
|
String nodeName = "The folder name is updated" + getRandomAlphanumeric();
|
||||||
|
String nodeTitle = "Update title " + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
|
||||||
|
// Create the record folder properties to update
|
||||||
|
RecordFolder recordFolder = RecordFolder.builder()
|
||||||
|
.name(nodeName)
|
||||||
|
.properties(RecordFolderProperties.builder()
|
||||||
|
.title(nodeTitle)
|
||||||
|
.description(nodeDescription)
|
||||||
|
.vitalRecordIndicator(true)
|
||||||
|
.reviewPeriod(new ReviewPeriod("month", "1"))
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Update the record folder
|
||||||
|
getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, nodeId);
|
||||||
|
|
||||||
|
// Check the Response Status Code
|
||||||
|
assertStatusCode(BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given other nodes type than record folders exists
|
||||||
|
* When I use the API from record-folders to delete the nodes
|
||||||
|
* Then the request fails
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Delete invalid nodes type with the DELETE record folders request",
|
||||||
|
dataProvider = "getInvalidNodesForRecordFolders"
|
||||||
|
)
|
||||||
|
public void deleteInvalidNodesRecordFolder(String nodeId) throws Exception
|
||||||
|
{
|
||||||
|
// Delete the nodes with record-folders end-point
|
||||||
|
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||||
|
recordFolderAPI.deleteRecordFolder(nodeId);
|
||||||
|
|
||||||
|
// Check the response status code
|
||||||
|
assertStatusCode(BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given that a record folder exists
|
||||||
|
* When I use the API to delete the record folder
|
||||||
|
* Then it is deleted according to the normal rules governing the deletion of record folders
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Delete record folder"
|
||||||
|
)
|
||||||
|
public void deleteRecordFolder() throws Exception
|
||||||
|
{
|
||||||
|
// Create the record category
|
||||||
|
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
|
RecordCategoryChild recordFolder = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME);
|
||||||
|
|
||||||
|
// Delete the record folder
|
||||||
|
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||||
|
String recordFolderId = recordFolder.getId();
|
||||||
|
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
||||||
|
|
||||||
|
// Check the response status code
|
||||||
|
assertStatusCode(NO_CONTENT);
|
||||||
|
|
||||||
|
// Check the record folder is not found
|
||||||
|
recordFolderAPI.getRecordFolder(recordFolderId);
|
||||||
|
|
||||||
|
// Check the response status code
|
||||||
|
assertStatusCode(NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that a record folder exists
|
||||||
|
* When the record folder is closed
|
||||||
|
* Then a request can be made to reopen it
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "A closed record folder can be reopened"
|
||||||
|
)
|
||||||
|
@Bug(id="RM-4808")
|
||||||
|
public void openClosedRecordFolder() throws Exception
|
||||||
|
{
|
||||||
|
// Create a record folder
|
||||||
|
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
||||||
|
|
||||||
|
// Assert that the record folder is not closed
|
||||||
|
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||||
|
|
||||||
|
// Get the record folder API
|
||||||
|
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||||
|
|
||||||
|
// Create a record folder model to close it
|
||||||
|
RecordFolder recordFolderModel = RecordFolder.builder()
|
||||||
|
.properties(RecordFolderProperties.builder()
|
||||||
|
.isClosed(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Make a request to close the record folder
|
||||||
|
RecordFolder updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
|
||||||
|
|
||||||
|
//FIXME - remove this workaround after RM-4921 is fixed.
|
||||||
|
updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
|
||||||
|
|
||||||
|
// Verify that the record folder is closed now
|
||||||
|
assertTrue(updatedRecordFolder.getProperties().getIsClosed());
|
||||||
|
|
||||||
|
// Create a record folder model to reopen it
|
||||||
|
recordFolderModel = RecordFolder.builder()
|
||||||
|
.properties(RecordFolderProperties.builder()
|
||||||
|
.isClosed(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Make a request to reopen the record folder
|
||||||
|
updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
|
||||||
|
|
||||||
|
//FIXME - remove this workaround after RM-4921 is fixed.
|
||||||
|
updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
|
||||||
|
|
||||||
|
// Verify that the record folder is open now
|
||||||
|
assertFalse(updatedRecordFolder.getProperties().getIsClosed());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a container that is a record folder
|
||||||
|
* When I try to list the records from the record folder
|
||||||
|
* Then I receive a list of all the records contained within the record folder
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void listRecordsFromRecordFolder() throws Exception
|
||||||
|
{
|
||||||
|
final int NUMBER_OF_RECORDS = 5;
|
||||||
|
String containerId = createCategoryFolderInFilePlan().getId();
|
||||||
|
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||||
|
// Create Electronic Records
|
||||||
|
ArrayList<Record> children = new ArrayList<Record>();
|
||||||
|
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
||||||
|
{
|
||||||
|
//build the electronic record
|
||||||
|
Record record = Record.builder()
|
||||||
|
.name(ELECTRONIC_RECORD_NAME + i)
|
||||||
|
.nodeType(CONTENT_TYPE)
|
||||||
|
.build();
|
||||||
|
//create a child
|
||||||
|
Record child = recordFolderAPI.createRecord(record, containerId, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i));
|
||||||
|
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
//Create NonElectronicRecords
|
||||||
|
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
||||||
|
{
|
||||||
|
Record nonelectronicRecord = Record.builder()
|
||||||
|
.properties(RecordProperties.builder()
|
||||||
|
.description("Description")
|
||||||
|
.title("Title")
|
||||||
|
.build())
|
||||||
|
.name(NONELECTRONIC_RECORD_NAME + i)
|
||||||
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||||
|
.build();
|
||||||
|
//create records
|
||||||
|
Record child = recordFolderAPI.createRecord(nonelectronicRecord, containerId);
|
||||||
|
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List children from API
|
||||||
|
RecordFolderCollection apiChildren = (RecordFolderCollection) recordFolderAPI.getRecordFolderChildren(containerId,"include=properties").assertThat().entriesListIsNotEmpty();
|
||||||
|
|
||||||
|
// Check status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
|
||||||
|
// Check listed children against created list
|
||||||
|
apiChildren.getEntries().forEach(c ->
|
||||||
|
{
|
||||||
|
Record record = c.getEntry();
|
||||||
|
assertNotNull(record.getId());
|
||||||
|
logger.info("Checking child " + record.getId());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Find this child in created children list
|
||||||
|
Record createdComponent = children.stream()
|
||||||
|
.filter(child -> child.getId().equals(record.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Is parent Id set correctly
|
||||||
|
assertEquals(record.getParentId(), containerId);
|
||||||
|
|
||||||
|
//check the record name
|
||||||
|
assertFalse(record.getName().equals(createdComponent.getName()),
|
||||||
|
"Record Name"+ record.getName()+" doesn't contain the record identifier");
|
||||||
|
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()),
|
||||||
|
"Record Name"+ createdComponent.getName()+" doesn't contain the record identifier in response when creating");
|
||||||
|
assertEquals(createdComponent.getNodeType(), record.getNodeType());
|
||||||
|
|
||||||
|
} catch (NoSuchElementException e)
|
||||||
|
{
|
||||||
|
fail("No child element for " + record.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
@AfterClass (alwaysRun = true)
|
||||||
|
public void tearDown() throws Exception
|
||||||
|
{
|
||||||
|
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI();
|
||||||
|
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||||
|
|
||||||
|
filePlansAPI.getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||||
|
{
|
||||||
|
recordCategoryAPI.deleteRecordCategory(recordCategoryEntry.getEntry().getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -24,7 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.records;
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||||
@@ -262,4 +262,5 @@ public class DeleteRecordTests extends BaseRMRestTest
|
|||||||
recordsAPI.deleteRecord(recordId);
|
recordsAPI.deleteRecord(recordId);
|
||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -24,7 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.records;
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
||||||
@@ -43,17 +43,12 @@ import static org.testng.Assert.assertEquals;
|
|||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
import org.alfresco.rest.rm.community.model.record.Record;
|
||||||
import org.alfresco.rest.rm.community.model.record.RecordBodyFile;
|
import org.alfresco.rest.rm.community.model.record.RecordBodyFile;
|
||||||
import org.alfresco.rest.rm.community.model.record.RecordContent;
|
import org.alfresco.rest.rm.community.model.record.RecordContent;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildEntry;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
@@ -89,7 +84,7 @@ public class FileRecordsTests extends BaseRMRestTest
|
|||||||
/**
|
/**
|
||||||
* Invalid containers where electronic and non-electronic records can be filed
|
* Invalid containers where electronic and non-electronic records can be filed
|
||||||
*/
|
*/
|
||||||
@DataProvider (name = "invalidContainersForFile")
|
@DataProvider (name = "invalidContainersToFile")
|
||||||
public String[][] getFolderContainers() throws Exception
|
public String[][] getFolderContainers() throws Exception
|
||||||
{
|
{
|
||||||
return new String[][] {
|
return new String[][] {
|
||||||
@@ -399,11 +394,11 @@ public class FileRecordsTests extends BaseRMRestTest
|
|||||||
c.getEntry().getParentId().equals(parentFolderId)));
|
c.getEntry().getParentId().equals(parentFolderId)));
|
||||||
|
|
||||||
// check the record doesn't exist into unfiled record container
|
// check the record doesn't exist into unfiled record container
|
||||||
// TODO add a check after the issue will be fixed RM-4578
|
|
||||||
assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink)
|
assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink)
|
||||||
.getEntries().stream()
|
.getEntries().stream()
|
||||||
.anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId())));
|
.anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) &&
|
||||||
|
c.getEntry().getParentId().equals(parentFolderId) &&
|
||||||
|
!c.getEntry().getParentId().equals(folderToLink)));
|
||||||
// check the record is added into the record folder
|
// check the record is added into the record folder
|
||||||
assertTrue(recordFolderAPI.getRecordFolderChildren(parentFolderId)
|
assertTrue(recordFolderAPI.getRecordFolderChildren(parentFolderId)
|
||||||
.getEntries()
|
.getEntries()
|
||||||
@@ -412,21 +407,22 @@ public class FileRecordsTests extends BaseRMRestTest
|
|||||||
c.getEntry().getParentId().equals(parentFolderId)));
|
c.getEntry().getParentId().equals(parentFolderId)));
|
||||||
|
|
||||||
// check the record doesn't exist into unfiled record container
|
// check the record doesn't exist into unfiled record container
|
||||||
// TODO add a check after the issue will be fixed RM-4578
|
|
||||||
assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink)
|
assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink)
|
||||||
.getEntries().stream()
|
.getEntries().stream()
|
||||||
.anyMatch(c -> c.getEntry().getId().equals(nonElectronicFiled.getId())));
|
.anyMatch(c -> c.getEntry().getId().equals(nonElectronicFiled.getId()) &&
|
||||||
|
c.getEntry().getParentId().equals(parentFolderId) &&
|
||||||
|
!c.getEntry().getParentId().equals(folderToLink)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an unfiled or filed record
|
* Given an unfiled container or filed record
|
||||||
* And a container that is NOT a record folder
|
* And a container that is NOT a record folder
|
||||||
* When I file the unfiled or filed record to the container
|
* When I file the unfiled container or filed record to the container
|
||||||
* Then I get an unsupported operation exception
|
* Then I get an unsupported operation exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
dataProvider = "invalidContainersForFile",
|
dataProvider = "invalidContainersToFile",
|
||||||
description = "File the unfiled record to the container that is not a record folder"
|
description = "File the unfiled record to the container that is not a record folder"
|
||||||
)
|
)
|
||||||
public void invalidContainerToFile(String containerId) throws Exception
|
public void invalidContainerToFile(String containerId) throws Exception
|
@@ -24,20 +24,16 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.records;
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
||||||
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.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_COMPLETED;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.CONTENT;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.CONTENT;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_COMPLETED;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
|
||||||
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.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
||||||
@@ -49,13 +45,10 @@ import static org.springframework.http.HttpStatus.OK;
|
|||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.base.TestData;
|
import org.alfresco.rest.rm.community.base.TestData;
|
||||||
@@ -64,14 +57,10 @@ import org.alfresco.rest.rm.community.model.record.RecordContent;
|
|||||||
import org.alfresco.rest.rm.community.model.record.RecordProperties;
|
import org.alfresco.rest.rm.community.model.record.RecordProperties;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
@@ -109,7 +98,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
* Then I receive an empty list
|
* Then I receive an empty list
|
||||||
*/
|
*/
|
||||||
@DataProvider(name="invalidContainersForRecords")
|
@DataProvider(name="invalidContainersForRecords")
|
||||||
public String[][] getInvalidContainersForRecords() throws Exception
|
public Object[][] getInvalidContainersForRecords() throws Exception
|
||||||
{
|
{
|
||||||
return new String[][] {
|
return new String[][] {
|
||||||
{ FILE_PLAN_ALIAS },
|
{ FILE_PLAN_ALIAS },
|
||||||
@@ -122,6 +111,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
dataProvider ="invalidContainersForRecords",
|
dataProvider ="invalidContainersForRecords",
|
||||||
description ="Reading records from invalid containers"
|
description ="Reading records from invalid containers"
|
||||||
)
|
)
|
||||||
|
@AlfrescoTest(jira="RM-4361")
|
||||||
public void readRecordsFromInvalidContainers(String container) throws Exception
|
public void readRecordsFromInvalidContainers(String container) throws Exception
|
||||||
{
|
{
|
||||||
Record electronicRecord = Record.builder()
|
Record electronicRecord = Record.builder()
|
||||||
@@ -154,7 +144,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
}
|
}
|
||||||
else if(TRANSFERS_ALIAS.equals(container))
|
else if(TRANSFERS_ALIAS.equals(container))
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getTransferContainerAPI().getTransfers(container, "where=(isFile=true)")
|
getRestAPIFactory().getTransferContainerAPI().getTransfers(container, "where=(isRecord=true)")
|
||||||
.assertThat()//check the list returned is empty
|
.assertThat()//check the list returned is empty
|
||||||
.entriesListIsEmpty().assertThat().paginationExist();
|
.entriesListIsEmpty().assertThat().paginationExist();
|
||||||
//check response status code
|
//check response status code
|
||||||
@@ -181,11 +171,12 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
* Then I successfully receive the meta-data values for that record
|
* Then I successfully receive the meta-data values for that record
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@AlfrescoTest (jira = "RM-4361")
|
||||||
public void readRecordMetadata() throws Exception
|
public void readRecordMetadata() throws Exception
|
||||||
{
|
{
|
||||||
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
||||||
|
|
||||||
RecordCategory recordCategoryModel = createRecordCategoryModel(RECORD_CATEGORY_NAME, RECORD_CATEGORY_TITLE);
|
RecordCategory recordCategoryModel = createRecordCategoryModel(CATEGORY_NAME, CATEGORY_NAME);
|
||||||
String recordCategoryId = getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS).getId();
|
String recordCategoryId = getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS).getId();
|
||||||
|
|
||||||
//create the containers from the relativePath
|
//create the containers from the relativePath
|
||||||
@@ -236,6 +227,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
* Then I successfully receive the content of the record
|
* Then I successfully receive the content of the record
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@AlfrescoTest (jira = "RM-4361")
|
||||||
public void readRecordContent() throws Exception
|
public void readRecordContent() throws Exception
|
||||||
{
|
{
|
||||||
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||||
@@ -299,6 +291,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
* Then I am informed that the record has no content
|
* Then I am informed that the record has no content
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@AlfrescoTest (jira = "RM-4361")
|
||||||
public void readNonElectronicRecordContent() throws Exception
|
public void readNonElectronicRecordContent() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -322,7 +315,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
* Then I receive an error
|
* Then I receive an error
|
||||||
*/
|
*/
|
||||||
@DataProvider(name="noContentNodes")
|
@DataProvider(name="noContentNodes")
|
||||||
public String[][] getNonRecordTypes() throws Exception
|
public Object[][] getNonRecordTypes() throws Exception
|
||||||
{
|
{
|
||||||
return new String[][] {
|
return new String[][] {
|
||||||
{ getFilePlan(FILE_PLAN_ALIAS).getId() },
|
{ getFilePlan(FILE_PLAN_ALIAS).getId() },
|
||||||
@@ -335,180 +328,12 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
dataProvider = "noContentNodes",
|
dataProvider = "noContentNodes",
|
||||||
description = "Reading records from invalid containers"
|
description = "Reading records from invalid containers"
|
||||||
)
|
)
|
||||||
|
@AlfrescoTest (jira = "RM-4361")
|
||||||
public void readContentFromInvalidContainers(String container) throws Exception
|
public void readContentFromInvalidContainers(String container) throws Exception
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getRecordsAPI().getRecordContent(container).asString();
|
getRestAPIFactory().getRecordsAPI().getRecordContent(container).asString();
|
||||||
assertStatusCode(BAD_REQUEST);
|
assertStatusCode(BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a container that is a record folder
|
|
||||||
* When I try to record the containers records
|
|
||||||
* Then I receive a list of all the records contained within the record folder
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void readRecordsFromRecordFolder() throws Exception
|
|
||||||
{
|
|
||||||
final int NUMBER_OF_RECORDS = 5;
|
|
||||||
String containerId = createCategoryFolderInFilePlan().getId();
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
// Create Electronic Records
|
|
||||||
ArrayList<Record> children = new ArrayList<Record>();
|
|
||||||
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
|
||||||
{
|
|
||||||
//build the electronic record
|
|
||||||
Record record = Record.builder()
|
|
||||||
.name(ELECTRONIC_RECORD_NAME + i)
|
|
||||||
.nodeType(CONTENT_TYPE)
|
|
||||||
.build();
|
|
||||||
//create a child
|
|
||||||
Record child = recordFolderAPI.createRecord(record, containerId, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i ));
|
|
||||||
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
//Create NonElectronicRecords
|
|
||||||
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
|
||||||
{
|
|
||||||
Record nonelectronicRecord = Record.builder()
|
|
||||||
.properties(RecordProperties.builder()
|
|
||||||
.description("Description")
|
|
||||||
.title("Title")
|
|
||||||
.build())
|
|
||||||
.name(NONELECTRONIC_RECORD_NAME+i)
|
|
||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
|
||||||
.build();
|
|
||||||
//create records
|
|
||||||
Record child = recordFolderAPI.createRecord(nonelectronicRecord, containerId);
|
|
||||||
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
// List children from API
|
|
||||||
RecordFolderCollection apiChildren = (RecordFolderCollection) recordFolderAPI.getRecordFolderChildren(containerId).assertThat().entriesListIsNotEmpty();
|
|
||||||
|
|
||||||
// Check status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
|
|
||||||
// Check listed children against created list
|
|
||||||
apiChildren.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
Record record = c.getEntry();
|
|
||||||
assertNotNull(record.getId());
|
|
||||||
logger.info("Checking child " + record.getId());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Find this child in created children list
|
|
||||||
Record createdComponent = children.stream()
|
|
||||||
.filter(child -> child.getId().equals(record.getId()))
|
|
||||||
.findFirst()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
// Is parent Id set correctly
|
|
||||||
assertEquals(record.getParentId(), containerId);
|
|
||||||
|
|
||||||
//check the record name
|
|
||||||
assertTrue(record.getName().equals(createdComponent.getName()));
|
|
||||||
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
|
|
||||||
assertEquals(createdComponent.getNodeType(), record.getNodeType());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (NoSuchElementException e)
|
|
||||||
{
|
|
||||||
fail("No child element for " + record.getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a container that is a unfiled record folder
|
|
||||||
* When I try to record the containers records
|
|
||||||
* Then I receive a list of all the records contained within the unfiled record folder
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void readRecordsFromUnfiledRecordFolder() throws Exception
|
|
||||||
{
|
|
||||||
final int NUMBER_OF_RECORDS = 5;
|
|
||||||
String containerId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
|
|
||||||
//we have unfiled record folder
|
|
||||||
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
|
|
||||||
// Create Electronic Records
|
|
||||||
ArrayList<UnfiledContainerChild> children = new ArrayList<UnfiledContainerChild>();
|
|
||||||
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
|
||||||
{
|
|
||||||
//build the electronic record
|
|
||||||
UnfiledContainerChild record = UnfiledContainerChild.builder()
|
|
||||||
.name(ELECTRONIC_RECORD_NAME + i)
|
|
||||||
.nodeType(CONTENT_TYPE)
|
|
||||||
.build();
|
|
||||||
//create a child
|
|
||||||
UnfiledContainerChild child = unfiledRecordFoldersAPI.uploadRecord(record, containerId, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i ));
|
|
||||||
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
//Create NonElectronicRecords
|
|
||||||
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
|
||||||
{
|
|
||||||
UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder()
|
|
||||||
.properties(UnfiledContainerChildProperties.builder()
|
|
||||||
.description("Description")
|
|
||||||
.title("Title")
|
|
||||||
.build())
|
|
||||||
.name(NONELECTRONIC_RECORD_NAME+i)
|
|
||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
|
||||||
.build();
|
|
||||||
//create records
|
|
||||||
UnfiledContainerChild child = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, containerId);
|
|
||||||
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
// List children from API
|
|
||||||
UnfiledContainerChildCollection apiChildren = (UnfiledContainerChildCollection) unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(containerId).assertThat().entriesListIsNotEmpty();
|
|
||||||
|
|
||||||
// Check status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
|
|
||||||
// Check listed children against created list
|
|
||||||
apiChildren.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
UnfiledContainerChild record = c.getEntry();
|
|
||||||
assertNotNull(record.getId());
|
|
||||||
logger.info("Checking child " + record.getId());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Find this child in created children list
|
|
||||||
UnfiledContainerChild createdComponent = children.stream()
|
|
||||||
.filter(child -> child.getId().equals(record.getId()))
|
|
||||||
.findFirst()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
// Is parent Id set correctly
|
|
||||||
assertEquals(record.getParentId(), containerId);
|
|
||||||
assertTrue(record.getIsRecord());
|
|
||||||
|
|
||||||
// Boolean properties related to node type
|
|
||||||
assertFalse(record.getIsUnfiledRecordFolder());
|
|
||||||
|
|
||||||
//check the record name
|
|
||||||
assertTrue(record.getName().equals(createdComponent.getName()));
|
|
||||||
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
|
|
||||||
assertEquals(createdComponent.getNodeType(), record.getNodeType());
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (NoSuchElementException e)
|
|
||||||
{
|
|
||||||
fail("No child element for " + record.getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@@ -24,7 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.records;
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
|
||||||
@@ -89,7 +89,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
|
|||||||
|
|
||||||
/** Incomplete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */
|
/** Incomplete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */
|
||||||
@DataProvider(name = "incompleteRecords")
|
@DataProvider(name = "incompleteRecords")
|
||||||
public String[][] getIncompleteRecords() throws Exception
|
public Object[][] getIncompleteRecords() throws Exception
|
||||||
{
|
{
|
||||||
//create electronic and nonElectronic record in record folder
|
//create electronic and nonElectronic record in record folder
|
||||||
String recordFolderId = createCategoryFolderInFilePlan().getId();
|
String recordFolderId = createCategoryFolderInFilePlan().getId();
|
||||||
@@ -131,7 +131,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
|
|||||||
|
|
||||||
/** Complete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */
|
/** Complete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */
|
||||||
@DataProvider(name = "completeRecords")
|
@DataProvider(name = "completeRecords")
|
||||||
public String[][] getCompleteRecords() throws Exception
|
public Object[][] getCompleteRecords() throws Exception
|
||||||
{
|
{
|
||||||
//create electronic and nonElectronic record in record folder
|
//create electronic and nonElectronic record in record folder
|
||||||
String recordFolderId = createCategoryFolderInFilePlan().getId();
|
String recordFolderId = createCategoryFolderInFilePlan().getId();
|
@@ -24,18 +24,22 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.unfiledcontainers;
|
||||||
|
|
||||||
import static java.time.LocalDateTime.now;
|
import static java.time.LocalDateTime.now;
|
||||||
|
|
||||||
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.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
@@ -46,13 +50,18 @@ import java.util.List;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.base.TestData;
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
|
||||||
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
||||||
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
|
import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterMethod;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,6 +75,22 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
/** Number of children (for children creation test) */
|
/** Number of children (for children creation test) */
|
||||||
private static final int NUMBER_OF_CHILDREN = 10;
|
private static final int NUMBER_OF_CHILDREN = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Provider with:
|
||||||
|
* with the object types for creating a Unfiled Record Folder
|
||||||
|
*
|
||||||
|
* @return file plan component alias
|
||||||
|
*/
|
||||||
|
@DataProvider (name = "unfiledFolderTypes")
|
||||||
|
public static Object[][] unfiledFolderTypes()
|
||||||
|
{
|
||||||
|
return new String[][] {
|
||||||
|
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||||
|
{ FOLDER_TYPE }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* Given the RM site exists
|
* Given the RM site exists
|
||||||
@@ -132,18 +157,32 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
description = "Create unfiled record folder child in unfiled root container"
|
description = "Create unfiled record folder child in unfiled root container",
|
||||||
|
dataProvider = "unfiledFolderTypes"
|
||||||
)
|
)
|
||||||
public void createUnfiledRecordFolderChild() throws Exception
|
public void createUnfiledRecordFolderChild(String folderType) throws Exception
|
||||||
{
|
{
|
||||||
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
||||||
UnfiledContainerChild unfiledRecordFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
|
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
|
||||||
|
|
||||||
assertNotNull(unfiledRecordFolder.getId());
|
assertNotNull(unfiledRecordFolderChild.getId());
|
||||||
UnfiledContainer container = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS);
|
|
||||||
assertEquals(unfiledRecordFolder.getParentId(), container.getId());
|
// Verify the returned file plan component
|
||||||
assertFalse(unfiledRecordFolder.getIsRecord());
|
assertFalse(unfiledRecordFolderChild.getIsRecord());
|
||||||
assertEquals(unfiledRecordFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
|
assertTrue(unfiledRecordFolderChild.getIsUnfiledRecordFolder()); // it is not a _normal_ record folder!
|
||||||
|
|
||||||
|
assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
|
||||||
|
assertEquals(unfiledRecordFolderChild.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
|
||||||
|
|
||||||
|
assertEquals(unfiledRecordFolderChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
UnfiledRecordFolder unfiledRecordFolder = getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getId());
|
||||||
|
// Verify the returned file plan component properties
|
||||||
|
UnfiledContainerChildProperties unfiledRecordFolderChildProperties = unfiledRecordFolder.getProperties();
|
||||||
|
assertEquals(unfiledRecordFolderChildProperties.getTitle(), FilePlanComponentsUtil.TITLE_PREFIX + unfiledRecordFolderName);
|
||||||
|
assertNotNull(unfiledRecordFolderChildProperties.getIdentifier());
|
||||||
|
assertEquals(unfiledRecordFolder.getParentId(),
|
||||||
|
getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +196,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
(
|
(
|
||||||
description = "Create unfiled record folder child in unfiled root container"
|
description = "Create unfiled record folder child in unfiled root container"
|
||||||
)
|
)
|
||||||
public void createUnfiledRecordFolderChildWithRealtivePathNotSuported() throws Exception
|
public void createUnfiledRecordFolderChildWithRelativePathNotSuported() throws Exception
|
||||||
{
|
{
|
||||||
UnfiledContainerAPI unfiledContainerAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
UnfiledContainerAPI unfiledContainerAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
||||||
// relativePath specify the container structure to create relative to
|
// relativePath specify the container structure to create relative to
|
||||||
@@ -186,7 +225,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
description = "Create record child in unfiled root container"
|
description = "Create non-electronic record child in unfiled root container"
|
||||||
)
|
)
|
||||||
public void createNonElectronicRecordChild() throws Exception
|
public void createNonElectronicRecordChild() throws Exception
|
||||||
{
|
{
|
||||||
@@ -270,7 +309,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get children from API
|
// Get children from API
|
||||||
UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS);
|
UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS,"include=properties");
|
||||||
|
|
||||||
// Check status code
|
// Check status code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
@@ -308,13 +347,15 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue(containerChild.getIsRecord());
|
assertTrue(containerChild.getIsRecord());
|
||||||
|
assertTrue(containerChild.getName().contains(containerChild.getProperties().getIdentifier()),
|
||||||
|
"Records don't have in name the identifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does returned object have the same contents as the created one?
|
// Does returned object have the same contents as the created one?
|
||||||
assertEquals(createdComponent.getName(), containerChild.getName());
|
assertEquals(createdComponent.getName(), containerChild.getName());
|
||||||
assertEquals(createdComponent.getNodeType(), containerChild.getNodeType());
|
assertEquals(createdComponent.getNodeType(), containerChild.getNodeType());
|
||||||
|
|
||||||
// FIXME: Verify properties
|
// check rm identifier
|
||||||
assertNotNull(createdComponent.getProperties().getIdentifier());
|
assertNotNull(createdComponent.getProperties().getIdentifier());
|
||||||
|
|
||||||
// add the element to the matched children list
|
// add the element to the matched children list
|
||||||
@@ -331,6 +372,34 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
|||||||
assertTrue(createdChildren.containsAll(verifiedChildren));
|
assertTrue(createdChildren.containsAll(verifiedChildren));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Negative test to check that invalid types cannot be created at unfiled container root level
|
||||||
|
* Only unfiled record folders and records can be created into unfiled container
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
dataProvider = "invalidRootTypes",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
description = "Only unfiled records folders and records can be created as children for unfiled container root"
|
||||||
|
)
|
||||||
|
public void createInvalidUnfiledChildren(String filePlanComponentType)
|
||||||
|
{
|
||||||
|
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
logger.info("creating " + filePlanComponentType);
|
||||||
|
|
||||||
|
// Build unfiled records folder properties
|
||||||
|
UnfiledContainerChild unfiledFolderModel = createUnfiledContainerChildModel(unfiledRecordFolderName, filePlanComponentType);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||||
|
} catch (Exception error)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// Verify the status code
|
||||||
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
@AfterMethod
|
@AfterMethod
|
||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
@@ -24,21 +24,22 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.unfiledrecordfolders;
|
||||||
|
|
||||||
import static java.time.LocalDateTime.now;
|
import static java.time.LocalDateTime.now;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_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.UNFILED_CONTAINER_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||||
@@ -48,18 +49,23 @@ import static org.testng.Assert.assertEquals;
|
|||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.base.TestData;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
|
import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -71,49 +77,40 @@ import org.testng.annotations.Test;
|
|||||||
*/
|
*/
|
||||||
public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
||||||
{
|
{
|
||||||
/** invalid root level types, at unfiled records root level these shouldn't be possible to create */
|
public static final String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||||
|
public static final String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||||
|
|
||||||
@DataProvider(name = "invalidRootTypes")
|
/**
|
||||||
public String[][] createData()
|
* valid root level types, at unfiled record folder level these possible to create
|
||||||
|
*/
|
||||||
|
|
||||||
|
@DataProvider (name = "validChildren")
|
||||||
|
public Object[][] childrenForUnfiledRecord()
|
||||||
{
|
{
|
||||||
return new String[][]
|
return new String[][]
|
||||||
{
|
{
|
||||||
{ FILE_PLAN_TYPE },
|
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||||
{ RECORD_CATEGORY_TYPE },
|
{ CONTENT_TYPE },
|
||||||
{ RECORD_FOLDER_TYPE },
|
{ NON_ELECTRONIC_RECORD_TYPE }
|
||||||
{ TRANSFER_CONTAINER_TYPE },
|
|
||||||
{ UNFILED_CONTAINER_TYPE }
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given the unfiled record container root
|
* Invalid containers that cannot be updated/deleted with record folder endpoint
|
||||||
* When I create an unfiled record folder via the ReST API
|
|
||||||
* Then a root unfiled record folder is created
|
|
||||||
*
|
|
||||||
* @throws Exception if folder couldn't be created
|
|
||||||
*/
|
*/
|
||||||
@Test(description = "Create root unfiled records folder")
|
@DataProvider (name = "invalidNodesForDelete")
|
||||||
public void createRootUnfiledRecordsFolder() throws Exception
|
public Object[][] getInvalidNodes() throws Exception
|
||||||
{
|
{
|
||||||
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
return new String[][] {
|
||||||
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
|
{ getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId() },
|
||||||
|
{ getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
|
||||||
assertNotNull(unfiledRecordFolderChild.getId());
|
{ getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
|
||||||
|
// an arbitrary record category
|
||||||
// Verify the returned file plan component
|
{ createRootCategory(RECORD_CATEGORY_NAME).getId() },
|
||||||
assertFalse(unfiledRecordFolderChild.getIsRecord());
|
// an arbitrary unfiled records folder
|
||||||
assertTrue(unfiledRecordFolderChild.getIsUnfiledRecordFolder()); // it is not a _normal_ record folder!
|
{createCategoryFolderInFilePlan().getId()},
|
||||||
|
{createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Record " + getRandomAlphanumeric(), CONTENT_TYPE).getId() }
|
||||||
assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
|
};
|
||||||
assertEquals(unfiledRecordFolderChild.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
|
|
||||||
|
|
||||||
assertEquals(unfiledRecordFolderChild.getCreatedByUser().getId(), getAdminUser().getUsername());
|
|
||||||
|
|
||||||
UnfiledRecordFolder unfiledRecordFolder = getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getId());
|
|
||||||
// Verify the returned file plan component properties
|
|
||||||
UnfiledContainerChildProperties unfiledRecordFolderChildProperties = unfiledRecordFolder.getProperties();
|
|
||||||
assertEquals(unfiledRecordFolderChildProperties.getTitle(), FilePlanComponentsUtil.TITLE_PREFIX + unfiledRecordFolderName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,10 +122,11 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
description = "Create a folder based on the relativePath. " +
|
description = "Create a child into unfiled record folder based on the relativePath. " +
|
||||||
"Containers in the relativePath that do not exist are created before the node is created"
|
"Containers in the relativePath that do not exist are created before the node is created",
|
||||||
|
dataProvider = "validChildren"
|
||||||
)
|
)
|
||||||
public void createUnfiledRecordFolderWithRelativePath() throws Exception
|
public void createUnfiledRecordFolderWithRelativePath(String nodeType) throws Exception
|
||||||
{
|
{
|
||||||
String unfiledRecordFolderName1 = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
String unfiledRecordFolderName1 = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
||||||
UnfiledContainerChild unfiledRecordFolderChild1 = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName1, UNFILED_RECORD_FOLDER_TYPE);
|
UnfiledContainerChild unfiledRecordFolderChild1 = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName1, UNFILED_RECORD_FOLDER_TYPE);
|
||||||
@@ -139,21 +137,19 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth();
|
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth();
|
||||||
|
|
||||||
// The record folder to be created
|
// The record folder to be created
|
||||||
UnfiledContainerChild unfiledFolderModel =UnfiledContainerChild.builder()
|
UnfiledContainerChild unfiledChildModel =UnfiledContainerChild.builder()
|
||||||
.name(unfiledRecordFolderName2)
|
.name(unfiledRecordFolderName2)
|
||||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE)
|
.nodeType(nodeType)
|
||||||
.relativePath(relativePath)
|
.relativePath(relativePath)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
UnfiledContainerChild unfiledRecordFolderChild = getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(unfiledFolderModel, unfiledRecordFolderChild1.getId(), "include=" + PATH);
|
UnfiledContainerChild unfiledRecordFolderChild = getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(unfiledChildModel, unfiledRecordFolderChild1.getId(), "include=" + PATH);
|
||||||
|
|
||||||
// Check the API response code
|
// Check the API response code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
// Verify the returned details for the record folder
|
// Verify the returned node type
|
||||||
assertFalse(unfiledRecordFolderChild.getIsRecord());
|
assertTrue(nodeType.equals(unfiledRecordFolderChild.getNodeType()));
|
||||||
assertTrue(unfiledRecordFolderChild.getIsUnfiledRecordFolder());
|
|
||||||
assertTrue(UNFILED_RECORD_FOLDER_TYPE.equals(unfiledRecordFolderChild.getNodeType()));
|
|
||||||
|
|
||||||
// Check the path return contains the relativePath
|
// Check the path return contains the relativePath
|
||||||
assertTrue(unfiledRecordFolderChild.getPath().getName().contains(relativePath));
|
assertTrue(unfiledRecordFolderChild.getPath().getName().contains(relativePath));
|
||||||
@@ -161,15 +157,6 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
// Check the parent is a folder, not a record
|
// Check the parent is a folder, not a record
|
||||||
assertTrue(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getParentId()).getNodeType().equals(UNFILED_RECORD_FOLDER_TYPE));
|
assertTrue(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getParentId()).getNodeType().equals(UNFILED_RECORD_FOLDER_TYPE));
|
||||||
|
|
||||||
// Check the created folder from the server
|
|
||||||
UnfiledRecordFolder recordFolder = getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getId(), "include=" + PATH);
|
|
||||||
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Check the path return contains the relativePath
|
|
||||||
assertTrue(recordFolder.getPath().getName().contains(relativePath));
|
|
||||||
|
|
||||||
// New relative path only a part of containers need to be created before the record folder
|
// New relative path only a part of containers need to be created before the record folder
|
||||||
String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1);
|
String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1);
|
||||||
|
|
||||||
@@ -177,7 +164,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
// The record folder to be created
|
// The record folder to be created
|
||||||
UnfiledContainerChild newUnfiledFolderModel =UnfiledContainerChild.builder()
|
UnfiledContainerChild newUnfiledFolderModel =UnfiledContainerChild.builder()
|
||||||
.name(unfiledRecordFolderName3)
|
.name(unfiledRecordFolderName3)
|
||||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE)
|
.nodeType(nodeType)
|
||||||
.relativePath(newRelativePath)
|
.relativePath(newRelativePath)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -185,30 +172,17 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
|
|
||||||
// Check the API response code
|
// Check the API response code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
// Verify the returned properties for the unfiled record folder
|
|
||||||
assertTrue(newUnfiledRecordFolderChild.getIsUnfiledRecordFolder());
|
|
||||||
assertFalse(newUnfiledRecordFolderChild.getIsRecord());
|
|
||||||
|
|
||||||
// Check the path return contains the newRelativePath
|
// Check the path return contains the newRelativePath
|
||||||
assertTrue(newUnfiledRecordFolderChild.getPath().getName().contains(newRelativePath));
|
assertTrue(newUnfiledRecordFolderChild.getPath().getName().contains(newRelativePath));
|
||||||
|
|
||||||
// Check the parent is a folder, not a record
|
// Check the parent is a folder, not a record
|
||||||
assertFalse(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(newUnfiledRecordFolderChild.getParentId()).equals(UNFILED_RECORD_FOLDER_TYPE));
|
assertFalse(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(newUnfiledRecordFolderChild.getParentId()).equals(UNFILED_RECORD_FOLDER_TYPE));
|
||||||
|
// Verify the returned node type
|
||||||
|
assertTrue(nodeType.equals(newUnfiledRecordFolderChild.getNodeType()));
|
||||||
|
|
||||||
// Check the folder created on the server
|
|
||||||
UnfiledRecordFolder newRecordFolder = getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(newUnfiledRecordFolderChild.getId(), "include=" + PATH);
|
|
||||||
|
|
||||||
// Check the API response code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Check the path return contains the newRelativePath
|
|
||||||
assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Negative test to check that invalid types cannot be created at unfiled container root level
|
* Negative test to check that invalid types cannot be created at unfiled container root level
|
||||||
* Only unfiled record folders and records can be created into unfiled container
|
* Only unfiled record folders and records can be created into unfiled container
|
||||||
@@ -216,12 +190,13 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
dataProvider = "invalidRootTypes",
|
dataProvider = "invalidRootTypes",
|
||||||
description = "Only unfiled records folders can be created at unfiled records root level"
|
dataProviderClass = TestData.class,
|
||||||
|
description = "Only unfiled records folders and records can be created as children for unfiled container root"
|
||||||
)
|
)
|
||||||
public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(String filePlanComponentType)
|
public void createInvalidUnfiledChildren(String filePlanComponentType) throws Exception
|
||||||
{
|
{
|
||||||
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
||||||
|
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
|
||||||
logger.info("creating " + filePlanComponentType);
|
logger.info("creating " + filePlanComponentType);
|
||||||
|
|
||||||
// Build unfiled records folder properties
|
// Build unfiled records folder properties
|
||||||
@@ -229,12 +204,11 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
|
getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(unfiledFolderModel, unfiledRecordFolderChild.getId());
|
||||||
}
|
}
|
||||||
catch (Exception error)
|
catch (Exception error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
@@ -261,9 +235,12 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
assertEquals(unfiledParentFolderName, unfiledParentFolder.getName());
|
assertEquals(unfiledParentFolderName, unfiledParentFolder.getName());
|
||||||
|
|
||||||
// Build the unfiled records folder properties
|
// Build the unfiled records folder properties
|
||||||
UnfiledContainerChild unfiledChildFolderModel = UnfiledContainerChild.builder().name(unfiledChildFolderName)
|
UnfiledContainerChild unfiledChildFolderModel =
|
||||||
|
UnfiledContainerChild.builder()
|
||||||
|
.name(unfiledChildFolderName)
|
||||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE)
|
.nodeType(UNFILED_RECORD_FOLDER_TYPE)
|
||||||
.properties(UnfiledContainerChildProperties.builder().title(FilePlanComponentsUtil.TITLE_PREFIX + unfiledChildFolderName)
|
.properties(UnfiledContainerChildProperties.builder()
|
||||||
|
.title(FilePlanComponentsUtil.TITLE_PREFIX + unfiledChildFolderName)
|
||||||
.description(FilePlanComponentsUtil.DESCRIPTION_PREFIX + unfiledChildFolderName).build())
|
.description(FilePlanComponentsUtil.DESCRIPTION_PREFIX + unfiledChildFolderName).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -331,16 +308,32 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
assertEquals(unfiledFolderName, unfiledFolderToModify.getName());
|
assertEquals(unfiledFolderName, unfiledFolderToModify.getName());
|
||||||
|
|
||||||
// Build the properties which will be updated
|
// Build the properties which will be updated
|
||||||
UnfiledRecordFolder unfiledChildFolderModel = UnfiledRecordFolder.builder().name(modified + unfiledFolderName)
|
UnfiledRecordFolder unfiledChildFolderModel =
|
||||||
.properties(UnfiledContainerChildProperties.builder().title(modified + unfiledFolderToModify.getProperties().getTitle())
|
UnfiledRecordFolder.builder()
|
||||||
.description(modified + unfiledFolderToModify.getProperties().getDescription()).build())
|
.name(modified + unfiledFolderName)
|
||||||
|
.properties
|
||||||
|
(UnfiledContainerChildProperties.builder()
|
||||||
|
.title(modified + unfiledFolderToModify.getProperties().getTitle())
|
||||||
|
.description(modified + unfiledFolderToModify.getProperties().getDescription())
|
||||||
|
.build()
|
||||||
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Update the unfiled records folder
|
// Update the unfiled records folder
|
||||||
getRestAPIFactory().getUnfiledRecordFoldersAPI().updateUnfiledRecordFolder(unfiledChildFolderModel, unfiledFolderToModify.getId());
|
UnfiledRecordFolder updatedRecordFolder=getRestAPIFactory().getUnfiledRecordFoldersAPI().updateUnfiledRecordFolder(unfiledChildFolderModel, unfiledFolderToModify.getId());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
// Verify the returned file plan component
|
||||||
|
assertEquals(unfiledChildFolderModel.getName(),
|
||||||
|
updatedRecordFolder.getName());
|
||||||
|
assertEquals(unfiledChildFolderModel.getProperties().getTitle(),
|
||||||
|
updatedRecordFolder.getProperties().getTitle());
|
||||||
|
assertEquals(unfiledChildFolderModel.getProperties().getDescription(),
|
||||||
|
updatedRecordFolder.getProperties().getDescription());
|
||||||
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
|
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
|
||||||
UnfiledRecordFolder renamedUnfiledFolder = getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledFolderToModify.getId());
|
UnfiledRecordFolder renamedUnfiledFolder = getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledFolderToModify.getId());
|
||||||
|
|
||||||
@@ -393,7 +386,121 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMethod
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given other nodes type than unfiled record folders exists
|
||||||
|
* When I use the API from unfiled record-folders to delete the nodes
|
||||||
|
* Then the request fails
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Delete invalid nodes type with the DELETE unfiled record folders request",
|
||||||
|
dataProvider = "invalidNodesForDelete"
|
||||||
|
)
|
||||||
|
public void deleteInvalidNodesUnfiled(String nodeId) throws Exception
|
||||||
|
{
|
||||||
|
// Delete the nodes with record-folders end-point
|
||||||
|
UnfiledRecordFolderAPI unfiledFolderAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
|
||||||
|
unfiledFolderAPI.deleteUnfiledRecordFolder(nodeId);
|
||||||
|
|
||||||
|
// Check the response status code
|
||||||
|
assertStatusCode(BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a container that is a unfiled record folder
|
||||||
|
* When I try to record the containers records
|
||||||
|
* Then I receive a list of all the records contained within the unfiled record folder
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void readRecordsFromUnfiledRecordFolder() throws Exception
|
||||||
|
{
|
||||||
|
final int NUMBER_OF_RECORDS = 5;
|
||||||
|
String containerId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
|
||||||
|
//we have unfiled record folder
|
||||||
|
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
|
||||||
|
// Create Electronic Records
|
||||||
|
ArrayList<UnfiledContainerChild> children = new ArrayList<UnfiledContainerChild>();
|
||||||
|
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
||||||
|
{
|
||||||
|
//build the electronic record
|
||||||
|
UnfiledContainerChild record = UnfiledContainerChild.builder()
|
||||||
|
.name(ELECTRONIC_RECORD_NAME + i)
|
||||||
|
.nodeType(CONTENT_TYPE)
|
||||||
|
.build();
|
||||||
|
//create a child
|
||||||
|
UnfiledContainerChild child = unfiledRecordFoldersAPI.uploadRecord(record, containerId, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i));
|
||||||
|
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
//Create NonElectronicRecords
|
||||||
|
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
|
||||||
|
{
|
||||||
|
UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder()
|
||||||
|
.properties(UnfiledContainerChildProperties.builder()
|
||||||
|
.description("Description")
|
||||||
|
.title("Title")
|
||||||
|
.build())
|
||||||
|
.name(NONELECTRONIC_RECORD_NAME + i)
|
||||||
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||||
|
.build();
|
||||||
|
//create records
|
||||||
|
UnfiledContainerChild child = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, containerId);
|
||||||
|
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List children from API
|
||||||
|
UnfiledContainerChildCollection apiChildren = (UnfiledContainerChildCollection) unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(containerId,"include=properties").assertThat().entriesListIsNotEmpty();
|
||||||
|
|
||||||
|
// Check status code
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
|
||||||
|
// Check listed children against created list
|
||||||
|
apiChildren.getEntries().forEach(c ->
|
||||||
|
{
|
||||||
|
UnfiledContainerChild record = c.getEntry();
|
||||||
|
assertNotNull(record.getId());
|
||||||
|
logger.info("Checking child " + record.getId());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Find this child in created children list
|
||||||
|
UnfiledContainerChild createdComponent = children.stream()
|
||||||
|
.filter(child -> child.getId().equals(record.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
|
// Is parent Id set correctly
|
||||||
|
assertEquals(record.getParentId(), containerId);
|
||||||
|
assertTrue(record.getIsRecord());
|
||||||
|
|
||||||
|
// Boolean properties related to node type
|
||||||
|
assertFalse(record.getIsUnfiledRecordFolder());
|
||||||
|
|
||||||
|
//check the record name
|
||||||
|
assertTrue(record.getName().equals(createdComponent.getName()),
|
||||||
|
"The record name "+ record.getName()+" is not equal with the record name returned when creating the record " + createdComponent
|
||||||
|
.getName());
|
||||||
|
|
||||||
|
assertTrue(record.getName().equals(record.getProperties().getIdentifier()));
|
||||||
|
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
|
||||||
|
assertEquals(createdComponent.getNodeType(), record.getNodeType());
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException e)
|
||||||
|
{
|
||||||
|
fail("No child element for " + record.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
@@ -106,6 +106,7 @@
|
|||||||
<property name="searchTypesFactory" ref="searchTypesFactory" />
|
<property name="searchTypesFactory" ref="searchTypesFactory" />
|
||||||
<property name="fileFolderService" ref="FileFolderService" />
|
<property name="fileFolderService" ref="FileFolderService" />
|
||||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||||
|
<property name="transactionService" ref="transactionService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean class="org.alfresco.rm.rest.api.recordfolders.RecordFolderEntityResource">
|
<bean class="org.alfresco.rm.rest.api.recordfolders.RecordFolderEntityResource">
|
||||||
|
@@ -35,6 +35,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -42,6 +43,7 @@ import java.util.Set;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.repo.node.getchildren.FilterProp;
|
import org.alfresco.repo.node.getchildren.FilterProp;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.impl.Util;
|
import org.alfresco.rest.api.impl.Util;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
import org.alfresco.rest.api.model.UserInfo;
|
||||||
@@ -60,6 +62,7 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
|||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +84,7 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
|
|||||||
private SearchTypesFactory searchTypesFactory;
|
private SearchTypesFactory searchTypesFactory;
|
||||||
private FileFolderService fileFolderService;
|
private FileFolderService fileFolderService;
|
||||||
private ApiNodesModelFactory nodesModelFactory;
|
private ApiNodesModelFactory nodesModelFactory;
|
||||||
|
private TransactionService transactionService;
|
||||||
|
|
||||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||||
{
|
{
|
||||||
@@ -102,6 +106,11 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
|
|||||||
this.nodesModelFactory = nodesModelFactory;
|
this.nodesModelFactory = nodesModelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTransactionService(TransactionService transactionService)
|
||||||
|
{
|
||||||
|
this.transactionService = transactionService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@WebApiDescription(title = "Return a paged list of record category children for the container identified by 'recordCategoryId'")
|
@WebApiDescription(title = "Return a paged list of record category children for the container identified by 'recordCategoryId'")
|
||||||
public CollectionWithPagingInfo<RecordCategoryChild> readAll(String recordCategoryId, Parameters parameters)
|
public CollectionWithPagingInfo<RecordCategoryChild> readAll(String recordCategoryId, Parameters parameters)
|
||||||
@@ -164,18 +173,33 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
|
|||||||
|
|
||||||
List<RecordCategoryChild> result = new ArrayList<>(nodeInfos.size());
|
List<RecordCategoryChild> result = new ArrayList<>(nodeInfos.size());
|
||||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||||
|
|
||||||
|
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>()
|
||||||
|
{
|
||||||
|
public List<NodeRef> execute()
|
||||||
|
{
|
||||||
|
List<NodeRef> createdNodes = new LinkedList<>();
|
||||||
for (RecordCategoryChild nodeInfo : nodeInfos)
|
for (RecordCategoryChild nodeInfo : nodeInfos)
|
||||||
{
|
{
|
||||||
// Resolve the parent node
|
// Resolve the parent node
|
||||||
NodeRef nodeParent = parentNodeRef;
|
NodeRef nodeParent = parentNodeRef;
|
||||||
if (StringUtils.isNoneBlank(nodeInfo.getRelativePath()))
|
if (StringUtils.isNoneBlank(nodeInfo.getRelativePath()))
|
||||||
{
|
{
|
||||||
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(), RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(),
|
||||||
|
RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the node
|
// Create the node
|
||||||
NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
||||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
createdNodes.add(newNode);
|
||||||
|
}
|
||||||
|
return createdNodes;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||||
|
|
||||||
|
for (NodeRef nodeInfo : createdNodes)
|
||||||
|
{
|
||||||
|
FileInfo info = fileFolderService.getFileInfo(nodeInfo);
|
||||||
result.add(nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, false));
|
result.add(nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -307,7 +307,6 @@ paths:
|
|||||||
- $ref: '#/parameters/filePlanIdWithAliasParam'
|
- $ref: '#/parameters/filePlanIdWithAliasParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/recordCategoryEntryIncludeParam'
|
- $ref: '#/parameters/recordCategoryEntryIncludeParam'
|
||||||
- $ref: '#/parameters/filePlanIncludeSourceParam'
|
- $ref: '#/parameters/filePlanIncludeSourceParam'
|
||||||
- $ref: '#/parameters/fieldsParam'
|
- $ref: '#/parameters/fieldsParam'
|
||||||
@@ -536,7 +535,6 @@ paths:
|
|||||||
- $ref: '#/parameters/unfiledContainerIdParam'
|
- $ref: '#/parameters/unfiledContainerIdParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/unfiledRecordFolderAndContainerWhereParam'
|
- $ref: '#/parameters/unfiledRecordFolderAndContainerWhereParam'
|
||||||
- $ref: '#/parameters/unfiledContainerEntryIncludeParam'
|
- $ref: '#/parameters/unfiledContainerEntryIncludeParam'
|
||||||
- $ref: '#/parameters/unfiledContainerIncludeSourceParam'
|
- $ref: '#/parameters/unfiledContainerIncludeSourceParam'
|
||||||
@@ -839,7 +837,6 @@ paths:
|
|||||||
- $ref: '#/parameters/unfiledRecordFolderIdParam'
|
- $ref: '#/parameters/unfiledRecordFolderIdParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/unfiledRecordFolderAndContainerWhereParam'
|
- $ref: '#/parameters/unfiledRecordFolderAndContainerWhereParam'
|
||||||
- $ref: '#/parameters/unfiledRecordFolderEntryIncludeParam'
|
- $ref: '#/parameters/unfiledRecordFolderEntryIncludeParam'
|
||||||
- $ref: '#/parameters/unfiledRecordFolderRelativePathParam'
|
- $ref: '#/parameters/unfiledRecordFolderRelativePathParam'
|
||||||
@@ -1148,7 +1145,6 @@ paths:
|
|||||||
- $ref: '#/parameters/recordCategoryIdParam'
|
- $ref: '#/parameters/recordCategoryIdParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/recordCategoryWhereParam'
|
- $ref: '#/parameters/recordCategoryWhereParam'
|
||||||
- $ref: '#/parameters/recordCategoryChildIncludeParam'
|
- $ref: '#/parameters/recordCategoryChildIncludeParam'
|
||||||
- $ref: '#/parameters/recordCategoryRelativePathParam'
|
- $ref: '#/parameters/recordCategoryRelativePathParam'
|
||||||
@@ -1453,7 +1449,6 @@ paths:
|
|||||||
- $ref: '#/parameters/recordFolderIdParam'
|
- $ref: '#/parameters/recordFolderIdParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/recordFolderWhereParam'
|
- $ref: '#/parameters/recordFolderWhereParam'
|
||||||
- $ref: '#/parameters/recordFolderChildEntryIncludeParam'
|
- $ref: '#/parameters/recordFolderChildEntryIncludeParam'
|
||||||
- $ref: '#/parameters/recordFolderIncludeSourceParam'
|
- $ref: '#/parameters/recordFolderIncludeSourceParam'
|
||||||
@@ -1962,7 +1957,6 @@ paths:
|
|||||||
- $ref: '#/parameters/transferContainerIdWithAliasParam'
|
- $ref: '#/parameters/transferContainerIdWithAliasParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/transferEntryIncludeParam'
|
- $ref: '#/parameters/transferEntryIncludeParam'
|
||||||
- $ref: '#/parameters/transferContainerIncludeSourceParam'
|
- $ref: '#/parameters/transferContainerIncludeSourceParam'
|
||||||
- $ref: '#/parameters/fieldsParam'
|
- $ref: '#/parameters/fieldsParam'
|
||||||
@@ -2037,7 +2031,6 @@ paths:
|
|||||||
- $ref: '#/parameters/transferIdParam'
|
- $ref: '#/parameters/transferIdParam'
|
||||||
- $ref: '#/parameters/skipCountParam'
|
- $ref: '#/parameters/skipCountParam'
|
||||||
- $ref: '#/parameters/maxItemsParam'
|
- $ref: '#/parameters/maxItemsParam'
|
||||||
- $ref: '#/parameters/orderByParam'
|
|
||||||
- $ref: '#/parameters/transferChildEntryIncludeParam'
|
- $ref: '#/parameters/transferChildEntryIncludeParam'
|
||||||
- $ref: '#/parameters/transferIncludeSourceParam'
|
- $ref: '#/parameters/transferIncludeSourceParam'
|
||||||
- $ref: '#/parameters/fieldsParam'
|
- $ref: '#/parameters/fieldsParam'
|
||||||
@@ -2422,23 +2415,6 @@ parameters:
|
|||||||
required: false
|
required: false
|
||||||
type: integer
|
type: integer
|
||||||
minimum: 1
|
minimum: 1
|
||||||
## Core parameter
|
|
||||||
orderByParam:
|
|
||||||
name: orderBy
|
|
||||||
in: query
|
|
||||||
description: |
|
|
||||||
A string to control the order of the entities returned in a list. You can use the **orderBy** parameter to
|
|
||||||
sort the list by one or more fields.
|
|
||||||
|
|
||||||
Each field has a default sort order, which is normally acending order. Read the API method implementation notes
|
|
||||||
above to check if any fields used in this method have a descending default search order.
|
|
||||||
|
|
||||||
To sort the entities in a specific order, you can use the **ASC** and **DESC** keywords for any field.
|
|
||||||
required: false
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
collectionFormat: csv
|
|
||||||
# Core definition
|
# Core definition
|
||||||
attachmentParam:
|
attachmentParam:
|
||||||
name: attachment
|
name: attachment
|
||||||
|
Reference in New Issue
Block a user