Merge branch 'master' into feature/RM-4488_Refactor_RM_Automation

This commit is contained in:
Tuna Aksoy
2016-12-22 18:51:08 +00:00
49 changed files with 1757 additions and 1155 deletions

View File

@@ -28,12 +28,19 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.RELATIVE_PATH;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for file plan component
*
@@ -41,6 +48,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* @author Rodica Sutu
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponent
{
@JsonProperty (required = true)
@@ -84,10 +95,11 @@ public class FilePlanComponent
@JsonProperty (value = ALLOWABLE_OPERATIONS)
private List<String> allowableOperations;
@JsonProperty (required = false)
private FilePlanComponentContent content;
@JsonProperty (value = PATH)
private FilePlanComponentPath path;
@JsonProperty (required = true)
@@ -99,324 +111,7 @@ public class FilePlanComponent
@JsonProperty (required = true)
private FilePlanComponentUserInfo modifiedByUser;
@JsonProperty (value = RELATIVE_PATH)
private String relativePath;
/**Helper constructor for creating the file plan component using
*
* @param name File Plan Component name
* @param nodeType File Plan Component node type
* @param properties File Plan Component properties
*/
public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties)
{
this.name = name;
this.nodeType = nodeType;
this.properties = properties;
}
/**
* Helper constructor to create empty file plan component
*/
public FilePlanComponent() { }
/**
* Helper constructor for creating the file plan component using
*
* @param name File Plan Component name
*/
public FilePlanComponent(String name)
{
this.name = name;
}
/**
* Helper constructor for creating the file plan component using
*
* @param name File Plan Component name
* @param properties File Plan Component properties
*/
public FilePlanComponent(String name, FilePlanComponentProperties properties)
{
this.name = name;
this.properties = properties;
}
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the parentId
*/
public String getParentId()
{
return this.parentId;
}
/**
* @param parentId the parentId to set
*/
public void setParentId(String parentId)
{
this.parentId = parentId;
}
/**
* @return the name
*/
public String getName()
{
return this.name;
}
/**
* @param name the name to set
*/
public void setName(String name)
{
this.name = name;
}
/**
* @return the nodeType
*/
public String getNodeType()
{
return this.nodeType;
}
/**
* @param nodeType the nodeType to set
*/
public void setNodeType(String nodeType)
{
this.nodeType = nodeType;
}
/**
* @return the isCategory
*/
public Boolean isCategory()
{
return this.isCategory;
}
/**
* @param isCategory the isCategory to set
*/
public void setCategory(Boolean isCategory)
{
this.isCategory = isCategory;
}
/**
* @return the isRecordFolder
*/
public Boolean isRecordFolder()
{
return this.isRecordFolder;
}
/**
* @param isRecordFolder the isRecordFolder to set
*/
public void setRecordFolder(Boolean isRecordFolder)
{
this.isRecordFolder = isRecordFolder;
}
/**
* @return the isFile
*/
public Boolean isFile()
{
return this.isFile;
}
/**
* @param isFile the isFile to set
*/
public void setFile(Boolean isFile)
{
this.isFile = isFile;
}
/**
* @return the hasRetentionSchedule
*/
public Boolean hasRetentionSchedule()
{
return this.hasRetentionSchedule;
}
/**
* @param hasRetentionSchedule the hasRetentionSchedule to set
*/
public void setHasRetentionSchedule(Boolean hasRetentionSchedule)
{
this.hasRetentionSchedule = hasRetentionSchedule;
}
/**
* @return the properties
*/
public FilePlanComponentProperties getProperties()
{
return properties;
}
/**
* @param properties the properties to set
*/
public void setProperties(FilePlanComponentProperties properties)
{
this.properties = properties;
}
/**
* @return the aspectNames
*/
public List<String> getAspectNames()
{
return this.aspectNames;
}
/**
* @param aspectNames the aspectNames to set
*/
public void setAspectNames(List<String> aspectNames)
{
this.aspectNames = aspectNames;
}
/**
* @return the createdByUser
*/
public FilePlanComponentUserInfo getCreatedByUser()
{
return this.createdByUser;
}
/**
* @param createdByUser the createdByUser to set
*/
public void setCreatedByUser(FilePlanComponentUserInfo createdByUser)
{
this.createdByUser = createdByUser;
}
/**
* @return the allowableOperations
*/
public List<String> getAllowableOperations()
{
return this.allowableOperations;
}
/**
* @return the path
*/
public FilePlanComponentPath getPath()
{
return this.path;
}
/**
* @param path the path to set
*/
public void setPath(FilePlanComponentPath path)
{
this.path = path;
}
/**
* @param modifiedAt the modifiedAt to set
*/
public void setModifiedAt(String modifiedAt)
{
this.modifiedAt = modifiedAt;
}
/**
* @param createdAt the createdAt to set
*/
public void setCreatedAt(String createdAt)
{
this.createdAt = createdAt;
}
/**
* @param modifiedByUser the modifiedByUser to set
*/
public void setModifiedByUser(FilePlanComponentUserInfo modifiedByUser)
{
this.modifiedByUser = modifiedByUser;
}
/**
* @return the modifiedAt
*/
public String getModifiedAt()
{
return this.modifiedAt;
}
/**
* @return the createdAt
*/
public String getCreatedAt()
{
return this.createdAt;
}
/**
* @return the modifiedByUser
*/
public FilePlanComponentUserInfo getModifiedByUser()
{
return this.modifiedByUser;
}
/**
* @return the isClosed
*/
public Boolean isClosed()
{
return this.isClosed;
}
/**
* @param closed the isClosed to set
*/
public void setClosed(Boolean closed)
{
this.isClosed = closed;
}
/**
* @return the isCompleted
*/
public Boolean isCompleted()
{
return this.isCompleted;
}
/**
* @param completed the isCompleted to set
*/
public void setCompleted(Boolean completed)
{
this.isCompleted = completed;
}
}

