From d968624c2fb9a32a29035ddbd8cd0441113e179a Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 28 Nov 2016 21:20:11 +0000 Subject: [PATCH 01/30] RM-4396: Experiment using lombok to remove boiler plate code --- .../.gitignore | 1 + .../rm-automation-community-rest-api/pom.xml | 6 + .../fileplancomponents/FilePlanComponent.java | 330 +----------------- .../FilePlanComponentProperties.java | 138 +------- .../rest/rm/community/base/BaseRestTest.java | 8 +- .../fileplancomponents/FilePlanTests.java | 16 +- .../RecordCategoryTest.java | 76 ++-- .../fileplancomponents/RecordFolderTests.java | 56 +-- .../UnfiledRecordsFolderTests.java | 53 ++- 9 files changed, 172 insertions(+), 512 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/.gitignore b/rm-automation/rm-automation-community-rest-api/.gitignore index d1a4acb433..bb654bad1e 100644 --- a/rm-automation/rm-automation-community-rest-api/.gitignore +++ b/rm-automation/rm-automation-community-rest-api/.gitignore @@ -6,3 +6,4 @@ /.idea/ *.iml /test-output/ +.factorypath \ No newline at end of file diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 43fe4370b4..da97092f1a 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -47,5 +47,11 @@ fluent-json 2.0.0 + + org.projectlombok + lombok + 1.16.10 + provided + diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java index c0fbe62a63..f7f47bf22c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java @@ -34,6 +34,11 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * POJO for file plan component * @@ -41,6 +46,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; * @author Rodica Sutu * @since 2.6 */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class FilePlanComponent { @JsonProperty (required = true) @@ -94,325 +103,4 @@ public class FilePlanComponent @JsonProperty (required = true) private FilePlanComponentUserInfo modifiedByUser; - - - /**Helper constructor for creating the file plan component using - * - * @param name File Plan Component name - * @param nodeType File Plan Component node type - * @param properties File Plan Component properties - */ - public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties) - { - this.name = name; - this.nodeType = nodeType; - this.properties = properties; - } - - /** - * Helper constructor to create empty file plan component - */ - public FilePlanComponent() { } - - /** - * Helper constructor for creating the file plan component using - * - * @param name File Plan Component name - */ - public FilePlanComponent(String name) - { - this.name = name; - } - - /** - * Helper constructor for creating the file plan component using - * - * @param name File Plan Component name - * @param properties File Plan Component properties - */ - public FilePlanComponent(String name, FilePlanComponentProperties properties) - { - this.name = name; - this.properties = properties; - } - - /** - * @return the id - */ - public String getId() - { - return this.id; - } - - /** - * @param id the id to set - */ - public void setId(String id) - { - this.id = id; - } - - /** - * @return the parentId - */ - public String getParentId() - { - return this.parentId; - } - - /** - * @param parentId the parentId to set - */ - public void setParentId(String parentId) - { - this.parentId = parentId; - } - - /** - * @return the name - */ - public String getName() - { - return this.name; - } - - /** - * @param name the name to set - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @return the nodeType - */ - public String getNodeType() - { - return this.nodeType; - } - - /** - * @param nodeType the nodeType to set - */ - public void setNodeType(String nodeType) - { - this.nodeType = nodeType; - } - - /** - * @return the isCategory - */ - public Boolean isIsCategory() - { - return this.isCategory; - } - - /** - * @param isCategory the isCategory to set - */ - public void setCategory(Boolean isCategory) - { - this.isCategory = isCategory; - } - - /** - * @return the isRecordFolder - */ - public Boolean isIsRecordFolder() - { - return this.isRecordFolder; - } - - /** - * @param isRecordFolder the isRecordFolder to set - */ - public void setRecordFolder(Boolean isRecordFolder) - { - this.isRecordFolder = isRecordFolder; - } - - /** - * @return the isFile - */ - public Boolean isIsFile() - { - return this.isFile; - } - - /** - * @param isFile the isFile to set - */ - public void setFile(Boolean isFile) - { - this.isFile = isFile; - } - - /** - * @return the hasRetentionSchedule - */ - public Boolean isHasRetentionSchedule() - { - return this.hasRetentionSchedule; - } - - /** - * @param hasRetentionSchedule the hasRetentionSchedule to set - */ - public void setHasRetentionSchedule(Boolean hasRetentionSchedule) - { - this.hasRetentionSchedule = hasRetentionSchedule; - } - - /** - * @return the properties - */ - public FilePlanComponentProperties getProperties() - { - return properties; - } - - /** - * @param properties the properties to set - */ - public void setProperties(FilePlanComponentProperties properties) - { - this.properties = properties; - } - - /** - * @return the aspectNames - */ - public List getAspectNames() - { - return this.aspectNames; - } - - /** - * @param aspectNames the aspectNames to set - */ - public void setAspectNames(List aspectNames) - { - this.aspectNames = aspectNames; - } - - /** - * @return the createdByUser - */ - public FilePlanComponentUserInfo getCreatedByUser() - { - return this.createdByUser; - } - - /** - * @param createdByUser the createdByUser to set - */ - public void setCreatedByUser(FilePlanComponentUserInfo createdByUser) - { - this.createdByUser = createdByUser; - } - - /** - * @return the allowableOperations - */ - public List getAllowableOperations() - { - return this.allowableOperations; - } - - /** - * @return the path - */ - public FilePlanComponentPath getPath() - { - return this.path; - } - - /** - * @param path the path to set - */ - public void setPath(FilePlanComponentPath path) - { - this.path = path; - } - - /** - * @param modifiedAt the modifiedAt to set - */ - public void setModifiedAt(String modifiedAt) - { - this.modifiedAt = modifiedAt; - } - - /** - * @param createdAt the createdAt to set - */ - public void setCreatedAt(String createdAt) - { - this.createdAt = createdAt; - } - - /** - * @param modifiedByUser the modifiedByUser to set - */ - public void setModifiedByUser(FilePlanComponentUserInfo modifiedByUser) - { - this.modifiedByUser = modifiedByUser; - } - - /** - * @return the modifiedAt - */ - public String getModifiedAt() - { - return this.modifiedAt; - } - - /** - * @return the createdAt - */ - public String getCreatedAt() - { - return this.createdAt; - } - - /** - * @return the modifiedByUser - */ - public FilePlanComponentUserInfo getModifiedByUser() - { - return this.modifiedByUser; - } - - /** - * @return the isClosed - */ - public Boolean isClosed() - { - return this.isClosed; - } - - /** - * @param closed the isClosed to set - */ - public void setClosed(Boolean closed) - { - this.isClosed = closed; - } - - /** - * @return the isCompleted - */ - public Boolean isCompleted() - { - return this.isCompleted; - } - - /** - * @param completed the isCompleted to set - */ - public void setCompleted(Boolean completed) - { - this.isCompleted = completed; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java index ab8fbcd253..84d9efa07f 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java @@ -42,6 +42,11 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * POJO for file plan component properties * @@ -50,6 +55,10 @@ import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer; */ //FIXME: Once the fields have been added the JsonIgnoreProperties annotation should be removed @JsonIgnoreProperties (ignoreUnknown = true) +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class FilePlanComponentProperties { @@ -74,133 +83,4 @@ public class FilePlanComponentProperties @JsonProperty(PROPERTIES_LOCATION) private String location; - - public FilePlanComponentProperties(String title, String description) - { - this.title = title; - this.description = description; - } - - public FilePlanComponentProperties(String title) - { - this.title = title; - } - - public FilePlanComponentProperties() - { - } - - - /** - * @return the vitalRecord - */ - public Boolean isVitalRecord() - { - return this.vitalRecord; - } - - /** - * @param vitalRecord the vitalRecord to set - */ - public void setVitalRecord(Boolean vitalRecord) - { - this.vitalRecord = vitalRecord; - } - - /** - * @return the title - */ - public String getTitle() - { - return this.title; - } - - /** - * @param title the title to set - */ - public void setTitle(String title) - { - this.title = title; - } - - /** - * @return the holdReason - */ - public String getHoldReason() - { - return this.holdReason; - } - - /** - * @param holdReason the holdReason to set - */ - public void setHoldReason(String holdReason) - { - this.holdReason = holdReason; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @return the description - */ - public String getDescription() - { - return this.description; - } - - /** - * @return the supplementalMarkingList - */ - public List getSupplementalMarkingList() - { - return this.supplementalMarkingList; - } - - /** - * @param supplementalMarkingList the supplementalMarkingList to set - */ - public void setSupplementalMarkingList(List supplementalMarkingList) - { - this.supplementalMarkingList = supplementalMarkingList; - } - - /** - * @return the reviewPeriod - */ - public ReviewPeriod getReviewPeriod() - { - return reviewPeriod; - } - - /** - * @param reviewPeriod the reviewPeriod to set - */ - public void setReviewPeriod(ReviewPeriod reviewPeriod) - { - this.reviewPeriod = reviewPeriod; - } - - /** - * @return the location - */ - public String getLocation() - { - return location; - } - - /** - * @param location the location to set - */ - public void setLocation(String location) - { - this.location = location; - } - } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java index 99711dd7fb..0df7427158 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java @@ -182,7 +182,13 @@ public class BaseRestTest extends RestTest { RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - FilePlanComponent filePlanComponent=new FilePlanComponent(componentName, componentType.toString(),new FilePlanComponentProperties(componentTitle)); + FilePlanComponent filePlanComponent = FilePlanComponent.builder() + .name(componentName) + .nodeType(componentType.toString()) + .properties(FilePlanComponentProperties.builder() + .title(componentTitle) + .build()) + .build(); FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(filePlanComponent, parentComponentId); restWrapper.assertStatusCodeIs(CREATED); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java index bd95856a50..ae7bf8729d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java @@ -199,9 +199,12 @@ public class FilePlanTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); // Build object for updating the filePlan - FilePlanComponent filePlanComponent= new FilePlanComponent(); - FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION); - filePlanComponent.setProperties(filePlanComponentProperties); + FilePlanComponent filePlanComponent = FilePlanComponent.builder() + .properties(FilePlanComponentProperties.builder() + .title(FILE_PLAN_TITLE) + .description(FILE_PLAN_DESCRIPTION) + .build()) + .build(); // Update the record category FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString()); @@ -301,7 +304,12 @@ public class FilePlanTests extends BaseRestTest String name = filePlanAlias + getRandomAlphanumeric(); // Build the file plan root properties - FilePlanComponent filePlanComponent=new FilePlanComponent(name,rmType.toString(),new FilePlanComponentProperties()); + FilePlanComponent filePlanComponent = FilePlanComponent.builder() + .name(name) + .nodeType(rmType.toString()) + .properties(FilePlanComponentProperties.builder() + .build()) + .build(); // Authenticate with admin user filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java index 6a5364e3ec..139efa5b60 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java @@ -94,8 +94,15 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - FilePlanComponent recordCategory= new FilePlanComponent(categoryName,RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties(categoryTitle)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(categoryName) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .properties( + FilePlanComponentProperties.builder() + .title(categoryTitle) + .build()) + .build(); + // Create the record category FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); @@ -103,9 +110,9 @@ public class RecordCategoryTest extends BaseRestTest restWrapper.assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertTrue(filePlanComponent.isIsCategory()); - assertFalse(filePlanComponent.isIsFile()); - assertFalse(filePlanComponent.isIsRecordFolder()); + assertTrue(filePlanComponent.getIsCategory()); + assertFalse(filePlanComponent.getIsFile()); + assertFalse(filePlanComponent.getIsRecordFolder()); assertEquals(filePlanComponent.getName(), categoryName); assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString()); @@ -139,8 +146,14 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties(categoryTitle)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(categoryName) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .properties( + FilePlanComponentProperties.builder() + .title(categoryTitle) + .build()) + .build(); // Create the record category FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); @@ -148,7 +161,7 @@ public class RecordCategoryTest extends BaseRestTest String newCategoryName = "Rename " + categoryName; // Build the properties which will be updated - FilePlanComponent recordCategoryUpdated = new FilePlanComponent(newCategoryName); + FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build(); // Update the record category FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId()); @@ -186,8 +199,15 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties(categoryTitle)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(categoryName) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .properties( + FilePlanComponentProperties.builder() + .title(categoryTitle) + .build()) + .build(); + // Create the record category FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); @@ -226,9 +246,9 @@ public class RecordCategoryTest extends BaseRestTest // Verify child category assertEquals(childCategory.getParentId(), rootCategory.getId()); - assertTrue(childCategory.isIsCategory()); - assertFalse(childCategory.isIsFile()); - assertFalse(childCategory.isIsRecordFolder()); + assertTrue(childCategory.getIsCategory()); + assertFalse(childCategory.getIsFile()); + assertFalse(childCategory.getIsRecordFolder()); assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString()); } @@ -295,19 +315,19 @@ public class RecordCategoryTest extends BaseRestTest assertEquals(filePlanComponent.getParentId(), rootCategory.getId()); // Only categories or folders have been created - assertFalse(filePlanComponent.isIsFile()); + assertFalse(filePlanComponent.getIsFile()); // Boolean properties related to node type // Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE.toString())) { - assertTrue(filePlanComponent.isIsCategory()); - assertFalse(filePlanComponent.isIsRecordFolder()); + assertTrue(filePlanComponent.getIsCategory()); + assertFalse(filePlanComponent.getIsRecordFolder()); } else { - assertTrue(filePlanComponent.isIsRecordFolder()); - assertFalse(filePlanComponent.isIsCategory()); + assertTrue(filePlanComponent.getIsRecordFolder()); + assertFalse(filePlanComponent.getIsCategory()); } // Does returned object have the same contents as the created one? @@ -348,8 +368,14 @@ public class RecordCategoryTest extends BaseRestTest FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME); //Build node properties - FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType, - new FilePlanComponentProperties("Title for " + COMPONENT_NAME)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(COMPONENT_NAME) + .nodeType(nodeType) + .properties( + FilePlanComponentProperties.builder() + .title("Title for " + COMPONENT_NAME) + .build()) + .build(); //create the invalid node type filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId()); @@ -383,8 +409,14 @@ public class RecordCategoryTest extends BaseRestTest { RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); //Build node properties - FilePlanComponent component = new FilePlanComponent(componentName, componentType.toString(), - new FilePlanComponentProperties("Title for " + componentName)); + FilePlanComponent component = FilePlanComponent.builder() + .name(componentName) + .nodeType(componentType.toString()) + .properties(FilePlanComponentProperties.builder() + .title("Title for " + componentName) + .build()) + .build(); + FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId); restWrapper.assertStatusCodeIs(CREATED); return fpc; diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java index bf38a0283a..30bcaddb81 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java @@ -93,8 +93,13 @@ public class RecordFolderTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); FilePlanComponent filePlanComponent=createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY); - FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(FOLDER_TITLE); - FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), filePlanComponentProperties); + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(FOLDER_TITLE) + .build()) + .build(); // Create the record folder FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId()); @@ -105,9 +110,9 @@ public class RecordFolderTests extends BaseRestTest // Check folder has been created within the category created assertEquals(filePlanComponent.getId(),folder.getParentId()); // Verify the returned properties for the file plan component - record folder - assertFalse(folder.isIsCategory()); - assertFalse(folder.isIsFile()); - assertTrue(folder.isIsRecordFolder()); + assertFalse(folder.getIsCategory()); + assertFalse(folder.getIsFile()); + assertTrue(folder.getIsRecordFolder()); assertEquals(folder.getName(), FOLDER_NAME); assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE.toString()); @@ -138,8 +143,14 @@ public class RecordFolderTests extends BaseRestTest String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId(); // Build the record category properties - FilePlanComponent recordFolder= new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), - new FilePlanComponentProperties(FOLDER_TITLE)); + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(FOLDER_TITLE) + .build()) + .build(); + // Create a record folder filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID); @@ -168,10 +179,10 @@ public class RecordFolderTests extends BaseRestTest // Verify the returned properties for the file plan component - record folder assertEquals(RECORD_FOLDER_TYPE.toString(),folderDetails.getNodeType()); - assertTrue(folderDetails.isIsRecordFolder()); - assertFalse(folderDetails.isIsCategory()); - assertFalse(folderDetails.isIsFile()); - assertFalse(folderDetails.isClosed()); + assertTrue(folderDetails.getIsRecordFolder()); + assertFalse(folderDetails.getIsCategory()); + assertFalse(folderDetails.getIsFile()); + assertFalse(folderDetails.getIsClosed()); assertEquals(FOLDER_NAME,folderDetails.getName()); assertEquals(dataUser.getAdminUser().getUsername(),folderDetails.getCreatedByUser().getId()); @@ -210,11 +221,16 @@ public class RecordFolderTests extends BaseRestTest String location="Location"+getRandomAlphanumeric(); //Create the file plan component properties to update - FilePlanComponentProperties filePlanComponentProperties= new FilePlanComponentProperties(folderTitle, folderDescription); - filePlanComponentProperties.setVitalRecord(true); - filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1")); - filePlanComponentProperties.setLocation(location); - FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties); + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(folderName) + .properties(FilePlanComponentProperties.builder() + .title(folderTitle) + .description(folderDescription) + .vitalRecord(true) + .reviewPeriod(new ReviewPeriod("month","1")) + .location(location) + .build()) + .build(); // Update the record category FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId()); @@ -226,7 +242,7 @@ public class RecordFolderTests extends BaseRestTest assertEquals(folderName, folderUpdated.getName()); assertEquals(folderDescription, folderUpdated.getProperties().getDescription()); assertEquals(folderTitle, folderUpdated.getProperties().getTitle()); - assertTrue(folderUpdated.getProperties().isVitalRecord()); + assertTrue(folderUpdated.getProperties().getVitalRecord()); assertEquals(location, folderUpdated.getProperties().getLocation()); assertNotNull(folderUpdated.getProperties().getReviewPeriod().getPeriodType()); assertNotNull(folderUpdated.getProperties().getReviewPeriod().getExpression()); @@ -325,11 +341,11 @@ public class RecordFolderTests extends BaseRestTest // Is parent Id set correctly assertEquals(filePlanComponent.getParentId(), category.getId()); - assertFalse(filePlanComponent.isIsFile()); + assertFalse(filePlanComponent.getIsFile()); // Boolean properties related to node type - assertTrue(filePlanComponent.isIsRecordFolder()); - assertFalse(filePlanComponent.isIsCategory()); + assertTrue(filePlanComponent.getIsRecordFolder()); + assertFalse(filePlanComponent.getIsCategory()); assertEquals(createdComponent.getName(), filePlanComponent.getName()); assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java index d1a4f29466..d1d14d4e19 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java @@ -107,8 +107,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest String folderDescription = folderName + " Description"; // Build unfiled records folder properties - FilePlanComponent unfiledFolder=new FilePlanComponent(folderName,UNFILED_RECORD_FOLDER_TYPE.toString(), - new FilePlanComponentProperties(folderTitle,folderDescription)); + FilePlanComponent unfiledFolder = FilePlanComponent.builder() + .name(folderName) + .nodeType(UNFILED_RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(folderTitle) + .description(folderDescription) + .build()) + .build(); FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS.toString()); @@ -117,9 +123,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertFalse(filePlanComponent.isIsCategory()); - assertFalse(filePlanComponent.isIsFile()); - assertFalse(filePlanComponent.isIsRecordFolder()); // it is not a _normal_ record folder! + assertFalse(filePlanComponent.getIsCategory()); + assertFalse(filePlanComponent.getIsFile()); + assertFalse(filePlanComponent.getIsRecordFolder()); // it is not a _normal_ record folder! assertEquals(filePlanComponent.getName(), folderName); assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString()); @@ -151,8 +157,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest logger.info("creating " + componentType.toString()); // Build unfiled records folder properties - FilePlanComponent unfiledFolder = new FilePlanComponent(folderName, componentType.toString(), - new FilePlanComponentProperties(folderTitle, folderDescription)); + FilePlanComponent unfiledFolder = FilePlanComponent.builder() + .name(folderName) + .nodeType(componentType.toString()) + .properties(FilePlanComponentProperties.builder() + .title(folderTitle) + .description(folderDescription) + .build()) + .build(); try { @@ -189,8 +201,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest assertEquals(parentFolderName, parentFolder.getName()); // Build the unfiled records folder properties - FilePlanComponent unfiledFolder = new FilePlanComponent(childFolderName, UNFILED_RECORD_FOLDER_TYPE.toString(), - new FilePlanComponentProperties(childFolderTitle, childFolderDescription)); + FilePlanComponent unfiledFolder = FilePlanComponent.builder() + .name(childFolderName) + .nodeType(UNFILED_RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(childFolderTitle) + .description(childFolderDescription) + .build()) + .build(); // Create it as a child of parentFolder FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder, @@ -200,9 +218,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest restWrapper.assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertFalse(childFolder.isIsCategory()); - assertFalse(childFolder.isIsFile()); - assertFalse(childFolder.isIsRecordFolder()); // it is not a _normal_ record folder! + assertFalse(childFolder.getIsCategory()); + assertFalse(childFolder.getIsFile()); + assertFalse(childFolder.getIsRecordFolder()); // it is not a _normal_ record folder! assertEquals(childFolder.getName(), childFolderName); assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString()); @@ -251,9 +269,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest assertEquals(folderName, folderToModify.getName()); // Build the properties which will be updated - FilePlanComponent folderToUpdate=new FilePlanComponent(modified + folderToModify.getName(), - new FilePlanComponentProperties(modified + folderToModify.getProperties().getTitle(), - modified + folderToModify.getProperties().getDescription())); + FilePlanComponent folderToUpdate = FilePlanComponent.builder() + .name(modified + folderToModify.getName()) + .properties(FilePlanComponentProperties.builder(). + title(modified + folderToModify.getProperties().getTitle()). + description(modified + folderToModify.getProperties().getDescription()) + .build()) + .build(); + // Update the unfiled records folder filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId()); // Verify the status code From b3deb5025af7e56a49001dc296fcd7520c32ab56 Mon Sep 17 00:00:00 2001 From: Samuel Langlois Date: Mon, 5 Dec 2016 18:03:16 +0000 Subject: [PATCH 02/30] BDE-837 Allow to specify URL of Alfresco installer in functional tests --- pom.xml | 5 +++++ rm-automation/pom.xml | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index c0df8bad0e..dd755c17d8 100644 --- a/pom.xml +++ b/pom.xml @@ -296,6 +296,11 @@ maven-failsafe-plugin 2.19 + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + org.codehaus.mojo build-helper-maven-plugin diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 78c62c3a3b..1e6d3439db 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -24,7 +24,6 @@ - releases 1.8 1.8 testng.xml @@ -109,22 +108,18 @@ Recreating database... drop database if exists alfresco; create database alfresco Downloading Alfresco installer... - + Installing Alfresco... + - - org.apache.ant - ant-jsch - 1.8.2 - postgresql postgresql From cd082da61e85687de6d4660a93127720b07ee9be Mon Sep 17 00:00:00 2001 From: Samuel Langlois Date: Mon, 5 Dec 2016 18:03:16 +0000 Subject: [PATCH 03/30] BDE-837 Allow to specify URL of Alfresco installer in functional tests --- pom.xml | 5 +++++ rm-automation/pom.xml | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index ecf6ff66d2..2efbbd8b87 100644 --- a/pom.xml +++ b/pom.xml @@ -298,6 +298,11 @@ maven-failsafe-plugin 2.19 + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + org.codehaus.mojo build-helper-maven-plugin diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 4edfe58243..6ddc73f194 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -17,7 +17,6 @@ 1.8 testng.xml true - releases @@ -206,22 +205,18 @@ Recreating database... drop database if exists alfresco; create database alfresco Downloading Alfresco installer... - + Installing Alfresco... + - - org.apache.ant - ant-jsch - 1.8.2 - postgresql postgresql From d554f9fdd25bc8fa06a9119aefcedd45fc615bd5 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Mon, 12 Dec 2016 11:20:54 +0000 Subject: [PATCH 04/30] RM-4542: record name doesn't default to file name --- .../requests/FilePlanComponentAPI.java | 1 + .../ElectronicRecordTests.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index 9d8c385a91..3a4ae7afa9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -178,6 +178,7 @@ public class FilePlanComponentAPI extends RestAPI .auth().basic(currentUser.getUsername(), currentUser.getPassword()) .multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name()) .multiPart("filedata", recordContent, ContentType.BINARY.name()) + .multiPart("name", electronicRecordModel.getName() != null ? electronicRecordModel.getName() : recordContent.getName()) .when() .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters()) .andReturn(); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java index 2b30770dc8..8dc9c84b83 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java @@ -223,6 +223,37 @@ public class ElectronicRecordTests extends BaseRestTest // verify the create request status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + // get newly created electonic record and verify its properties + FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); + // created record will have record identifier inserted in its name but will be prefixed with + // the name it was created as + assertTrue(electronicRecord.getName().startsWith(record.getName())); + } + + /** + * This test verified that in the test client implementation if record name isn't specified it + * defaults to filed file name. + * @param container valid record container + * @throws Exception if record creation failed + */ + @Test + ( + dataProvider = "validRootContainers", + description = "Electronic records can be created in unfiled record folder or unfiled record root" + ) + public void recordNameDerivedFromFileName(FilePlanComponent container) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // record object without name set + FilePlanComponent record = new FilePlanComponent(); + record.setNodeType(CONTENT_TYPE.toString()); + record.setProperties(new FilePlanComponentProperties()); + String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); + + // verify the create request status code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + // get newly created electonic record and verify its properties FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); // record will have record identifier inserted in its name but will for sure start with file name From 947367299b6ffc2f11ff53fd5590c7a8396ce8d8 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Mon, 12 Dec 2016 15:43:18 +0200 Subject: [PATCH 05/30] updates to use Lombok library --- .../FilePlanComponentContent.java | 69 +------- .../FilePlanComponentEntry.java | 12 +- .../FilePlanComponentIdNamePair.java | 40 +---- .../FilePlanComponentPath.java | 56 +----- .../FilePlanComponentProperties.java | 1 - .../FilePlanComponentUserInfo.java | 40 +---- .../fileplancomponents/ReviewPeriod.java | 61 +------ .../rest/rm/community/model/site/RMSite.java | 58 +------ .../rest/rm/community/base/BaseRestTest.java | 8 +- .../ElectronicRecordTests.java | 62 ++++--- .../NonElectronicRecordTests.java | 162 ++++++++++-------- .../rest/rm/community/site/RMSiteTests.java | 16 +- 12 files changed, 195 insertions(+), 390 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java index eb2f102266..5a22064c4a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java @@ -37,77 +37,14 @@ public class FilePlanComponentContent { @JsonProperty (required = true) private String encoding; - + @JsonProperty (required = true) private String mimeType; - + @JsonProperty (required = true) private String mimeTypeName; - + @JsonProperty (required = true) private Integer sizeInBytes; - /** - * @return the encoding - */ - public String getEncoding() - { - return this.encoding; - } - - /** - * @param encoding the encoding to set - */ - public void setEncoding(String encoding) - { - this.encoding = encoding; - } - - /** - * @return the mimeType - */ - public String getMimeType() - { - return this.mimeType; - } - - /** - * @param mimeType the mimeType to set - */ - public void setMimeType(String mimeType) - { - this.mimeType = mimeType; - } - - /** - * @return the mimeTypeName - */ - public String getMimeTypeName() - { - return this.mimeTypeName; - } - - /** - * @param mimeTypeName the mimeTypeName to set - */ - public void setMimeTypeName(String mimeTypeName) - { - this.mimeTypeName = mimeTypeName; - } - - /** - * @return the sizeInBytes - */ - public Integer getSizeInBytes() - { - return this.sizeInBytes; - } - - /** - * @param sizeInBytes the sizeInBytes to set - */ - public void setSizeInBytes(Integer sizeInBytes) - { - this.sizeInBytes = sizeInBytes; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java index 7d88b233c8..6aa037599b 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java @@ -30,6 +30,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.alfresco.rest.core.RestModels; /** @@ -38,13 +42,13 @@ import org.alfresco.rest.core.RestModels; * @author Tuna Aksoy * @since 2.6 */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class FilePlanComponentEntry extends RestModels { @JsonProperty(ENTRY) FilePlanComponent filePlanComponent; - public FilePlanComponent getFilePlanComponent() - { - return filePlanComponent; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java index c6c0e55dc7..25b9f3eadb 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java @@ -26,46 +26,24 @@ */ package org.alfresco.rest.rm.community.model.fileplancomponents; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * POJO for id/name pair * * @author Kristijan Conkas * @since 2.6 */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class FilePlanComponentIdNamePair { public String id; public String name; - /** - * @return the id - */ - public String getId() - { - return this.id; - } - - /** - * @param id the id to set - */ - public void setId(String id) - { - this.id = id; - } - - /** - * @return the name - */ - public String getName() - { - return this.name; - } - - /** - * @param name the name to set - */ - public void setName(String name) - { - this.name = name; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java index ca612a556d..5660d0e895 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java @@ -30,12 +30,21 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * POJO for FilePlanComponent path parameter *
* @author Kristijan Conkas * @since 2.6 */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class FilePlanComponentPath { @@ -43,51 +52,4 @@ public class FilePlanComponentPath private Boolean isComplete; private List elements; - /** - * @return the name - */ - public String getName() - { - return this.name; - } - - /** - * @param name the name to set - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @return the isComplete - */ - public Boolean isComplete() - { - return this.isComplete; - } - - /** - * @param isComplete the isComplete to set - */ - public void setComplete(Boolean isComplete) - { - this.isComplete = isComplete; - } - - /** - * @return the elements - */ - public List getElements() - { - return this.elements; - } - - /** - * @param elements the elements to set - */ - public void setElements(List elements) - { - this.elements = elements; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java index 68b73c0cb3..b95bf61720 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java @@ -90,7 +90,6 @@ public class FilePlanComponentProperties @JsonProperty(PROPERTIES_LOCATION) private String location; - @JsonProperty(value = PROPERTIES_IS_CLOSED, required = false) private Boolean isClosed; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java index 58773d1fd7..f2c7cf4a1b 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java @@ -26,46 +26,24 @@ */ package org.alfresco.rest.rm.community.model.fileplancomponents; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * POJO for file plan component created by object * * @author Kristijan Conkas * @since 2.6 */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class FilePlanComponentUserInfo { private String id; private String displayName; - /** - * @return the id - */ - public String getId() - { - return this.id; - } - - /** - * @param id the id to set - */ - public void setId(String id) - { - this.id = id; - } - - /** - * @return the displayName - */ - public String getDisplayName() - { - return this.displayName; - } - - /** - * @param displayName the displayName to set - */ - public void setDisplayName(String displayName) - { - this.displayName = displayName; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java index 30c2c63938..c8891acb65 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java @@ -26,66 +26,23 @@ */ package org.alfresco.rest.rm.community.model.fileplancomponents; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * POJO for the review period * * @author Rodica Sutu * @since 2.6 */ - +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class ReviewPeriod { private String periodType; private String expression; - - /** - * Helper constructor with - * - * @param periodType - * @param expression - */ - public ReviewPeriod(String periodType, String expression) - { - this.periodType = periodType; - this.expression = expression; - } - - /** - * Helper constructor - */ - public ReviewPeriod() - { - } - - /** - * @return the periodType - */ - public String getPeriodType() - { - return this.periodType; - } - - /** - * @param periodType the periodType to set - */ - public void setPeriodType(String periodType) - { - this.periodType = periodType; - } - - /** - * @return the expression - */ - public String getExpression() - { - return this.expression; - } - - /** - * @param expression the expression to set - */ - public void setExpression(String expression) - { - this.expression = expression; - } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java index e9f80ede48..8added36da 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java @@ -30,6 +30,10 @@ import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.alfresco.rest.model.RestSiteModel; /** @@ -38,59 +42,13 @@ import org.alfresco.rest.model.RestSiteModel; * @author Rodica Sutu * @since 2.6 */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor public class RMSite extends RestSiteModel { @JsonProperty (value = COMPLIANCE,required = true) private RMSiteCompliance compliance; - /** - * Helper constructor to create RM Site object using - * - * @param title - * @param description - * @param compliance - */ - public RMSite(String title, String description, RMSiteCompliance compliance) - { - this.title=title; - this.description=description; - this.compliance=compliance; - } - - /** - * Helper constructor for creating the RM Site - */ - public RMSite() { } - - /** - * Helper constructor to create RM Site object using - * - * @param compliance RM Site Compliance - */ - public RMSite(RMSiteCompliance compliance) - { - super(); - this.compliance = compliance; - } - - /** - * Helper method to set RM site compliance - * - * @param compliance {@link RMSiteCompliance} the compliance to set - */ - public void setCompliance(RMSiteCompliance compliance) - { - this.compliance = compliance; - } - - /** - * Helper method to get RM site compliance - * - * @return compliance the RM Site compliance to get - */ - public RMSiteCompliance getCompliance() - { - return compliance; - } - } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java index bd445a05df..1bd23e434c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java @@ -113,7 +113,7 @@ public class BaseRestTest extends RestTest { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) } }; } - + /** * @see org.alfresco.rest.RestTest#checkServerHealth() */ @@ -141,7 +141,9 @@ public class BaseRestTest extends RestTest rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); // Create the RM site - RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD); + RMSite rmSite = RMSite.builder().compliance(STANDARD).build(); + rmSite.setTitle(RM_TITLE); + rmSite.setDescription(RM_DESCRIPTION); rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -217,7 +219,7 @@ public class BaseRestTest extends RestTest /** * Helper method to close folder - * @param folderToClose + * @param folderId * @return * @throws Exception */ diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java index 2b30770dc8..5920840fd8 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java @@ -41,7 +41,6 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; import org.alfresco.utility.data.DataUser; import org.springframework.beans.factory.annotation.Autowired; @@ -64,16 +63,16 @@ public class ElectronicRecordTests extends BaseRestTest @Autowired private DataUser dataUser; - + /** image resource file to be used for records body */ private static final String IMAGE_FILE = "money.JPG"; - + /** Valid root containers where electronic records can be created */ @DataProvider(name = "invalidParentContainers") public Object[][] invalidContainers() throws Exception { return new Object[][] { // record category - { getFilePlanComponentAsUser(dataUser.getAdminUser(), + { getFilePlanComponentAsUser(dataUser.getAdminUser(), createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getParentId()) }, // file plan root { getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, @@ -83,7 +82,7 @@ public class ElectronicRecordTests extends BaseRestTest { getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS.toString()) }, }; } - + /** *
      * Given a parent container that is NOT a record folder or an unfiled record folder
@@ -103,10 +102,13 @@ public class ElectronicRecordTests extends BaseRestTest
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
 
-        FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), 
-            new FilePlanComponentProperties());
+        // Build object the filePlan
+        FilePlanComponent record = FilePlanComponent.builder()
+                                                .name("Record " + getRandomAlphanumeric())
+                                                .nodeType(CONTENT_TYPE.toString())
+                                                .build();
         filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId());
