mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'master' of https://gitlab.alfresco.com/records-management/records-management into feature/RM-4396_Lombok_UseModelInsteadJsonObject
# Conflicts: # rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java # rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java
This commit is contained in:
@@ -94,6 +94,9 @@ public class FilePlanComponent
|
||||
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
||||
private List<String> allowableOperations;
|
||||
|
||||
@JsonProperty (required = false)
|
||||
private FilePlanComponentContent content;
|
||||
|
||||
private FilePlanComponentPath path;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
@@ -104,4 +107,5 @@ public class FilePlanComponent
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo modifiedByUser;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.model.fileplancomponents;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* POJO for FilePlanComponent content field
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlanComponentContent
|
||||
{
|
||||
@JsonProperty (required = true)
|
||||
private String encoding;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String mimeType;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String mimeTypeName;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Integer sizeInBytes;
|
||||
|
||||
/**
|
||||
* @return the encoding
|
||||
*/
|
||||
public String getEncoding()
|
||||
{
|
||||
return this.encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param encoding the encoding to set
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mimeType
|
||||
*/
|
||||
public String getMimeType()
|
||||
{
|
||||
return this.mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimeType the mimeType to set
|
||||
*/
|
||||
public void setMimeType(String mimeType)
|
||||
{
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mimeTypeName
|
||||
*/
|
||||
public String getMimeTypeName()
|
||||
{
|
||||
return this.mimeTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimeTypeName the mimeTypeName to set
|
||||
*/
|
||||
public void setMimeTypeName(String mimeTypeName)
|
||||
{
|
||||
this.mimeTypeName = mimeTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sizeInBytes
|
||||
*/
|
||||
public Integer getSizeInBytes()
|
||||
{
|
||||
return this.sizeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sizeInBytes the sizeInBytes to set
|
||||
*/
|
||||
public void setSizeInBytes(Integer sizeInBytes)
|
||||
{
|
||||
this.sizeInBytes = sizeInBytes;
|
||||
}
|
||||
}
|
@@ -45,7 +45,17 @@ public class FilePlanComponentFields
|
||||
public static final String PROPERTIES_DESCRIPTION = "cm:description";
|
||||
public static final String PROPERTIES_SUPPLEMENTAL_MARKING_LIST = "rmc:supplementalMarkingList";
|
||||
public static final String ALLOWABLE_OPERATIONS = "allowableOperations";
|
||||
public static final String IS_CLOSED="isClosed";
|
||||
public static final String PROPERTIES_REVIEW_PERIOD="rma:reviewPeriod";
|
||||
public static final String PROPERTIES_LOCATION="rma:location";
|
||||
public static final String IS_CLOSED = "isClosed";
|
||||
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
|
||||
public static final String PROPERTIES_LOCATION = "rma:location";
|
||||
public static final String PROPERTIES_IS_CLOSED = "rma:isClosed"; // not to be confused with IS_CLOSED!
|
||||
|
||||
// for non-electronic records
|
||||
public static final String PROPERTIES_BOX = "rma:box";
|
||||
public static final String PROPERTIES_FILE = "rma:file";
|
||||
public static final String PROPERTIES_NUMBER_OF_COPIES = "rma:numberOfCopies";
|
||||
public static final String PROPERTIES_PHYSICAL_SIZE = "rma:physicalSize";
|
||||
public static final String PROPERTIES_SHELF = "rma:shelf";
|
||||
public static final String PROPERTIES_STORAGE_LOCATION = "rma:storageLocation";
|
||||
|
||||
}
|
||||
|
@@ -26,10 +26,16 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_BOX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_FILE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_HOLD_REASON;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IS_CLOSED;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_NUMBER_OF_COPIES;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PHYSICAL_SIZE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SHELF;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SUPPLEMENTAL_MARKING_LIST;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
|
||||
@@ -83,4 +89,25 @@ public class FilePlanComponentProperties
|
||||
|
||||
@JsonProperty(PROPERTIES_LOCATION)
|
||||
private String location;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_IS_CLOSED, required = false)
|
||||
private Boolean isClosed;
|
||||
|
||||
@JsonProperty(value = PROPERTIES_BOX, required = false)
|
||||
private String box;
|
||||
|
||||
@JsonProperty(value = PROPERTIES_FILE, required = false)
|
||||
private String file;
|
||||
|
||||
@JsonProperty(value = PROPERTIES_SHELF, required = false)
|
||||
private String shelf;
|
||||
|
||||
@JsonProperty(value = PROPERTIES_NUMBER_OF_COPIES, required = false)
|
||||
private Integer numberOfCopies;
|
||||
|
||||
@JsonProperty(value = PROPERTIES_PHYSICAL_SIZE, required = false)
|
||||
private Integer physicalSize;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -46,7 +46,8 @@ public enum FilePlanComponentType
|
||||
TRANSFER_CONTAINER_TYPE("rma:transferContainer"),
|
||||
UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"),
|
||||
FOLDER_TYPE("cm:folder"),
|
||||
CONTENT_TYPE("cm:content");
|
||||
CONTENT_TYPE("cm:content"),
|
||||
NON_ELECTRONIC_RECORD_TYPE("rma:nonElectronicDocument");
|
||||
|
||||
private String type;
|
||||
|
||||
|
@@ -26,6 +26,8 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.requests;
|
||||
|
||||
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;
|
||||
@@ -35,10 +37,19 @@ import static org.springframework.http.HttpMethod.DELETE;
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
import static org.springframework.http.HttpMethod.POST;
|
||||
import static org.springframework.http.HttpMethod.PUT;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.response.Response;
|
||||
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -119,13 +130,62 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
|
||||
POST,
|
||||
toJson(filePlanComponentModel),
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
parentId
|
||||
));
|
||||
POST,
|
||||
toJson(filePlanComponentModel),
|
||||
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
||||
parentId,
|
||||
getParameters()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param fileName the name of the resource file
|
||||
* @param parentId parent container id
|
||||
* @return newly created {@link FilePlanComponent}
|
||||
* @throws Exception if operation failed
|
||||
*/
|
||||
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, String fileName, String parentId) throws Exception
|
||||
{
|
||||
return createElectronicRecord(electronicRecordModel, new File(Resources.getResource(fileName).getFile()), parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", electronicRecordModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
if (!electronicRecordModel.getNodeType().equals(FilePlanComponentType.CONTENT_TYPE.toString()))
|
||||
{
|
||||
fail("Only electronic records are supported");
|
||||
}
|
||||
|
||||
/*
|
||||
* RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests.
|
||||
* Upload the file using RestAssured library.
|
||||
*/
|
||||
UserModel currentUser = usingRestWrapper().getTestUser();
|
||||
Response response = given()
|
||||
.auth().basic(currentUser.getUsername(), currentUser.getPassword())
|
||||
.multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name())
|
||||
.multiPart("filedata", recordContent, ContentType.BINARY.name())
|
||||
.when()
|
||||
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters())
|
||||
.andReturn();
|
||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
LOG.info("electronic record created: " + response.getBody().prettyPrint());
|
||||
|
||||
/* return a FilePlanComponent object representing Response */
|
||||
return response.jsonPath().getObject("entry", FilePlanComponent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,8 +212,9 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(filePlanComponent),
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId,
|
||||
getParameters()
|
||||
));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user