mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4488 (Refactor REST API Automation test code according to the latest changes)
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class ExtendedRestProperties extends RestProperties
|
||||
{
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class ExtendedRestWrapper extends RestWrapper
|
||||
{
|
||||
@Autowired
|
||||
private ExtendedRestProperties extendedRestProperties;
|
||||
|
||||
public RestIGCoreAPI withIGCoreAPI()
|
||||
{
|
||||
return new RestIGCoreAPI(this, extendedRestProperties);
|
||||
}
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* #%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.core;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@Configuration
|
||||
@PropertySource(value = {"classpath:default.properties", "classpath:config.properties"})
|
||||
@PropertySource(value = "classpath:module.properties", ignoreResourceNotFound = true)
|
||||
@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true)
|
||||
public class RMRestProperties extends RestProperties
|
||||
{
|
||||
@Value ("${alfresco.scheme}")
|
||||
private String scheme;
|
||||
|
||||
@Value ("${alfresco.server}")
|
||||
private String server;
|
||||
|
||||
@Value ("${alfresco.port}")
|
||||
private String port;
|
||||
|
||||
@Value ("${rest.rmPath}")
|
||||
private String restRmPath;
|
||||
|
||||
/**
|
||||
* @return the scheme
|
||||
*/
|
||||
public String getScheme()
|
||||
{
|
||||
return this.scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the server
|
||||
*/
|
||||
public String getServer()
|
||||
{
|
||||
return this.server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public String getPort()
|
||||
{
|
||||
return this.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the restRmPath
|
||||
*/
|
||||
public String getRestRmPath()
|
||||
{
|
||||
return this.restRmPath;
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* #%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.core;
|
||||
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RMRestWrapper extends RestWrapper
|
||||
{
|
||||
@Autowired
|
||||
private RMRestProperties rmRestProperties;
|
||||
|
||||
public RestIGCoreAPI withIGCoreAPI()
|
||||
{
|
||||
return new RestIGCoreAPI(this, rmRestProperties);
|
||||
}
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* #%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 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
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponent
|
||||
{
|
||||
@JsonProperty (required = true)
|
||||
private String id;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String parentId;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String nodeType;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Boolean isCategory;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Boolean isRecordFolder;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Boolean isFile;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean hasRetentionSchedule;
|
||||
|
||||
@JsonProperty(value = IS_CLOSED)
|
||||
private Boolean isClosed;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean isCompleted;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private List<String> aspectNames;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo createdByUser;
|
||||
|
||||
@JsonProperty(value = PROPERTIES, required = true)
|
||||
private FilePlanComponentProperties properties;
|
||||
|
||||
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
||||
private List<String> allowableOperations;
|
||||
|
||||
@JsonProperty (required = false)
|
||||
private FilePlanComponentContent content;
|
||||
|
||||
@JsonProperty (value = PATH)
|
||||
private FilePlanComponentPath path;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String modifiedAt;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String createdAt;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo modifiedByUser;
|
||||
|
||||
@JsonProperty (value = RELATIVE_PATH)
|
||||
private String relativePath;
|
||||
|
||||
}
|
@@ -26,58 +26,16 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
|
||||
/**
|
||||
* File plan component alias enumeration
|
||||
* File plan component alias
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public enum FilePlanComponentAlias
|
||||
public class FilePlanComponentAlias
|
||||
{
|
||||
FILE_PLAN_ALIAS("-filePlan-"),
|
||||
TRANSFERS_ALIAS("-transfers-"),
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS("-unfiled-"),
|
||||
HOLDS_ALIAS("-holds-");
|
||||
|
||||
private String alias;
|
||||
|
||||
private FilePlanComponentAlias(String alias)
|
||||
{
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public static final FilePlanComponentAlias getFilePlanComponentAlias(String alias)
|
||||
{
|
||||
mandatoryString("alias", alias);
|
||||
|
||||
FilePlanComponentAlias result = null;
|
||||
FilePlanComponentAlias[] values = values();
|
||||
|
||||
for (FilePlanComponentAlias filePlanComponentAlias : values)
|
||||
{
|
||||
if (filePlanComponentAlias.toString().equals(alias))
|
||||
{
|
||||
result = filePlanComponentAlias;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid file plan component alias enum value: '" + alias + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Enum#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.alias;
|
||||
}
|
||||
public static final String FILE_PLAN_ALIAS = "-filePlan-";
|
||||
public static final String TRANSFERS_ALIAS = "-transfers-";
|
||||
public static final String UNFILED_RECORDS_CONTAINER_ALIAS = "-unfiled-";
|
||||
public static final String HOLDS_ALIAS = "-holds-";
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* POJO for FilePlanComponent content field
|
||||
*
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
@@ -46,5 +47,4 @@ public class FilePlanComponentContent
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Integer sizeInBytes;
|
||||
|
||||
}
|
||||
|
@@ -30,11 +30,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* POJO for file plan component entry
|
||||
@@ -44,11 +46,11 @@ import org.alfresco.rest.core.RestModels;
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponentEntry extends RestModels<FilePlanComponent, FilePlanComponentEntry>
|
||||
public class FilePlanComponentEntry extends RestModels<FilePlanComponentModel, FilePlanComponentEntry>
|
||||
{
|
||||
@JsonProperty(ENTRY)
|
||||
FilePlanComponent filePlanComponent;
|
||||
|
||||
FilePlanComponentModel filePlanComponentModel;
|
||||
}
|
||||
|
@@ -45,5 +45,4 @@ public class FilePlanComponentIdNamePair
|
||||
{
|
||||
public String id;
|
||||
public String name;
|
||||
|
||||
}
|
||||
|
@@ -28,7 +28,9 @@ 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;
|
||||
|
||||
@@ -36,6 +38,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* POJO for file plan component
|
||||
*
|
||||
@@ -43,6 +51,11 @@ import org.alfresco.utility.model.TestModel;
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponentModel extends TestModel
|
||||
{
|
||||
@JsonProperty (required = true)
|
||||
@@ -87,6 +100,10 @@ public class FilePlanComponentModel extends TestModel
|
||||
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
||||
private List<String> allowableOperations;
|
||||
|
||||
@JsonProperty (required = false)
|
||||
private FilePlanComponentContent content;
|
||||
|
||||
@JsonProperty (value = PATH)
|
||||
private FilePlanComponentPath path;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
@@ -98,324 +115,6 @@ public class FilePlanComponentModel extends TestModel
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo modifiedByUser;
|
||||
|
||||
|
||||
/**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 FilePlanComponentModel(String name, String nodeType, FilePlanComponentProperties properties)
|
||||
{
|
||||
this.name = name;
|
||||
this.nodeType = nodeType;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor to create empty file plan component
|
||||
*/
|
||||
public FilePlanComponentModel() { }
|
||||
|
||||
/**
|
||||
* Helper constructor for creating the file plan component using
|
||||
*
|
||||
* @param name File Plan Component name
|
||||
*/
|
||||
public FilePlanComponentModel(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 FilePlanComponentModel(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;
|
||||
}
|
||||
@JsonProperty (value = RELATIVE_PATH)
|
||||
private String relativePath;
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* POJO for FilePlanComponent path parameter
|
||||
* <br>
|
||||
*
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
@@ -51,5 +51,4 @@ public class FilePlanComponentPath
|
||||
private String name;
|
||||
private Boolean isComplete;
|
||||
private List<FilePlanComponentIdNamePair> elements;
|
||||
|
||||
}
|
||||
|
@@ -67,7 +67,6 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponentProperties
|
||||
{
|
||||
|
||||
@JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR)
|
||||
private Boolean vitalRecord;
|
||||
|
||||
@@ -92,21 +91,19 @@ public class FilePlanComponentProperties
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -26,66 +26,24 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
|
||||
/**
|
||||
* File plan component type enumeration
|
||||
* File plan component type
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public enum FilePlanComponentType
|
||||
public class FilePlanComponentType
|
||||
{
|
||||
FILE_PLAN_TYPE("rma:filePlan"),
|
||||
RECORD_CATEGORY_TYPE("rma:recordCategory"),
|
||||
RECORD_FOLDER_TYPE("rma:recordFolder"),
|
||||
HOLD_TYPE("rma:hold"),
|
||||
UNFILED_RECORD_FOLDER_TYPE("rma:unfiledRecordFolder"),
|
||||
HOLD_CONTAINER_TYPE("rma:holdContainer"),
|
||||
TRANSFER_TYPE("rma:transfer"),
|
||||
TRANSFER_CONTAINER_TYPE("rma:transferContainer"),
|
||||
UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"),
|
||||
FOLDER_TYPE("cm:folder"),
|
||||
CONTENT_TYPE("cm:content"),
|
||||
NON_ELECTRONIC_RECORD_TYPE("rma:nonElectronicDocument");
|
||||
|
||||
private String type;
|
||||
|
||||
private FilePlanComponentType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static final FilePlanComponentType getFilePlanComponentType(String type)
|
||||
{
|
||||
mandatoryString("type", type);
|
||||
|
||||
FilePlanComponentType result = null;
|
||||
FilePlanComponentType[] values = values();
|
||||
|
||||
for (FilePlanComponentType filePlanComponentType : values)
|
||||
{
|
||||
if (filePlanComponentType.toString().equals(filePlanComponentType))
|
||||
{
|
||||
result = filePlanComponentType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid file plan component type enum value: '" + type + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Enum#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
public static final String FILE_PLAN_TYPE = "rma:filePlan";
|
||||
public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
|
||||
public static final String RECORD_FOLDER_TYPE = "rma:recordFolder";
|
||||
public static final String HOLD_TYPE = "rma:hold";
|
||||
public static final String UNFILED_RECORD_FOLDER_TYPE = "rma:unfiledRecordFolder";
|
||||
public static final String HOLD_CONTAINER_TYPE = "rma:holdContainer";
|
||||
public static final String TRANSFER_TYPE = "rma:transfer";
|
||||
public static final String TRANSFER_CONTAINER_TYPE = "rma:transferContainer";
|
||||
public static final String UNFILED_CONTAINER_TYPE = "rma:unfiledRecordContainer";
|
||||
public static final String FOLDER_TYPE = "cm:folder";
|
||||
public static final String CONTENT_TYPE = "cm:content";
|
||||
public static final String NON_ELECTRONIC_RECORD_TYPE = "rma:nonElectronicDocument";
|
||||
}
|
||||
|
@@ -45,5 +45,4 @@ public class FilePlanComponentUserInfo
|
||||
{
|
||||
private String id;
|
||||
private String displayName;
|
||||
|
||||
}
|
||||
|
@@ -30,11 +30,13 @@ import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
|
||||
/**
|
||||
* POJO for RM Site component
|
||||
@@ -44,11 +46,11 @@ import org.alfresco.rest.model.RestSiteModel;
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RMSite extends RestSiteModel
|
||||
public class RMSiteModel extends RestSiteModel
|
||||
{
|
||||
@JsonProperty (value = COMPLIANCE,required = true)
|
||||
@JsonProperty (value = COMPLIANCE, required = true)
|
||||
private RMSiteCompliance compliance;
|
||||
|
||||
}
|
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
* #%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.basic;
|
||||
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.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 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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* File plan component REST API Wrapper
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
@Component
|
||||
@Scope(value = "prototype")
|
||||
public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
||||
{
|
||||
/**
|
||||
* Get a file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component to get
|
||||
* @return The {@link FilePlanComponent} for the given file plan component id
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent getFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId, getParameters()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* List child components of a file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component of which to get child components
|
||||
* @return The {@link FilePlanComponent} for the given file plan component id
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponentsCollection listChildComponents(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return usingRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
filePlanComponentId
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file plan component with the given properties under the parent node with the given id
|
||||
*
|
||||
* @param filePlanComponentModel The properties of the file plan component to be created
|
||||
* @param parentId The id of the parent where the new file plan component should be created
|
||||
* @return The {@link FilePlanComponent} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to add children to {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>new name clashes with an existing node in the current parent container</li>
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
|
||||
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");
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
Response response = given()
|
||||
.spec(builder.build())
|
||||
.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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a file plan component
|
||||
*
|
||||
* @param filePlanComponent The properties to be updated
|
||||
* @param filePlanComponentId The id of the file plan component which will be updated
|
||||
* @param returns The updated {@link FilePlanComponent}
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>the update request is invalid or {@code fileplanComponentId} is not a valid format or {@code filePlanComponentProperties} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to update {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>the updated name clashes with an existing node in the current parent folder</li>
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponent);
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(filePlanComponent),
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId,
|
||||
getParameters()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component to be deleted
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to delete {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>{@code fileplanComponentId} is locked and cannot be deleted</li>
|
||||
* </ul>
|
||||
*/
|
||||
public void deleteFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
usingRestWrapper().processEmptyModel(simpleRequest(
|
||||
DELETE,
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@@ -4,28 +4,58 @@
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
* 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.basic;
|
||||
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.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||
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.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 org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.requests.ModelRequest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
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;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
@@ -33,24 +63,21 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlanComponents extends ModelRequest
|
||||
public class FilePlanComponents extends RMModelRequest
|
||||
{
|
||||
private FilePlanComponentModel filePlanComponentModel;
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
public FilePlanComponents(FilePlanComponentModel filePlanComponentModel, RestWrapper restWrapper)
|
||||
public FilePlanComponents(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(restWrapper);
|
||||
this.filePlanComponentModel = filePlanComponentModel;
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component to get
|
||||
* @return The {@link FilePlanComponent} for the given file plan component id
|
||||
* @return The {@link FilePlanComponentModel} for the given file plan component id
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
@@ -58,21 +85,30 @@ public class FilePlanComponents extends ModelRequest
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent getFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
public FilePlanComponentModel getFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
/*
|
||||
return restWrapper.processModel(FilePlanComponent.class, simpleRequest(
|
||||
return getFilePlanComponent(filePlanComponentId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param filePlanComponentId FIXME!!!
|
||||
* @param parameters FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel getFilePlanComponent(String filePlanComponentId, String parameters) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return getRMRestWrapper().processModel(FilePlanComponentModel.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId, getParameters()
|
||||
*/
|
||||
// FIXME!!!
|
||||
return restWrapper.processModel(FilePlanComponent.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
filePlanComponentId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
@@ -92,7 +128,7 @@ public class FilePlanComponents extends ModelRequest
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return restWrapper.processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||
return getRMRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
filePlanComponentId
|
||||
@@ -104,7 +140,7 @@ public class FilePlanComponents extends ModelRequest
|
||||
*
|
||||
* @param filePlanComponentModel The properties of the file plan component to be created
|
||||
* @param parentId The id of the parent where the new file plan component should be created
|
||||
* @return The {@link FilePlanComponent} with the given properties
|
||||
* @return The {@link FilePlanComponentModel} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
@@ -115,23 +151,107 @@ public class FilePlanComponents extends ModelRequest
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception
|
||||
public FilePlanComponentModel createFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
return restWrapper.processModel(FilePlanComponent.class, requestWithBody(
|
||||
return createFilePlanComponent(filePlanComponentModel, parentId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param filePlanComponentModel FIXME!!!
|
||||
* @param parentId FIXME!!!
|
||||
* @param parameters FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel createFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String parentId, String parameters) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
return getRMRestWrapper().processModel(FilePlanComponentModel.class, requestWithBody(
|
||||
POST,
|
||||
toJson(filePlanComponentModel),
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
parentId
|
||||
));
|
||||
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
||||
parentId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 FilePlanComponentModel createElectronicRecord(FilePlanComponentModel 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 FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, File recordContent, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", electronicRecordModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
if (!electronicRecordModel.getNodeType().equals(CONTENT_TYPE))
|
||||
{
|
||||
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));
|
||||
|
||||
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", FilePlanComponentModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a file plan component
|
||||
*
|
||||
* @param filePlanComponent The properties to be updated
|
||||
* @param filePlanComponentModel The properties to be updated
|
||||
* @param filePlanComponentId The id of the file plan component which will be updated
|
||||
* @param returns The updated {@link FilePlanComponent}
|
||||
* @throws Exception for the following cases:
|
||||
@@ -144,17 +264,26 @@ public class FilePlanComponents extends ModelRequest
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId) throws Exception
|
||||
public FilePlanComponentModel updateFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return updateFilePlanComponent(filePlanComponentModel, filePlanComponentId, EMPTY);
|
||||
}
|
||||
|
||||
public FilePlanComponentModel updateFilePlanComponent(FilePlanComponentModel filePlanComponent, String filePlanComponentId, String parameters) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponent);
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return restWrapper.processModel(FilePlanComponent.class, requestWithBody(
|
||||
return getRMRestWrapper().processModel(FilePlanComponentModel.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(filePlanComponent),
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
));
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +303,7 @@ public class FilePlanComponents extends ModelRequest
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
restWrapper.processEmptyModel(simpleRequest(
|
||||
getRMRestWrapper().processEmptyModel(simpleRequest(
|
||||
DELETE,
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* #%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 org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.requests.ModelRequest;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class RMModelRequest extends ModelRequest
|
||||
{
|
||||
private RMRestWrapper rmRestWrapper;
|
||||
|
||||
/**
|
||||
* @return the rmRestWrapper
|
||||
*/
|
||||
protected RMRestWrapper getRMRestWrapper()
|
||||
{
|
||||
return this.rmRestWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
public RMModelRequest(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
}
|
@@ -36,31 +36,35 @@ import static org.springframework.http.HttpMethod.POST;
|
||||
import static org.springframework.http.HttpMethod.PUT;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSite;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* File plan component REST API Wrapper
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Component
|
||||
@Scope (value = "prototype")
|
||||
public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
public class RMSite extends RMModelRequest
|
||||
{
|
||||
// FIXME!!!
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
public RMSite(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RM site
|
||||
*
|
||||
* @return The {@link RMSite} for the given file plan component id
|
||||
* @return The {@link RMSiteModel} for the given file plan component id
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM site</li>
|
||||
@@ -69,9 +73,9 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* <li>Api Response code default Unexpected error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RMSite getSite() throws Exception
|
||||
public RMSiteModel getSite() throws Exception
|
||||
{
|
||||
return usingRestWrapper().processModel(RMSite.class, simpleRequest(
|
||||
return getRMRestWrapper().processModel(RMSiteModel.class, simpleRequest(
|
||||
GET,
|
||||
"ig-sites/rm"
|
||||
));
|
||||
@@ -81,7 +85,7 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* Create the RM site
|
||||
*
|
||||
* @param rmSite The properties of the rm site to be created
|
||||
* @return The {@link RMSite} with the given properties
|
||||
* @return The {@link RMSiteModel} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>Api Response code 400 Invalid parameter: title, or description exceed the maximum length; or siteBodyCreate invalid</li>
|
||||
@@ -90,13 +94,13 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* <li>Api Response code default Unexpected error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RMSite createRMSite(RMSite rmSite) throws Exception
|
||||
public RMSiteModel createRMSite(RMSiteModel rmSiteModel) throws Exception
|
||||
{
|
||||
mandatoryObject("rmSiteProperties", rmSite);
|
||||
mandatoryObject("rmSiteModel", rmSiteModel);
|
||||
|
||||
return usingRestWrapper().processModel(RMSite.class, requestWithBody(
|
||||
return getRMRestWrapper().processModel(RMSiteModel.class, requestWithBody(
|
||||
POST,
|
||||
toJson(rmSite),
|
||||
toJson(rmSiteModel),
|
||||
"ig-sites"
|
||||
));
|
||||
}
|
||||
@@ -114,7 +118,7 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
*/
|
||||
public void deleteRMSite() throws Exception
|
||||
{
|
||||
usingRestWrapper().processEmptyModel(simpleRequest(
|
||||
getRMRestWrapper().processEmptyModel(simpleRequest(
|
||||
DELETE,
|
||||
"ig-sites/rm"
|
||||
));
|
||||
@@ -124,23 +128,23 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* Update RM site
|
||||
*
|
||||
* @param rmSiteProperties The properties to be updated
|
||||
* @return The updated {@link RMSite}
|
||||
* @return The updated {@link RMSiteModel}
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>Api Response code 400 the update request is invalid {@code rmSiteProperties} is invalid</li>
|
||||
* <li>Api Response code 400 the update request is invalid {@code rmSiteModel} is invalid</li>
|
||||
* <li>Api Response code 401 If authentication fails</li>
|
||||
* <li>Api Response code 403 does not have permission to update {@code RMSite}</li>
|
||||
* <li>Api Response code 404 {@code RMSite} does not exist</li>
|
||||
* <li>Api Response code 404 {@code RMSiteModel} does not exist</li>
|
||||
* <li>Api Response code default Unexpected error,model integrity exception</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RMSite updateRMSite(RMSite rmSiteProperties) throws Exception
|
||||
public RMSiteModel updateRMSite(RMSiteModel rmSiteModel) throws Exception
|
||||
{
|
||||
mandatoryObject("rmSiteProperties", rmSiteProperties);
|
||||
mandatoryObject("rmSiteProperties", rmSiteModel);
|
||||
|
||||
return usingRestWrapper().processModel(RMSite.class, requestWithBody(
|
||||
return getRMRestWrapper().processModel(RMSiteModel.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(rmSiteProperties),
|
||||
toJson(rmSiteModel),
|
||||
"ig-sites/rm"
|
||||
));
|
||||
}
|
||||
@@ -159,8 +163,8 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
*/
|
||||
public boolean existsRMSite() throws Exception
|
||||
{
|
||||
usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
getRMRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
getSite();
|
||||
return usingRestWrapper().getStatusCode().equals(OK.toString());
|
||||
return getRMRestWrapper().getStatusCode().equals(OK.toString());
|
||||
}
|
||||
}
|
@@ -42,12 +42,12 @@ 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
|
||||
// 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")
|
||||
@@ -55,21 +55,21 @@ 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()
|
||||
|
@@ -4,42 +4,83 @@
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
* 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.igCoreAPI;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
|
||||
import org.alfresco.rest.core.ExtendedRestProperties;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.requests.ModelRequest;
|
||||
import org.alfresco.rest.core.RMRestProperties;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponents;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.rest.rm.community.requests.RMSite;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
* Defines the entire IG Core API
|
||||
* {@link http://host:port/ig-api-explorer} select "IG Core API"
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RestIGCoreAPI extends ModelRequest
|
||||
public class RestIGCoreAPI extends RMModelRequest
|
||||
{
|
||||
private ExtendedRestProperties extendedRestProperties;
|
||||
@SuppressWarnings("unused")
|
||||
private RMRestProperties rmRestProperties;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param restWrapper FIXME!!!
|
||||
* @param restProperties FIXME!!!
|
||||
* @param rmRestWrapper FIXME!!!
|
||||
* @param rmRestProperties FIXME!!!
|
||||
*/
|
||||
public RestIGCoreAPI(RestWrapper restWrapper, ExtendedRestProperties extendedRestProperties)
|
||||
public RestIGCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties)
|
||||
{
|
||||
super(restWrapper);
|
||||
this.extendedRestProperties = extendedRestProperties;
|
||||
// FIXME
|
||||
RestAssured.baseURI = extendedRestProperties.envProperty().getTestServerUrl();
|
||||
RestAssured.port = extendedRestProperties.envProperty().getPort();
|
||||
RestAssured.basePath = extendedRestProperties.getRestWorkflowPath();
|
||||
super(rmRestWrapper);
|
||||
this.rmRestProperties = rmRestProperties;
|
||||
RestAssured.baseURI = format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer());
|
||||
RestAssured.port = parseInt(rmRestProperties.getPort());
|
||||
RestAssured.basePath = rmRestProperties.getRestRmPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides DSL on all REST calls under <code>ig-sites/rm/...</code> API path
|
||||
*
|
||||
* @return {@link RMSite}
|
||||
*/
|
||||
public RMSite usingRMSite()
|
||||
{
|
||||
return new RMSite(getRMRestWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public FilePlanComponents usingFilePlanComponents()
|
||||
{
|
||||
return new FilePlanComponents(getRMRestWrapper());
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,6 @@ public class PojoUtility
|
||||
{
|
||||
//return the json object
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||
|
||||
}
|
||||
catch (JsonGenerationException e)
|
||||
{
|
||||
|
@@ -35,7 +35,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
|
||||
|
||||
|
||||
/**
|
||||
* Utility class for serializing the Review Period type
|
||||
*
|
||||
@@ -44,7 +43,6 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
|
||||
*/
|
||||
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
|
||||
{
|
||||
|
||||
/**
|
||||
* @param value The Review Period value that is being serialized.
|
||||
* @param gen Jackson utility is responsible for writing JSON
|
||||
@@ -57,8 +55,5 @@ public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
|
||||
{
|
||||
//create the custom string value for the Review Period type
|
||||
gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -0,0 +1,2 @@
|
||||
alfresco.server=localhost
|
||||
rest.rmPath=alfresco/api/-default-/public/ig/versions/1
|
Reference in New Issue
Block a user