mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge master into RM-4159_EnterpriseReSTTests.
Update the RMRestWrapper with a couple more passthrough methods.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Localisation config overrides for Records Management module
|
||||
MESSAGE_SEARCH_PATH="rm-community/rm-community-repo/config rm-community/rm-community-share rm-community/rm-share/source rm-enterprise/rm-enterprise-repo/src/main rm-enterprise/rm-enterprise-share/src/main "
|
||||
EXCLUDED_FILES="$EXCLUDED_FILES rm-method-security.properties springloaded.properties file-mapping.properties classified-content-notForTranslating.properties notForTranslating"
|
||||
EXCLUDED_FILES="$EXCLUDED_FILES rm-method-security.properties springloaded.properties file-mapping.properties classified-content-notForTranslating.properties notForTranslating version.properties"
|
||||
EXTENSION_PREFIX=-RM
|
||||
|
6
pom.xml
6
pom.xml
@@ -21,9 +21,9 @@
|
||||
</organization>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://gitlab.alfresco.com/records-management/records-management.git</connection>
|
||||
<developerConnection>scm:git:https://gitlab.alfresco.com/records-management/records-management.git</developerConnection>
|
||||
<url>https://gitlab.alfresco.com/records-management/records-management</url>
|
||||
<connection>scm:git:https://git.alfresco.com/records-management/records-management.git</connection>
|
||||
<developerConnection>scm:git:https://git.alfresco.com/records-management/records-management.git</developerConnection>
|
||||
<url>https://git.alfresco.com/records-management/records-management</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<maven.build.sourceVersion>1.8</maven.build.sourceVersion>
|
||||
<alfresco.rm.share>alfresco-rm-community-share</alfresco.rm.share>
|
||||
<alfresco.rm.repo>alfresco-rm-community-repo</alfresco.rm.repo>
|
||||
<tas.restapi.version>5.2.0-0</tas.restapi.version>
|
||||
<tas.restapi.version>5.2.0-4</tas.restapi.version>
|
||||
<fluent.json.version>2.0.0</fluent.json.version>
|
||||
</properties>
|
||||
|
||||
|
@@ -26,9 +26,13 @@
|
||||
*/
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyJsonResponseException;
|
||||
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.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -143,4 +147,44 @@ public class RMRestWrapper
|
||||
{
|
||||
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
|
||||
*/
|
||||
public RMRestProperties getRmRestProperties()
|
||||
{
|
||||
return this.rmRestProperties;
|
||||
}
|
||||
}
|
||||
|
@@ -28,12 +28,16 @@ package org.alfresco.rest.core;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilesAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RecordsAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.RepoTestModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -69,6 +73,22 @@ public class RestAPIFactory
|
||||
return getRmRestWrapper().withIGCoreAPI();
|
||||
}
|
||||
|
||||
private RestCoreAPI getRestCoreAPI(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser());
|
||||
return getRmRestWrapper().withCoreAPI();
|
||||
}
|
||||
|
||||
public Node getNodeAPI(RepoTestModel model) throws Exception
|
||||
{
|
||||
return getRestCoreAPI(null).usingNode(model);
|
||||
}
|
||||
|
||||
public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws Exception
|
||||
{
|
||||
return getRestCoreAPI(userModel).usingNode(model);
|
||||
}
|
||||
|
||||
public RMSiteAPI getRMSiteAPI()
|
||||
{
|
||||
return getRestIGCoreAPI(null).usingRMSite();
|
||||
@@ -108,4 +128,14 @@ public class RestAPIFactory
|
||||
{
|
||||
return getRestIGCoreAPI(userModel).usingFiles();
|
||||
}
|
||||
|
||||
public RMUserAPI getRMUserAPI()
|
||||
{
|
||||
return getRestIGCoreAPI(null).usingRMUser();
|
||||
}
|
||||
|
||||
public RMUserAPI getRMUserAPI(UserModel userModel)
|
||||
{
|
||||
return getRestIGCoreAPI(userModel).usingRMUser();
|
||||
}
|
||||
}
|
||||
|
@@ -109,5 +109,5 @@ public class FilePlanComponentProperties
|
||||
private Integer physicalSize;
|
||||
|
||||
@JsonProperty(value = PROPERTIES_RECORD_ID, required = false)
|
||||
private String recordId;
|
||||
private String rmIdentifier;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ import org.alfresco.rest.requests.ModelRequest;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class RMModelRequest extends ModelRequest
|
||||
public abstract class RMModelRequest extends ModelRequest<RMModelRequest>
|
||||
{
|
||||
private RMRestWrapper rmRestWrapper;
|
||||
|
||||
|
@@ -34,6 +34,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJsonElectronicRecord;
|
||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
||||
import static org.springframework.http.HttpMethod.DELETE;
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
@@ -49,13 +50,11 @@ 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;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
/**
|
||||
* File plan component REST API Wrapper
|
||||
@@ -235,13 +234,15 @@ public class FilePlanComponentAPI extends RMModelRequest
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
*
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param recordContent {@link File} pointing to the content of the electronic record to be created
|
||||
* @param parentId parent container id
|
||||
* @return newly created {@link FilePlanComponent}
|
||||
* @throws Exception if operation failed
|
||||
* @throws Exception for invalid electronicRecordModel JSON strings
|
||||
*/
|
||||
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent, String parentId) throws Exception
|
||||
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent,
|
||||
String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("electronicRecordModel", electronicRecordModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
@@ -250,40 +251,23 @@ public class FilePlanComponentAPI extends RMModelRequest
|
||||
fail("Only electronic records are supported");
|
||||
}
|
||||
|
||||
UserModel currentUser = getRMRestWrapper().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();
|
||||
JsonNode root = mapper.readTree(toJson(electronicRecordModel));
|
||||
|
||||
RequestSpecBuilder builder = getRMRestWrapper().configureRequestSpec();
|
||||
JsonNode root = new ObjectMapper().readTree(toJsonElectronicRecord(electronicRecordModel));
|
||||
// add request fields
|
||||
Iterator<String> fieldNames = root.fieldNames();
|
||||
while (fieldNames.hasNext())
|
||||
{
|
||||
String fieldName = fieldNames.next();
|
||||
builder.addMultiPart(fieldName, root.get(fieldName).asText(), ContentType.JSON.name());
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
Response response = given()
|
||||
.spec(builder.build())
|
||||
.when()
|
||||
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getRMRestWrapper().getParameters())
|
||||
.andReturn();
|
||||
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
|
||||
/* return a FilePlanComponent object representing Response */
|
||||
return response.jsonPath().getObject("entry", FilePlanComponent.class);
|
||||
// create node with given content
|
||||
return createFilePlanComponent(electronicRecordModel, parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,9 +26,11 @@
|
||||
*/
|
||||
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.jglue.fluentjson.JsonBuilderFactory.buildObject;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
@@ -38,12 +40,13 @@ import com.jayway.restassured.specification.RequestSpecification;
|
||||
|
||||
import org.alfresco.dataprep.AlfrescoHttpClient;
|
||||
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
|
||||
import org.alfresco.dataprep.UserService;
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.core.RMRestProperties;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -58,21 +61,44 @@ import org.springframework.stereotype.Component;
|
||||
// "old-style" API calls.
|
||||
@Component
|
||||
@Scope (value = "prototype")
|
||||
public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
public class RMUserAPI extends RMModelRequest
|
||||
{
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
/**
|
||||
* @param rmRestWrapper
|
||||
*/
|
||||
public RMUserAPI(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
/**
|
||||
* Helper method to obtain {@link AlfrescoHttpClient}
|
||||
* @return Initialized {@link AlfrescoHttpClient} instance
|
||||
*/
|
||||
private AlfrescoHttpClient getAlfrescoHttpClient()
|
||||
{
|
||||
RMRestProperties properties = getRMRestWrapper().getRmRestProperties();
|
||||
|
||||
@Autowired
|
||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
AlfrescoHttpClientFactory factory = new AlfrescoHttpClientFactory();
|
||||
factory.setHost(properties.getServer());
|
||||
factory.setPort(Integer.parseInt(properties.getPort()));
|
||||
factory.setScheme(properties.getScheme());
|
||||
|
||||
return factory.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign RM role to user
|
||||
* @param userName User's username
|
||||
* @param userRole User's RM role, one of {@link UserRoles} roles
|
||||
* @throws Exception for failed requests
|
||||
*/
|
||||
public void assignRoleToUser(String userName, String userRole) throws Exception
|
||||
{
|
||||
UserModel adminUser = getRMRestWrapper().getTestUser();
|
||||
|
||||
// get an "old-style" REST API client
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
@@ -85,13 +111,13 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
.log().all()
|
||||
.pathParam("role", userRole)
|
||||
.pathParam("authority", userName)
|
||||
.param("alf_ticket", client.getAlfTicket(
|
||||
dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword()))
|
||||
.param("alf_ticket", client.getAlfTicket(adminUser.getUsername(),
|
||||
adminUser.getPassword()))
|
||||
.when()
|
||||
.post("/rm/roles/{role}/authorities/{authority}")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,8 +128,10 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
*/
|
||||
public void addUserPermission(FilePlanComponent component, UserModel user, String permission)
|
||||
{
|
||||
UserModel adminUser = getRMRestWrapper().getTestUser();
|
||||
|
||||
// get an "old-style" REST API client
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
|
||||
JsonObject bodyJson = buildObject()
|
||||
.addArray("permissions")
|
||||
@@ -122,7 +150,7 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
// execute an "old-style" API call
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.auth().basic(dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword())
|
||||
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
|
||||
.contentType(ContentType.JSON)
|
||||
.body(bodyJson.toString())
|
||||
.pathParam("nodeId", component.getId())
|
||||
@@ -131,23 +159,47 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a user with the given name using the old APIs
|
||||
*
|
||||
* @param userName The user name
|
||||
* @param userPassword The user's password
|
||||
* @param userEmail The user's e-mail address
|
||||
* @return <code>true</code> if the user was created successfully, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean createUser(String userName)
|
||||
public boolean createUser(String userName, String userPassword, String userEmail)
|
||||
{
|
||||
return userService.create(dataUser.getAdminUser().getUsername(),
|
||||
dataUser.getAdminUser().getPassword(),
|
||||
userName,
|
||||
"password",
|
||||
"default@alfresco.com",
|
||||
userName,
|
||||
userName);
|
||||
UserModel adminUser = getRMRestWrapper().getTestUser();
|
||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
|
||||
JsonObject body = buildObject()
|
||||
.add("userName", userName)
|
||||
.add("firstName", userName)
|
||||
.add("lastName", userName)
|
||||
.add("password", userPassword)
|
||||
.add("email", userEmail)
|
||||
.getJson();
|
||||
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.setAuth(basic(adminUser.getUsername(), adminUser.getPassword()))
|
||||
.setContentType(ContentType.JSON)
|
||||
.setBody(body.toString())
|
||||
.build();
|
||||
|
||||
// create POST request to "people" endpoint
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.log().all()
|
||||
.when()
|
||||
.post("people")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
|
||||
return (response.getStatusCode() == OK.value());
|
||||
}
|
||||
}
|
||||
|
@@ -28,13 +28,14 @@ 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.simpleRequest;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
import static org.springframework.http.HttpMethod.POST;
|
||||
|
||||
import com.jayway.restassured.response.Response;
|
||||
import com.jayway.restassured.response.ResponseBody;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
@@ -78,14 +79,11 @@ public class RecordsAPI extends RMModelRequest
|
||||
public ResponseBody<?> getRecordContent(String recordId) throws Exception
|
||||
{
|
||||
mandatoryString("recordId", recordId);
|
||||
Response response = given()
|
||||
.auth().basic(getRMRestWrapper().getTestUser().getUsername(),
|
||||
getRMRestWrapper().getTestUser().getPassword())
|
||||
.when()
|
||||
.get("records/{recordId}/content", recordId)
|
||||
.andReturn();
|
||||
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
return response.getBody();
|
||||
|
||||
return getRMRestWrapper()
|
||||
.processHtmlResponse(simpleRequest(GET,"records/{recordId}/content", recordId))
|
||||
.getBody();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,6 +141,5 @@ public class RecordsAPI extends RMModelRequest
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -56,6 +56,7 @@ public class RestIGCoreAPI extends RMModelRequest
|
||||
RestAssured.baseURI = format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer());
|
||||
RestAssured.port = parseInt(rmRestProperties.getPort());
|
||||
RestAssured.basePath = rmRestProperties.getRestRmPath();
|
||||
restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,4 +98,14 @@ public class RestIGCoreAPI extends RMModelRequest
|
||||
{
|
||||
return new FilesAPI(getRMRestWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides DSL for RM user management API
|
||||
*
|
||||
* @return {@link RMUserAPI}
|
||||
*/
|
||||
public RMUserAPI usingRMUser()
|
||||
{
|
||||
return new RMUserAPI(getRMRestWrapper());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
|
||||
/**
|
||||
* Mix class for FilePlanComponent POJO class
|
||||
* Mix-in annotations are: a way to associate annotations with classes
|
||||
* without modifying (target) classes themselves.
|
||||
*
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class FilePlanComponentMixIn
|
||||
{
|
||||
/**
|
||||
* Annotation used to indicate that a property should be serialized "unwrapped"
|
||||
* Its properties are instead included as properties of its containing Object
|
||||
*/
|
||||
@JsonUnwrapped
|
||||
abstract FilePlanComponentProperties getProperties();
|
||||
|
||||
}
|
@@ -26,13 +26,12 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonGenerationException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
|
||||
/**
|
||||
* Utility class for creating the json object
|
||||
*
|
||||
@@ -56,15 +55,35 @@ public class PojoUtility
|
||||
//return the json object
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||
}
|
||||
catch (JsonGenerationException e)
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
return e.toString();
|
||||
}
|
||||
catch (JsonMappingException e)
|
||||
{
|
||||
return e.toString();
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
|
||||
/**
|
||||
* Converting object to JSON string for electronic records
|
||||
*
|
||||
* @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 toJsonElectronicRecord(Object model)
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
//inject the "mix-in" annotations from FilePlanComponentMix to
|
||||
// FilePlanComponent POJO class when converting to json
|
||||
mapper.addMixIn(FilePlanComponent.class, FilePlanComponentMixIn.class);
|
||||
|
||||
//include only values that differ from default settings to be included
|
||||
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
||||
try
|
||||
{
|
||||
//return the json object
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
return e.toString();
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
|
||||
@@ -146,8 +148,39 @@ public interface TestData
|
||||
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||
{ HOLD_TYPE },
|
||||
{ TRANSFER_TYPE },
|
||||
{ FOLDER_TYPE },
|
||||
{ CONTENT_TYPE }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Data Provider with:
|
||||
* with the object types for creating a Record Folder
|
||||
*
|
||||
* @return file plan component alias
|
||||
*/
|
||||
@DataProvider
|
||||
public static Object[][] folderTypes()
|
||||
{
|
||||
return new Object[][] {
|
||||
{ RECORD_FOLDER_TYPE },
|
||||
{ FOLDER_TYPE }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Data Provider with:
|
||||
* with the object types for creating a Record Category
|
||||
*
|
||||
* @return file plan component alias
|
||||
*/
|
||||
@DataProvider
|
||||
public static Object[][] categoryTypes()
|
||||
{
|
||||
return new Object[][] {
|
||||
{ FOLDER_TYPE },
|
||||
{ RECORD_CATEGORY_TYPE }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -41,12 +41,10 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -60,9 +58,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class DeleteRecordTests extends BaseRMRestTest
|
||||
{
|
||||
@Autowired
|
||||
private RMUserAPI rmUserAPI;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a record
|
||||
@@ -149,8 +144,8 @@ public class DeleteRecordTests extends BaseRMRestTest
|
||||
getDataUser().addUserToSite(deleteUser, new SiteModel(getRestAPIFactory().getRMSiteAPI().getSite().getId()), UserRole.SiteCollaborator);
|
||||
|
||||
// add RM role to user
|
||||
rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
getRestAPIFactory().getRMUserAPI().assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// try to delete newRecord
|
||||
getRestAPIFactory().getFilePlanComponentsAPI(deleteUser).deleteFilePlanComponent(newRecord.getId());
|
||||
@@ -183,8 +178,8 @@ public class DeleteRecordTests extends BaseRMRestTest
|
||||
logger.info("test user: " + deleteUser.getUsername());
|
||||
|
||||
// add RM role to user, RM Power User doesn't have the Delete Record capabilities
|
||||
rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
getRestAPIFactory().getRMUserAPI().assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// create random folder
|
||||
FilePlanComponent randomFolder = createCategoryFolderInFilePlan();
|
||||
@@ -193,9 +188,9 @@ public class DeleteRecordTests extends BaseRMRestTest
|
||||
// grant deleteUser Filing privileges on randomFolder category, this will be
|
||||
// inherited to randomFolder
|
||||
FilePlanComponentAPI filePlanComponentsAPIAsAdmin = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
rmUserAPI.addUserPermission(filePlanComponentsAPIAsAdmin.getFilePlanComponent(randomFolder.getParentId()),
|
||||
getRestAPIFactory().getRMUserAPI().addUserPermission(filePlanComponentsAPIAsAdmin.getFilePlanComponent(randomFolder.getParentId()),
|
||||
deleteUser, UserPermissions.PERMISSION_FILING);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// create a non-electronic record in randomFolder
|
||||
FilePlanComponent newRecord = filePlanComponentsAPIAsAdmin.createFilePlanComponent(createNonElectronicRecordModel(), randomFolder.getId());
|
||||
|
@@ -26,6 +26,9 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||
@@ -34,6 +37,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
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.createTempFile;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
@@ -42,7 +47,11 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -91,7 +100,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
)
|
||||
public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponent container) throws Exception
|
||||
{
|
||||
// Build object the filePlan
|
||||
// Build object the filePlan, this should throw an IllegalArgumentException
|
||||
getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId());
|
||||
|
||||
// verify the create request status code
|
||||
@@ -108,7 +117,10 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
* </pre>
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(description = "Electronic record can't be created in closed record folder")
|
||||
@Test
|
||||
(
|
||||
description = "Electronic record can't be created in closed record folder"
|
||||
)
|
||||
public void cantCreateElectronicRecordInClosedFolder() throws Exception
|
||||
{
|
||||
FilePlanComponent recordFolder = createCategoryFolderInFilePlan();
|
||||
@@ -119,7 +131,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// close the folder
|
||||
closeFolder(recordFolder.getId());
|
||||
|
||||
// try to create it, this should fail
|
||||
// try to create it, this should throw IllegalArgumentException
|
||||
getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, recordFolder.getId());
|
||||
|
||||
// verify the status code
|
||||
@@ -209,6 +221,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// 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()));
|
||||
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getRmIdentifier()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,5 +253,93 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
||||
// record will have record identifier inserted in its name but will for sure start with file name
|
||||
// and end with its extension
|
||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
||||
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getRmIdentifier()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Bug (id = "RM-4568")
|
||||
/**
|
||||
* Given I want to create an electronic record
|
||||
* When I use the path relative to the filePlanComponentid
|
||||
* Then the containers in the relativePath that don't exist are created before creating the electronic record
|
||||
*/
|
||||
public void createElectronicRecordWithRelativePath() throws Exception
|
||||
{
|
||||
//the containers specified on the RELATIVE_PATH parameter don't exist on server
|
||||
String RELATIVE_PATH = CATEGORY_NAME + "/" + CATEGORY_NAME + "/" + FOLDER_NAME;
|
||||
FilePlanComponent electronicRecord = FilePlanComponent.builder()
|
||||
.name(ELECTRONIC_RECORD_NAME)
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.content(FilePlanComponentContent
|
||||
.builder()
|
||||
.mimeType("text/plain")
|
||||
.build()
|
||||
)
|
||||
.properties(FilePlanComponentProperties
|
||||
.builder()
|
||||
.description(ELECTRONIC_RECORD_NAME)
|
||||
.build()
|
||||
)
|
||||
.relativePath(RELATIVE_PATH)
|
||||
.build();
|
||||
|
||||
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getProperties().getDescription().equals(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId())
|
||||
.getName().equals(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName())
|
||||
.getId().equals(recordCreated.getId()));
|
||||
|
||||
//the category specified via the RELATIVE_PATH exist, folder doesn't exist
|
||||
RELATIVE_PATH = CATEGORY_NAME + "/" + FOLDER_NAME;
|
||||
electronicRecord.setRelativePath(RELATIVE_PATH);
|
||||
recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId())
|
||||
.getName().startsWith(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName())
|
||||
.getId().equals(recordCreated.getId()));
|
||||
|
||||
//the containers from the RELATIVE PATH exists
|
||||
electronicRecord.setName(ELECTRONIC_RECORD_NAME + getRandomAlphanumeric());
|
||||
recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId())
|
||||
.getName().startsWith(FOLDER_NAME));
|
||||
//get newly created electronic record using the relativePath
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName())
|
||||
.getId().equals(recordCreated.getId()));
|
||||
|
||||
//create the container structure relative to the categoryId
|
||||
String categoryId = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + CATEGORY_NAME)
|
||||
.getId();
|
||||
RELATIVE_PATH = CATEGORY_NAME + CATEGORY_NAME + "/" + FOLDER_NAME;
|
||||
electronicRecord.setRelativePath(RELATIVE_PATH);
|
||||
recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), categoryId);
|
||||
// verify the create request status code
|
||||
assertStatusCode(CREATED);
|
||||
// get newly created electronic record and verify its properties
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId())
|
||||
.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId())
|
||||
.getName().startsWith(FOLDER_NAME));
|
||||
}
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -142,6 +143,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
||||
String file = "File " + getRandomAlphanumeric();
|
||||
String shelf = "Shelf " + getRandomAlphanumeric();
|
||||
String location = "Location " + getRandomAlphanumeric();
|
||||
String name = "Record " + getRandomAlphanumeric();
|
||||
|
||||
Random random = new Random();
|
||||
Integer copies = random.nextInt(Integer.MAX_VALUE);
|
||||
@@ -149,7 +151,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
||||
|
||||
// set values of all available properties for the non electronic records
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.name(name)
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(title)
|
||||
@@ -183,6 +185,8 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
||||
assertEquals(location, nonElectronicRecord.getProperties().getLocation());
|
||||
assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
|
||||
assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
|
||||
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getRmIdentifier()));
|
||||
assertTrue(nonElectronicRecord.getName().contains(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -178,6 +178,8 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
assertNotNull(recordWithContent.getContent().getEncoding());
|
||||
assertNotNull(recordWithContent.getContent().getMimeType());
|
||||
assertNotNull(recordWithContent.getAspectNames());
|
||||
assertFalse(recordWithContent.getName().equals(ELECTRONIC_RECORD_NAME));
|
||||
assertTrue(recordWithContent.getName().contains(recordWithContent.getProperties().getRmIdentifier()));
|
||||
assertStatusCode(OK);
|
||||
|
||||
//create non-electronic record
|
||||
@@ -196,6 +198,8 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
assertNotNull(nonElectronicRecord.getContent().getMimeType());
|
||||
assertNotNull(nonElectronicRecord.getAspectNames());
|
||||
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
|
||||
assertFalse(nonElectronicRecord.getName().equals(NONELECTRONIC_RECORD_NAME));
|
||||
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getRmIdentifier()));
|
||||
assertStatusCode(OK);
|
||||
}
|
||||
|
||||
@@ -390,8 +394,9 @@ public class ReadRecordTests extends BaseRMRestTest
|
||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
|
||||
//assertEquals(createdComponent.getName(), filePlanComponent.getName());
|
||||
assertTrue(filePlanComponent.getName().startsWith(createdComponent.getName()));
|
||||
//check the record name
|
||||
assertTrue(filePlanComponent.getName().equals(createdComponent.getName()));
|
||||
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getRmIdentifier()));
|
||||
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
|
||||
|
||||
}
|
||||
|
@@ -70,12 +70,21 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
* Given that a file plan exists
|
||||
* When I ask the API to create a root record category
|
||||
* Then it is created as a root record category
|
||||
*
|
||||
*
|
||||
* Given that a file plan exists
|
||||
* When I use the API to create a folder (cm:folder type) into the fileplan
|
||||
* Then the folder is converted to rma:recordCategory
|
||||
* (see RM-4572 comments)
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
(
|
||||
description = "Create root category"
|
||||
description = "Create root category",
|
||||
dataProviderClass= TestData.class,
|
||||
dataProvider = "categoryTypes"
|
||||
)
|
||||
public void createCategoryTest() throws Exception
|
||||
public void createCategoryTest(String nodeType) throws Exception
|
||||
{
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
@@ -83,7 +92,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE)
|
||||
.nodeType(nodeType)
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
@@ -109,7 +118,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
// Verify the returned file plan component properties
|
||||
FilePlanComponentProperties filePlanComponentProperties = filePlanComponent.getProperties();
|
||||
assertEquals(filePlanComponentProperties.getTitle(), categoryTitle);
|
||||
|
||||
assertNotNull(filePlanComponentProperties.getRmIdentifier());
|
||||
logger.info("Aspects: " + filePlanComponent.getAspectNames());
|
||||
}
|
||||
|
||||
@@ -316,6 +325,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
|
||||
// Verify properties
|
||||
// FIXME: Verify properties
|
||||
assertNotNull(createdComponent.getProperties().getRmIdentifier());
|
||||
}
|
||||
catch (NoSuchElementException e)
|
||||
{
|
||||
@@ -336,7 +346,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
||||
dataProvider = "childrenNotAllowedForCategory"
|
||||
|
||||
)
|
||||
@Bug (id="RM-4367")
|
||||
@Bug (id="RM-4367, RM-4572")
|
||||
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
||||
{
|
||||
String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
|
||||
|
@@ -74,12 +74,21 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
* Given that a record category exists
|
||||
* When I use the API to create a new record folder
|
||||
* Then it is created within the record category
|
||||
*
|
||||
* Given that a record category exists
|
||||
* When I use the API to create a folder (cm:folder type)
|
||||
* Then the folder is converted to rma:recordFolder within the record category
|
||||
* (see RM-4572 comments)
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
(
|
||||
description = "Create a folder into a record category"
|
||||
description = "Create a folder into a record category.",
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "folderTypes"
|
||||
)
|
||||
public void createFolderTest() throws Exception
|
||||
@Bug (id = "RM-4572")
|
||||
public void createFolderTest(String folderType) throws Exception
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
@@ -88,7 +97,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.nodeType(folderType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FOLDER_TITLE)
|
||||
.build())
|
||||
@@ -113,6 +122,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
// Verify the returned file plan component properties
|
||||
FilePlanComponentProperties folderProperties = folder.getProperties();
|
||||
assertEquals(folderProperties.getTitle(), FOLDER_TITLE);
|
||||
assertNotNull(folderProperties.getRmIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -60,9 +59,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class UpdateRecordsTests extends BaseRMRestTest
|
||||
{
|
||||
@Autowired
|
||||
private RMUserAPI rmUserAPI;
|
||||
|
||||
/* to be used to append to modifications */
|
||||
private final String MODIFIED_PREFIX = "modified_";
|
||||
|
||||
@@ -132,6 +128,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
|
||||
@AlfrescoTest(jira="RM-4362")
|
||||
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);
|
||||
@@ -139,7 +136,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
|
||||
|
||||
// RM Security Officer is the lowest role with Edit Record Metadata capabilities
|
||||
rmUserAPI.assignRoleToUser(updateUser.getUsername(), UserRoles.ROLE_RM_SECURITY_OFFICER);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// create random folder
|
||||
FilePlanComponent randomFolder = createCategoryFolderInFilePlan();
|
||||
@@ -150,7 +147,7 @@ public class UpdateRecordsTests extends BaseRMRestTest
|
||||
FilePlanComponentAPI filePlanComponentsAPIAsAdmin = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
rmUserAPI.addUserPermission(filePlanComponentsAPIAsAdmin.getFilePlanComponent(randomFolder.getParentId()),
|
||||
updateUser, UserPermissions.PERMISSION_FILING);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// create electronic and non-electronic records in a folder
|
||||
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||
@@ -236,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());
|
||||
|
@@ -39,6 +39,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentEntry;
|
||||
@@ -125,23 +126,23 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
assertEquals(matchingRecords.size(), 1, "More than one record matching document name");
|
||||
|
||||
// verify the original file in collaboration site has been renamed to reflect the record identifier
|
||||
// FIXME: this call uses the FilePlanComponentAPI due to no TAS support for Node API in TAS restapi v 5.2.0-0. See RM-4585 for details.
|
||||
List<FilePlanComponentEntry> filesAfterRename = filePlanComponentAPI.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
||||
List<RestNodeModel> filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder)
|
||||
.listChildren()
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(filesAfterRename.size(), 1, "There should be only one file in folder " + testFolder.getName());
|
||||
|
||||
// verify the new name has the form of "<original name> (<record Id>).<original extension>"
|
||||
assertEquals(filesAfterRename.get(0).getFilePlanComponentModel().getName(),
|
||||
document.getName().replace(".", String.format(" (%s).", record.getProperties().getRecordId())));
|
||||
String recordName = filesAfterRename.get(0).onModel().getName();
|
||||
assertEquals(recordName, document.getName().replace(".", String.format(" (%s).", record.getProperties().getRmIdentifier())));
|
||||
|
||||
// verify the document in collaboration site is now a record, note the file is now renamed hence folder + doc. name concatenation
|
||||
// this also verifies the document is still in the initial folder
|
||||
Document documentPostFiling = dataContent.usingSite(testSite)
|
||||
.usingUser(testUser)
|
||||
.getCMISDocument(testFolder.getCmisLocation() + "/" + filesAfterRename.get(0).getFilePlanComponentModel().getName());
|
||||
.getCMISDocument(testFolder.getCmisLocation() + "/" + recordName);
|
||||
|
||||
// a document is a record if "Record" is one of its secondary types
|
||||
List<SecondaryType> documentSecondary = documentPostFiling.getSecondaryTypes()
|
||||
@@ -185,12 +186,11 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
||||
assertStatusCode(FORBIDDEN);
|
||||
|
||||
// verify the document is still in the original folder
|
||||
// FIXME: this call uses the FilePlanComponentAPI due to no TAS support for Node API in TAS restapi v 5.2.0-0. See RM-4585 for details.
|
||||
List<FilePlanComponentEntry> filesAfterRename = getRestAPIFactory().getFilePlanComponentsAPI()
|
||||
.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
||||
List<RestNodeModel> filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder)
|
||||
.listChildren()
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(filesAfterRename.size(), 1, "Declare as record failed but original document is missing");
|
||||
}
|
||||
|
@@ -49,13 +49,12 @@ import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.base.TestData;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSite;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -67,9 +66,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class RMSiteTests extends BaseRMRestTest
|
||||
{
|
||||
@Autowired
|
||||
private RMUserAPI rmUserAPI;
|
||||
|
||||
/**
|
||||
* Given that RM module is installed
|
||||
* When I want to create the RM site with specific title, description and compliance
|
||||
@@ -208,7 +204,7 @@ public class RMSiteTests extends BaseRMRestTest
|
||||
}
|
||||
|
||||
// Create user
|
||||
rmUserAPI.createUser(ANOTHER_ADMIN);
|
||||
getRestAPIFactory().getRMUserAPI().createUser(ANOTHER_ADMIN, TestData.DEFAULT_PASSWORD, TestData.DEFAULT_EMAIL);
|
||||
|
||||
// Create the RM site
|
||||
RMSite rmSiteModel = getRestAPIFactory().getRMSiteAPI(new UserModel(ANOTHER_ADMIN, DEFAULT_PASSWORD)).createRMSite(createDOD5015RMSiteModel());
|
||||
|
@@ -28,7 +28,7 @@ rm.action.not-hold-type=Die Aktion kann nicht f\u00fcr {1} durchgef\u00fchrt wer
|
||||
rm.action.no-read-mime-message=Die Dateityp-Nachricht konnte nicht gelesen werden, da {0}.
|
||||
rm.action.email-declared=Die E-Mail konnte nicht geteilt werden, da der Record abgeschlossen ist. (actionedUponNodeRef={0})
|
||||
rm.action.email-not-record=Die E-Mail konnte nicht geteilt werden, da die Datei, der Ordner bzw. die Kategorie kein Record ist. (actionedUponNodeRef={0})
|
||||
rm.action.email-create-child-assoc=Benutzerdefinierte Kindzuordnung konnte nicht erstellt werden.
|
||||
rm.action.email-create-child-assoc=Benutzerdefinierte Unterordnung konnte nicht erstellt werden.
|
||||
rm.action.node-already-transfer=Datei, Ordner oder Kategorie wird bereits \u00fcbertragen.
|
||||
rm.action.node-not-transfer=Datei, Ordner oder Kategorie ist kein \u00dcbertragungsobjekt.
|
||||
rm.action.undo-not-last=Trennung kann nicht aufgehoben werden, da die letzte Aufbewahrungsaktion nicht getrennt wurde.
|
||||
|
@@ -28,7 +28,7 @@ rm.action.not-hold-type=Impossible d''effectuer l''action sur {1}, car ce n''est
|
||||
rm.action.no-read-mime-message=Le message filetype est illisible, car {0}.
|
||||
rm.action.email-declared=Impossible de partager l''e-mail, car le document d''archives n''est pas complet. (actionedUponNodeRef={0})
|
||||
rm.action.email-not-record=Impossible de partager l''e-mail, car le fichier, le dossier ou la cat\u00e9gorie n''est pas un document d''archives. (actionedUponNodeRef={0})
|
||||
rm.action.email-create-child-assoc=Impossible de cr\u00e9er une association d'enfant personnalis\u00e9e.
|
||||
rm.action.email-create-child-assoc=Impossible de cr\u00e9er une sous-association personnalis\u00e9e.
|
||||
rm.action.node-already-transfer=Le fichier, le dossier ou la cat\u00e9gorie est d\u00e9j\u00e0 en cours de transfert.
|
||||
rm.action.node-not-transfer=Le fichier, le dossier ou la cat\u00e9gorie n'est pas un objet de transfert.
|
||||
rm.action.undo-not-last=Impossible d'annuler le d\u00e9classement car la derni\u00e8re action de r\u00e9tention n'\u00e9tait pas un d\u00e9classement.
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=Der Record-Ordner konnte nicht geschlo
|
||||
rm.service.node-has-aspect=Record-Typ {1} wird bereits f\u00fcr Record {0} angezeigt.
|
||||
rm.service.final-version=Endg\u00fcltig
|
||||
rm.service.final-version-description=Die endg\u00fcltige archivierte Version des Records
|
||||
rm.service.enable-autoversion-on-record-creation=Automatische Versionsnummer bei Record-Erstellung
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=No se pudo cerrar la carpeta de docume
|
||||
rm.service.node-has-aspect=El tipo de documento de archivo ''{1}'' ya se est\u00e1 mostrando para el documento de archivo ''{0}''.
|
||||
rm.service.final-version=Final
|
||||
rm.service.final-version-description=La versi\u00f3n final del documento de archivo archivado
|
||||
rm.service.enable-autoversion-on-record-creation=Versi\u00f3n autom\u00e1tica al crear documento de archivo
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=Le dossier d''archives n''a pas pu \u0
|
||||
rm.service.node-has-aspect=Le type de document d''archives {1} est d\u00e9j\u00e0 affich\u00e9 pour le document d''archives {0}.
|
||||
rm.service.final-version=Finale
|
||||
rm.service.final-version-description=Version finale du document archiv\u00e9
|
||||
rm.service.enable-autoversion-on-record-creation=Version automatique lors de la cr\u00e9ation du document d'archives
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=Non \u00e8 stato possibile chiudere la
|
||||
rm.service.node-has-aspect=Il tipo di record {1} sta gi\u00e0 visualizzando per il record {0}.
|
||||
rm.service.final-version=Finale
|
||||
rm.service.final-version-description=Versione del record archiviata finale
|
||||
rm.service.enable-autoversion-on-record-creation=Versione automatica sulla creazione del record
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u
|
||||
rm.service.node-has-aspect=\u30ec\u30b3\u30fc\u30c9\u30bf\u30a4\u30d7 ''{1}'' \u306f\u3059\u3067\u306b\u30ec\u30b3\u30fc\u30c9 ''{0}'' \u306e\u3082\u306e\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002
|
||||
rm.service.final-version=\u6700\u7d42\u7248
|
||||
rm.service.final-version-description=\u30ec\u30b3\u30fc\u30c9\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u6e08\u307f\u6700\u7d42\u30d0\u30fc\u30b8\u30e7\u30f3
|
||||
rm.service.enable-autoversion-on-record-creation=\u30ec\u30b3\u30fc\u30c9\u306e\u4f5c\u6210\u6642\u306b\u81ea\u52d5\u30d0\u30fc\u30b8\u30e7\u30cb\u30f3\u30b0\u3092\u884c\u3046
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=Oppf\u00f8ringsmappen kan ikke lukkes
|
||||
rm.service.node-has-aspect=Oppf\u00f8ringstypen {1} vises allerede i oppf\u00f8ringen {0}.
|
||||
rm.service.final-version=Endelig
|
||||
rm.service.final-version-description=Den endelig arkiverte oppf\u00f8ringsversjonen
|
||||
rm.service.enable-autoversion-on-record-creation=Automatisk versjon om opprettelse av oppf\u00f8ringer
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=De archiefmap kan niet worden gesloten
|
||||
rm.service.node-has-aspect=Het recordtype {1} wordt al weergegeven voor record {0}.
|
||||
rm.service.final-version=Definitief
|
||||
rm.service.final-version-description=De definitieve gearchiveerde recordversie
|
||||
rm.service.enable-autoversion-on-record-creation=Automatische versie bij maken van record
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=N\u00e3o foi poss\u00edvel fechar a pa
|
||||
rm.service.node-has-aspect=O tipo de documento arquiv\u00edstico {1} j\u00e1 est\u00e1 sendo mostrado para o documento arquiv\u00edstico {0}.
|
||||
rm.service.final-version=Final
|
||||
rm.service.final-version-description=A vers\u00e3o do documento arquiv\u00edstico arquivado final
|
||||
rm.service.enable-autoversion-on-record-creation=Vers\u00e3o autom\u00e1tica na cria\u00e7\u00e3o de documento arquiv\u00edstico
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=\u041d\u0435\u0432\u043e\u0437\u043c\u
|
||||
rm.service.node-has-aspect=\u0417\u0430\u043f\u0438\u0441\u044c \u0442\u0438\u043f\u0430 {1} \u0443\u0436\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 {0}.
|
||||
rm.service.final-version=\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f
|
||||
rm.service.final-version-description=\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0430\u0440\u0445\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438
|
||||
rm.service.enable-autoversion-on-record-creation=\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0437\u0430\u043f\u0438\u0441\u0435\u0439
|
||||
|
@@ -19,3 +19,4 @@ rm.service.close-record-folder-not-folder=\u65e0\u6cd5\u5173\u95ed\u8bb0\u5f55\u
|
||||
rm.service.node-has-aspect=\u8bb0\u5f55\u7c7b\u578b {1} \u5df2\u4e3a\u8bb0\u5f55 {0} \u663e\u793a\u3002
|
||||
rm.service.final-version=\u6700\u7ec8
|
||||
rm.service.final-version-description=\u6700\u7ec8\u5b58\u6863\u7684\u8bb0\u5f55\u7248\u672c
|
||||
rm.service.enable-autoversion-on-record-creation=\u521b\u5efa\u8bb0\u5f55\u7684\u81ea\u52a8\u7248\u672c
|
||||
|
@@ -702,6 +702,13 @@
|
||||
<protected>true</protected>
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
<!-- This aspect can only be used by the system to allow the rma:identifier to be explicitly set in the upload transaction -->
|
||||
<property name="rma:idIsTemporarilyEditable">
|
||||
<title>Record Component Identifier Temporarily Editable Indicator</title>
|
||||
<type>d:boolean</type>
|
||||
<protected>true</protected>
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
</properties>
|
||||
<mandatory-aspects>
|
||||
<aspect>rma:filePlanComponent</aspect>
|
||||
|
@@ -78,6 +78,7 @@
|
||||
<bean id="recordsManagementPermissionPostProcessor" class="org.alfresco.module.org_alfresco_module_rm.permission.RecordsManagementPermissionPostProcessor" parent="parentPermissionPostProcessor">
|
||||
<property name="nodeService" ref="nodeService"/>
|
||||
<property name="permissionService" ref="permissionService"/>
|
||||
<property name="permissionModel" ref="permissionsModelDAO"/>
|
||||
</bean>
|
||||
|
||||
<!-- Import RM model -->
|
||||
|
@@ -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 -->
|
||||
|
||||
@@ -32,7 +43,8 @@
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<property name="authenticationUtil" ref="rm.authenticationUtil"/>
|
||||
<property name='transactionalResourceHelper' ref="rm.transactionalResourceHelper" />
|
||||
<property name="transactionalResourceHelper" ref="rm.transactionalResourceHelper" />
|
||||
<property name="renditionService" ref="RenditionService" />
|
||||
</bean>
|
||||
|
||||
<!-- Records Management Service Registry -->
|
||||
@@ -1060,8 +1072,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"/>
|
||||
|
@@ -128,6 +128,7 @@ rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockType=RM.Read.
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.checkForLock=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLocks=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.isLockedAndReadOnly=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.isLocked=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.*=RM_DENY
|
||||
|
||||
## Multilingual Content Service
|
||||
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -1,3 +0,0 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=2501
|
@@ -126,6 +126,7 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
QName ASPECT_RECORD_COMPONENT_ID = QName.createQName(RM_URI, "recordComponentIdentifier");
|
||||
QName PROP_IDENTIFIER = QName.createQName(RM_URI, "identifier");
|
||||
QName PROP_DB_UNIQUENESS_ID = QName.createQName(RM_URI, "dbUniquenessId");
|
||||
QName PROP_ID_IS_TEMPORARILY_EDITABLE = QName.createQName(RM_URI, "idIsTemporarilyEditable");
|
||||
|
||||
// Vital record definition aspect
|
||||
QName ASPECT_VITAL_RECORD_DEFINITION = QName.createQName(RM_URI, "vitalRecordDefinition");
|
||||
|
@@ -47,6 +47,7 @@ import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
@@ -64,6 +65,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
CopyServicePolicies.OnCopyCompletePolicy
|
||||
{
|
||||
/** I18N */
|
||||
@@ -127,7 +129,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
if (newIdValue != null)
|
||||
{
|
||||
String oldIdValue = (String)before.get(PROP_IDENTIFIER);
|
||||
if (oldIdValue != null && !oldIdValue.equals(newIdValue))
|
||||
if (oldIdValue != null && !oldIdValue.equals(newIdValue) && !isRecordIdentifierEditable(nodeRef))
|
||||
{
|
||||
throw new IntegrityException(I18NUtil.getMessage(MSG_SET_ID, nodeRef.toString()), null);
|
||||
}
|
||||
@@ -140,6 +142,17 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that checks if a record's identifier is temporarily editable
|
||||
* @param record the record to check
|
||||
* @return true if it is editable false otherwise
|
||||
*/
|
||||
private boolean isRecordIdentifierEditable(NodeRef record)
|
||||
{
|
||||
Boolean isEditableProperty = (Boolean)nodeService.getProperty(record, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE);
|
||||
return isEditableProperty == null ? false : isEditableProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the {@link RecordsManagementModel#PROP_IDENTIFIER rma:identifier} property unique triplet.
|
||||
*
|
||||
@@ -230,7 +243,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
// Do a blanket removal in case this is a contextual nodes
|
||||
attributeService.removeAttributes(CONTEXT_VALUE, nodeRef);
|
||||
}
|
||||
else
|
||||
else if(!beforeId.equals(afterId))
|
||||
{
|
||||
// This is a full update
|
||||
attributeService.updateOrCreateAttribute(
|
||||
@@ -238,4 +251,30 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
CONTEXT_VALUE, contextNodeRef, afterId);
|
||||
}
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
@Override
|
||||
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
/*
|
||||
* When creating a new record the identifier is writable to allow the upload in multiple steps.
|
||||
* On transaction commit make the identifier read only (remove the editable aspect).
|
||||
*/
|
||||
NodeRef newNode = childAssocRef.getChildRef();
|
||||
if(nodeService.exists(newNode))
|
||||
{
|
||||
nodeService.setProperty(newNode, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
@@ -213,6 +214,14 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
@Override
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
// We need to automatically cast the created folder to category if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes.
|
||||
// Some modules use hidden files to store information (see RM-3283)
|
||||
if (nodeService.getType(childAssocRef.getChildRef()).equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||
@@ -111,13 +112,22 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
NodeRef parentRef = childAssocRef.getParentRef();
|
||||
validateNewChildAssociation(parentRef, nodeRef, ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
QName childType = nodeService.getType(childAssocRef.getChildRef());
|
||||
|
||||
// We need to automatically cast the created folder to record folder if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes.
|
||||
// Some modules use hidden folders to store information (see RM-3283).
|
||||
if (childType.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
|
||||
if (bNew)
|
||||
{
|
||||
// setup the record folder
|
||||
recordFolderService.setupRecordFolder(nodeRef);
|
||||
recordFolderService.setupRecordFolder(childAssocRef.getChildRef());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +142,9 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
policy = "alf:onCreateChildAssociation",
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew)
|
||||
{
|
||||
final NodeRef recordCategory = childAssocRef.getChildRef();
|
||||
final NodeRef child = childAssocRef.getChildRef();
|
||||
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
@@ -145,7 +155,7 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
public Void doWork()
|
||||
{
|
||||
// setup vital record definition
|
||||
vitalRecordService.setupVitalRecordDefinition(recordCategory);
|
||||
vitalRecordService.setupVitalRecordDefinition(child);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
@@ -44,7 +43,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* rma:recordsManagementContainer behaviour bean.
|
||||
@@ -124,7 +122,8 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT,
|
||||
// Execute on first event to make all type conversions and set all the properties before transaction ends and response is returned
|
||||
notificationFrequency = NotificationFrequency.EVERY_EVENT,
|
||||
name = BEHAVIOUR_NAME
|
||||
)
|
||||
public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
@@ -152,32 +151,6 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to automatically cast the created folder to RM type if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
if (!nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT))
|
||||
{
|
||||
// Throw exception if the type is not cm:folder
|
||||
if (!ContentModel.TYPE_FOLDER.equals(childType))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_CAST_TO_RM_TYPE));
|
||||
}
|
||||
// check the type of the parent to determine what 'kind' of artifact to create
|
||||
NodeRef parent = childAssocRef.getParentRef();
|
||||
QName parentType = nodeService.getType(parent);
|
||||
|
||||
if (dictionaryService.isSubClass(parentType, TYPE_FILE_PLAN))
|
||||
{
|
||||
// create a rma:recordCategoty since we are in the root of the file plan
|
||||
nodeService.setType(child, TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
// create a rma:recordFolder and initialise record folder
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
recordFolderService.setupRecordFolder(child);
|
||||
}
|
||||
}
|
||||
|
||||
// Catch all to generate the rm id (assuming it doesn't already have one!)
|
||||
setIdenifierProperty(child);
|
||||
}
|
||||
@@ -223,8 +196,10 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) &&
|
||||
nodeService.getProperty(nodeRef, PROP_IDENTIFIER) == null)
|
||||
{
|
||||
// Generate identifier and leave it editable until the transaction ends
|
||||
String id = identifierService.generateIdentifier(nodeRef);
|
||||
nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER, id);
|
||||
nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.permissions.PermissionReference;
|
||||
import org.alfresco.repo.security.permissions.impl.model.PermissionModel;
|
||||
import org.alfresco.repo.security.permissions.processor.impl.PermissionPostProcessorBaseImpl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -53,25 +55,29 @@ public class RecordsManagementPermissionPostProcessor extends PermissionPostProc
|
||||
private PermissionService permissionService;
|
||||
public void setPermissionService(PermissionService permissionService) {this.permissionService=permissionService;}
|
||||
|
||||
/** The permission model DAO. */
|
||||
private PermissionModel permissionModel;
|
||||
public void setPermissionModel(PermissionModel permissionModel) {this.permissionModel=permissionModel;}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.security.permissions.processor.PermissionPostProcessor#process(org.alfresco.service.cmr.security.AccessStatus, org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm,
|
||||
List configuredReadPermissions, List configuredFilePermissions)
|
||||
List<String> configuredReadPermissions, List<String> configuredFilePermissions)
|
||||
{
|
||||
AccessStatus result = accessStatus;
|
||||
if (AccessStatus.DENIED.equals(accessStatus) &&
|
||||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
{
|
||||
// if read denied on rm artifact
|
||||
if (PermissionService.READ.equals(perm) || configuredReadPermissions.contains(perm))
|
||||
if (PermissionService.READ.equals(perm) || isPermissionContained(perm, configuredReadPermissions))
|
||||
{
|
||||
// check for read record
|
||||
result = permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS);
|
||||
}
|
||||
// if write deinied on rm artificat
|
||||
else if (PermissionService.WRITE.equals(perm) || configuredFilePermissions.contains(perm))
|
||||
// if write denied on rm artifact
|
||||
else if (PermissionService.WRITE.equals(perm) || isPermissionContained(perm, configuredFilePermissions))
|
||||
{
|
||||
// check for file record
|
||||
result = permissionService.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS);
|
||||
@@ -82,4 +88,34 @@ public class RecordsManagementPermissionPostProcessor extends PermissionPostProc
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given permission is implied by a list of permission groups.
|
||||
*
|
||||
* @param perm The name of the permission in question.
|
||||
* @param configuredPermissions The list of permission group names.
|
||||
* @return true if the permission is contained or implied by the list of permissions.
|
||||
*/
|
||||
private boolean isPermissionContained(String perm, List<String> configuredPermissions)
|
||||
{
|
||||
// Check if the permission is explicitly in the list
|
||||
if (configuredPermissions.contains(perm))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Check if the permission is implied by one from the list.
|
||||
for (String configuredPermission : configuredPermissions)
|
||||
{
|
||||
// TODO: Here we are assuming the permission name is unique across all contexts (but I think we're doing that in the properties file anyway).
|
||||
PermissionReference permissionReference = permissionModel.getPermissionReference(null, configuredPermission);
|
||||
for (PermissionReference granteePermission : permissionModel.getGranteePermissions(permissionReference))
|
||||
{
|
||||
if (granteePermission.getName().equals(perm))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -44,6 +44,7 @@ import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.security.authority.RMAuthority;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
@@ -520,7 +521,10 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
|
||||
String groupShortName = getIPRGroupShortName(groupNamePrefix, children, index);
|
||||
|
||||
// create group
|
||||
String group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM));
|
||||
String group;
|
||||
try
|
||||
{
|
||||
group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM));
|
||||
|
||||
// add root parent
|
||||
authorityService.addAuthority(getRootIRPGroup(), group);
|
||||
@@ -530,13 +534,18 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
for (String child : children)
|
||||
{
|
||||
if (authorityService.authorityExists(child) &&
|
||||
!PermissionService.ALL_AUTHORITIES.equals(child))
|
||||
if (authorityService.authorityExists(child) && !PermissionService.ALL_AUTHORITIES.equals(child))
|
||||
{
|
||||
authorityService.addAuthority(group, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(DuplicateChildNodeNameException ex)
|
||||
{
|
||||
// the group was concurrently created
|
||||
group = authorityService.getName(AuthorityType.GROUP, groupShortName);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
@@ -52,5 +52,5 @@ public interface PermissionPostProcessor
|
||||
* @return {@link AccessStatus}
|
||||
*/
|
||||
AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm,
|
||||
List configuredReadPermissions, List configuredFilePermissions);
|
||||
List<String> configuredReadPermissions, List<String> configuredFilePermissions);
|
||||
}
|
||||
|
@@ -64,6 +64,8 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
@@ -355,6 +357,36 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
return super.createNode(parentNodeRef.getId(), nodeInfo, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node upload(String parentFolderNodeId, FormData formData, Parameters parameters)
|
||||
{
|
||||
if (formData == null || !formData.getIsMultiPart())
|
||||
{
|
||||
throw new InvalidArgumentException("The request content-type is not multipart: "+parentFolderNodeId);
|
||||
}
|
||||
|
||||
for (FormData.FormField field : formData.getFields())
|
||||
{
|
||||
if(field.getName().equalsIgnoreCase("relativepath"))
|
||||
{
|
||||
// Create the path if it does not exist
|
||||
getOrCreatePath(parentFolderNodeId, getStringOrNull(field.getValue()), ContentModel.TYPE_CONTENT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return super.upload(parentFolderNodeId, formData, parameters);
|
||||
}
|
||||
|
||||
private String getStringOrNull(String value)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(value))
|
||||
{
|
||||
return value.equalsIgnoreCase("null") ? null : value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getOrCreatePath(String parentFolderNodeId, String relativePath, QName nodeTypeQName)
|
||||
{
|
||||
|
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* #%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 org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
/**
|
||||
* Unit test for RM-4619
|
||||
*
|
||||
* When creating regular folders through clients that are not RM aware
|
||||
* the folders must be converted to the appropriate RM container
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RM4619Test extends BaseRMTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Given the RM site is created
|
||||
* When we create a regular folder in the fileplan
|
||||
* Then the folder is immediately converted to a record category
|
||||
*/
|
||||
public void testConvertFolderToCategory() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception
|
||||
{
|
||||
FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(info.getType(), TYPE_RECORD_CATEGORY);
|
||||
return null;
|
||||
}
|
||||
|
||||
}, ADMIN_USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an existing category
|
||||
* When we create a regular folder in the category
|
||||
* Then the folder is immediately converted to a record folder
|
||||
*/
|
||||
public void testConvertFolderToRecordFolder() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception
|
||||
{
|
||||
FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(info.getType(), TYPE_RECORD_FOLDER);
|
||||
return null;
|
||||
}
|
||||
|
||||
}, ADMIN_USER);
|
||||
}
|
||||
}
|
@@ -218,10 +218,6 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
|
||||
|
||||
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
|
||||
// Set the record folder identifier
|
||||
String identifier = identifierService.generateIdentifier(TYPE_RECORD_FOLDER, recordCategory);
|
||||
nodeService.setProperty(recordFolder, PROP_IDENTIFIER, identifier);
|
||||
|
||||
// Complete event
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
@@ -27,11 +27,13 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
|
@@ -26,13 +26,11 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
@@ -52,33 +50,10 @@ public class RecordsManagementContainerTypeUnitTest extends BaseUnitTest
|
||||
/** test object */
|
||||
private @InjectMocks RecordsManagementContainerType recordManagementContainerType;
|
||||
|
||||
/**
|
||||
* Having the Unfilled Record container and a folder
|
||||
* When adding a child association between the folder and the container
|
||||
* Then the folder type shouldn't be renamed
|
||||
*/
|
||||
@Test
|
||||
public void testAddFolderToRMContainer()
|
||||
{
|
||||
/* Having a RM container and a folder */
|
||||
NodeRef rmContainer = generateRMContainer();
|
||||
NodeRef rmFolder = generateFolderNode(false);
|
||||
|
||||
/*
|
||||
* When adding a child association between the folder and the container
|
||||
*/
|
||||
ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rmContainer, ContentModel.ASSOC_CONTAINS, rmFolder);
|
||||
recordManagementContainerType.onCreateChildAssociation(childAssoc, true);
|
||||
|
||||
/* Then the node type should not be changed to TYPE_RECORD_FOLDER */
|
||||
verify(mockedNodeService).setType(rmFolder, TYPE_RECORD_FOLDER);
|
||||
verify(mockedRecordFolderService).setupRecordFolder(rmFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Having the Unfilled Record container and a folder having the aspect ASPECT_HIDDEN
|
||||
* When adding a child association between the folder and the container
|
||||
* Then the folder type shouldn't be renamed
|
||||
* Then the new folder should not be altered
|
||||
*/
|
||||
@Test
|
||||
public void testAddHiddenFolderToRMContainer()
|
||||
@@ -93,31 +68,9 @@ public class RecordsManagementContainerTypeUnitTest extends BaseUnitTest
|
||||
ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rmContainer, ContentModel.ASSOC_CONTAINS, rmFolder);
|
||||
recordManagementContainerType.onCreateChildAssociation(childAssoc, true);
|
||||
|
||||
/* Then the node type should not be changed to TYPE_RECORD_FOLDER */
|
||||
verify(mockedNodeService, never()).setType(rmFolder, TYPE_RECORD_FOLDER);
|
||||
verify(mockedRecordFolderService, never()).setupRecordFolder(rmFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trying to create a RM folder and its sub-types via SFDC, IMap, WebDav, etc
|
||||
* Check that exception is thrown on creating child associations
|
||||
*/
|
||||
@Test
|
||||
public void testRM3450()
|
||||
{
|
||||
NodeRef rmContainer = generateRMContainer();
|
||||
NodeRef nonRmFolder = generateNonRmFolderNode();
|
||||
|
||||
ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, rmContainer, TestModel.NOT_RM_FOLDER_TYPE, nonRmFolder);
|
||||
try
|
||||
{
|
||||
recordManagementContainerType.onCreateChildAssociation(childAssoc, true);
|
||||
fail("Expected to throw exception on create child association.");
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
assertTrue(e instanceof AlfrescoRuntimeException);
|
||||
}
|
||||
/* The type should not be changed and no aspects should be added */
|
||||
verify(mockedNodeService, never()).setType(any(), any());
|
||||
verify(mockedNodeService, never()).addAspect(any(), any(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,8 +28,8 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.permission;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
@@ -37,6 +37,8 @@ import java.util.List;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
import org.alfresco.repo.security.permissions.PermissionReference;
|
||||
import org.alfresco.repo.security.permissions.impl.model.PermissionModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
@@ -47,20 +49,26 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RecordsManagementPermissionPostProcessor}.
|
||||
*
|
||||
* @author David Webster
|
||||
* @author Tom Page
|
||||
* @since 2.4.1
|
||||
*/
|
||||
public class RecordsManagementPermissionPostProcessorUnitTest
|
||||
{
|
||||
@InjectMocks
|
||||
private RecordsManagementPermissionPostProcessor recordsManagementPermissionPostProcessor = new RecordsManagementPermissionPostProcessor();
|
||||
|
||||
private @InjectMocks
|
||||
RecordsManagementPermissionPostProcessor recordsManagementPermissionPostProcessor = new RecordsManagementPermissionPostProcessor();
|
||||
|
||||
private @Mock NodeService nodeService;
|
||||
private @Mock PermissionService permissionService;
|
||||
@Mock
|
||||
private NodeService mockNodeService;
|
||||
@Mock
|
||||
private PermissionService mockPermissionService;
|
||||
@Mock
|
||||
private PermissionModel mockPermissionModel;
|
||||
|
||||
@Before
|
||||
public void setup()
|
||||
@@ -83,9 +91,9 @@ public class RecordsManagementPermissionPostProcessorUnitTest
|
||||
List<String> configuredReadPermissions = asList("ReadProperties", "ReadChildren", perm);
|
||||
List<String> configuredFilePermissions = asList("WriteProperties", "AddChildren");
|
||||
|
||||
when(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
when(mockNodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
.thenReturn(true);
|
||||
when(permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
|
||||
when(mockPermissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
|
||||
.thenReturn(AccessStatus.ALLOWED);
|
||||
|
||||
AccessStatus result = recordsManagementPermissionPostProcessor.process(accessStatus, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
|
||||
@@ -108,13 +116,51 @@ public class RecordsManagementPermissionPostProcessorUnitTest
|
||||
List<String> configuredReadPermissions = asList("ReadProperties", "ReadChildren");
|
||||
List<String> configuredFilePermissions = asList("WriteProperties", "AddChildren");
|
||||
|
||||
when(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
when(mockNodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
.thenReturn(true);
|
||||
when(permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
|
||||
when(mockPermissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
|
||||
.thenReturn(AccessStatus.ALLOWED);
|
||||
|
||||
AccessStatus result = recordsManagementPermissionPostProcessor.process(accessStatus, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
|
||||
|
||||
assertEquals(AccessStatus.DENIED, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the permission groups configured in the global properties file imply descendant permission groups.
|
||||
* <p>
|
||||
* Given a configured permission is an ancestor of another permission P
|
||||
* And the post processor checks if the user has P
|
||||
* Then the post processor says that they do.
|
||||
*/
|
||||
@Test
|
||||
public void permissionInherittedFromConfiguredGroup()
|
||||
{
|
||||
NodeRef nodeRef = new NodeRef("node://ref/");
|
||||
// permissions do not include perm created above
|
||||
List<String> configuredReadPermissions = asList();
|
||||
List<String> configuredFilePermissions = asList("WriteProperties");
|
||||
|
||||
when(mockNodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
.thenReturn(true);
|
||||
when(mockPermissionService.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS))
|
||||
.thenReturn(AccessStatus.ALLOWED);
|
||||
|
||||
// Set up "WriteProperties" to imply three other permission groups.
|
||||
PermissionReference mockWritePropsPermRef = mock(PermissionReference.class);
|
||||
when(mockPermissionModel.getPermissionReference(null, "WriteProperties")).thenReturn(mockWritePropsPermRef);
|
||||
PermissionReference childOne = mock(PermissionReference.class);
|
||||
when(childOne.getName()).thenReturn("Not this one");
|
||||
PermissionReference childTwo = mock(PermissionReference.class);
|
||||
when(childTwo.getName()).thenReturn("This is the requested permission");
|
||||
PermissionReference childThree = mock(PermissionReference.class);
|
||||
when(childThree.getName()).thenReturn("Not this one either");
|
||||
when(mockPermissionModel.getGranteePermissions(mockWritePropsPermRef)).thenReturn(Sets.newHashSet(childOne, childTwo, childThree));
|
||||
|
||||
// Call the method under test.
|
||||
AccessStatus result = recordsManagementPermissionPostProcessor.process(AccessStatus.DENIED, nodeRef,
|
||||
"This is the requested permission", configuredReadPermissions, configuredFilePermissions);
|
||||
|
||||
assertEquals(AccessStatus.ALLOWED, result);
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ paths:
|
||||
operationId: getFileplanComponent
|
||||
parameters:
|
||||
- $ref: '#/parameters/fileplanComponentIdWithAliasParam'
|
||||
- $ref: '#/parameters/IGNodeEntryIncludeParam'
|
||||
- $ref: '#/parameters/FilePlanComponentEntryIncludeParam'
|
||||
- $ref: '#/parameters/relativePathParam'
|
||||
- $ref: '#/parameters/fieldsParam'
|
||||
produces:
|
||||
@@ -45,7 +45,7 @@ paths:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeEntry'
|
||||
$ref: '#/definitions/FilePlanComponentEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **fileplanComponentId** is not a valid format
|
||||
@@ -86,21 +86,21 @@ paths:
|
||||
operationId: updateFileplanComponent
|
||||
parameters:
|
||||
- $ref: '#/parameters/fileplanComponentIdWithAliasParam'
|
||||
- $ref: '#/parameters/IGNodeEntryIncludeParam'
|
||||
- $ref: '#/parameters/FilePlanComponentEntryIncludeParam'
|
||||
- $ref: '#/parameters/fieldsParam'
|
||||
- in: body
|
||||
name: nodeBodyUpdate
|
||||
description: The node information to update.
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeBodyUpdate'
|
||||
$ref: '#/definitions/FilePlanComponentBodyUpdate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeEntry'
|
||||
$ref: '#/definitions/FilePlanComponentEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: the update request is invalid or **fileplanComponentId** is not a valid format or **nodeBody** is invalid
|
||||
@@ -175,7 +175,7 @@ paths:
|
||||
- $ref: '#/parameters/maxItemsParam'
|
||||
- $ref: '#/parameters/orderByParam'
|
||||
- $ref: '#/parameters/whereParam'
|
||||
- $ref: '#/parameters/IGNodeEntryIncludeParam'
|
||||
- $ref: '#/parameters/FilePlanComponentEntryIncludeParam'
|
||||
- $ref: '#/parameters/relativePathParam'
|
||||
- $ref: '#/parameters/includeSourceParam'
|
||||
- $ref: '#/parameters/fieldsParam'
|
||||
@@ -183,7 +183,7 @@ paths:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeAssociationPaging'
|
||||
$ref: '#/definitions/FilePlanComponentAssociationPaging'
|
||||
'401':
|
||||
description: If authentication fails
|
||||
'403':
|
||||
@@ -289,7 +289,7 @@ paths:
|
||||
}
|
||||
```
|
||||
|
||||
You can create an empty electronic record and use the record endpoint to create content:
|
||||
You can create an empty electronic record:
|
||||
```JSON
|
||||
{
|
||||
"name":"My Electronic Record",
|
||||
@@ -375,7 +375,7 @@ paths:
|
||||
description: If true, then a name clash will cause an attempt to auto rename by finding a unique name using an integer suffix.
|
||||
required: false
|
||||
type: boolean
|
||||
- $ref: '#/parameters/IGNodeEntryIncludeParam'
|
||||
- $ref: '#/parameters/FilePlanComponentEntryIncludeParam'
|
||||
- $ref: '#/parameters/fieldsParam'
|
||||
- in: body
|
||||
name: nodeBodyCreate
|
||||
@@ -395,7 +395,7 @@ paths:
|
||||
'201':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeEntry'
|
||||
$ref: '#/definitions/FilePlanComponentEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **fileplanComponentId** is not a valid format or **nodeBodyCreate** is invalid
|
||||
@@ -617,7 +617,7 @@ paths:
|
||||
operationId: fileRecord
|
||||
parameters:
|
||||
- $ref: '#/parameters/recordIdParam'
|
||||
- $ref: '#/parameters/IGNodeEntryIncludeParam'
|
||||
- $ref: '#/parameters/FilePlanComponentEntryIncludeParam'
|
||||
- $ref: '#/parameters/fieldsParam'
|
||||
- in: body
|
||||
name: nodeBodyFile
|
||||
@@ -633,7 +633,7 @@ paths:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeEntry'
|
||||
$ref: '#/definitions/FilePlanComponentEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **recordIdParam** or **targetParentId** is not a valid format,
|
||||
@@ -670,7 +670,7 @@ paths:
|
||||
description: Flag to indicate whether the record should be hidden from the current parent folder.
|
||||
type: boolean
|
||||
default: false
|
||||
- $ref: '#/parameters/IGNodeEntryIncludeParam'
|
||||
- $ref: '#/parameters/FilePlanComponentEntryIncludeParam'
|
||||
- $ref: '#/parameters/fieldsParam'
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -680,7 +680,7 @@ paths:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/IGNodeEntry'
|
||||
$ref: '#/definitions/FilePlanComponentEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **fileId** is not a valid format
|
||||
@@ -742,7 +742,7 @@ parameters:
|
||||
information is returned on the node resolved by this path.
|
||||
required: false
|
||||
type: string
|
||||
IGNodeEntryIncludeParam:
|
||||
FilePlanComponentEntryIncludeParam:
|
||||
name: include
|
||||
in: query
|
||||
description: |
|
||||
@@ -854,14 +854,14 @@ parameters:
|
||||
type: string
|
||||
format: date-time
|
||||
definitions:
|
||||
IGNodeEntry:
|
||||
FilePlanComponentEntry:
|
||||
type: object
|
||||
required:
|
||||
- entry
|
||||
properties:
|
||||
entry:
|
||||
$ref: '#/definitions/IGNode'
|
||||
IGNode:
|
||||
$ref: '#/definitions/FilePlanComponent'
|
||||
FilePlanComponent:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
@@ -932,7 +932,7 @@ definitions:
|
||||
type: string
|
||||
path:
|
||||
$ref: '#/definitions/PathInfo'
|
||||
IGNodeAssociationPaging:
|
||||
FilePlanComponentAssociationPaging:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
@@ -943,24 +943,24 @@ definitions:
|
||||
entries:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/IGNodeChildAssociationEntry'
|
||||
$ref: '#/definitions/FilePlanComponentChildAssociationEntry'
|
||||
source:
|
||||
$ref: '#/definitions/IGNode'
|
||||
IGNodeChildAssociationEntry:
|
||||
$ref: '#/definitions/FilePlanComponent'
|
||||
FilePlanComponentChildAssociationEntry:
|
||||
type: object
|
||||
required:
|
||||
- entry
|
||||
properties:
|
||||
entry:
|
||||
$ref: '#/definitions/IGNodeChildAssociation'
|
||||
IGNodeChildAssociation:
|
||||
$ref: '#/definitions/FilePlanComponentChildAssociation'
|
||||
FilePlanComponentChildAssociation:
|
||||
allOf:
|
||||
- $ref: '#/definitions/IGNode'
|
||||
- $ref: '#/definitions/FilePlanComponent'
|
||||
- type: object
|
||||
properties:
|
||||
association:
|
||||
$ref: '#/definitions/ChildAssociationInfo'
|
||||
IGNodeBodyUpdate:
|
||||
FilePlanComponentBodyUpdate:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
|
Reference in New Issue
Block a user