mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'master' into feature/RM-5087_UpdateNotesForGETEndpoints
This commit is contained in:
@@ -48,9 +48,18 @@ public class FilePlanComponentFields
|
||||
public static final String PROPERTIES_VITAL_RECORD_INDICATOR = "rma:vitalRecordIndicator";
|
||||
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
|
||||
public static final String PROPERTIES_OWNER = "cm:owner";
|
||||
public static final String PROPERTIES_AUTHOR="cm:author";
|
||||
|
||||
/** Common properties for record folders and records */
|
||||
public static final String PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE = "rma:recordSearchHasDispositionSchedule";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION = "rma:recordSearchDispositionPeriodExpression";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY = "rma:recordSearchDispositionAuthority";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF = "rma:recordSearchDispositionActionAsOf";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD = "rma:recordSearchDispositionPeriod";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME = "rma:recordSearchDispositionActionName";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE = "rma:recordSearchDispositionEventsEligible";
|
||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS = "rma:recordSearchDispositionInstructions";
|
||||
|
||||
|
||||
/** File plan properties */
|
||||
public static final String PROPERTIES_COMPONENT_ID = "st:componentId";
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
package org.alfresco.rest.rm.community.model.record;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_AUTHOR;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_BOX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_FILED;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_TIME_ORIGINAL;
|
||||
@@ -200,4 +201,7 @@ public class RecordProperties extends TestModel
|
||||
|
||||
@JsonProperty (PROPERTIES_OWNER)
|
||||
private Owner owner;
|
||||
|
||||
@JsonProperty(PROPERTIES_AUTHOR)
|
||||
private String author;
|
||||
}
|
||||
|
@@ -32,15 +32,26 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ID_IS_TEMPORARILY_EDITABLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IS_CLOSED;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
|
||||
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_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS;
|
||||
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_TITLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.common.Owner;
|
||||
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
||||
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
@@ -103,4 +114,28 @@ public class RecordCategoryChildProperties extends TestModel
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
|
||||
private Boolean recordSearchHasDispositionSchedule;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
|
||||
private String recordSearchDispositionPeriodExpression;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
|
||||
private String recordSearchDispositionAuthority;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF)
|
||||
private Date recordSearchDispositionActionAsOf;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD)
|
||||
private String recordSearchDispositionPeriod;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME)
|
||||
private String recordSearchDispositionActionName;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE)
|
||||
private Boolean recordSearchDispositionEventsEligible;
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
|
||||
private String recordSearchDispositionInstructions;
|
||||
|
||||
@JsonProperty (PROPERTIES_OWNER)
|
||||
private Owner owner;
|
||||
}
|
@@ -29,12 +29,11 @@ package org.alfresco.rest.rm.community.model.transfer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.model.RestByUserModel;
|
||||
import org.alfresco.rest.rm.community.model.common.Path;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.model.RestByUserModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@@ -29,12 +29,11 @@ package org.alfresco.rest.rm.community.model.transfercontainer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.model.RestByUserModel;
|
||||
import org.alfresco.rest.rm.community.model.common.Path;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.model.RestByUserModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@@ -58,13 +58,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
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 org.alfresco.rest.rm.community.model.common.Owner;
|
||||
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
||||
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.common.Owner;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -159,7 +157,7 @@ public class UnfiledContainerChildProperties extends TestModel
|
||||
|
||||
@JsonProperty (PROPERTIES_Y_RESOLUTION)
|
||||
private Double yResolution;
|
||||
|
||||
|
||||
@JsonProperty (PROPERTIES_ORIGINAL_NAME)
|
||||
private String originalName;
|
||||
|
||||
|
@@ -28,15 +28,12 @@ package org.alfresco.rest.rm.community.model.unfiledcontainer;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ID_IS_TEMPORARILY_EDITABLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
|
||||
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 org.alfresco.rest.rm.community.model.common.Owner;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -67,5 +64,4 @@ public class UnfiledContainerProperties extends TestModel
|
||||
|
||||
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
|
||||
private String rootNodeRef;
|
||||
|
||||
}
|
||||
|
@@ -41,19 +41,18 @@ import static org.testng.Assert.fail;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
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.UnfiledContainerChildCollection;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
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.UnfiledContainerChildCollection;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
|
||||
|
||||
/**
|
||||
* Unfiled Container REST API Wrapper
|
||||
*
|
||||
@@ -209,7 +208,7 @@ public class UnfiledContainerAPI extends RMModelRequest
|
||||
* to the request.
|
||||
*/
|
||||
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
|
||||
JsonNode root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, Record.class, FilePlanComponentMixIn.class));
|
||||
JsonNode root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class));
|
||||
// add request fields
|
||||
Iterator<String> fieldNames = root.fieldNames();
|
||||
while (fieldNames.hasNext())
|
||||
|
@@ -42,19 +42,18 @@ import static org.testng.Assert.fail;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
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.UnfiledRecordFolder;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
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.UnfiledRecordFolder;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
|
||||
|
||||
/**
|
||||
* Unfiled Record Folders REST API Wrapper
|
||||
*
|
||||
@@ -209,7 +208,7 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
|
||||
* to the request.
|
||||
*/
|
||||
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
|
||||
JsonNode root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, Record.class, FilePlanComponentMixIn.class));
|
||||
JsonNode root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class));
|
||||
// add request fields
|
||||
Iterator<String> fieldNames = root.fieldNames();
|
||||
while (fieldNames.hasNext())
|
||||
|
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
||||
|
||||
/**
|
||||
* Mix class for Record POJO class
|
||||
* Mix-in annotations are: a way to associate annotations with classes
|
||||
* without modifying (target) classes themselves.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class UnfiledContainerChildMixin
|
||||
{
|
||||
/**
|
||||
* Annotation used to indicate that a property should be serialized "unwrapped"
|
||||
* Its properties are instead included as properties of its containing Object
|
||||
*/
|
||||
@JsonUnwrapped
|
||||
abstract UnfiledContainerChildProperties getProperties();
|
||||
}
|
@@ -54,7 +54,6 @@ import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -77,8 +76,6 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
||||
@Autowired
|
||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/** user service */
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
@@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.base;
|
||||
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE;
|
||||
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;
|
||||
@@ -35,10 +36,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
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.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.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.createRecordCategoryChildModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
||||
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.RMSiteUtil.createStandardRMSiteModel;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
@@ -52,6 +54,7 @@ import java.util.List;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestAPIFactory;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
@@ -334,8 +337,17 @@ public class BaseRMRestTest extends RestTest
|
||||
*/
|
||||
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
||||
{
|
||||
UnfiledContainerChild child = null;
|
||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||
UnfiledContainerChild child = getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(childModel, parentId);
|
||||
|
||||
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
|
||||
{
|
||||
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
||||
}
|
||||
else
|
||||
{
|
||||
child = getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(childModel, parentId);
|
||||
}
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
return child;
|
||||
|
@@ -159,6 +159,22 @@ public interface TestData
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Data Provider with:
|
||||
* with the object types for creating a Record Category Child
|
||||
*
|
||||
* @return record category child type
|
||||
*/
|
||||
@DataProvider
|
||||
public static Object[][] categoryChild()
|
||||
{
|
||||
return new String[][] {
|
||||
{ RECORD_FOLDER_TYPE },
|
||||
{ FOLDER_TYPE },
|
||||
{ RECORD_CATEGORY_TYPE }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalid root level types, at unfiled record folder/unfiled containers container level that shouldn't be possible to create
|
||||
*/
|
||||
|
@@ -45,12 +45,14 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
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.CONFLICT;
|
||||
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.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
@@ -241,10 +243,10 @@ public class FilePlanTests extends BaseRMRestTest
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Verify the returned description field for the file plan component
|
||||
assertEquals(renamedFilePlan.getProperties().getDescription(), FILE_PLAN_DESCRIPTION);
|
||||
assertEquals(FILE_PLAN_DESCRIPTION, renamedFilePlan.getProperties().getDescription());
|
||||
|
||||
// Verify the returned title field for the file plan component
|
||||
assertEquals(renamedFilePlan.getProperties().getTitle(), FILE_PLAN_TITLE);
|
||||
assertEquals(FILE_PLAN_TITLE, renamedFilePlan.getProperties().getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,6 +324,56 @@ public class FilePlanTests extends BaseRMRestTest
|
||||
assertNotNull(rootRecordCategoryProperties.getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a root category
|
||||
* When I ask the API to create a root category having the same name
|
||||
* Then the response code received is 409 - name clashes with an existing node
|
||||
*</pre>
|
||||
* <pre>
|
||||
* Given a root category
|
||||
* When I ask the API to create a root category having the same name with autoRename parameter on true
|
||||
* Then the record category is created the record category has a unique name by adding an integer suffix
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Bug(id = "RM-5116")
|
||||
public void createDuplicateCategories() 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())
|
||||
.build();
|
||||
// Create the root record category
|
||||
RecordCategory rootRecordCategory = getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory,FILE_PLAN_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(CREATED);
|
||||
assertEquals(rootRecordCategory.getName(), categoryName);
|
||||
|
||||
// Create the same root record category
|
||||
getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(CONFLICT);
|
||||
|
||||
//create the same category with autoRename parameter on true
|
||||
RecordCategory rootRecordCategoryAutoRename = getRestAPIFactory().getFilePlansAPI()
|
||||
.createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS,"autoRename=true");
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(CREATED);
|
||||
assertNotEquals(rootRecordCategoryAutoRename.getName(), categoryName);
|
||||
assertTrue(rootRecordCategoryAutoRename.getName().startsWith(categoryName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listFilePlanChildren() throws Exception
|
||||
{
|
||||
|
@@ -38,8 +38,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
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.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||
@@ -47,6 +49,7 @@ 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.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
@@ -294,6 +297,42 @@ public class RecordCategoryTests extends BaseRMRestTest
|
||||
assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
|
||||
assertNotNull(folderProperties.getIdentifier());
|
||||
}
|
||||
@Test
|
||||
(
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "categoryChild"
|
||||
)
|
||||
@Bug(id = "RM-5116")
|
||||
public void createdDuplicateChild(String childType)throws Exception
|
||||
{
|
||||
// create a root category
|
||||
String rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId();
|
||||
|
||||
// Create the record category child
|
||||
RecordCategoryChild recordFolder = createRecordCategoryChild(rootRecordCategory, RECORD_FOLDER_NAME, childType);
|
||||
|
||||
// check the response code
|
||||
assertStatusCode(CREATED);
|
||||
assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
|
||||
|
||||
// Create a record category child with the same name as the exiting one
|
||||
|
||||
RecordCategoryChild recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI().createRecordCategoryChild(
|
||||
createRecordCategoryChildModel(RECORD_FOLDER_NAME, childType), rootRecordCategory);
|
||||
|
||||
// check the response code
|
||||
assertStatusCode(CONFLICT);
|
||||
|
||||
// Create a record folder with the same name as the exiting one and with the autoRename parameter on true
|
||||
recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI()
|
||||
.createRecordCategoryChild(createRecordCategoryChildModel(RECORD_FOLDER_NAME,
|
||||
childType),
|
||||
rootRecordCategory, "autoRename=true");
|
||||
// check the response code
|
||||
assertStatusCode(CREATED);
|
||||
assertNotEquals(recordFolderDuplicate.getName(), RECORD_FOLDER_NAME);
|
||||
assertTrue(recordFolderDuplicate.getName().contains(RECORD_FOLDER_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
@@ -349,9 +349,6 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
UnfiledContainerChild unfiledContainerChildModel= UnfiledContainerChild.builder()
|
||||
.name(ELECTRONIC_RECORD_NAME)
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.content(RecordContent.builder()
|
||||
.mimeType(TEXT_PLAIN_VALUE)
|
||||
.build())
|
||||
.relativePath(relativePath)
|
||||
.build();
|
||||
|
||||
|
@@ -38,10 +38,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
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.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
@@ -59,6 +62,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChi
|
||||
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.utils.FilePlanComponentsUtil;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -163,7 +167,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
||||
public void createUnfiledRecordFolderChild(String folderType) throws Exception
|
||||
{
|
||||
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
||||
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
|
||||
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, folderType);
|
||||
|
||||
assertNotNull(unfiledRecordFolderChild.getId());
|
||||
|
||||
@@ -184,7 +188,40 @@ public class UnfiledContainerTests extends BaseRMRestTest
|
||||
assertEquals(unfiledRecordFolder.getParentId(),
|
||||
getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
( description = "Create duplicate unfiled folder child",
|
||||
dataProvider = "unfiledFolderTypes"
|
||||
)
|
||||
@Bug(id ="RM-5116, RM-5148")
|
||||
public void createDuplicateUnfiledFolderChild(String folderType) throws Exception
|
||||
{
|
||||
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
|
||||
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
|
||||
unfiledRecordFolderName, folderType);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(CREATED);
|
||||
assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
|
||||
|
||||
// create the same unfiled folder
|
||||
UnfiledContainerChild unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
|
||||
.createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(CONFLICT);
|
||||
|
||||
// create the same unfiled folder with the autoRename parameter on true
|
||||
unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
|
||||
.createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),UNFILED_RECORDS_CONTAINER_ALIAS,"autoRename=true");
|
||||
|
||||
//verify the response status code
|
||||
assertStatusCode(CREATED);
|
||||
assertNotEquals(unfiledRecordFolderDuplicate.getName(), unfiledRecordFolderName);
|
||||
assertTrue(unfiledRecordFolderDuplicate.getName().startsWith(unfiledRecordFolderName));
|
||||
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* Given that an unfiled records container exists
|
||||
|
@@ -58,6 +58,7 @@
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.fileplans.FilePlanChildrenRelation">
|
||||
@@ -65,12 +66,14 @@
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="searchTypesFactory" ref="searchTypesFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.unfiledcontainers.UnfiledContainerEntityResource">
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.unfiledcontainers.UnfiledContainerChildrenRelation">
|
||||
@@ -85,6 +88,7 @@
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.unfiledrecordfolders.UnfiledRecordFolderChildrenRelation">
|
||||
@@ -99,6 +103,7 @@
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.recordcategories.RecordCategoryChildrenRelation">
|
||||
@@ -106,12 +111,14 @@
|
||||
<property name="searchTypesFactory" ref="searchTypesFactory" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.recordfolders.RecordFolderEntityResource">
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.recordfolders.RecordFolderChildrenRelation">
|
||||
@@ -128,6 +135,7 @@
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="recordService" ref="RecordService"/>
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.files.FilesEntityResource">
|
||||
@@ -142,6 +150,7 @@
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.transfercontainers.TransferContainerChildrenRelation">
|
||||
|
@@ -33,12 +33,15 @@ import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.node.getchildren.FilterProp;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
@@ -51,11 +54,13 @@ import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.FilePlan;
|
||||
import org.alfresco.rm.rest.api.model.Record;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategory;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -76,6 +81,7 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -97,6 +103,11 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -173,22 +184,38 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
QName filePlanType = apiUtils.getFilePlanType();
|
||||
if(filePlanType == null)// rm site not created
|
||||
if (filePlanType == null)// rm site not created
|
||||
{
|
||||
throw new EntityNotFoundException(filePlanId);
|
||||
}
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
|
||||
|
||||
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>()
|
||||
{
|
||||
public List<NodeRef> execute()
|
||||
{
|
||||
List<NodeRef> createdNodes = new LinkedList<>();
|
||||
for (RecordCategory nodeInfo : nodeInfos)
|
||||
{
|
||||
// Create the node
|
||||
nodeInfo.setNodeType(RECORD_CATEGORY_TYPE);
|
||||
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
|
||||
createdNodes.add(newNodeRef);
|
||||
}
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// Get the nodes info
|
||||
List<RecordCategory> result = new ArrayList<>(nodeInfos.size());
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for (RecordCategory nodeInfo : nodeInfos)
|
||||
for (NodeRef newNodeRef : createdNodes)
|
||||
{
|
||||
// Create the node
|
||||
nodeInfo.setNodeType(RECORD_CATEGORY_TYPE);
|
||||
NodeRef newNode = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
|
||||
result.add(nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ package org.alfresco.rm.rest.api.fileplans;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -60,6 +62,7 @@ public class FilePlanEntityResource
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -76,6 +79,11 @@ public class FilePlanEntityResource
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -117,9 +125,26 @@ public class FilePlanEntityResource
|
||||
throw new EntityNotFoundException(filePlanId);
|
||||
}
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
|
||||
apiUtils.updateNode(nodeRef, filePlanInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
RetryingTransactionCallback<Void> updateCallback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateNode(nodeRef, filePlanInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(updateCallback, false, true);
|
||||
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(nodeRef);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
return nodesModelFactory.createFilePlan(info, parameters, null, false);
|
||||
}
|
||||
}
|
||||
|
@@ -628,7 +628,7 @@ public class FilePlanComponentsApiUtils
|
||||
QName typeQName = nodes.createQName(nodeType);
|
||||
|
||||
// Existing file/folder name handling
|
||||
if (TYPES_CAN_CREATE.contains(typeQName) && autoRename)
|
||||
if (TYPES_CAN_USE_AUTORENAME.contains(typeQName) && autoRename)
|
||||
{
|
||||
NodeRef existingNode = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, nodeName);
|
||||
if (existingNode != null)
|
||||
|
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
@@ -50,6 +51,8 @@ public class UploadInfo
|
||||
|
||||
public UploadInfo(FormData formData)
|
||||
{
|
||||
properties = new HashMap<>();
|
||||
|
||||
for (FormData.FormField field : formData.getFields())
|
||||
{
|
||||
switch (field.getName().toLowerCase())
|
||||
|
@@ -31,6 +31,7 @@ import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.c
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.rm.rest.api.model.RecordCategory;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -62,6 +64,7 @@ public class RecordCategoriesEntityResource implements
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -78,6 +81,11 @@ public class RecordCategoriesEntityResource implements
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -111,9 +119,26 @@ public class RecordCategoriesEntityResource implements
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
apiUtils.updateNode(nodeRef, recordCategoryInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateNode(nodeRef, recordCategoryInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(nodeRef);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
return nodesModelFactory.createRecordCategory(info, parameters, null, false);
|
||||
}
|
||||
|
||||
|
@@ -36,6 +36,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -44,6 +45,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
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.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
@@ -62,6 +64,7 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -83,6 +86,7 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -104,6 +108,11 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of record category children for the container identified by 'recordCategoryId'")
|
||||
public CollectionWithPagingInfo<RecordCategoryChild> readAll(String recordCategoryId, Parameters parameters)
|
||||
@@ -167,18 +176,33 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
|
||||
|
||||
List<RecordCategoryChild> result = new ArrayList<>(nodeInfos.size());
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for (RecordCategoryChild nodeInfo : nodeInfos)
|
||||
{
|
||||
// Resolve the parent node
|
||||
NodeRef nodeParent = parentNodeRef;
|
||||
if(StringUtils.isNoneBlank(nodeInfo.getRelativePath()))
|
||||
{
|
||||
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(), RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
|
||||
// Create the node
|
||||
NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo, parameters);
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>()
|
||||
{
|
||||
public List<NodeRef> execute()
|
||||
{
|
||||
List<NodeRef> createdNodes = new LinkedList<>();
|
||||
for (RecordCategoryChild nodeInfo : nodeInfos)
|
||||
{
|
||||
// Resolve the parent node
|
||||
NodeRef nodeParent = parentNodeRef;
|
||||
if (StringUtils.isNoneBlank(nodeInfo.getRelativePath()))
|
||||
{
|
||||
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(),
|
||||
RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
// Create the node
|
||||
NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo, parameters);
|
||||
createdNodes.add(newNode);
|
||||
}
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
for (NodeRef nodeInfo : createdNodes)
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeInfo);
|
||||
result.add(nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
|
||||
|
@@ -173,7 +173,7 @@ public class RecordFolderChildrenRelation implements RelationshipResourceAction.
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// Get the nodes info
|
||||
List<Record> result = new LinkedList<>();
|
||||
@@ -211,7 +211,7 @@ public class RecordFolderChildrenRelation implements RelationshipResourceAction.
|
||||
uploadInfo.getContent().getInputStream());
|
||||
}
|
||||
};
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// Get file info for response
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
|
@@ -31,6 +31,7 @@ import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.c
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
@@ -42,6 +43,7 @@ import org.alfresco.rm.rest.api.model.RecordFolder;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -59,6 +61,7 @@ public class RecordFolderEntityResource implements EntityResourceAction.ReadById
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -75,6 +78,11 @@ public class RecordFolderEntityResource implements EntityResourceAction.ReadById
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -106,9 +114,26 @@ public class RecordFolderEntityResource implements EntityResourceAction.ReadById
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
apiUtils.updateNode(nodeRef, recordFolderInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateNode(nodeRef, recordFolderInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(nodeRef);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
return nodesModelFactory.createRecordFolder(info, parameters, null, false);
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
@@ -56,6 +57,7 @@ import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
@@ -80,6 +82,7 @@ public class RecordsEntityResource implements BinaryResourceAction.Read,
|
||||
private FileFolderService fileFolderService;
|
||||
private RecordService recordService;
|
||||
private NodeService nodeService;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
@@ -105,6 +108,12 @@ public class RecordsEntityResource implements BinaryResourceAction.Read,
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download content
|
||||
*
|
||||
@@ -197,10 +206,26 @@ public class RecordsEntityResource implements BinaryResourceAction.Read,
|
||||
NodeRef record = apiUtils.validateRecord(recordId);
|
||||
|
||||
// update info
|
||||
apiUtils.updateNode(record, recordInfo, parameters);
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateNode(record, recordInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// return record state
|
||||
FileInfo info = fileFolderService.getFileInfo(record);
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(record);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
apiUtils.postActivity(info, recordInfo.getParentId(), ActivityType.FILE_UPDATED);
|
||||
return nodesModelFactory.createRecord(info, parameters, null, false);
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.c
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.rm.rest.api.model.TransferContainer;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -60,6 +62,7 @@ public class TransferContainerEntityResource implements
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -76,6 +79,11 @@ public class TransferContainerEntityResource implements
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -108,9 +116,27 @@ public class TransferContainerEntityResource implements
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
|
||||
apiUtils.updateTransferContainer(nodeRef, transferContainerInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
// update info
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateTransferContainer(nodeRef, transferContainerInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(nodeRef);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
return nodesModelFactory.createTransferContainer(info, parameters, null, false);
|
||||
}
|
||||
}
|
||||
|
@@ -192,7 +192,7 @@ public class UnfiledContainerChildrenRelation implements RelationshipResourceAct
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// Get the nodes info
|
||||
List<UnfiledContainerChild> result = new LinkedList<>();
|
||||
@@ -226,7 +226,7 @@ public class UnfiledContainerChildrenRelation implements RelationshipResourceAct
|
||||
return apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
|
||||
}
|
||||
};
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// Get file info for response
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
|
@@ -32,6 +32,7 @@ import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.rm.rest.api.model.UnfiledContainer;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -60,6 +62,7 @@ public class UnfiledContainerEntityResource
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
@@ -76,6 +79,11 @@ public class UnfiledContainerEntityResource
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -107,9 +115,26 @@ public class UnfiledContainerEntityResource
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
apiUtils.updateNode(nodeRef, unfiledContainerInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateNode(nodeRef, unfiledContainerInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(nodeRef);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
apiUtils.postActivity(info, unfiledContainerInfo.getParentId(), ActivityType.FILE_UPDATED);
|
||||
return nodesModelFactory.createUnfiledContainer(info, parameters, null, false);
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
@@ -198,7 +199,7 @@ public class UnfiledRecordFolderChildrenRelation implements RelationshipResource
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
// Get the nodes info
|
||||
List<UnfiledRecordFolderChild> result = new LinkedList<>();
|
||||
@@ -224,21 +225,25 @@ public class UnfiledRecordFolderChildrenRelation implements RelationshipResource
|
||||
|
||||
// Retrieve the input data and resolve the parent node
|
||||
final UploadInfo uploadInfo = new UploadInfo(formData);
|
||||
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, uploadInfo.getRelativePath());
|
||||
|
||||
// Create the record
|
||||
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||
// Create the record - returns pair(newNode,parentNode)
|
||||
RetryingTransactionCallback<Pair<NodeRef,NodeRef>> callback = new RetryingTransactionCallback<Pair<NodeRef,NodeRef>>()
|
||||
{
|
||||
public NodeRef execute()
|
||||
public Pair<NodeRef,NodeRef> execute()
|
||||
{
|
||||
return apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
|
||||
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, uploadInfo.getRelativePath());
|
||||
NodeRef newNode = apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
|
||||
return new Pair<NodeRef, NodeRef>(newNode, parentNodeRef);
|
||||
}
|
||||
};
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
Pair<NodeRef,NodeRef> nodeAndParentInfo = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
NodeRef newNode = nodeAndParentInfo.getFirst();
|
||||
NodeRef parent = nodeAndParentInfo.getSecond();
|
||||
|
||||
// Get file info for response
|
||||
// Get file info for response
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
apiUtils.postActivity(info, parent, ActivityType.FILE_ADDED);
|
||||
|
||||
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, null, false);
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
@@ -44,6 +45,7 @@ import org.alfresco.rm.rest.api.model.UnfiledRecordFolder;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -61,6 +63,8 @@ public class UnfiledRecordFolderEntityResource implements EntityResourceAction.R
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
@@ -76,6 +80,11 @@ public class UnfiledRecordFolderEntityResource implements EntityResourceAction.R
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
@@ -110,9 +119,26 @@ public class UnfiledRecordFolderEntityResource implements EntityResourceAction.R
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
|
||||
apiUtils.updateNode(nodeRef, unfiledRecordFolderInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute()
|
||||
{
|
||||
apiUtils.updateNode(nodeRef, unfiledRecordFolderInfo, parameters);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
|
||||
|
||||
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
|
||||
{
|
||||
public FileInfo execute()
|
||||
{
|
||||
return fileFolderService.getFileInfo(nodeRef);
|
||||
}
|
||||
};
|
||||
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
|
||||
|
||||
apiUtils.postActivity(info, unfiledRecordFolderInfo.getParentId(), ActivityType.FILE_UPDATED);
|
||||
return nodesModelFactory.createUnfiledRecordFolder(info, parameters, null, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user