View File

@@ -37,77 +37,14 @@ 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;
}
}

View File

@@ -30,6 +30,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.alfresco.rest.core.RestModels;
/**
@@ -38,13 +42,13 @@ import org.alfresco.rest.core.RestModels;
* @author Tuna Aksoy
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponentEntry extends RestModels<FilePlanComponent, FilePlanComponentEntry>
{
@JsonProperty(ENTRY)
FilePlanComponent filePlanComponent;
public FilePlanComponent getFilePlanComponent()
{
return filePlanComponent;
}
}

View File

@@ -49,7 +49,7 @@ public class FilePlanComponentFields
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";
@@ -57,5 +57,8 @@ public class FilePlanComponentFields
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";
//RelativePath specifies the container structure to create relative to the node nodeId.
public static final String RELATIVE_PATH = "relativePath";
public static final String PATH = "path";
}

View File

@@ -26,46 +26,24 @@
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for id/name pair
*
* @author Kristijan Conkas
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponentIdNamePair
{
public String id;
public String name;
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the name
*/
public String getName()
{
return this.name;
}
/**
* @param name the name to set
*/
public void setName(String name)
{
this.name = name;
}
}

View File

@@ -30,12 +30,21 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for FilePlanComponent path parameter
* <br>
* @author Kristijan Conkas
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class FilePlanComponentPath
{
@@ -43,51 +52,4 @@ public class FilePlanComponentPath
private Boolean isComplete;
private List<FilePlanComponentIdNamePair> elements;
/**
* @return the name
*/
public String getName()
{
return this.name;
}
/**
* @param name the name to set
*/
public void setName(String name)
{
this.name = name;
}
/**
* @return the isComplete
*/
public Boolean isComplete()
{
return this.isComplete;
}
/**
* @param isComplete the isComplete to set
*/
public void setComplete(Boolean isComplete)
{
this.isComplete = isComplete;
}
/**
* @return the elements
*/
public List<FilePlanComponentIdNamePair> getElements()
{
return this.elements;
}
/**
* @param elements the elements to set
*/
public void setElements(List<FilePlanComponentIdNamePair> elements)
{
this.elements = elements;
}
}

View File

