mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'master' into feature/RM-4113-Navigate-Clasification-Guide
This commit is contained in:
@@ -30,6 +30,17 @@
|
|||||||
<descriptionTemplate>${project.parent.parent.basedir}/license/description.ftl</descriptionTemplate>
|
<descriptionTemplate>${project.parent.parent.basedir}/license/description.ftl</descriptionTemplate>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>test-jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@@ -26,10 +26,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.core;
|
package org.alfresco.rest.core;
|
||||||
|
|
||||||
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
|
|
||||||
|
import org.alfresco.rest.exception.EmptyJsonResponseException;
|
||||||
|
import org.alfresco.rest.model.RestErrorModel;
|
||||||
|
import org.alfresco.rest.model.RestHtmlResponse;
|
||||||
|
import org.alfresco.rest.model.RestSiteModel;
|
||||||
|
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||||
|
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||||
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,11 +47,13 @@ import org.springframework.stereotype.Service;
|
|||||||
* @author Tuna Aksoy
|
* @author Tuna Aksoy
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Primary
|
|
||||||
@Service
|
@Service
|
||||||
@Scope(value = "prototype")
|
@Scope(value = "prototype")
|
||||||
public class RMRestWrapper extends RestWrapper
|
public class RMRestWrapper
|
||||||
{
|
{
|
||||||
|
/** The class that wraps the ReST APIs from core. */
|
||||||
|
@Autowired
|
||||||
|
private RestWrapper restWrapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RMRestProperties rmRestProperties;
|
private RMRestProperties rmRestProperties;
|
||||||
|
|
||||||
@@ -51,6 +62,131 @@ public class RMRestWrapper extends RestWrapper
|
|||||||
return new RestIGCoreAPI(this, rmRestProperties);
|
return new RestIGCoreAPI(this, rmRestProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the core class that wraps the ReST APIs. */
|
||||||
|
public RestWrapper getRestWrapper()
|
||||||
|
{
|
||||||
|
return restWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Authenticate specific user to Alfresco REST API */
|
||||||
|
public void authenticateUser(UserModel userModel)
|
||||||
|
{
|
||||||
|
restWrapper.authenticateUser(userModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the last error thrown (if any). */
|
||||||
|
public RestErrorModel assertLastError()
|
||||||
|
{
|
||||||
|
return restWrapper.assertLastError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Process responses for a collection of models as {@link RestSiteModelsCollection}. */
|
||||||
|
public <T> T processModels(Class<T> classz, RestRequest simpleRequest)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return restWrapper.processModels(classz, simpleRequest);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// TODO Hopefully remove this check when TAS stops using checked exceptions.
|
||||||
|
// See https://gitlab.alfresco.com/tas/alfresco-tas-restapi-test/merge_requests/392
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Process responses for a single model as {@link RestSiteModel}. */
|
||||||
|
public <T> T processModel(Class<T> classz, RestRequest restRequest)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return restWrapper.processModel(classz, restRequest);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// TODO Hopefully remove this check when TAS stops using checked exceptions.
|
||||||
|
// See https://gitlab.alfresco.com/tas/alfresco-tas-restapi-test/merge_requests/392
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Process a response that has no body - basically will need only the status code from it. */
|
||||||
|
public void processEmptyModel(RestRequest simpleRequest)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
restWrapper.processEmptyModel(simpleRequest);
|
||||||
|
}
|
||||||
|
catch (EmptyJsonResponseException e)
|
||||||
|
{
|
||||||
|
// TODO Hopefully remove this check when TAS stops using checked exceptions.
|
||||||
|
// See https://gitlab.alfresco.com/tas/alfresco-tas-restapi-test/merge_requests/392
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the most recently returned status code. */
|
||||||
|
public String getStatusCode()
|
||||||
|
{
|
||||||
|
return restWrapper.getStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the status code. This should only be needed when calling APIs without using the TAS framework. */
|
||||||
|
public void setStatusCode(String statusCode)
|
||||||
|
{
|
||||||
|
restWrapper.setStatusCode(statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Assert that a specific status code is returned. */
|
||||||
|
public void assertStatusCodeIs(HttpStatus statusCode)
|
||||||
|
{
|
||||||
|
restWrapper.assertStatusCodeIs(statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return A parameters string that you could pass on the request ?param=value */
|
||||||
|
public String getParameters()
|
||||||
|
{
|
||||||
|
return restWrapper.getParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a {@link UserModel} for a new test user. */
|
||||||
|
public UserModel getTestUser()
|
||||||
|
{
|
||||||
|
return restWrapper.getTestUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the Alfresco Core API. */
|
||||||
|
public RestCoreAPI withCoreAPI()
|
||||||
|
{
|
||||||
|
return restWrapper.withCoreAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You can handle the request sent to server by calling this method.
|
||||||
|
* If for example you want to sent multipart form data you can use: <pre>
|
||||||
|
* restClient.configureRequestSpec()
|
||||||
|
* .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||||
|
* .addFormParam("renditions", "doclib")
|
||||||
|
* .addFormParam("autoRename", true);
|
||||||
|
*
|
||||||
|
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
||||||
|
* </pre> This will create the node using the multipart data defined.
|
||||||
|
*/
|
||||||
|
public RequestSpecBuilder configureRequestSpec()
|
||||||
|
{
|
||||||
|
return restWrapper.configureRequestSpec();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a response that returns a html
|
||||||
|
*
|
||||||
|
* @throws EmptyJsonResponseException If there is no response from the server.
|
||||||
|
*/
|
||||||
|
public RestHtmlResponse processHtmlResponse(RestRequest simpleRequest)
|
||||||
|
{
|
||||||
|
return restWrapper.processHtmlResponse(simpleRequest);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rmRestProperties
|
* @return the rmRestProperties
|
||||||
*/
|
*/
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.core;
|
package org.alfresco.rest.core;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.alfresco.rest.requests.Node;
|
import org.alfresco.rest.requests.Node;
|
||||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
@@ -54,7 +56,7 @@ public class RestAPIFactory
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DataUser dataUser;
|
private DataUser dataUser;
|
||||||
|
|
||||||
@Autowired
|
@Resource(name = "RMRestWrapper")
|
||||||
private RMRestWrapper rmRestWrapper;
|
private RMRestWrapper rmRestWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +67,11 @@ public class RestAPIFactory
|
|||||||
return this.rmRestWrapper;
|
return this.rmRestWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRmRestWrapper(RMRestWrapper rmRestWrapper)
|
||||||
|
{
|
||||||
|
this.rmRestWrapper = rmRestWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
private RestIGCoreAPI getRestIGCoreAPI(UserModel userModel)
|
private RestIGCoreAPI getRestIGCoreAPI(UserModel userModel)
|
||||||
{
|
{
|
||||||
getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser());
|
getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser());
|
||||||
|
@@ -42,17 +42,17 @@ public abstract class RMModelRequest extends ModelRequest<RMModelRequest>
|
|||||||
/**
|
/**
|
||||||
* @return the rmRestWrapper
|
* @return the rmRestWrapper
|
||||||
*/
|
*/
|
||||||
protected RMRestWrapper getRMRestWrapper()
|
public RMRestWrapper getRMRestWrapper()
|
||||||
{
|
{
|
||||||
return this.rmRestWrapper;
|
return this.rmRestWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param restWrapper
|
* @param rmRestWrapper
|
||||||
*/
|
*/
|
||||||
public RMModelRequest(RMRestWrapper rmRestWrapper)
|
public RMModelRequest(RMRestWrapper rmRestWrapper)
|
||||||
{
|
{
|
||||||
super(rmRestWrapper);
|
super(rmRestWrapper.getRestWrapper());
|
||||||
this.rmRestWrapper = rmRestWrapper;
|
this.rmRestWrapper = rmRestWrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.requests.igCoreAPI;
|
package org.alfresco.rest.rm.community.requests.igCoreAPI;
|
||||||
|
|
||||||
|
import static com.jayway.restassured.RestAssured.basic;
|
||||||
|
import static com.jayway.restassured.RestAssured.given;
|
||||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
||||||
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.requests.igCoreAPI;
|
package org.alfresco.rest.rm.community.requests.igCoreAPI;
|
||||||
|
|
||||||
|
import static com.jayway.restassured.RestAssured.given;
|
||||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
||||||
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
||||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
||||||
|
@@ -26,12 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.util;
|
package org.alfresco.rest.rm.community.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||||
import com.fasterxml.jackson.core.JsonGenerationException;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||||
@@ -48,9 +44,8 @@ public class PojoUtility
|
|||||||
* Converting object to JSON string
|
* Converting object to JSON string
|
||||||
*
|
*
|
||||||
* @param model The java object model to convert
|
* @param model The java object model to convert
|
||||||
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
|
|
||||||
*/
|
*/
|
||||||
public static String toJson(Object model) throws JsonProcessingException
|
public static String toJson(Object model)
|
||||||
{
|
{
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
//include only values that differ from default settings to be included
|
//include only values that differ from default settings to be included
|
||||||
@@ -60,15 +55,7 @@ public class PojoUtility
|
|||||||
//return the json object
|
//return the json object
|
||||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e)
|
catch (JsonProcessingException e)
|
||||||
{
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
catch (JsonMappingException e)
|
|
||||||
{
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
{
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
@@ -81,7 +68,7 @@ public class PojoUtility
|
|||||||
* @param model The java object model to convert
|
* @param model The java object model to convert
|
||||||
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
|
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
|
||||||
*/
|
*/
|
||||||
public static String toJsonElectronicRecord(Object model) throws JsonProcessingException
|
public static String toJsonElectronicRecord(Object model)
|
||||||
{
|
{
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
@@ -93,20 +80,10 @@ public class PojoUtility
|
|||||||
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
//return the json object
|
//return the json object
|
||||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e)
|
catch (JsonProcessingException e)
|
||||||
{
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
catch (JsonMappingException e)
|
|
||||||
{
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
{
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
*/
|
*/
|
||||||
protected void assertStatusCode(HttpStatus statusCode)
|
protected void assertStatusCode(HttpStatus statusCode)
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getRmRestWrapper().assertStatusCodeIs(statusCode);
|
restAPIFactory.getRmRestWrapper().assertStatusCodeIs(statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +145,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
*/
|
*/
|
||||||
public void createRMSiteIfNotExists() throws Exception
|
public void createRMSiteIfNotExists() throws Exception
|
||||||
{
|
{
|
||||||
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
RMSiteAPI rmSiteAPI = restAPIFactory.getRMSiteAPI();
|
||||||
|
|
||||||
// Check RM site doesn't exist
|
// Check RM site doesn't exist
|
||||||
if (!rmSiteAPI.existsRMSite())
|
if (!rmSiteAPI.existsRMSite())
|
||||||
|
@@ -60,9 +60,9 @@
|
|||||||
class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.TransferredCapabilityCondition">
|
class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.TransferredCapabilityCondition">
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="capabilityCondition.movable"
|
<bean id="capabilityCondition.movableRecordFolder"
|
||||||
parent="capabilityCondition.base"
|
parent="capabilityCondition.base"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.MovableCapabilityCondition">
|
class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.MovableRecordFolderCapabilityCondition">
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="capabilityCondition.destroyed"
|
<bean id="capabilityCondition.destroyed"
|
||||||
|
@@ -122,6 +122,11 @@
|
|||||||
<property name="name" value="MoveRecordFolder"/>
|
<property name="name" value="MoveRecordFolder"/>
|
||||||
<property name="private" value="true"/>
|
<property name="private" value="true"/>
|
||||||
<property name="undetermined" value="true"/>
|
<property name="undetermined" value="true"/>
|
||||||
|
<property name="kinds">
|
||||||
|
<list>
|
||||||
|
<value>RECORD_FOLDER</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
<property name="capabilities">
|
<property name="capabilities">
|
||||||
<list>
|
<list>
|
||||||
<ref bean="rmDeleteRecordFolderCapability"/>
|
<ref bean="rmDeleteRecordFolderCapability"/>
|
||||||
@@ -129,7 +134,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="conditions">
|
<property name="conditions">
|
||||||
<map>
|
<map>
|
||||||
<entry key="capabilityCondition.movable" value="true"/>
|
<entry key="capabilityCondition.movableRecordFolder" value="true"/>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
<property name="targetCapability" ref="rmCreateRecordFolderCapability"/>
|
<property name="targetCapability" ref="rmCreateRecordFolderCapability"/>
|
||||||
|
@@ -36,7 +36,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
* @since 2.4.1
|
* @since 2.4.1
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MovableCapabilityCondition extends AbstractCapabilityCondition
|
public class MovableRecordFolderCapabilityCondition extends AbstractCapabilityCondition
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +47,6 @@ public class MovableCapabilityCondition extends AbstractCapabilityCondition
|
|||||||
{
|
{
|
||||||
if (nodeService.hasAspect(nodeRef, ASPECT_GHOSTED) && dispositionService.isDisposableItemCutoff(nodeRef))
|
if (nodeService.hasAspect(nodeRef, ASPECT_GHOSTED) && dispositionService.isDisposableItemCutoff(nodeRef))
|
||||||
return true;
|
return true;
|
||||||
return !dispositionService.isDisposableItemCutoff(nodeRef);
|
return !(dispositionService.isDisposableItemCutoff(nodeRef) || recordFolderService.isRecordFolderClosed(nodeRef));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -27,6 +27,12 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.record;
|
package org.alfresco.module.org_alfresco_module_rm.record;
|
||||||
|
|
||||||
|
|
||||||
|
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.FIRST_EVENT;
|
||||||
|
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT;
|
||||||
|
import static org.alfresco.repo.policy.annotation.BehaviourKind.ASSOCIATION;
|
||||||
|
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -67,10 +73,9 @@ import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel;
|
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService;
|
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService;
|
||||||
|
import org.alfresco.repo.content.ContentServicePolicies;
|
||||||
import org.alfresco.repo.node.NodeServicePolicies;
|
import org.alfresco.repo.node.NodeServicePolicies;
|
||||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
|
||||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||||
@@ -82,16 +87,13 @@ import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService;
|
|||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.model.FileExistsException;
|
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.security.AccessPermission;
|
import org.alfresco.service.cmr.security.AccessPermission;
|
||||||
@@ -126,9 +128,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
RecordsManagementModel,
|
RecordsManagementModel,
|
||||||
RecordsManagementCustomModel,
|
RecordsManagementCustomModel,
|
||||||
NodeServicePolicies.OnCreateChildAssociationPolicy,
|
NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||||
NodeServicePolicies.OnAddAspectPolicy,
|
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||||
NodeServicePolicies.OnRemoveAspectPolicy,
|
ContentServicePolicies.OnContentUpdatePolicy
|
||||||
NodeServicePolicies.OnUpdatePropertiesPolicy
|
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RecordServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(RecordServiceImpl.class);
|
||||||
@@ -141,7 +142,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
/** transation data key */
|
/** transation data key */
|
||||||
private static final String KEY_IGNORE_ON_UPDATE = "ignoreOnUpdate";
|
private static final String KEY_IGNORE_ON_UPDATE = "ignoreOnUpdate";
|
||||||
private static final String KEY_PENDING_FILLING = "pendingFilling";
|
|
||||||
public static final String KEY_NEW_RECORDS = "newRecords";
|
public static final String KEY_NEW_RECORDS = "newRecords";
|
||||||
|
|
||||||
/** I18N */
|
/** I18N */
|
||||||
@@ -257,12 +257,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
private ClassPolicyDelegate<BeforeFileRecord> beforeFileRecord;
|
private ClassPolicyDelegate<BeforeFileRecord> beforeFileRecord;
|
||||||
private ClassPolicyDelegate<OnFileRecord> onFileRecord;
|
private ClassPolicyDelegate<OnFileRecord> onFileRecord;
|
||||||
|
|
||||||
/** Behaviours */
|
|
||||||
private JavaBehaviour onCreateChildAssociation = new JavaBehaviour(
|
|
||||||
this,
|
|
||||||
"onCreateChildAssociation",
|
|
||||||
NotificationFrequency.FIRST_EVENT);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param identifierService identifier service
|
* @param identifierService identifier service
|
||||||
*/
|
*/
|
||||||
@@ -415,13 +409,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
// bind policies
|
// bind policies
|
||||||
beforeFileRecord = policyComponent.registerClassPolicy(BeforeFileRecord.class);
|
beforeFileRecord = policyComponent.registerClassPolicy(BeforeFileRecord.class);
|
||||||
onFileRecord = policyComponent.registerClassPolicy(OnFileRecord.class);
|
onFileRecord = policyComponent.registerClassPolicy(OnFileRecord.class);
|
||||||
|
|
||||||
// bind behaviours
|
|
||||||
policyComponent.bindAssociationBehaviour(
|
|
||||||
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
|
|
||||||
TYPE_RECORD_FOLDER,
|
|
||||||
ContentModel.ASSOC_CONTAINS,
|
|
||||||
onCreateChildAssociation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -430,88 +417,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
@Override
|
@Override
|
||||||
@Behaviour
|
@Behaviour
|
||||||
(
|
(
|
||||||
kind = BehaviourKind.CLASS,
|
kind = ASSOCIATION,
|
||||||
type = "sys:noContent"
|
type = "rma:recordFolder",
|
||||||
|
notificationFrequency = FIRST_EVENT
|
||||||
)
|
)
|
||||||
public void onRemoveAspect(NodeRef nodeRef, QName aspect)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (nodeService.hasAspect(nodeRef, ASPECT_RECORD))
|
|
||||||
{
|
|
||||||
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
|
||||||
|
|
||||||
// Only switch name back to the format of "name (identifierId)" if content size is non-zero, else leave it as the original name to avoid CIFS shuffling issues.
|
|
||||||
if (contentData != null && contentData.getSize() > 0)
|
|
||||||
{
|
|
||||||
switchNames(nodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check whether filling is pending aspect removal
|
|
||||||
Set<NodeRef> pendingFilling = transactionalResourceHelper.getSet(KEY_PENDING_FILLING);
|
|
||||||
if (pendingFilling.contains(nodeRef))
|
|
||||||
{
|
|
||||||
file(nodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Behaviour
|
|
||||||
(
|
|
||||||
kind = BehaviourKind.CLASS,
|
|
||||||
type = "sys:noContent"
|
|
||||||
)
|
|
||||||
public void onAddAspect(NodeRef nodeRef, QName aspect)
|
|
||||||
{
|
|
||||||
switchNames(nodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to switch the name of the record around. Used to support record creation via
|
|
||||||
* file protocols.
|
|
||||||
*
|
|
||||||
* @param nodeRef node reference (record)
|
|
||||||
*/
|
|
||||||
private void switchNames(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (nodeService.hasAspect(nodeRef, ASPECT_RECORD))
|
|
||||||
{
|
|
||||||
String origionalName = (String)nodeService.getProperty(nodeRef, PROP_ORIGIONAL_NAME);
|
|
||||||
if (origionalName != null)
|
|
||||||
{
|
|
||||||
String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
|
||||||
fileFolderService.rename(nodeRef, origionalName);
|
|
||||||
nodeService.setProperty(nodeRef, PROP_ORIGIONAL_NAME, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (FileExistsException e)
|
|
||||||
{
|
|
||||||
LOGGER.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
catch (InvalidNodeRefException e)
|
|
||||||
{
|
|
||||||
LOGGER.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException e)
|
|
||||||
{
|
|
||||||
LOGGER.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Behaviour executed when a new item is added to a record folder.
|
|
||||||
*
|
|
||||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, final boolean bNew)
|
public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, final boolean bNew)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
@@ -519,7 +428,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
@Override
|
@Override
|
||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
onCreateChildAssociation.disable();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||||
@@ -527,14 +435,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) &&
|
!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) &&
|
||||||
!nodeService.getType(nodeRef).equals(TYPE_RECORD_FOLDER) &&
|
!nodeService.getType(nodeRef).equals(TYPE_RECORD_FOLDER) &&
|
||||||
!nodeService.getType(nodeRef).equals(TYPE_RECORD_CATEGORY))
|
!nodeService.getType(nodeRef).equals(TYPE_RECORD_CATEGORY))
|
||||||
{
|
|
||||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT))
|
|
||||||
{
|
|
||||||
// we need to postpone filling until the NO_CONTENT aspect is removed
|
|
||||||
Set<NodeRef> pendingFilling = transactionalResourceHelper.getSet(KEY_PENDING_FILLING);
|
|
||||||
pendingFilling.add(nodeRef);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// store information about the 'new' record in the transaction
|
// store information about the 'new' record in the transaction
|
||||||
// @since 2.3
|
// @since 2.3
|
||||||
@@ -561,7 +461,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
dispositionService.recalculateNextDispositionStep(nodeRef);
|
dispositionService.recalculateNextDispositionStep(nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (RecordLinkRuntimeException e)
|
catch (RecordLinkRuntimeException e)
|
||||||
{
|
{
|
||||||
// rethrow exception
|
// rethrow exception
|
||||||
@@ -572,10 +471,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
// do nothing but log error
|
// do nothing but log error
|
||||||
LOGGER.warn("Unable to file pending record.", e);
|
LOGGER.warn("Unable to file pending record.", e);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
onCreateChildAssociation.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -908,6 +803,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
// make the document a record
|
// make the document a record
|
||||||
makeRecord(nodeRef);
|
makeRecord(nodeRef);
|
||||||
|
renameRecord(nodeRef);
|
||||||
|
|
||||||
if (latestVersionRecord != null)
|
if (latestVersionRecord != null)
|
||||||
{
|
{
|
||||||
@@ -1116,6 +1012,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
// make record
|
// make record
|
||||||
makeRecord(record);
|
makeRecord(record);
|
||||||
|
renameRecord(record);
|
||||||
|
|
||||||
// remove added copy assocs
|
// remove added copy assocs
|
||||||
List<AssociationRef> recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL);
|
List<AssociationRef> recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL);
|
||||||
@@ -1250,6 +1147,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
// make record
|
// make record
|
||||||
makeRecord(record);
|
makeRecord(record);
|
||||||
|
renameRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
@@ -1286,28 +1184,6 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
// get the record name
|
// get the record name
|
||||||
String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME);
|
String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME);
|
||||||
|
|
||||||
// rename the record
|
|
||||||
int dotIndex = name.lastIndexOf('.');
|
|
||||||
String prefix = name;
|
|
||||||
String postfix = "";
|
|
||||||
if (dotIndex != -1)
|
|
||||||
{
|
|
||||||
prefix = name.substring(0, dotIndex);
|
|
||||||
postfix = name.substring(dotIndex);
|
|
||||||
}
|
|
||||||
String recordName = prefix + " (" + recordId + ")" + postfix;
|
|
||||||
behaviourFilter.disableBehaviour();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fileFolderService.rename(document, recordName);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
behaviourFilter.enableBehaviour();
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.debug("Rename {} to {}", name, recordName);
|
|
||||||
|
|
||||||
// add the record aspect
|
// add the record aspect
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
|
||||||
props.put(PROP_IDENTIFIER, recordId);
|
props.put(PROP_IDENTIFIER, recordId);
|
||||||
@@ -1319,10 +1195,11 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
// remove the owner
|
// remove the owner
|
||||||
ownableService.setOwner(document, OwnableService.NO_OWNER);
|
ownableService.setOwner(document, OwnableService.NO_OWNER);
|
||||||
}
|
|
||||||
catch (FileNotFoundException e)
|
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unable to make record, because rename failed.", e);
|
renameRecord(document);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -1875,4 +1752,49 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
throw new RecordLinkRuntimeException("Can only unlink a record from a record folder.");
|
throw new RecordLinkRuntimeException("Can only unlink a record from a record folder.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Behaviour
|
||||||
|
(
|
||||||
|
kind = BehaviourKind.CLASS,
|
||||||
|
type = "rma:record",
|
||||||
|
notificationFrequency = TRANSACTION_COMMIT
|
||||||
|
)
|
||||||
|
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||||
|
{
|
||||||
|
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))
|
||||||
|
{
|
||||||
|
renameRecord(nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renameRecord(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
// get the record id
|
||||||
|
String recordId = (String) nodeService.getProperty(nodeRef, PROP_IDENTIFIER);
|
||||||
|
|
||||||
|
if (isNotBlank(recordId))
|
||||||
|
{
|
||||||
|
// get the record name
|
||||||
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
|
|
||||||
|
// rename the record
|
||||||
|
int dotIndex = name.lastIndexOf('.');
|
||||||
|
String prefix = name;
|
||||||
|
String postfix = "";
|
||||||
|
if (dotIndex > 0)
|
||||||
|
{
|
||||||
|
prefix = name.substring(0, dotIndex);
|
||||||
|
postfix = name.substring(dotIndex);
|
||||||
|
}
|
||||||
|
String recordName = prefix + " (" + recordId + ")" + postfix;
|
||||||
|
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, recordName);
|
||||||
|
|
||||||
|
LOGGER.debug("Rename " + name + " to " + recordName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -222,15 +222,14 @@ public class TransferServiceImpl extends ServiceBaseImpl
|
|||||||
nodeRef,
|
nodeRef,
|
||||||
ASSOC_TRANSFERRED,
|
ASSOC_TRANSFERRED,
|
||||||
ASSOC_TRANSFERRED);
|
ASSOC_TRANSFERRED);
|
||||||
|
// Set PDF indicator flag
|
||||||
|
setPDFIndicationFlag(transferNodeRef, nodeRef);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
transferType.enable();
|
transferType.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set PDF indicator flag
|
|
||||||
setPDFIndicationFlag(transferNodeRef, nodeRef);
|
|
||||||
|
|
||||||
// Set the transferring indicator aspect
|
// Set the transferring indicator aspect
|
||||||
nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null);
|
nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null);
|
||||||
if (isRecordFolder(nodeRef))
|
if (isRecordFolder(nodeRef))
|
||||||
|
@@ -52,6 +52,7 @@ import org.junit.runner.RunWith;
|
|||||||
"!.*RM2190Test",
|
"!.*RM2190Test",
|
||||||
"!.*RM981SystemTest",
|
"!.*RM981SystemTest",
|
||||||
"!.*RM3993Test",
|
"!.*RM3993Test",
|
||||||
|
"!.*RM4163Test",
|
||||||
"!.*RecordsManagementEventServiceImplTest",
|
"!.*RecordsManagementEventServiceImplTest",
|
||||||
"!.*RmRestApiTest",
|
"!.*RmRestApiTest",
|
||||||
"!.*NotificationServiceHelperSystemTest",
|
"!.*NotificationServiceHelperSystemTest",
|
||||||
|
@@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* -
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
* -
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.rule.Rule;
|
||||||
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System test for RM-4163
|
||||||
|
*
|
||||||
|
* @author Silviu Dinuta
|
||||||
|
* @since 2.4.1
|
||||||
|
*/
|
||||||
|
public class RM4163Test extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
private RuleService ruleService;
|
||||||
|
private NodeRef ruleFolder;
|
||||||
|
private NodeRef nodeRefCategory1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initServices()
|
||||||
|
{
|
||||||
|
super.initServices();
|
||||||
|
|
||||||
|
ruleService = (RuleService) applicationContext.getBean("RuleService");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isCollaborationSiteTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isRecordTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDeclareRecordsConcurently() throws Exception
|
||||||
|
{
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
// create the folder
|
||||||
|
ruleFolder = fileFolderService.create(documentLibrary, "mytestfolder", ContentModel.TYPE_FOLDER)
|
||||||
|
.getNodeRef();
|
||||||
|
|
||||||
|
// create record category
|
||||||
|
nodeRefCategory1 = filePlanService.createRecordCategory(filePlan, "category1");
|
||||||
|
|
||||||
|
//define declare as record rule and apply it to the created folder from documentLibrary
|
||||||
|
Action action = actionService.createAction(CreateRecordAction.NAME);
|
||||||
|
action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
|
||||||
|
|
||||||
|
Rule rule = new Rule();
|
||||||
|
rule.setRuleType(RuleType.INBOUND);
|
||||||
|
rule.setTitle("declareAsRecordRule");
|
||||||
|
rule.setAction(action);
|
||||||
|
rule.setExecuteAsynchronously(true);
|
||||||
|
ruleService.saveRule(ruleFolder, rule);
|
||||||
|
|
||||||
|
//define filing rule and apply it to unfiled record container
|
||||||
|
Action fileAction = actionService.createAction(FileToAction.NAME);
|
||||||
|
fileAction.setParameterValue(FileToAction.PARAM_PATH,
|
||||||
|
"/category1/{node.cm:description}");
|
||||||
|
fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true);
|
||||||
|
|
||||||
|
Rule fileRule = new Rule();
|
||||||
|
fileRule.setRuleType(RuleType.INBOUND);
|
||||||
|
fileRule.setTitle("filingRule");
|
||||||
|
fileRule.setAction(fileAction);
|
||||||
|
fileRule.setExecuteAsynchronously(true);
|
||||||
|
ruleService.saveRule(filePlanService.getUnfiledContainer(filePlan), fileRule);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void test(Void result) throws Exception
|
||||||
|
{
|
||||||
|
assertFalse(ruleService.getRules(ruleFolder).isEmpty());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//create 4 documents in documentLibrary
|
||||||
|
List<NodeRef> documents = new ArrayList<NodeRef>(4);
|
||||||
|
documents.addAll(doTestInTransaction(new Test<List<NodeRef>>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public List<NodeRef> run() throws Exception
|
||||||
|
{
|
||||||
|
List<NodeRef> documents = new ArrayList<NodeRef>(4);
|
||||||
|
NodeRef document = createFile(documentLibrary, "document1.txt", "desc1", ContentModel.TYPE_CONTENT);
|
||||||
|
documents.add(document);
|
||||||
|
document = createFile(documentLibrary, "document2.txt", "desc2", ContentModel.TYPE_CONTENT);
|
||||||
|
documents.add(document);
|
||||||
|
document = createFile(documentLibrary, "document3.txt", "desc1", ContentModel.TYPE_CONTENT);
|
||||||
|
documents.add(document);
|
||||||
|
document = createFile(documentLibrary, "document4.txt", "desc1", ContentModel.TYPE_CONTENT);
|
||||||
|
documents.add(document);
|
||||||
|
return documents;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
//move created documents in the folder that has Declare as Record rule
|
||||||
|
final Iterator<NodeRef> temp = documents.iterator();
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void run() throws Exception
|
||||||
|
{
|
||||||
|
while (temp.hasNext())
|
||||||
|
{
|
||||||
|
NodeRef document = temp.next();
|
||||||
|
fileFolderService.move(document, ruleFolder, null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//give enough time for filing all records
|
||||||
|
Thread.sleep(5000);
|
||||||
|
|
||||||
|
//check that target category has in created record folders 4 records
|
||||||
|
Integer numberOfRecords = AuthenticationUtil.runAsSystem(new RunAsWork<Integer>()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer doWork() throws Exception
|
||||||
|
{
|
||||||
|
List<NodeRef> containedRecordFolders = filePlanService.getContainedRecordFolders(nodeRefCategory1);
|
||||||
|
int numberOfRecords = 0;
|
||||||
|
for(NodeRef recordFolder : containedRecordFolders)
|
||||||
|
{
|
||||||
|
numberOfRecords = numberOfRecords + fileFolderService.list(recordFolder).size();
|
||||||
|
}
|
||||||
|
return numberOfRecords;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertEquals(4, numberOfRecords.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef createFile(NodeRef parentNodeRef, String name, String descrption, QName typeQName)
|
||||||
|
{
|
||||||
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
|
||||||
|
properties.put(ContentModel.PROP_NAME, (Serializable) name);
|
||||||
|
properties.put(ContentModel.PROP_DESCRIPTION, (Serializable) descrption);
|
||||||
|
QName assocQName = QName.createQName(
|
||||||
|
NamespaceService.CONTENT_MODEL_1_0_URI,
|
||||||
|
QName.createValidLocalName(name));
|
||||||
|
ChildAssociationRef assocRef = nodeService.createNode(
|
||||||
|
parentNodeRef,
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
assocQName,
|
||||||
|
typeQName,
|
||||||
|
properties);
|
||||||
|
NodeRef nodeRef = assocRef.getChildRef();
|
||||||
|
return nodeRef;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* -
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
* -
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||||
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.extensions.webscripts.GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration test for RM-4804
|
||||||
|
*
|
||||||
|
* Completed records of type pdf can be transferred
|
||||||
|
*
|
||||||
|
* @author Ramona Popa
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
public class RM4804Test extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Given a category with disposition schedule applied on folder with Cut Of and Transfer, a record folder and a file PDF document
|
||||||
|
* to folder, complete the record
|
||||||
|
* When execute disposition schedule steps
|
||||||
|
* Then the Transfer step is successfully finished
|
||||||
|
*/
|
||||||
|
@org.junit.Test
|
||||||
|
public void testTransferCompletedRecordOfTypePDF() throws Exception
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
NodeRef recordCategory;
|
||||||
|
NodeRef recordFolder;
|
||||||
|
NodeRef record;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// category is created
|
||||||
|
recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create a disposition schedule for category, applied on folder
|
||||||
|
Map<QName, Serializable> dsProps = new HashMap<QName, Serializable>(3);
|
||||||
|
dsProps.put(PROP_DISPOSITION_AUTHORITY, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY);
|
||||||
|
dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, GUID.generate());
|
||||||
|
dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false);
|
||||||
|
|
||||||
|
DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(recordCategory, dsProps);
|
||||||
|
|
||||||
|
// cutoff immediately
|
||||||
|
Map<QName, Serializable> dispositionActionCutOff = new HashMap<QName, Serializable>(3);
|
||||||
|
dispositionActionCutOff.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||||
|
dispositionActionCutOff.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
|
||||||
|
dispositionActionCutOff.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||||
|
|
||||||
|
dispositionService.addDispositionActionDefinition(dispositionSchedule, dispositionActionCutOff);
|
||||||
|
|
||||||
|
// transfer immediately
|
||||||
|
Map<QName, Serializable> dispositionActionTransfer = new HashMap<QName, Serializable>(4);
|
||||||
|
dispositionActionTransfer.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);
|
||||||
|
dispositionActionTransfer.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
|
||||||
|
dispositionActionTransfer.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||||
|
dispositionActionTransfer.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY);
|
||||||
|
|
||||||
|
dispositionService.addDispositionActionDefinition(dispositionSchedule, dispositionActionTransfer);
|
||||||
|
|
||||||
|
// add folder under category
|
||||||
|
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
|
||||||
|
// add record of type PDF under folder
|
||||||
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
|
props.put(ContentModel.PROP_TITLE, GUID.generate());
|
||||||
|
InputStream inputStream = IOUtils.toInputStream(GUID.generate());
|
||||||
|
record = utils.createRecord(recordFolder, GUID.generate(), props, MimetypeMap.MIMETYPE_PDF, inputStream);
|
||||||
|
|
||||||
|
// complete the record
|
||||||
|
utils.completeRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// cut off and transfer record
|
||||||
|
rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME, null);
|
||||||
|
NodeRef transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(recordFolder, TransferAction.NAME)
|
||||||
|
.getValue();
|
||||||
|
rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
// verify record is transferred
|
||||||
|
assertTrue(nodeService.hasAspect(record, ASPECT_TRANSFERRED));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -510,6 +510,46 @@ public class MoveRecordFolderTest extends BaseRMTestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a closed folder
|
||||||
|
* When we evaluate the move capability on it
|
||||||
|
* The access is denied
|
||||||
|
*/
|
||||||
|
public void testMoveClosedFolder()
|
||||||
|
{
|
||||||
|
final NodeRef destination = doTestInTransaction(new Test<NodeRef>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NodeRef run()
|
||||||
|
{
|
||||||
|
// create a record category
|
||||||
|
return filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final NodeRef testFolder = doTestInTransaction(new Test<NodeRef>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NodeRef run()
|
||||||
|
{
|
||||||
|
// create folder
|
||||||
|
NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, GUID.generate());
|
||||||
|
|
||||||
|
// close folder
|
||||||
|
recordFolderService.closeRecordFolder(testFolder);
|
||||||
|
|
||||||
|
return testFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void test(NodeRef testFolder) throws Exception
|
||||||
|
{
|
||||||
|
Capability moveCapability = capabilityService.getCapability("MoveRecordFolder");
|
||||||
|
assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private NodeRef createRecordCategory(boolean recordLevel)
|
private NodeRef createRecordCategory(boolean recordLevel)
|
||||||
{
|
{
|
||||||
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
Reference in New Issue
Block a user