-        
+
         // verify the create request status code
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
     }
@@ -114,7 +116,7 @@ public class ElectronicRecordTests extends BaseRestTest
     /**
      * 
      * Given a parent container that is a record folder
-     * And the record folder is closed 
+     * And the record folder is closed
      * When I try to create an electronic record within the parent container
      * Then nothing happens
      * And an error is reported
@@ -126,22 +128,24 @@ public class ElectronicRecordTests extends BaseRestTest
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
         FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
-        
+
         // the folder should be open
         assertFalse(recordFolder.getProperties().getIsClosed());
-        
+
         // close the folder
         closeFolder(recordFolder.getId());
-        
+
         // try to create it, this should fail
-        FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), 
-            new FilePlanComponentProperties());
+        FilePlanComponent record = FilePlanComponent.builder()
+                                                .name("Record " + getRandomAlphanumeric())
+                                                .nodeType(CONTENT_TYPE.toString())
+                                                .build();
         filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, recordFolder.getId());
-        
+
         // verify the status code
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
     }
-    
+
     /**
      * 
      * Given a parent container that is a record folder
@@ -164,13 +168,13 @@ public class ElectronicRecordTests extends BaseRestTest
      */
     @Test
     (
-        dataProvider = "validRootContainers", 
+        dataProvider = "validRootContainers",
         description = "Electronic record can only be created if all mandatory properties are given"
     )
     public void canCreateElectronicRecordOnlyWithMandatoryProperties(FilePlanComponent container) throws Exception
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
-        
+
         logger.info("Root container:\n" + toJson(container));
         if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
         {
@@ -179,17 +183,17 @@ public class ElectronicRecordTests extends BaseRestTest
         }
 
         // component without name