@@ -48,6 +48,11 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for file plan component properties
*
@@ -56,6 +61,10 @@ import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
*/
//FIXME: Once the fields have been added the JsonIgnoreProperties annotation should be removed
@JsonIgnoreProperties (ignoreUnknown = true)
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponentProperties
{
@@ -80,7 +89,7 @@ public class FilePlanComponentProperties
@JsonProperty(PROPERTIES_LOCATION)
private String location;
@JsonProperty(value = PROPERTIES_IS_CLOSED, required = false)
private Boolean isClosed;
@@ -100,227 +109,4 @@ public class FilePlanComponentProperties
private Integer physicalSize;
public FilePlanComponentProperties(String title, String description)
{
this.title = title;
this.description = description;
}
public FilePlanComponentProperties(String title)
{
this.title = title;
}
public FilePlanComponentProperties()
{
}
/**
* @return the vitalRecord
*/
public Boolean isVitalRecord()
{
return this.vitalRecord;
}
/**
* @param vitalRecord the vitalRecord to set
*/
public void setVitalRecord(Boolean vitalRecord)
{
this.vitalRecord = vitalRecord;
}
/**
* @return the title
*/
public String getTitle()
{
return this.title;
}
/**
* @param title the title to set
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* @return the holdReason
*/
public String getHoldReason()
{
return this.holdReason;
}
/**
* @param holdReason the holdReason to set
*/
public void setHoldReason(String holdReason)
{
this.holdReason = holdReason;
}
/**
* @param description the description to set
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* @return the description
*/
public String getDescription()
{
return this.description;
}
/**
* @return the supplementalMarkingList
*/
public List<String> getSupplementalMarkingList()
{
return this.supplementalMarkingList;
}
/**
* @param supplementalMarkingList the supplementalMarkingList to set
*/
public void setSupplementalMarkingList(List<String> supplementalMarkingList)
{
this.supplementalMarkingList = supplementalMarkingList;
}
/**
* @return the reviewPeriod
*/
public ReviewPeriod getReviewPeriod()
{
return reviewPeriod;
}
/**
* @param reviewPeriod the reviewPeriod to set
*/
public void setReviewPeriod(ReviewPeriod reviewPeriod)
{
this.reviewPeriod = reviewPeriod;
}
/**
* @return the location
*/
public String getLocation()
{
return location;
}
/**
* @param location the location to set
*/
public void setLocation(String location)
{
this.location = location;
}
/**
* @return the box
*/
public String getBox()
{
return this.box;
}
/**
* @param box the box to set
*/
public void setBox(String box)
{
this.box = box;
}
/**
* @return the file
*/
public String getFile()
{
return this.file;
}
/**
* @param file the file to set
*/
public void setFile(String file)
{
this.file = file;
}
/**
* @return the shelf
*/
public String getShelf()
{
return this.shelf;
}
/**
* @param shelf the shelf to set
*/
public void setShelf(String shelf)
{
this.shelf = shelf;
}
/**
* @return the numberOfCopies
*/
public Integer getNumberOfCopies()
{
return this.numberOfCopies;
}
/**
* @param numberOfCopies the numberOfCopies to set
*/
public void setNumberOfCopies(Integer numberOfCopies)
{
this.numberOfCopies = numberOfCopies;
}
/**
* @return the physicalSize
*/
public Integer getPhysicalSize()
{
return this.physicalSize;
}
/**
* @param physicalSize the physicalSize to set
*/
public void setPhysicalSize(Integer physicalSize)
{
this.physicalSize = physicalSize;
}
/**
* @return the isClosed
*/
public Boolean getIsClosed()
{
return this.isClosed;
}
/**
* @param isClosed the isClosed to set
*/
public void setIsClosed(Boolean isClosed)
{
this.isClosed = isClosed;
}
}

View File

@@ -26,46 +26,24 @@
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for file plan component created by object
*
* @author Kristijan Conkas
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponentUserInfo
{
private String id;
private String displayName;
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the displayName
*/
public String getDisplayName()
{
return this.displayName;
}
/**
* @param displayName the displayName to set
*/
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
}

View File

@@ -26,66 +26,23 @@
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for the review period
*
* @author Rodica Sutu
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReviewPeriod
{
private String periodType;
private String expression;
/**
* Helper constructor with
*
* @param periodType
* @param expression
*/
public ReviewPeriod(String periodType, String expression)
{
this.periodType = periodType;
this.expression = expression;
}
/**
* Helper constructor
*/
public ReviewPeriod()
{
}
/**
* @return the periodType
*/
public String getPeriodType()
{
return this.periodType;
}
/**
* @param periodType the periodType to set
*/
public void setPeriodType(String periodType)
{
this.periodType = periodType;
}
/**
* @return the expression
*/
public String getExpression()
{
return this.expression;
}
/**
* @param expression the expression to set
*/
public void setExpression(String expression)
{
this.expression = expression;
}
}

View File

