Merge branch 'feature/RM-4576_Completed_records_can_be_modified' into 'master'

RM-4576 (Completed records can be modified)

See merge request !5
This commit is contained in:
Tuna Aksoy
2017-01-25 13:42:00 +00:00
3 changed files with 62 additions and 36 deletions

View File

@@ -29,8 +29,8 @@ package org.alfresco.rest.rm.community.fileplancomponents;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.OK;
import static org.testng.Assert.assertEquals;
@@ -62,10 +62,10 @@ public class UpdateRecordsTests extends BaseRMRestTest
{
@Autowired
private RMUserAPI rmUserAPI;
/* to be used to append to modifications */
private final String MODIFIED_PREFIX = "modified_";
/**
* <pre>
* Given an incomplete record
@@ -83,14 +83,14 @@ public class UpdateRecordsTests extends BaseRMRestTest
public void incompleteRecordsCanBeUpdated(FilePlanComponent recordFolder) throws Exception
{
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
// create electronic and non-electronic records in a folder
FilePlanComponent electronicRecord = filePlanComponentsAPI.createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, recordFolder.getId());
assertStatusCode(CREATED);
FilePlanComponent nonElectronicRecord = filePlanComponentsAPI.createFilePlanComponent(createNonElectronicRecordModel(), recordFolder.getId());
assertStatusCode(CREATED);
for (FilePlanComponent record: Arrays.asList(electronicRecord, nonElectronicRecord)) {
for (FilePlanComponent record: Arrays.asList(electronicRecord, nonElectronicRecord)) {
// generate update metadata
String newName = getModifiedPropertyValue(record.getName());
String newTitle = getModifiedPropertyValue(record.getProperties().getTitle());
@@ -115,7 +115,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
assertEquals(updatedRecord.getProperties().getDescription(), newDescription);
}
}
/**
* <pre>
* Given an incomplete record
@@ -131,7 +131,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
)
@AlfrescoTest(jira="RM-4362")
public void userWithEditMetadataCapsCanUpdateMetadata() throws Exception
{
{
// create test user and add it with collab. privileges
UserModel updateUser = getDataUser().createRandomTestUser("updateuser");
updateUser.setUserRole(UserRole.SiteCollaborator);
@@ -151,21 +151,21 @@ public class UpdateRecordsTests extends BaseRMRestTest
rmUserAPI.addUserPermission(filePlanComponentsAPIAsAdmin.getFilePlanComponent(randomFolder.getParentId()),
updateUser, UserPermissions.PERMISSION_FILING);
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
// create electronic and non-electronic records in a folder
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
FilePlanComponent electronicRecord = filePlanComponentsAPI.createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, randomFolder.getId());
assertStatusCode(CREATED);
FilePlanComponent nonElectronicRecord = filePlanComponentsAPI.createFilePlanComponent(createNonElectronicRecordModel(), randomFolder.getId());
assertStatusCode(CREATED);
// get FilePlanComponentAPI instance initialised to updateUser
FilePlanComponentAPI filePlanComponentsAPIAsUser = getRestAPIFactory().getFilePlanComponentsAPI(updateUser);
for (FilePlanComponent record: Arrays.asList(electronicRecord, nonElectronicRecord)) {
filePlanComponentsAPIAsUser.getFilePlanComponent(record.getId());
assertStatusCode(OK);
// generate update metadata
String newName = getModifiedPropertyValue(record.getName());
String newTitle = getModifiedPropertyValue(record.getProperties().getTitle());
@@ -191,7 +191,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
assertEquals(updatedRecord.getModifiedByUser().getId(), updateUser.getUsername());
}
}
/**
* <pre>
* Given a complete record
@@ -210,16 +210,16 @@ public class UpdateRecordsTests extends BaseRMRestTest
public void completeRecordsCantBeUpdated(FilePlanComponent recordFolder) throws Exception
{
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
// create electronic and non-electronic records in a folder
FilePlanComponent electronicRecord = filePlanComponentsAPI.createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, recordFolder.getId());
assertStatusCode(CREATED);
closeRecord(electronicRecord);
FilePlanComponent nonElectronicRecord = filePlanComponentsAPI.createFilePlanComponent(createNonElectronicRecordModel(), recordFolder.getId());
assertStatusCode(CREATED);
closeRecord(nonElectronicRecord);
for (FilePlanComponent record: Arrays.asList(electronicRecord, nonElectronicRecord)) {
// generate update metadata
String newName = getModifiedPropertyValue(record.getName());
@@ -236,7 +236,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
// attempt to update record
filePlanComponentsAPI.updateFilePlanComponent(updateRecord, record.getId());
assertStatusCode(BAD_REQUEST);
assertStatusCode(FORBIDDEN);
// verify the original record metatada has been retained
FilePlanComponent updatedRecord = filePlanComponentsAPI.getFilePlanComponent(record.getId());
@@ -245,7 +245,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
assertEquals(updatedRecord.getProperties().getDescription(), record.getProperties().getTitle());
}
}
/**
* Helper method to generate modified property value based on original value
* @param originalValue original value

View File

@@ -1,7 +1,18 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<!-- Helper beans -->
@@ -569,9 +580,9 @@
parent="baseService">
<property name="nodeService" ref="nodeService"/>
<property name="filePlanService" ref="filePlanService" />
<property name="filePlanRoleService" ref="filePlanRoleService" />
<property name="authorityService" ref="authorityService"/>
<property name="permissionService" ref="permissionService"/>
<property name="filePlanRoleService" ref="filePlanRoleService" />
<property name="authorityService" ref="authorityService"/>
<property name="permissionService" ref="permissionService"/>
<property name="transactionService" ref="transactionService"/>
</bean>
@@ -1060,8 +1071,21 @@
<property name="renditionService" ref="RenditionService" />
<property name="dispositionService" ref="DispositionService"/>
<property name="recordableVersionService" ref="RecordableVersionService"/>
<property name="alwaysEditURIs" ref="recordService_alwaysEditURIs" />
</bean>
<!-- Defines a list of namespace URIs for properties, which should be always editable -->
<util:list id="recordService_alwaysEditURIs" value-type="java.lang.String">
<value>http://www.alfresco.org/model/security/1.0</value>
<value>http://www.alfresco.org/model/system/1.0</value>
<value>http://www.alfresco.org/model/workflow/1.0</value>
<value>http://www.alfresco.org/model/application/1.0</value>
<value>http://www.alfresco.org/model/datalist/1.0</value>
<value>http://www.alfresco.org/model/dictionary/1.0</value>
<value>http://www.alfresco.org/model/bpm/1.0</value>
<value>http://www.alfresco.org/model/rendition/1.0</value>
</util:list>
<bean id="recordMetadataAspectBootstrap" class="org.alfresco.module.org_alfresco_module_rm.record.RecordMetadataBootstrap" init-method="init" abstract="true">
<property name="recordService" ref="recordService"/>
<property name="namespaceService" ref="namespaceService"/>

View File

@@ -27,8 +27,6 @@
package org.alfresco.module.org_alfresco_module_rm.record;
import static com.google.common.collect.Lists.newArrayList;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -158,18 +156,22 @@ public class RecordServiceImpl extends BaseBehaviourBean
};
/** always edit model URI's */
private List<String> alwaysEditURIs;
/**
* @param alwaysEditURIs the alwaysEditURIs to set
*/
public void setAlwaysEditURIs(List<String> alwaysEditURIs)
{
this.alwaysEditURIs = alwaysEditURIs;
}
/**
* @return the alwaysEditURIs
*/
protected List<String> getAlwaysEditURIs()
{
return newArrayList(
NamespaceService.SECURITY_MODEL_1_0_URI,
NamespaceService.SYSTEM_MODEL_1_0_URI,
NamespaceService.WORKFLOW_MODEL_1_0_URI,
NamespaceService.APP_MODEL_1_0_URI,
NamespaceService.DATALIST_MODEL_1_0_URI,
NamespaceService.DICTIONARY_MODEL_1_0_URI,
NamespaceService.BPM_MODEL_1_0_URI,
NamespaceService.RENDITION_MODEL_1_0_URI
);
return this.alwaysEditURIs;
}
/** record model URI's */