-        FilePlanComponent record = new FilePlanComponent();
-        record.setNodeType(CONTENT_TYPE.toString());
-        record.setProperties(new FilePlanComponentProperties());
-        
+        FilePlanComponent record = FilePlanComponent.builder()
+                                                    .nodeType(CONTENT_TYPE.toString())
+                                                    .build();
+
         // try to create it
         filePlanComponentAPI.createFilePlanComponent(record, container.getId());
 
         // verify the status code is BAD_REQUEST
-        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);      
+        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
     }
-    
+
     /**
      * 
      * Given a parent container that is a record folder
@@ -216,13 +220,15 @@ public class ElectronicRecordTests extends BaseRestTest
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
 
-        FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), 
-            new FilePlanComponentProperties());
+        FilePlanComponent record = FilePlanComponent.builder()
+                                                    .name("Record " + getRandomAlphanumeric())
+                                                    .nodeType(CONTENT_TYPE.toString())
+                                                    .build();
         String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
-        
+
         // verify the create request status code
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
-        
+
         // get newly created electonic record and verify its properties
         FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId);
         // record will have record identifier inserted in its name but will for sure start with file name
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java
index c8cc153545..968edbe9dd 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java
@@ -70,10 +70,10 @@ public class NonElectronicRecordTests extends BaseRestTest
 
     @Autowired
     private DataUser dataUser;
-    
+
     @Autowired
     private RMSiteAPI rmSiteAPI;
-        
+
     /**
      * 
      * Given a parent container that is NOT a record folder or an unfiled record folder
@@ -87,24 +87,25 @@ public class NonElectronicRecordTests extends BaseRestTest
     public void cantCreateForInvalidParentIds() throws Exception
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
-        
+
         // non-electronic record object to be used for create tests
-        FilePlanComponent nonElectronicRecord = new FilePlanComponent(
-            "Record " + getRandomAlphanumeric(),
-            NON_ELECTRONIC_RECORD_TYPE.toString(),
-            new FilePlanComponentProperties());
-        
+        FilePlanComponent nonElectronicRecord = FilePlanComponent.builder()
+                                                .name("Record " + getRandomAlphanumeric())
+                                                .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
+                                                .build();
+
         // create record category, non-electronic records can't be its children
-        FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent(
-            new FilePlanComponent("Category " + getRandomAlphanumeric(), 
-                RECORD_CATEGORY_TYPE.toString(),
-                new FilePlanComponentProperties()), 
-            FILE_PLAN_ALIAS.toString());
-        
+        FilePlanComponent recordCategoryModel = FilePlanComponent.builder()
+                                                         .name("Category " + getRandomAlphanumeric())
+                                                         .nodeType(RECORD_CATEGORY_TYPE.toString())
+                                                         .build();
+
+        FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS.toString());
+
         // iterate through all invalid parent containers and try to create/file an electronic record
         asList(FILE_PLAN_ALIAS.toString(), TRANSFERS_ALIAS.toString(), HOLDS_ALIAS.toString(), recordCategory.getId())
             .stream()
-            .forEach(id -> 
+            .forEach(id ->
             {
                 try
                 {
@@ -118,7 +119,7 @@ public class NonElectronicRecordTests extends BaseRestTest
                 filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
             });
     }
-    
+
     /**
      * 
      * Given a parent container that is a record folder
@@ -144,14 +145,14 @@ public class NonElectronicRecordTests extends BaseRestTest
     public void canCreateInValidContainers(FilePlanComponent container) throws Exception
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
-        
+
         logger.info("Root container:\n" + toJson(container));
         if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
         {
             // only record folders can be open or closed
             assertFalse(container.getProperties().getIsClosed());
         }
-        
+
         // use these properties for non-electronic record to be created
         String title = "Title " + getRandomAlphanumeric();
         String description = "Description " + getRandomAlphanumeric();
@@ -159,33 +160,38 @@ public class NonElectronicRecordTests extends BaseRestTest
         String file = "File " + getRandomAlphanumeric();
         String shelf = "Shelf " + getRandomAlphanumeric();
         String location = "Location " + getRandomAlphanumeric();
-        
+
         Random random = new Random();
         Integer copies = random.nextInt(Integer.MAX_VALUE);
         Integer size = random.nextInt(Integer.MAX_VALUE);
-        
-        // set values of all available properties
-        FilePlanComponentProperties properties = new FilePlanComponentProperties(title, description);
-        properties.setBox(box);
-        properties.setFile(file);
-        properties.setShelf(shelf);
-        properties.setLocation(location);
-        properties.setNumberOfCopies(copies);
-        properties.setPhysicalSize(size);
-        
+
+        // set values of all available properties for the non electronic records
+        FilePlanComponent filePlanComponent = FilePlanComponent.builder()
+                                                           .name("Record " + getRandomAlphanumeric())
+                                                           .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
+                                                           .properties(FilePlanComponentProperties.builder()
+                                                                                                  .title(title)
+                                                                                                  .description(description)
+                                                                                                  .box(box)
+                                                                                                  .file(file)
+                                                                                                  .shelf(shelf)
+                                                                                                  .location(location)
+                                                                                                  .numberOfCopies(copies)
+                                                                                                  .physicalSize(size)
+                                                                                                  .build())
+                                                           .build();
+
         // create non-electronic record
         String nonElectronicId = filePlanComponentAPI.createFilePlanComponent(
-            new FilePlanComponent("Record " + getRandomAlphanumeric(), 
-                NON_ELECTRONIC_RECORD_TYPE.toString(),
-                properties), 
+            filePlanComponent,
             container.getId()).getId();
-        
+
         // verify the create request status code
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
-        
+
         // get newly created non-electonic record and verify its properties
         FilePlanComponent nonElectronicRecord = filePlanComponentAPI.getFilePlanComponent(nonElectronicId);
-        
+
         assertEquals(title, nonElectronicRecord.getProperties().getTitle());
         assertEquals(description, nonElectronicRecord.getProperties().getDescription());
         assertEquals(box, nonElectronicRecord.getProperties().getBox());
@@ -195,11 +201,11 @@ public class NonElectronicRecordTests extends BaseRestTest
         assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
         assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
     }
-    
+
     /**
      * 
      * Given a parent container that is a record folder
-     * And the record folder is closed 
+     * And the record folder is closed
      * When I try to create a non-electronic record within the parent container
      * Then nothing happens
      * And an error is reported
@@ -211,21 +217,22 @@ public class NonElectronicRecordTests extends BaseRestTest
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
         FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
-        
+
         // the folder should be open
         assertFalse(recordFolder.getProperties().getIsClosed());
-        
+
         // close the folder
         closeFolder(recordFolder.getId());
-        
+
         // try to create it, this should fail and throw an exception
 
-        filePlanComponentAPI.createFilePlanComponent(
-            new FilePlanComponent("Record " + getRandomAlphanumeric(), 
-                NON_ELECTRONIC_RECORD_TYPE.toString(),
-                new FilePlanComponentProperties()), 
-            recordFolder.getId()).getId();
-        
+        filePlanComponentAPI.createFilePlanComponent(FilePlanComponent.builder()
+                                                                      .name("Record " + getRandomAlphanumeric())
+                                                                      .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
+                                                                      .build(),
+                                                    recordFolder.getId())
+                                                                    .getId();
+
         // verify the status code
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
     }
@@ -251,31 +258,32 @@ public class NonElectronicRecordTests extends BaseRestTest
      */
     @Test
     (
-        dataProvider = "validRootContainers", 
+        dataProvider = "validRootContainers",
         description = "Non-electronic record can only be created if all mandatory properties are given"
     )
     public void allMandatoryPropertiesRequired(FilePlanComponent container) throws Exception
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
-        
+
         logger.info("Root container:\n" + toJson(container));
         if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
         {
             // only record folders can be open or closed
             assertFalse(container.getProperties().getIsClosed());
         }