@@ -30,6 +30,10 @@ import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestSiteModel;
/**
@@ -38,59 +42,13 @@ import org.alfresco.rest.model.RestSiteModel;
* @author Rodica Sutu
* @since 2.6
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RMSite extends RestSiteModel
{
@JsonProperty (value = COMPLIANCE,required = true)
private RMSiteCompliance compliance;
/**
* Helper constructor to create RM Site object using
*
* @param title
* @param description
* @param compliance
*/
public RMSite(String title, String description, RMSiteCompliance compliance)
{
this.title=title;
this.description=description;
this.compliance=compliance;
}
/**
* Helper constructor for creating the RM Site
*/
public RMSite() { }
/**
* Helper constructor to create RM Site object using
*
* @param compliance RM Site Compliance
*/
public RMSite(RMSiteCompliance compliance)
{
super();
this.compliance = compliance;
}
/**
* Helper method to set RM site compliance
*
* @param compliance {@link RMSiteCompliance} the compliance to set
*/
public void setCompliance(RMSiteCompliance compliance)
{
this.compliance = compliance;
}
/**
* Helper method to get RM site compliance
*
* @return compliance the RM Site compliance to get
*/
public RMSiteCompliance getCompliance()
{
return compliance;
}
}

View File

@@ -0,0 +1,40 @@
/*
* #%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.user;
/**
* Constants for RM user capabilities
*
* @author Kristijan Conkas
* @since 2.6
*/
public class UserPermissions
{
public static final String PERMISSION_FILING = "Filing";
public static final String PERMISSION_READ_RECORDS = "ReadRecords";
public static final String PERMISSION_FILE_RECORDS = "FileRecords";
}

View File

@@ -0,0 +1,42 @@
/*
* #%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.user;
/**
* Constants for RM user roles
*
* @author Kristijan Conkas
* @since 2.6
*/
public class UserRoles
{
public static final String ROLE_RM_ADMIN = "Administrator";
public static final String ROLE_RM_MANAGER = "RecordsManager";
public static final String ROLE_RM_POWER_USER = "PowerUser";
public static final String ROLE_RM_SECURITY_OFFICER = "SecurityOfficer";
public static final String ROLE_RM_USER = "User";
}

View File

@@ -26,6 +26,7 @@
*/
package org.alfresco.rest.rm.community.requests;
import static com.jayway.restassured.RestAssured.basic;
import static com.jayway.restassured.RestAssured.given;
import static org.alfresco.rest.core.RestRequest.requestWithBody;
@@ -40,8 +41,12 @@ import static org.springframework.http.HttpMethod.PUT;
import static org.testng.Assert.fail;
import java.io.File;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
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;
@@ -168,16 +173,41 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
{
fail("Only electronic records are supported");
}
UserModel currentUser = usingRestWrapper().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));
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())
{
String f = fieldNames.next();
try
{
builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name());
}
catch (Exception error)
{
LOG.error("Failed to set " + f + " error: " + error);
}
}
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.
*/
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())
.spec(builder.build())
.when()
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters())
.andReturn();

View File

@@ -0,0 +1,86 @@
/*
* #%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.requests;
import static com.jayway.restassured.RestAssured.given;
import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.response.Response;
import com.jayway.restassured.specification.RequestSpecification;
import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.rest.core.RestAPI;
import org.alfresco.utility.data.DataUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* RM user management API
*
* @author Kristijan Conkas
* @since 2.6
*/
// FIXME: As of December 2016 there is no v1-style API for managing RM users and users'
// roles. Until such APIs have become available, methods in this class are just proxies to
// "old-style" API calls.
@Component
@Scope (value = "prototype")
public class RMUserAPI extends RestAPI<RMUserAPI>
{
@Autowired
private DataUser dataUser;
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
public void assignRoleToUser(String userName, String userRole) throws Exception
{
// get an "old-style" REST API client
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
// override v1 baseURI and basePath
RequestSpecification spec = new RequestSpecBuilder()
.setBaseUri(client.getApiUrl())
.setBasePath("/")
.build();
Response response = given()
.spec(spec)
.log().all()
.pathParam("role", userRole)
.pathParam("authority", userName)
.param("alf_ticket", client.getAlfTicket(
dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword()))
.when()
.post("/rm/roles/{role}/authorities/{authority}")
.prettyPeek()
.andReturn();
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
}
}