Merge remote-tracking branch 'origin/master' into feature/RM-4615_TAS_Binary_Request_Handler

This commit is contained in:
Kristijan Conkas
2017-01-25 15:17:51 +00:00
3 changed files with 59 additions and 34 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;
@@ -61,7 +61,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
{
/* to be used to append to modifications */
private final String MODIFIED_PREFIX = "modified_";
/**
* <pre>
* Given an incomplete record
@@ -79,14 +79,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());
@@ -111,7 +111,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
assertEquals(updatedRecord.getProperties().getDescription(), newDescription);
}
}
/**
* <pre>
* Given an incomplete record
@@ -129,7 +129,6 @@ public class UpdateRecordsTests extends BaseRMRestTest
public void userWithEditMetadataCapsCanUpdateMetadata() throws Exception
{
RMUserAPI rmUserAPI = getRestAPIFactory().getRMUserAPI();
// create test user and add it with collab. privileges
UserModel updateUser = getDataUser().createRandomTestUser("updateuser");
updateUser.setUserRole(UserRole.SiteCollaborator);
@@ -156,14 +155,14 @@ public class UpdateRecordsTests extends BaseRMRestTest
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());
@@ -189,7 +188,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
assertEquals(updatedRecord.getModifiedByUser().getId(), updateUser.getUsername());
}
}
/**
* <pre>
* Given a complete record
@@ -208,16 +207,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());
@@ -234,7 +233,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());
@@ -243,7 +242,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 */