-        
+
         // component without name and title
-        FilePlanComponent noNameOrTitle = getDummyNonElectronicRecord(); 
-        
+        FilePlanComponent noNameOrTitle = getDummyNonElectronicRecord();
+
         // component with title only
         FilePlanComponent titleOnly = getDummyNonElectronicRecord();
-        FilePlanComponentProperties properties = new FilePlanComponentProperties();
-        properties.setTitle("Title " + getRandomAlphanumeric());
+        FilePlanComponentProperties properties = FilePlanComponentProperties.builder()
+                                                                            .title("Title " + getRandomAlphanumeric())
+                                                                            .build();
         titleOnly.setProperties(properties);
 
-        // try to create invalid components 
-        asList(noNameOrTitle, titleOnly).stream().forEach(c -> 
+        // try to create invalid components
+        asList(noNameOrTitle, titleOnly).stream().forEach(c ->
         {
             try
             {
@@ -284,21 +292,21 @@ public class NonElectronicRecordTests extends BaseRestTest
             catch (Exception error)
             {
             }
-            
+
             // this should fail and throw an exception
             try
-            {                
+            {
                 filePlanComponentAPI.createFilePlanComponent(c, container.getId());
-            } 
+            }
             catch (Exception e)
             {
             }
 
             // verify the status code is BAD_REQUEST
             filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
-        });        
+        });
     }
-    
+
     /**
      * 
      * Given that I am a user without RM privileges
@@ -310,7 +318,7 @@ public class NonElectronicRecordTests extends BaseRestTest
      */
     @Test
     (
-        dataProvider = "validRootContainers", 
+        dataProvider = "validRootContainers",
         description = "Non-electronic record can't be created if user doesn't have RM privileges"
     )
     public void cantCreateIfNoRmPrivileges(FilePlanComponent container) throws Exception
@@ -319,16 +327,23 @@ public class NonElectronicRecordTests extends BaseRestTest
         UserModel user = createUserWithRole(username, UserRole.SiteManager);
 
         filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
-        
+
         // try to create a fileplan component
-        FilePlanComponent record = new FilePlanComponent("Record Name", NON_ELECTRONIC_RECORD_TYPE.toString(),
-            new FilePlanComponentProperties("Name", "Title"));
-            
+        FilePlanComponent record=FilePlanComponent.builder()
+                                                  .properties(FilePlanComponentProperties.builder()
+                                                                                         .description("Description")
+                                                                                         .title("Title")
+                                                                                         .build())
+                                                  .name("Record Name")
+                                                  .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
+                                                  .build();
+
+
         // this should fail and throw an exception
         try
-        {                
+        {
             filePlanComponentAPI.createFilePlanComponent(record, container.getId());
-        } 
+        }
         catch (Exception e)
         {
         }
@@ -336,18 +351,19 @@ public class NonElectronicRecordTests extends BaseRestTest
         // user who isn't an RM site member can't access the container path
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
     }
-    
+
     /**
      * Helper function to return an empty FilePlanComponent for non-electronic record
      * @return
      */
     private FilePlanComponent getDummyNonElectronicRecord()
     {
-        FilePlanComponent component = new FilePlanComponent();
-        component.setNodeType(NON_ELECTRONIC_RECORD_TYPE.toString());
+        FilePlanComponent component=FilePlanComponent.builder()
+                                            .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
+                                            .build();
         return component;
     }
-    
+
     /**
      * Create user with given role and add it to RM site
      * 
@@ -369,13 +385,13 @@ public class NonElectronicRecordTests extends BaseRestTest UserModel user = new UserModel(); user.setUsername(userName); user.setPassword(userName); - + if (!dataUser.isUserInRepo(userName)) { // user doesn't exist, create it user = dataUser.createUser(userName, userName); user.setUserRole(userRole); - + dataUser.addUserToSite(user, new SiteModel(siteId), userRole); } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java index 417895d64f..cb562d6525 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java @@ -95,7 +95,10 @@ public class RMSiteTests extends BaseRestTest } // Create the RM site - RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD); + RMSite rmSite =RMSite.builder().compliance(STANDARD).build(); + rmSite.setTitle(RM_TITLE); + rmSite.setDescription(RM_DESCRIPTION); + RMSite rmSiteResponse = rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -132,7 +135,10 @@ public class RMSiteTests extends BaseRestTest String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists"; // Create the RM site - RMSite rmSite = new RMSite(newTitle, newDescription, STANDARD); + RMSite rmSite = RMSite.builder().compliance(STANDARD).build(); + rmSite.setTitle(newTitle); + rmSite.setDescription(newDescription); + rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -236,7 +242,9 @@ public class RMSiteTests extends BaseRestTest rmSiteAPI.usingRestWrapper().authenticateUser(userModel); // Create the RM site - RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, DOD5015); + RMSite rmSite = RMSite.builder().compliance(DOD5015).build(); + rmSite.setTitle(RM_TITLE); + rmSite.setDescription(RM_DESCRIPTION); rmSite=rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -325,7 +333,7 @@ public class RMSiteTests extends BaseRestTest createRMSiteIfNotExists(); // Build the RM site properties - RMSite rmSiteToUpdate = new RMSite(DOD5015); + RMSite rmSiteToUpdate = RMSite.builder().compliance(DOD5015).build(); // Update the RM site rmSiteAPI.updateRMSite(rmSiteToUpdate); From 6fc3538f1b3a6f0dd924f8f733b4bcaeb8967b72 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Mon, 12 Dec 2016 16:12:38 +0000 Subject: [PATCH 06/30] RM-4542: parameters handling for file upload --- .../requests/FilePlanComponentAPI.java | 38 ++++++++++++++++--- .../ElectronicRecordTests.java | 8 ++-- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index 3a4ae7afa9..7fd5575280 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -26,6 +26,7 @@ */ package org.alfresco.rest.rm.community.requests; +import static com.jayway.restassured.RestAssured.basic; import static com.jayway.restassured.RestAssured.given; import static org.alfresco.rest.core.RestRequest.requestWithBody; @@ -41,7 +42,11 @@ import static org.testng.Assert.fail; import java.io.File; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.io.Resources; +import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.http.ContentType; import com.jayway.restassured.response.Response; @@ -168,17 +173,40 @@ public class FilePlanComponentAPI extends RestAPI { fail("Only electronic records are supported"); } + + UserModel currentUser = usingRestWrapper().getTestUser(); + + /* + * For file uploads nodeBodyCreate is ignored hence can't be used. Append all FilePlanComponent fields + * to the request. + */ + RequestSpecBuilder builder = new RequestSpecBuilder(); + builder.setAuth(basic(currentUser.getUsername(), currentUser.getPassword())); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_DEFAULT); + JsonNode root = mapper.readTree(toJson(electronicRecordModel)); + + root.fieldNames().forEachRemaining(f -> { + try + { + builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name()); + } + catch (Exception error) + { + LOG.error("Failed to set " + f + " error: " + error); + } + }); + + builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name()); /* * RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests. * Upload the file using RestAssured library. */ - UserModel currentUser = usingRestWrapper().getTestUser(); Response response = given() - .auth().basic(currentUser.getUsername(), currentUser.getPassword()) - .multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name()) - .multiPart("filedata", recordContent, ContentType.BINARY.name()) - .multiPart("name", electronicRecordModel.getName() != null ? electronicRecordModel.getName() : recordContent.getName()) + .spec(builder.build()) + .log().everything() .when() .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters()) .andReturn(); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java index 8dc9c84b83..53a407f552 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java @@ -216,8 +216,10 @@ public class ElectronicRecordTests extends BaseRestTest { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), - new FilePlanComponentProperties()); + FilePlanComponent record = new FilePlanComponent(); + record.setName("Record " + getRandomAlphanumeric()); + record.setNodeType(CONTENT_TYPE.toString()); + String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); // verify the create request status code @@ -248,7 +250,7 @@ public class ElectronicRecordTests extends BaseRestTest // record object without name set FilePlanComponent record = new FilePlanComponent(); record.setNodeType(CONTENT_TYPE.toString()); - record.setProperties(new FilePlanComponentProperties()); + String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); // verify the create request status code From e646b1795d36f439c84e0a49882248e78c981e00 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Mon, 12 Dec 2016 16:14:05 +0000 Subject: [PATCH 07/30] RM-4542: removed debugging log --- .../rest/rm/community/requests/FilePlanComponentAPI.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index 7fd5575280..feb5cb712a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -190,7 +190,7 @@ public class FilePlanComponentAPI extends RestAPI root.fieldNames().forEachRemaining(f -> { try { - builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name()); + builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name()); } catch (Exception error) { @@ -206,7 +206,6 @@ public class FilePlanComponentAPI extends RestAPI */ Response response = given() .spec(builder.build()) - .log().everything() .when() .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters()) .andReturn(); From 66350eb594757fa5fef730417eba3caedb99d7b0 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Mon, 12 Dec 2016 16:16:03 +0000 Subject: [PATCH 08/30] RM-4542: code tidy-up --- .../rest/rm/community/requests/FilePlanComponentAPI.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index feb5cb712a..f738adea83 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -42,7 +42,6 @@ import static org.testng.Assert.fail; import java.io.File; -import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.io.Resources; @@ -184,7 +183,6 @@ public class FilePlanComponentAPI extends RestAPI builder.setAuth(basic(currentUser.getUsername(), currentUser.getPassword())); ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_DEFAULT); JsonNode root = mapper.readTree(toJson(electronicRecordModel)); root.fieldNames().forEachRemaining(f -> { From c494d6ad9bdf8605101759e5eaf287b2ace36e67 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Mon, 12 Dec 2016 19:36:13 +0200 Subject: [PATCH 09/30] RM-4543 - added clarification that nodeBodyCreate is ignored for multipart uploads --- .../src/main/webapp/definitions/ig-core-api.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml index ade891e07b..0ce6571246 100644 --- a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml +++ b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml @@ -377,7 +377,10 @@ paths: - $ref: '#/parameters/fieldsParam' - in: body name: nodeBodyCreate - description: The node information to create. + description: | + The node information to create. + + This field is ignored for multipart/form-data content uploads. required: true schema: $ref: '#/definitions/RMNodeBodyCreate' From d2d09b4f982dc84719a29f064d9b9ff3f9b557f2 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Mon, 12 Dec 2016 17:54:36 +0000 Subject: [PATCH 10/30] RM-4542: refactoring perfectly valid code due to Bamboo pulling Java 1.7 and complaining about the lambda --- .../rm/community/requests/FilePlanComponentAPI.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index f738adea83..39431a9cef 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -41,6 +41,7 @@ import static org.springframework.http.HttpMethod.PUT; import static org.testng.Assert.fail; import java.io.File; +import java.util.Iterator; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -184,8 +185,11 @@ public class FilePlanComponentAPI extends RestAPI ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readTree(toJson(electronicRecordModel)); - - root.fieldNames().forEachRemaining(f -> { + + Iterator fieldNames = root.fieldNames(); + while (fieldNames.hasNext()) + { + String f = fieldNames.next(); try { builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name()); @@ -194,8 +198,8 @@ public class FilePlanComponentAPI extends RestAPI { LOG.error("Failed to set " + f + " error: " + error); } - }); - + } + builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name()); /* From f99ab33248916572badf407cd1a2a7f06d128786 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 12 Dec 2016 20:59:58 +0000 Subject: [PATCH 11/30] RM-4398 (RM Benchmark project config) --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index c0df8bad0e..4ea36d3b7d 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,7 @@ rm-enterprise rm-automation + rm-benchmark From 8ce598313156a4ee3fb9c7d3e9a8e8a2a6d15774 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 15 Dec 2016 11:38:19 +0200 Subject: [PATCH 12/30] Add support for creating a node using the relativePath Add test with the relativePath attribute --- .../fileplancomponents/FilePlanComponent.java | 6 ++ .../FilePlanComponentFields.java | 7 +- .../fileplancomponents/RecordFolderTests.java | 70 ++++++++++++++++++- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java index d821768829..7a320ca658 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java @@ -28,7 +28,9 @@ package org.alfresco.rest.rm.community.model.fileplancomponents; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.RELATIVE_PATH; import java.util.List; @@ -97,6 +99,7 @@ public class FilePlanComponent @JsonProperty (required = false) private FilePlanComponentContent content; + @JsonProperty (value = PATH) private FilePlanComponentPath path; @JsonProperty (required = true) @@ -108,4 +111,7 @@ public class FilePlanComponent @JsonProperty (required = true) private FilePlanComponentUserInfo modifiedByUser; + @JsonProperty (value = RELATIVE_PATH) + private String relativePath; + } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java index 11b14c1906..e4730b3663 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java @@ -49,7 +49,7 @@ public class FilePlanComponentFields public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod"; public static final String PROPERTIES_LOCATION = "rma:location"; public static final String PROPERTIES_IS_CLOSED = "rma:isClosed"; // not to be confused with IS_CLOSED! - + // for non-electronic records public static final String PROPERTIES_BOX = "rma:box"; public static final String PROPERTIES_FILE = "rma:file"; @@ -57,5 +57,8 @@ public class FilePlanComponentFields public static final String PROPERTIES_PHYSICAL_SIZE = "rma:physicalSize"; public static final String PROPERTIES_SHELF = "rma:shelf"; public static final String PROPERTIES_STORAGE_LOCATION = "rma:storageLocation"; - + + //RelativePath specifies the container structure to create relative to the node nodeId. + public static final String RELATIVE_PATH = "relativePath"; + public static final String PATH = "path"; } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java index 4c7d836a43..8b54224e4e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java @@ -31,6 +31,7 @@ import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME; import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.CREATED; @@ -44,6 +45,7 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.fail; import static org.testng.AssertJUnit.assertTrue; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.NoSuchElementException; @@ -58,7 +60,6 @@ import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.report.Bug; import org.springframework.beans.factory.annotation.Autowired; -import org.testng.annotations.AfterClass; import org.testng.annotations.Test; /** @@ -358,6 +359,73 @@ public class RecordFolderTests extends BaseRestTest ); } + + + /** + * Given that I want to create a record folder + * When I use the API with the relativePath + * Then the categories specified in the relativePath that don't exist are created within the record folder + * + * Containers in the relativePath that do not exist are created before the node is created + */ + @Test + ( + description = "Create a folder based on the relativePath. " + + "Containers in the relativePath that do not exist are created before the node is created" + ) + public void createFolderWithRelativePath() throws Exception + { + //RelativePath specifies the container structure to create relative to the node nodeId. + String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth(); + + // Authenticate with admin user + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + //The record folder to be created + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .relativePath(RELATIVE_PATH) + .build(); + + // Create the record folder + FilePlanComponent folder = filePlanComponentAPI.withParams("include="+ PATH).createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + // Verify the returned properties for the file plan component - record folder + assertFalse(folder.getIsCategory()); + assertFalse(folder.getIsFile()); + assertTrue(folder.getIsRecordFolder()); + + //Check the path return contains the RELATIVE_PATH + assertTrue(folder.getPath().getName().contains(RELATIVE_PATH)); + //check the parent is a category + assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); + //New Relative Path only a part of containers need to be created before the recrod folder + String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1); + //The record folder to be created + FilePlanComponent recordFolder2 = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .relativePath(NEW_RELATIVE_PATH) + .build(); + + // Create the record folder + FilePlanComponent folder2 = filePlanComponentAPI.withParams("include=" + PATH).createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS.toString()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + // Verify the returned properties for the file plan component - record folder + assertFalse(folder2.getIsCategory()); + assertFalse(folder2.getIsFile()); + assertTrue(folder2.getIsRecordFolder()); + //Check the path return contains the NEW_RELATIVE_PATH + assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH)); + + //check the parent is a category + assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); + + } @AfterClass (alwaysRun = true) public void tearDown() throws Exception { From 6a6d5732a41fd230e00f89d97aabcde56a4152be Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 15 Dec 2016 11:43:01 +0200 Subject: [PATCH 13/30] minor update --- .../community/fileplancomponents/RecordFolderTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java index 8b54224e4e..296394618e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java @@ -60,6 +60,7 @@ import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.report.Bug; import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.AfterClass; import org.testng.annotations.Test; /** @@ -360,7 +361,6 @@ public class RecordFolderTests extends BaseRestTest } - /** * Given that I want to create a record folder * When I use the API with the relativePath @@ -375,7 +375,7 @@ public class RecordFolderTests extends BaseRestTest ) public void createFolderWithRelativePath() throws Exception { - //RelativePath specifies the container structure to create relative to the node nodeId. + //RelativePath specify the container structure to create relative to the record folder to be created String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth(); // Authenticate with admin user @@ -401,7 +401,8 @@ public class RecordFolderTests extends BaseRestTest assertTrue(folder.getPath().getName().contains(RELATIVE_PATH)); //check the parent is a category assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); - //New Relative Path only a part of containers need to be created before the recrod folder + + //New Relative Path only a part of containers need to be created before the record folder String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1); //The record folder to be created FilePlanComponent recordFolder2 = FilePlanComponent.builder() @@ -424,8 +425,8 @@ public class RecordFolderTests extends BaseRestTest //check the parent is a category assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); - } + @AfterClass (alwaysRun = true) public void tearDown() throws Exception { From 2564371a06ec470ff22898639d93cab1652c1740 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 15 Dec 2016 12:28:10 +0200 Subject: [PATCH 14/30] indentation fix --- .../community/model/fileplancomponents/FilePlanComponent.java | 4 ++-- .../model/fileplancomponents/FilePlanComponentFields.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java index 7a320ca658..b9edeb4002 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java @@ -98,8 +98,8 @@ public class FilePlanComponent @JsonProperty (required = false) private FilePlanComponentContent content; - - @JsonProperty (value = PATH) + + @JsonProperty (value = PATH) private FilePlanComponentPath path; @JsonProperty (required = true) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java index e4730b3663..130cb388f5 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java @@ -57,8 +57,8 @@ public class FilePlanComponentFields public static final String PROPERTIES_PHYSICAL_SIZE = "rma:physicalSize"; public static final String PROPERTIES_SHELF = "rma:shelf"; public static final String PROPERTIES_STORAGE_LOCATION = "rma:storageLocation"; - - //RelativePath specifies the container structure to create relative to the node nodeId. + + //RelativePath specifies the container structure to create relative to the node nodeId. public static final String RELATIVE_PATH = "relativePath"; public static final String PATH = "path"; } From 4e3cb0ee2843d0449d6208f52caa207b4acd0cbe Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 15 Dec 2016 13:36:57 +0200 Subject: [PATCH 15/30] checks added according to the review --- .../fileplancomponents/RecordFolderTests.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java index 296394618e..bab76aec0c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java @@ -401,7 +401,19 @@ public class RecordFolderTests extends BaseRestTest assertTrue(folder.getPath().getName().contains(RELATIVE_PATH)); //check the parent is a category assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); - + + //check the created folder from the server + folder=filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder.getId()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + // Verify the returned properties for the file plan component - record folder + assertFalse(folder.getIsCategory()); + assertFalse(folder.getIsFile()); + assertTrue(folder.getIsRecordFolder()); + + //Check the path return contains the RELATIVE_PATH + assertTrue(folder.getPath().getName().contains(RELATIVE_PATH)); + //New Relative Path only a part of containers need to be created before the record folder String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1); //The record folder to be created @@ -425,6 +437,18 @@ public class RecordFolderTests extends BaseRestTest //check the parent is a category assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); + + // Check the folder created on the server + folder2 = filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder2.getId()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // Verify the returned properties for the file plan component - record folder + assertFalse(folder2.getIsCategory()); + assertFalse(folder2.getIsFile()); + assertTrue(folder2.getIsRecordFolder()); + //Check the path return contains the NEW_RELATIVE_PATH + assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH)); } @AfterClass (alwaysRun = true) From cfc6510b3794e15ce2bd7e4c5133b7dbab2ab827 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 15 Dec 2016 17:09:20 +0200 Subject: [PATCH 16/30] RM-4362 - removed update content RM-4430 - documented file record RM-4429 - documented declare record --- .../main/webapp/definitions/ig-core-api.yaml | 143 ++++++++++-------- 1 file changed, 82 insertions(+), 61 deletions(-) diff --git a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml index 0ce6571246..528838c063 100644 --- a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml +++ b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml @@ -567,7 +567,6 @@ paths: $ref: '#/definitions/Error' '/records/{recordId}/content': get: - x-alfresco-since: "5.2" tags: - records summary: Get record content @@ -586,75 +585,48 @@ paths: description: Content has not been modified since the date provided in the If-Modified-Since header '400': description: | - Invalid parameter: **nodeId** is not a valid format, or is not a file + Invalid parameter: **recordId** is not a valid format, or is not a record '401': - description: Authentication failed + description: Authentication failed '404': description: | - **nodeId** does not exist + **recordId** does not exist default: description: Unexpected error schema: $ref: '#/definitions/Error' - put: - x-alfresco-since: "5.2" - tags: + '/records/{recordId}/file': + post: + tags: - records - summary: Update record content + summary: File a record description: | - Updates the content of the record with identifier **recordId**. + Files the record **recordId** in the target record folder. - The request body for this endpoint can be any text or binary stream. + You can specify the target record folder by providing its id **targetParentId** + or by providing the id of a parent container **targetParentId** and a relative path **relativePath**. - The **majorVersion** and **comment** parameters can be used to control versioning behaviour. If the content is versionable, - a new minor version is created by default. + The **relativePath** specifies the container structure relative to the node **targetParentId**. + If targetParentId is missing the path will be relative to the fileplan. + The relativePath is made of record containers and a record folder as the last element. + Containers that are missing from relativePath will be created before filing. - Optionally a new **name** parameter can also be specified that must be unique within the parent folder. If specified and valid then this - will rename the node. If invalid then an error is returned and the content is not updated. - - **Note:** This API method accepts any content type, but for testing with this tool text based content can be provided. - This is because the OpenAPI Specification does not allow a wildcard to be provided or the ability for - tooling to accept an arbitrary file. - operationId: updateRecordContent - parameters: + If the record is already filed, a link to the target record folder is created. + operationId: fileRecord + parameters: - $ref: '#/parameters/recordIdParam' - - name: majorVersion - in: query - description: | - If **true**, create a major version. - Setting this parameter also enables versioning of this node, if it is not already versioned. - required: false - type: boolean - default: false - - name: comment - in: query - description: | - Add a version comment which will appear in version history. - Setting this parameter also enables versioning of this node, if it is not already versioned. - required: false - type: string - - name: name - in: query - description: | - Optional new name. This should include the file extension. - The name must not contain spaces or the following special characters: * " < > \ / ? : and |. - The character `.` must not be used at the end of the name. - required: false - type: string - pattern: "^(?!(.*[\\\"\\*\\\\\\>\\<\\?\\/\\:\\|]+.*)|(.*[\\.]?.*[\\.]+$)|(.*[ ]+$))" - $ref: '#/parameters/IGNodeEntryIncludeParam' - $ref: '#/parameters/fieldsParam' - in: body - name: contentBodyUpdate - description: The binary content + name: nodeBodyFile + description: The target record folder id required: true schema: - type: string - format: binary + $ref: '#/definitions/RequestBodyFile' + consumes: + - application/json produces: - application/json - consumes: - - application/octet-stream responses: '200': description: Successful response @@ -662,22 +634,64 @@ paths: $ref: '#/definitions/IGNodeEntry' '400': description: | - Invalid parameter: **recordId** is not a valid format, or is not a file + Invalid parameter: **recordIdParam** or **targetParentId** is not a valid format, + **recordIdParam** is not a record, **targetParentId** is not a record container or **nodeBodyFile** is invalid '401': - description: Authentication failed + description: Authentication failed '403': - description: Current user does not have permission to update **recordId** + description: Current user does not have permission to create children of **nodeId** '404': description: | - **recordId** does not exist - '409': - description: Optional new name clashes with an existing node in the current parent folder - '413': - description: Content exceeds individual file size limit (configured for network/system) + **recordIdParam** or **targetParentId** does not exist '422': - description: Model integrity exception including a file name containing invalid characters - '507': - description: Content exceeds overall storage quota limit configured for the network/system + description: | + Model integrity exception: the action breaks system's integrity restrictions + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' + '/records/{nodeId}/declare': + post: + tags: + - records + summary: Declare a record + description: Declares the file **nodeId** in the unfiled record container. + operationId: declareRecord + parameters: + - name: nodeId + in: path + description: The identifier of a non-record file. + required: true + type: string + - name: hideRecord + in: query + description: Flag to indicate whether the record should be hiden from the curent parent folder. + type: boolean + default: false + - $ref: '#/parameters/IGNodeEntryIncludeParam' + - $ref: '#/parameters/fieldsParam' + consumes: + - application/json + produces: + - application/json + responses: + '200': + description: Successful response + schema: + $ref: '#/definitions/IGNodeEntry' + '400': + description: | + Invalid parameter: **nodeId** is not a valid format + '401': + description: Authentication failed + '403': + description: Current user does not have permission to declare a record + '404': + description: | + **nodeId** does not exist + '422': + description: | + Model integrity exception: the action breaks system's integrity restrictions default: description: Unexpected error schema: @@ -961,6 +975,13 @@ definitions: type: object additionalProperties: type: string + RequestBodyFile: + type: object + properties: + targetParentId: + type: string + relativePath: + type: string ## Core definition ChildAssociationInfo: type: object From 9701b0020ff2cb929786ccddf90b8bdbb9d5999e Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 16 Dec 2016 11:39:11 +0200 Subject: [PATCH 17/30] RM-4418 - removed posibility to update content --- .../model/rma/aspect/RecordAspect.java | 20 +++++++++++++- .../rest/api/nodes/RecordsEntityResource.java | 27 +------------------ 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java index e49df9f140..7e0a4e72b3 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java @@ -37,17 +37,20 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; +import org.alfresco.repo.content.ContentServicePolicies; import org.alfresco.repo.copy.CopyBehaviourCallback; import org.alfresco.repo.copy.CopyDetails; import org.alfresco.repo.copy.CopyServicePolicies; import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; import org.alfresco.repo.policy.annotation.BehaviourKind; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.ScriptService; import org.alfresco.service.namespace.QName; @@ -67,7 +70,8 @@ public class RecordAspect extends AbstractDisposableItem RecordsManagementPolicies.OnCreateReference, RecordsManagementPolicies.OnRemoveReference, NodeServicePolicies.OnMoveNodePolicy, - CopyServicePolicies.OnCopyCompletePolicy + CopyServicePolicies.OnCopyCompletePolicy, + ContentServicePolicies.OnContentPropertyUpdatePolicy { /** Well-known location of the scripts folder. */ // TODO make configurable @@ -336,4 +340,18 @@ public class RecordAspect extends AbstractDisposableItem extendedSecurityService.remove(targetNodeRef); } } + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void onContentPropertyUpdate(NodeRef nodeRef, QName propertyQName, ContentData beforeValue, ContentData afterValue) + { + if (beforeValue != null) + { + throw new IntegrityException("Content property cannot be updated for records", null); + } + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/RecordsEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/RecordsEntityResource.java index 215a43f49a..55f7058d87 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/RecordsEntityResource.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/RecordsEntityResource.java @@ -27,15 +27,11 @@ package org.alfresco.rm.rest.api.nodes; -import java.io.InputStream; - -import org.alfresco.rest.api.model.Node; import org.alfresco.rest.framework.BinaryProperties; import org.alfresco.rest.framework.WebApiDescription; import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; import org.alfresco.rest.framework.resource.EntityResource; import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction; -import org.alfresco.rest.framework.resource.content.BasicContentInfo; import org.alfresco.rest.framework.resource.content.BinaryResource; import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rm.rest.api.RMNodes; @@ -49,8 +45,7 @@ import org.springframework.beans.factory.InitializingBean; * @since 2.6 */ @EntityResource(name="records", title = "Records") -public class RecordsEntityResource implements BinaryResourceAction.Update, - BinaryResourceAction.Read, +public class RecordsEntityResource implements BinaryResourceAction.Read, InitializingBean { @@ -83,24 +78,4 @@ public class RecordsEntityResource implements BinaryResourceAction.Update, return nodes.getContent(recordId, parameters, true); } - /** - * Upload new version of content - * - * This allow binary content update of an existing record. - * - * Note: alternatively, can upload via POST (multipart/form-data) with existing file name and form "overwrite=true". - * - * @param recordId the id of the record to set the content for - * @param contentInfo Basic information about the content stream - * @param stream an inputstream representing the new content of the node - * @param parameters {@link Parameters} - * @return information about the record that has been updated - */ - @Override - @WebApiDescription(title = "Upload content", description = "Upload content") - @BinaryProperties({"content"}) - public Node updateProperty(String recordId, BasicContentInfo contentInfo, InputStream stream, Parameters parameters) - { - return nodes.updateContent(recordId, contentInfo, stream, parameters); - } } From ede1386710f81d7e97f604ccb78d55329a4242ff Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 16 Dec 2016 14:27:01 +0200 Subject: [PATCH 18/30] RM-4418 - added comments and localization --- .../messages/records-management-service.properties | 3 ++- .../model/rma/aspect/RecordAspect.java | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties index 37b4cd6ede..a42ee061f7 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties @@ -20,4 +20,5 @@ rm.service.node-has-aspect=The record type {1} is already showing for record {0} rm.service.final-version=Final rm.service.final-version-description=The final archived record version rm.service.enable-autoversion-on-record-creation=Auto Version on Record Creation -rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder \ No newline at end of file +rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder +rm.service.update-record-content=Could not update content property as it's immutable for records. \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java index 7e0a4e72b3..ba5a48da63 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java @@ -54,6 +54,7 @@ import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.ScriptService; import org.alfresco.service.namespace.QName; +import org.springframework.extensions.surf.util.I18NUtil; /** * rma:record behaviour bean @@ -85,7 +86,10 @@ public class RecordAspect extends AbstractDisposableItem /** record service */ protected RecordService recordService; - + + /** I18N */ + private static final String MSG_CANNOT_UPDATE_RECORD_CONTENT = "rm.service.update-record-content"; + /** * @param extendedSecurityService extended security service */ @@ -349,9 +353,10 @@ public class RecordAspect extends AbstractDisposableItem ) public void onContentPropertyUpdate(NodeRef nodeRef, QName propertyQName, ContentData beforeValue, ContentData afterValue) { + // Allow creation of content but not update if (beforeValue != null) { - throw new IntegrityException("Content property cannot be updated for records", null); + throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_UPDATE_RECORD_CONTENT), null); } } } From 10405e4e735ac5c471eae209df93609f05f18b75 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 16 Dec 2016 16:50:05 +0200 Subject: [PATCH 19/30] RM-4429 - moved declare action in files endpoint --- .../src/main/webapp/definitions/ig-core-api.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml index 528838c063..e1275d29fb 100644 --- a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml +++ b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/ig-core-api.yaml @@ -21,6 +21,8 @@ tags: description: Retrieve and manage the RM site - name: records description: Perform record specific operations + - name: files + description: Perform operations on non-record files paths: '/fileplan-components/{fileplanComponentId}': get: @@ -650,15 +652,15 @@ paths: description: Unexpected error schema: $ref: '#/definitions/Error' - '/records/{nodeId}/declare': + '/files/{fileId}/declare': post: tags: - - records - summary: Declare a record - description: Declares the file **nodeId** in the unfiled record container. + - files + summary: Declare as record + description: Declares the file **fileId** in the unfiled record container. operationId: declareRecord parameters: - - name: nodeId + - name: fileId in: path description: The identifier of a non-record file. required: true @@ -681,14 +683,14 @@ paths: $ref: '#/definitions/IGNodeEntry' '400': description: | - Invalid parameter: **nodeId** is not a valid format + Invalid parameter: **fileId** is not a valid format '401': description: Authentication failed '403': description: Current user does not have permission to declare a record '404': description: | - **nodeId** does not exist + **fileId** does not exist '422': description: | Model integrity exception: the action breaks system's integrity restrictions From d1b4c611bb0332b31734c105942cc7f65848169c Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Fri, 16 Dec 2016 22:06:47 +0000 Subject: [PATCH 20/30] RM-4565 (Update RM API Explorer dependency and split war files) --- rm-community/rm-community-repo/pom.xml | 11 ++++++++++- rm-community/rm-community-rest-api-explorer/pom.xml | 5 ++++- .../src/main/webapp/index.html | 6 +----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 51cd214259..b408484633 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -25,6 +25,7 @@ alfresco-rm-community-repo true ${project.build.directory}/solr/home + 1.4 @@ -532,11 +533,19 @@ /solr4 ${alfresco.solr.home}/context.xml + + org.alfresco + api-explorer + ${api.explorer.version} + /api-explorer + war + true + org.alfresco alfresco-rm-community-rest-api-explorer ${project.version} - /api-explorer + /rm-api-explorer war true diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index 84e073c0db..00fef984bf 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -11,7 +11,7 @@ - 2.0-SNAPSHOT + 1.4 2.1.4 1.7 1.7 @@ -30,6 +30,9 @@ org.alfresco api-explorer + + definitions/* + diff --git a/rm-community/rm-community-rest-api-explorer/src/main/webapp/index.html b/rm-community/rm-community-rest-api-explorer/src/main/webapp/index.html index b08cfe78ef..f20f567268 100644 --- a/rm-community/rm-community-rest-api-explorer/src/main/webapp/index.html +++ b/rm-community/rm-community-rest-api-explorer/src/main/webapp/index.html @@ -32,7 +32,7 @@