getWriters(NodeRef nodeRef);
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java
index 5920b071e7..7af2408b09 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java
@@ -184,7 +184,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
}
/**
- * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getReaders(org.alfresco.service.cmr.repository.NodeRef)
+ * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#getReaders(org.alfresco.service.cmr.repository.NodeRef)
*/
@SuppressWarnings("unchecked")
@Override
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java
index 010c76db62..8e798f30d4 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionService.java
@@ -42,7 +42,7 @@ public interface FilePlanPermissionService
/**
* Setup permissions for a record category
*
- * @param nodeRef record category node reference
+ * @param recordCategory record category node reference
*/
void setupRecordCategoryPermissions(NodeRef recordCategory);
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java
index 5a51c73585..fd28505b70 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java
@@ -28,8 +28,7 @@
package org.alfresco.module.org_alfresco_module_rm.security;
import static java.util.Collections.singletonMap;
-import static org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority.EXTENDED_READER;
-import static org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority.EXTENDED_WRITER;
+
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT;
import static org.alfresco.repo.policy.annotation.BehaviourKind.CLASS;
import static org.alfresco.repo.security.authentication.AuthenticationUtil.getSystemUserName;
@@ -589,7 +588,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
}
/**
- * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#setPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, boolean)
+ * @see org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService#setPermission(NodeRef, String, String)
*/
@Override
public void setPermission(final NodeRef nodeRef, final String authority, final String permission)
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java
index 4723c1b52d..4d1ba62780 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/AuthenticationUtil.java
@@ -45,7 +45,7 @@ public class AuthenticationUtil
*
* Useful when testing using mocks.
*
- * @see org.alfresco.repo.security.authentication.AuthenticationUtil#runAsSystem(RunAsWork, String)
+ * @see org.alfresco.repo.security.authentication.AuthenticationUtil#runAsSystem(RunAsWork)
*/
public R runAsSystem(RunAsWork runAsWork)
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java
index f1f53750b4..79695c3428 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionNodeServiceImpl.java
@@ -101,7 +101,7 @@ public class RecordableVersionNodeServiceImpl extends Node2ServiceImpl
* Process properties map before returning as frozen state.
*
* @param properties properties map
- * @return {@link Map}<{@link QName}, {@link Serializable}> processed property map
+ * @return {@link Map}<{@link QName}, {@link Serializable}> processed property map
*/
protected Map processProperties(NodeRef version, Map properties)
{
@@ -229,7 +229,7 @@ public class RecordableVersionNodeServiceImpl extends Node2ServiceImpl
* Process frozen aspects.
*
* @param aspects aspect set
- * @return {@link Set}<{@link QName}> processed aspect set
+ * @return {@link Set}<{@link QName}> processed aspect set
*/
protected Set processAspects(Set aspects)
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java
index 643d009458..c7d80b5abe 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionService.java
@@ -69,7 +69,7 @@ public interface RecordableVersionService
/**
* Gets the version that relates to the version record
*
- * @param versionRecord version record node reference
+ * @param record version record node reference
* @return Version version or null if not found
*/
Version getRecordedVersion(NodeRef record);
@@ -89,7 +89,7 @@ public interface RecordableVersionService
*
* Does not create a record if the node is not versionable or the latest version is already recorded.
*
- * @param nodeRef parent node reference
+ * @param filePlan parent node reference
* @param nodeRef node reference
* @param autoVersion true, create new record version from latest version, false creates a record from the latest frozen version
* @return NodeRef node reference to the created record.
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java
index 2380e3309a..1fceed588f 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java
@@ -620,7 +620,7 @@ public class RecordableVersionServiceImpl extends Version2ServiceImpl
}
/**
- * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isLatestVersionRecorded(org.alfresco.service.cmr.repository.NodeRef)
+ * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#isCurrentVersionRecorded(NodeRef)
*/
@Override
public boolean isCurrentVersionRecorded(NodeRef nodeRef)
@@ -672,7 +672,7 @@ public class RecordableVersionServiceImpl extends Version2ServiceImpl
/**
* Create Version Store Ref
*
- * @param store ref
+ * @param storeRef store ref
* @return store ref for version store
*/
public StoreRef convertStoreRef(StoreRef storeRef)
@@ -693,7 +693,7 @@ public class RecordableVersionServiceImpl extends Version2ServiceImpl
}
/**
- * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#createRecordFromLatestVersion(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, autoVersion)
+ * @see org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService#createRecordFromLatestVersion(NodeRef, NodeRef, boolean autoVersion)
*/
@Override
public NodeRef createRecordFromLatestVersion(final NodeRef filePlan, final NodeRef nodeRef, final boolean isEnableAutoVersionOnRecordCreation)
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java
index b1deb19f16..762f12bce9 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java
@@ -52,7 +52,7 @@ public class NodeParameterSuggesterBootstrap
private NodeParameterProcessor nodeParameterProcessor;
/**
- * @param recordMetadataAspects map of record metadata aspects against file plan types
+ * @param nodeParameterProcessorAspectsNames map of record metadata aspects against file plan types
*/
public void setNodeParameterProcessorAspects(String nodeParameterProcessorAspectsNames)
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java
index dd5d89d3fd..6f8c6d6619 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/ParameterProcessorComponent.java
@@ -137,7 +137,7 @@ public class ParameterProcessorComponent implements ParameterSubstitutionSuggest
/**
* Return a list of substitution suggestions for the passed string fragment.
*
- * @param subtitutionFragment Text fragment to search on.
+ * @param substitutionFragment Text fragment to search on.
* @return A list of substitutions that match the substitution fragment.
*/
public List getSubstitutionSuggestions(final String substitutionFragment)
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java
index 6fab4e94a2..83fb1501a9 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionService.java
@@ -45,7 +45,7 @@ public interface ExtendedPermissionService extends PermissionService
* Get a set of all the authorities that have write access.
*
* @param aclId acl id
- * @return {@link Set}<{@link String}> set of authorities with write access
+ * @return {@link Set}<{@link String}> set of authorities with write access
*/
Set getWriters(Long aclId);
@@ -55,7 +55,7 @@ public interface ExtendedPermissionService extends PermissionService
* The writers list includes the owner for the node.
*
* @param nodeRef node reference
- * @return Pair, Set> first is a set containing all the authorities that have read permission on the
+ * @return Pair<Set<String>, Set<String>> first is a set containing all the authorities that have read permission on the
* document and second is a set containing all the authorities that have write
* permission on the document, including the owner.
*
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPreProcessor.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPreProcessor.java
index 689c00748b..ff42e9f192 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPreProcessor.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPreProcessor.java
@@ -41,8 +41,7 @@ public interface PermissionPreProcessor
{
/**
* Process permission.
- *
- * @param accessStatus current access status
+ *
* @param nodeRef node reference
* @param perm permission
* @return {@link AccessStatus}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionProcessorRegistry.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionProcessorRegistry.java
index 766ac302ce..96794d1daf 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionProcessorRegistry.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionProcessorRegistry.java
@@ -67,7 +67,7 @@ public class PermissionProcessorRegistry
/**
* Get a list of the registered permission pre-processors.
*
- * @return {@link List}<{@link PermissionPreProcessor}> list of permission pre-processors
+ * @return {@link List}<{@link PermissionPreProcessor}> list of permission pre-processors
*/
public List getPermissionPreProcessors()
{
@@ -77,7 +77,7 @@ public class PermissionProcessorRegistry
/**
* Get a list of the registered permission post-processors.
*
- * @return <{@link List}>{@link PermissionPreProcessor} list of permission post-processors
+ * @return <{@link List}>{@link PermissionPreProcessor} list of permission post-processors
*/
public List getPermissionPostProcessors()
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/impl/PermissionProcessorBaseImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/impl/PermissionProcessorBaseImpl.java
index 6e1d6e6330..5eede3afe2 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/impl/PermissionProcessorBaseImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/impl/PermissionProcessorBaseImpl.java
@@ -41,7 +41,7 @@ import org.alfresco.repo.security.permissions.processor.PermissionProcessorRegis
private PermissionProcessorRegistry permissionProcessorRegistry;
/**
- * @param PermissionProcessorRegistry permission processor registry
+ * @param permissionProcessorRegistry permission processor registry
*/
public void setPermissionProcessorRegistry(PermissionProcessorRegistry permissionProcessorRegistry)
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java
index d95cd506e6..ccec29a168 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java
@@ -44,7 +44,7 @@ import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
- * Webscript to get the Propertydefinitions for a given classname eg. =>cm_person
+ * Webscript to get the Propertydefinitions for a given classname eg. =>cm_person
*
* This class makes it possible to get only RM related property definitions
* @see PropertiesGet for the original implementation
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java
index a4e9f1798e..c435076953 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java
@@ -91,9 +91,9 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
}
/**
- * Set the parameter processor component bean
+ * Set the node service
*
- * @param parameterProcessorComponent
+ * @param nodeService
*/
public void setNodeService(NodeService nodeService)
{
@@ -109,7 +109,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
}
/**
- * @param filePlanService file plan service
+ * @param capabilityService file plan service
*/
public void setCapabilityService(CapabilityService capabilityService)
{
@@ -119,7 +119,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
/**
* Set the minimum fragment size to process for suggestion processing
*
- * @param maximumNumberSuggestions
+ * @param substitutionMinimumFragmentSize
*/
public void setSubstitutionMinimumFragmentSize(int substitutionMinimumFragmentSize)
{
@@ -129,7 +129,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
/**
* Set the maxmimum number of suggestions returned from the global property
*
- * @param maximumNumberSuggestions
+ * @param pathSubstitutionMaximumNumberSuggestions
*/
public void setPathSubstitutionMaximumNumberSuggestions(int pathSubstitutionMaximumNumberSuggestions)
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/ApiNodesModelFactory.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/ApiNodesModelFactory.java
index fbd2b911a3..60bab513dd 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/ApiNodesModelFactory.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/ApiNodesModelFactory.java
@@ -641,8 +641,7 @@ public class ApiNodesModelFactory
* Creates an object of type FilePlan
*
* @param info info of the file plan
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return FilePlan object
@@ -659,8 +658,7 @@ public class ApiNodesModelFactory
* Creates an object of type RecordCategory
*
* @param info info of the record category
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return RecordCategory object
@@ -685,8 +683,7 @@ public class ApiNodesModelFactory
* Creates an object of type RecordCategory
*
* @param info
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return RecordCategory object
@@ -710,8 +707,7 @@ public class ApiNodesModelFactory
* Creates an object of type UnfiledContainer
*
* @param info
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return UnfiledContainer object
@@ -729,8 +725,7 @@ public class ApiNodesModelFactory
* Creates an object of type TransferContainer
*
* @param info
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return UnfiledContainer object
@@ -747,8 +742,7 @@ public class ApiNodesModelFactory
* Creates an object of type Transfer
*
* @param info
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return UnfiledContainer object
@@ -765,8 +759,7 @@ public class ApiNodesModelFactory
* Creates an object of type TransferChild
*
* @param info
- * @param propertyFilter
- * @param includeParam
+ * @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return UnfiledContainer object
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java
index 78b0e5a5b2..472d079ef8 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java
@@ -39,7 +39,6 @@ import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -65,8 +64,6 @@ import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.rest.antlr.WhereClauseParser;
import org.alfresco.rest.api.Activities;
import org.alfresco.rest.api.Nodes;
-import org.alfresco.rest.api.model.PathInfo;
-import org.alfresco.rest.api.model.PathInfo.ElementInfo;
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InsufficientStorageException;
@@ -90,7 +87,6 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.lock.NodeLockedException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
@@ -98,10 +94,7 @@ import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.repository.Path;
-import org.alfresco.service.cmr.repository.Path.Element;
import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.usage.ContentQuotaException;
import org.alfresco.service.namespace.QName;
@@ -781,7 +774,7 @@ public class FilePlanComponentsApiUtils
* Returns a List of filter properties specified by request parameters.
* @param parameters The {@link Parameters} object to get the parameters passed into the request
* including:
- * - filter, sort & paging params (where, orderBy, skipCount, maxItems)
+ * - filter, sort & paging params (where, orderBy, skipCount, maxItems)
* @return The list of {@link FilterProp}. Can be null.
*/
public List getListChildrenFilterProps(Parameters parameters, Set listFolderChildrenEqualsQueryProperties)
@@ -912,8 +905,9 @@ public class FilePlanComponentsApiUtils
/**
* Helper method that generates allowable operation for the provided node
* @param nodeRef the node to get the allowable operations for
- * @param type the type of the provided nodeRef
- * @return a sublist of [{@link Nodes.OP_DELETE}, {@link Nodes.OP_CREATE}, {@link Nodes.OP_UPDATE}] representing the allowable operations for the provided node
+ * @param typeQName the type of the provided nodeRef
+ * @return a sublist of [{@link Nodes#OP_DELETE}, {@link Nodes#OP_CREATE}, {@link Nodes#OP_UPDATE}] representing
+ * the allowable operations for the provided node
*/
protected List getAllowableOperations(NodeRef nodeRef, QName typeQName)
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RecordCategoryChild.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RecordCategoryChild.java
index 8619a42c99..cd35c889ff 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RecordCategoryChild.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RecordCategoryChild.java
@@ -48,6 +48,7 @@ public class RecordCategoryChild extends RMNode
public RecordCategoryChild()
{
+ //Default constructor
}
public Boolean getIsRecordCategory()
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TargetContainer.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TargetContainer.java
index 124896d6a5..bc810cbb45 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TargetContainer.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TargetContainer.java
@@ -39,6 +39,7 @@ public class TargetContainer
public TargetContainer()
{
+ //Default constructor
}
public String getTargetParentId()
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/Transfer.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/Transfer.java
index 57a5eb34f7..2bd605ee06 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/Transfer.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/Transfer.java
@@ -67,6 +67,7 @@ public class Transfer
public Transfer()
{
+ //Default constructor
}
@JsonProperty ("id")
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferChild.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferChild.java
index 812107c990..8f2ef1d3e7 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferChild.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferChild.java
@@ -45,6 +45,7 @@ public class TransferChild extends RMNode
public TransferChild()
{
+ //Default constructor
}
public Boolean getIsClosed()
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferContainer.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferContainer.java
index 77677120d4..e51e7948c7 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferContainer.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/TransferContainer.java
@@ -60,6 +60,7 @@ public class TransferContainer
public TransferContainer()
{
+ //Default constructor
}
@JsonProperty ("id")
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/util/SortDirection.java b/rm-community/rm-community-repo/source/java/org/alfresco/util/SortDirection.java
index 6be0c21d74..72282d6279 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/util/SortDirection.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/util/SortDirection.java
@@ -72,7 +72,7 @@ public enum SortDirection
if (sortDirection == null)
{
- throw new AlfrescoRuntimeException("Sort direction '" + sortDirection +"' unknown.");
+ throw new AlfrescoRuntimeException("Sort direction unknown.");
}
return sortDirection;
From 4fa230a3223e164c50456b5944c9a586f7c84666 Mon Sep 17 00:00:00 2001
From: cagache
Date: Fri, 10 May 2019 15:24:03 +0300
Subject: [PATCH 15/25] removed contentService from child classes and made it
protected in parent class
---
.../src/main/java/org/alfresco/rest/v0/RecordsAPI.java | 5 -----
1 file changed, 5 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java
index ac2fe6933f..0598a95d06 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java
@@ -33,7 +33,6 @@ import java.text.MessageFormat;
import java.util.Map;
import org.alfresco.dataprep.CMISUtil.DocumentType;
-import org.alfresco.dataprep.ContentService;
import org.alfresco.rest.core.v0.BaseAPI;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.commons.lang3.tuple.Pair;
@@ -42,7 +41,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@@ -59,9 +57,6 @@ public class RecordsAPI extends BaseAPI
private static final String CREATE_NON_ELECTRONIC_RECORD_API = "{0}type/rma:nonElectronicDocument/formprocessor";
- @Autowired
- private ContentService contentService;
-
/**
* Declare documents as records
*
From 3c341d85c5d955a6801e45082ebe1fc0a0193473 Mon Sep 17 00:00:00 2001
From: cagache
Date: Fri, 10 May 2019 17:05:15 +0300
Subject: [PATCH 16/25] delete unnecessary imports
---
.../org/alfresco/rest/rm/community/base/DataProviderClass.java | 1 -
.../alfresco/rest/rm/community/records/CompleteRecordTests.java | 2 --
2 files changed, 3 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java
index d437da677a..5f90e68072 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java
@@ -38,7 +38,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
-import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import org.testng.annotations.DataProvider;
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CompleteRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CompleteRecordTests.java
index d5ca79d7e3..cdd9fe2644 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CompleteRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CompleteRecordTests.java
@@ -42,8 +42,6 @@ import java.util.List;
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record;
-import org.alfresco.rest.rm.community.model.site.RMSite;
-import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
import org.alfresco.test.AlfrescoTest;
From 5dcae9c6086175f20ff0a00a08cba84978a03f85 Mon Sep 17 00:00:00 2001
From: cagache
Date: Fri, 10 May 2019 17:08:33 +0300
Subject: [PATCH 17/25] delete unnecessary semicolon
---
.../rest/rm/community/files/DeclareDocumentAsRecordTests.java | 4 ++--
.../rm/community/recordcategories/RecordCategoryTests.java | 1 -
.../alfresco/rest/rm/community/records/ReadRecordTests.java | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java
index 5e08e5fd7f..af871ccabe 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java
@@ -162,8 +162,8 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
try
(
InputStream recordInputStream = getRestAPIFactory().getRecordsAPI().getRecordContent(record.getId()).asInputStream();
- InputStream documentInputStream = documentPostFiling.getContentStream().getStream();
- )
+ InputStream documentInputStream = documentPostFiling.getContentStream().getStream()
+ )
{
assertEquals(DigestUtils.sha1(recordInputStream), DigestUtils.sha1(documentInputStream));
}
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java
index 9cd8b476b6..8580839556 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java
@@ -775,7 +775,6 @@ public class RecordCategoryTests extends BaseRMRestTest
{
//is unfiled container
containerId = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(containerAlias).getId();
- ;
}
// Create a record folder
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/ReadRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/ReadRecordTests.java
index 06b513ccac..e2c48d8695 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/ReadRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/ReadRecordTests.java
@@ -269,7 +269,7 @@ public class ReadRecordTests extends BaseRMRestTest
try
(
InputStream recordContentStream = recordsAPI.getRecordContent(binaryRecordId).asInputStream();
- FileInputStream localFileStream = new FileInputStream(getFile(IMAGE_FILE));
+ FileInputStream localFileStream = new FileInputStream(getFile(IMAGE_FILE))
)
{
assertEquals(DigestUtils.sha1(recordContentStream), DigestUtils.sha1(localFileStream));
From 929980e7c2327adbee38cf206c512d54f7f7130b Mon Sep 17 00:00:00 2001
From: cagache
Date: Mon, 13 May 2019 10:00:29 +0300
Subject: [PATCH 18/25] Fix "Either re-interrupt this method or rethrow the
"InterruptedException"." sonar bug
---
.../org/alfresco/rest/rm/community/base/BaseRMRestTest.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
index 4ecf318e2a..fccd1bf693 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
@@ -642,6 +642,8 @@ public class BaseRMRestTest extends RestTest
}
catch (InterruptedException e)
{
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
}
}
@@ -690,6 +692,8 @@ public class BaseRMRestTest extends RestTest
}
catch (InterruptedException e)
{
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
}
}
@@ -739,6 +743,8 @@ public class BaseRMRestTest extends RestTest
}
catch (InterruptedException e)
{
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
}
}
result = searchApi.searchForNodePropertyAsUser(user.getUsername(), user.getPassword(), nodeRef,
From 7e9147ceef01473ec219887ff66c064d43eee8ba Mon Sep 17 00:00:00 2001
From: cagache
Date: Mon, 13 May 2019 15:00:42 +0300
Subject: [PATCH 19/25] Added parentId parameter for tests that use
declareRecord v1 api
---
.../rm/community/requests/RMModelRequest.java | 2 +-
.../requests/gscore/api/FilesAPI.java | 31 ++----
.../DeclareAndFileDocumentAsRecordTests.java | 96 ++++++++++++++-----
3 files changed, 84 insertions(+), 45 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java
index b2510f80f7..7f1435142a 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java
@@ -41,7 +41,7 @@ import lombok.Setter;
* @author Tuna Aksoy
* @since 2.6
*/
-public abstract class RMModelRequest extends ModelRequest
+public abstract class RMModelRequest extends ModelRequest
{
@Getter (value = PROTECTED)
@Setter (value = PRIVATE)
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java
index 5440b3866c..8559459294 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java
@@ -41,8 +41,10 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Kristijan Conkas
* @since 2.6
*/
-public class FilesAPI extends RMModelRequest
+public class FilesAPI extends RMModelRequest
{
+ public static final String PARENT_ID_PARAM = "parentId";
+
/**
* @param rmRestWrapper RM REST Wrapper
*/
@@ -55,26 +57,6 @@ public class FilesAPI extends RMModelRequest
* Declare file as record
*
* @param fileId The Id of a file to declare as record
- * @param parameters Request parameters, refer to API documentation for more details
- * @return The {@link Record} for created record
- * @throws Exception for malformed JSON responses
- */
- public Record declareAsRecord(String fileId, String parameters) throws Exception
- {
- mandatoryString("fileId", fileId);
-
- return getRmRestWrapper().processModel(Record.class, simpleRequest(
- POST,
- "/files/{fileId}/declare?{parameters}",
- fileId,
- parameters
- ));
- }
-
- /**
- * A no-parameter version of {@link FilesAPI#declareAsRecord}
- *
- * @param fileId The Id of a file to declare as record
* @return The {@link Record} for created record
* @throws Exception for malformed JSON responses
*/
@@ -82,7 +64,12 @@ public class FilesAPI extends RMModelRequest
{
mandatoryString("fileId", fileId);
- return declareAsRecord(fileId, EMPTY);
+ return getRmRestWrapper().processModel(Record.class, simpleRequest(
+ POST,
+ "/files/{fileId}/declare?{parameters}",
+ fileId,
+ getRmRestWrapper().getParameters()
+ ));
}
}
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
index 899466aeaf..379ceb45ed 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
@@ -26,16 +26,19 @@
*/
package org.alfresco.rest.rm.community.files;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_POWER_USER;
-import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
+import static org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI.PARENT_ID_PARAM;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.ACCEPTED;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
@@ -57,6 +60,7 @@ import org.alfresco.test.AlfrescoTest;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
@@ -77,10 +81,11 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private final static String DESTINATION_PATH_NOT_RESOLVED_EXC = "Unable to execute create-record action, because the destination path could not be resolved.";
private final static String INVALID_DESTINATION_PATH_EXC = "Unable to execute create-record action, because the destination path is invalid.";
private final static String DESTINATION_PATH_NOT_RECORD_FOLDER_EXC = "Unable to execute create-record action, because the destination path is not a record folder.";
- private final static String CLOSED_RECORD_FOLDER_EXC = "You can't add new items to a closed record folder";
+ private final static String CLOSED_RECORD_FOLDER_EXC = "Unable to create record, because container is closed";
private UserModel userFillingPermission, userReadOnlyPermission;
private SiteModel publicSite;
+ private FolderModel testFolder;
private RecordCategory recordCategory;
private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory;
private UnfiledContainerChild unfiledContainerFolder;
@@ -92,16 +97,14 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private RoleService roleService;
/**
- * Invalid containers where in-place records can't be filed
+ * Invalid destination paths where in-place records can't be filed
*/
- @DataProvider (name = "invalidFileLocations")
- public Object[][] getInvalidFileLocations() throws Exception
+ @DataProvider (name = "invalidDestinationPaths")
+ public Object[][] getInvalidDestinationPaths() throws Exception
{
RecordCategoryChild closedFolder = createFolder(recordCategory.getId(), getRandomName("closedFolder"));
closeFolder(closedFolder.getId());
- unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
- "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE);
return new String[][]
{
{ "/", DESTINATION_PATH_NOT_RESOLVED_EXC},
@@ -115,25 +118,49 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
// an arbitrary unfiled records folder
{ "Unfiled Records/" + unfiledContainerFolder.getName(), INVALID_DESTINATION_PATH_EXC },
// a collaboration site folder
- { dataContent.usingAdmin().usingSite(publicSite).createFolder().getCmisLocation(), DESTINATION_PATH_NOT_RESOLVED_EXC }
+ { testFolder.getCmisLocation(), DESTINATION_PATH_NOT_RESOLVED_EXC }
};
}
+ /**
+ * Invalid destination ids where in-place records can't be filed
+ */
+ @DataProvider (name = "invalidDestinationIds")
+ public Object[][] getInvalidDestinationIds()
+ {
+ return new String[][]
+ {
+ { getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId() },
+ { getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
+ { getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
+ { getContentService().getNodeRefByPath(getAdminUser().getUsername(), getAdminUser().getPassword(), "/Sites/rm/documentLibrary/Holds") },
+ { recordCategory.getId() },
+ { unfiledContainerFolder.getId() },
+ { testFolder.getNodeRef() }
+ };
+ }
+
@BeforeClass (alwaysRun = true)
public void declareAndFileDocumentAsRecordSetup() throws Exception
{
STEP("Create test collaboration site to store documents in.");
publicSite = dataSite.usingAdmin().createPublicRandomSite();
+ STEP("Create a test foloder within the collaboration site");
+ testFolder = dataContent.usingAdmin().usingSite(publicSite).createFolder();
+
STEP("Create record categories and record folders");
recordCategory = createRootCategory(getRandomName("recordCategory"));
subCategory = createRecordCategory(recordCategory.getId(), getRandomName("subCategory"));
recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
subcategoryRecordFolder = createFolder(subCategory.getId(), getRandomName("recordFolder"));
+ unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
+ "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE);
STEP("Create rm users with different permissions on the record category");
userFillingPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory, ROLE_RM_POWER_USER, PERMISSION_FILING);
- userReadOnlyPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory,ROLE_RM_USER, PERMISSION_READ_RECORDS);
+ userReadOnlyPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory,
+ ROLE_RM_POWER_USER, PERMISSION_READ_RECORDS);
}
/**
@@ -194,7 +221,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
* Then I receive an error indicating that I have attempted to declare and file a document into an invalid record folder
* And the document is not declared as a record
*/
- @Test (dataProvider = "invalidFileLocations")
+ @Test (dataProvider = "invalidDestinationPaths")
public void declareAndFileToInvalidLocationUsingActionsAPI(String containerPath, String expectedException) throws Exception
{
STEP("Create a document in the collaboration site");
@@ -232,8 +259,8 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
STEP("Declare document as record with a location parameter value");
- //TODO add recordFolder location parameter value
Record record = getRestAPIFactory().getFilesAPI(userFillingPermission)
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
.declareAsRecord(testFile.getNodeRefWithoutVersion());
assertStatusCode(CREATED);
@@ -244,6 +271,30 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
assertTrue(hasRecordAspect(testFile), "File should have record aspect");
}
+ /**
+ * Given I declare a record using the v1 API
+ * When I provide an invalid record folder in the location parameter
+ * Then I receive an error indicating that I have attempted to declare and file a document into an invalid record folder
+ * And the document is not declared as a record
+ */
+ @Test (dataProvider = "invalidDestinationIds")
+ public void declareAndFileToInvalidLocationUsingFilesAPI(String containerID) throws Exception
+ {
+ STEP("Create a document in the collaboration site");
+ FileModel testFile = dataContent.usingSite(publicSite)
+ .usingAdmin()
+ .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+
+ STEP("Declare document as record with an invalid location parameter value");
+ getRestAPIFactory().getFilesAPI()
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, containerID))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
+ assertStatusCode(BAD_REQUEST);
+
+ STEP("Check that the file is not a record");
+ assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
+ }
+
/**
* Given I am an user with read only permissions on a record folder
* When I declare and file a record to the record folder
@@ -258,9 +309,9 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
STEP("Declare document as record with a record folder as location parameter");
- //TODO add recordFolder location parameter value
- getRestAPIFactory().getFilesAPI(userReadOnlyPermission).declareAsRecord(testFile.getNodeRefWithoutVersion());
- //TODO check what status code should be returned
+ getRestAPIFactory().getFilesAPI(userReadOnlyPermission)
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
assertStatusCode(FORBIDDEN);
STEP("Check that the file is not a record");
@@ -285,8 +336,9 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
STEP("Declare document as record with a record folder as location parameter");
- //TODO add recordFolder location parameter value
- getRestAPIFactory().getFilesAPI(nonRMUser).declareAsRecord(testFile.getNodeRefWithoutVersion());
+ getRestAPIFactory().getFilesAPI(nonRMUser)
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
assertStatusCode(FORBIDDEN);
STEP("Check that the file is not a record");
@@ -308,13 +360,15 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
STEP("Declare document as record with a record folder as location parameter");
- //TODO add subcategoryRecordFolder as location parameter value
- getRestAPIFactory().getFilesAPI(userFillingPermission).declareAsRecord(testFile.getNodeRefWithoutVersion());
+ getRestAPIFactory().getFilesAPI(userFillingPermission)
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, subcategoryRecordFolder.getId()))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
assertStatusCode(CREATED);
STEP("Declare it again using a different record folder as location parameter");
- //TODO add recordFolder as location parameter value
- getRestAPIFactory().getFilesAPI(userFillingPermission).declareAsRecord(testFile.getNodeRefWithoutVersion());
+ getRestAPIFactory().getFilesAPI(userFillingPermission)
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
assertStatusCode(UNPROCESSABLE_ENTITY);
STEP("Verify the declared record is placed in the first record folder");
@@ -324,8 +378,6 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
"Record should not be filed to subcategoryRecordFolder");
}
-
-
@AfterClass(alwaysRun = true)
public void declareAndFileDocumentAsRecordCleanup()
{
From bb1e01a6ccfedee90fb67aa5a4ffb6efa97db0b9 Mon Sep 17 00:00:00 2001
From: cagache
Date: Mon, 13 May 2019 16:46:32 +0300
Subject: [PATCH 20/25] Fix sonar bugs for DockerHelper class
---
.../rest/rm/community/util/DockerHelper.java | 16 ++++++++++------
.../DeclareAndFileDocumentAsRecordTests.java | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java
index adbb4ab30c..ce17d71717 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java
@@ -39,6 +39,8 @@ import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.core.DockerClientBuilder;
import com.github.dockerjava.core.command.LogContainerResultCallback;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.lang.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,8 +57,10 @@ import org.springframework.stereotype.Service;
@Service
public class DockerHelper
{
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private static final Logger LOGGER = LoggerFactory.getLogger(DockerHelper.class);
private static final String REPO_IMAGE_NAME = "repository";
+ @Getter
+ @Setter
private DockerClient dockerClient;
@Autowired
@@ -82,9 +86,9 @@ public class DockerHelper
{
final List logs = new ArrayList<>();
// get the logs since current time - 10 seconds
- int timeStamp = (int) (System.currentTimeMillis() / 1000) - 10;
+ final int timeStamp = (int) (System.currentTimeMillis() / 1000) - 10;
- LogContainerCmd logContainerCmd = dockerClient.logContainerCmd(containerId);
+ final LogContainerCmd logContainerCmd = getDockerClient().logContainerCmd(containerId);
logContainerCmd.withStdOut(true)
.withStdErr(true)
.withSince(timeStamp) // UNIX timestamp to filter logs. Output log-entries since that timestamp.
@@ -104,7 +108,7 @@ public class DockerHelper
catch (InterruptedException e)
{
Thread.currentThread().interrupt(); // set interrupt flag
- logger.error("Failed to retrieve logs of container " + containerId, e);
+ LOGGER.error("Failed to retrieve logs of container " + containerId, e);
}
return logs;
@@ -117,7 +121,7 @@ public class DockerHelper
*/
public List getAlfrescoLogs()
{
- Optional alfrescoContainer = findContainerByImageName(REPO_IMAGE_NAME);
+ final Optional alfrescoContainer = findContainerByImageName(REPO_IMAGE_NAME);
return (alfrescoContainer.isPresent()) ? getDockerLogs(alfrescoContainer.get().getId()) : Collections.emptyList();
}
@@ -129,7 +133,7 @@ public class DockerHelper
*/
private Optional findContainerByImageName(String imageName)
{
- List containers = dockerClient.listContainersCmd().withShowAll(true).exec();
+ final List containers = getDockerClient().listContainersCmd().withShowAll(true).exec();
return containers.stream()
.filter(container -> container.getImage().contains(imageName))
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
index 379ceb45ed..327b70d7b4 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
@@ -146,7 +146,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
STEP("Create test collaboration site to store documents in.");
publicSite = dataSite.usingAdmin().createPublicRandomSite();
- STEP("Create a test foloder within the collaboration site");
+ STEP("Create a test folder within the collaboration site");
testFolder = dataContent.usingAdmin().usingSite(publicSite).createFolder();
STEP("Create record categories and record folders");
From 60f8a61599b04eb784ef6af316d7f94acfad2536 Mon Sep 17 00:00:00 2001
From: cagache
Date: Tue, 14 May 2019 09:54:16 +0300
Subject: [PATCH 21/25] Added closed folder to invalidDestinationIds data
provider
---
.../files/DeclareAndFileDocumentAsRecordTests.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
index 327b70d7b4..90db7d8d16 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
@@ -87,7 +87,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private SiteModel publicSite;
private FolderModel testFolder;
private RecordCategory recordCategory;
- private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory;
+ private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedFolder;
private UnfiledContainerChild unfiledContainerFolder;
@Autowired
@@ -100,11 +100,8 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
* Invalid destination paths where in-place records can't be filed
*/
@DataProvider (name = "invalidDestinationPaths")
- public Object[][] getInvalidDestinationPaths() throws Exception
+ public Object[][] getInvalidDestinationPaths()
{
- RecordCategoryChild closedFolder = createFolder(recordCategory.getId(), getRandomName("closedFolder"));
- closeFolder(closedFolder.getId());
-
return new String[][]
{
{ "/", DESTINATION_PATH_NOT_RESOLVED_EXC},
@@ -135,6 +132,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{ getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
{ getContentService().getNodeRefByPath(getAdminUser().getUsername(), getAdminUser().getPassword(), "/Sites/rm/documentLibrary/Holds") },
{ recordCategory.getId() },
+ { closedFolder.getId() },
{ unfiledContainerFolder.getId() },
{ testFolder.getNodeRef() }
};
@@ -156,6 +154,8 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
subcategoryRecordFolder = createFolder(subCategory.getId(), getRandomName("recordFolder"));
unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE);
+ closedFolder = createFolder(recordCategory.getId(), getRandomName("closedFolder"));
+ closeFolder(closedFolder.getId());
STEP("Create rm users with different permissions on the record category");
userFillingPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory, ROLE_RM_POWER_USER, PERMISSION_FILING);
From e5ac7ad9b77d7893e3fd98579b7fdaebfe2d24d5 Mon Sep 17 00:00:00 2001
From: cagache
Date: Tue, 14 May 2019 15:18:24 +0300
Subject: [PATCH 22/25] code review comments
---
.../rm/community/base/BaseRMRestTest.java | 12 +-
.../DeclareAndFileDocumentAsRecordTests.java | 111 +++++++++++-------
2 files changed, 73 insertions(+), 50 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
index fccd1bf693..baa37afc28 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
@@ -480,32 +480,32 @@ public class BaseRMRestTest extends RestTest
return createCategoryFolderInFilePlan(getAdminUser());
}
- public UnfiledContainer getUnfiledContainerAsUser(UserModel user, String componentId) throws Exception
+ public UnfiledContainer getUnfiledContainerAsUser(UserModel user, String componentId)
{
return getRestAPIFactory().getUnfiledContainersAPI(user).getUnfiledContainer(componentId);
}
- public UnfiledContainer getUnfiledContainer(String componentId) throws Exception
+ public UnfiledContainer getUnfiledContainer(String componentId)
{
return getUnfiledContainerAsUser(getAdminUser(), componentId);
}
- public TransferContainer getTransferContainerAsUser(UserModel user, String componentId) throws Exception
+ public TransferContainer getTransferContainerAsUser(UserModel user, String componentId)
{
return getRestAPIFactory().getTransferContainerAPI(user).getTransferContainer(componentId);
}
- public TransferContainer getTransferContainer(String componentId) throws Exception
+ public TransferContainer getTransferContainer(String componentId)
{
return getTransferContainerAsUser(getAdminUser(), componentId);
}
- public FilePlan getFilePlanAsUser(UserModel user, String componentId) throws Exception
+ public FilePlan getFilePlanAsUser(UserModel user, String componentId)
{
return getRestAPIFactory().getFilePlansAPI(user).getFilePlan(componentId);
}
- public FilePlan getFilePlan(String componentId) throws Exception
+ public FilePlan getFilePlan(String componentId)
{
return getFilePlanAsUser(getAdminUser(), componentId);
}
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
index 90db7d8d16..0044f48ddb 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
@@ -41,6 +41,7 @@ import static org.springframework.http.HttpStatus.ACCEPTED;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
+import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -66,6 +67,7 @@ import org.alfresco.utility.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -86,8 +88,9 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private UserModel userFillingPermission, userReadOnlyPermission;
private SiteModel publicSite;
private FolderModel testFolder;
+ private FileModel testFile;
private RecordCategory recordCategory;
- private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedFolder;
+ private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedRecordFolder;
private UnfiledContainerChild unfiledContainerFolder;
@Autowired
@@ -111,7 +114,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{ "rm/documentlibrary", DESTINATION_PATH_NOT_RESOLVED_EXC },
{ recordCategory.getName(), DESTINATION_PATH_NOT_RECORD_FOLDER_EXC },
// a closed record folder
- { Utility.buildPath(recordCategory.getName(), closedFolder.getName()), CLOSED_RECORD_FOLDER_EXC},
+ { Utility.buildPath(recordCategory.getName(), closedRecordFolder.getName()), CLOSED_RECORD_FOLDER_EXC},
// an arbitrary unfiled records folder
{ "Unfiled Records/" + unfiledContainerFolder.getName(), INVALID_DESTINATION_PATH_EXC },
// a collaboration site folder
@@ -127,12 +130,11 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{
return new String[][]
{
- { getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId() },
- { getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
- { getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
+ { getFilePlan(FILE_PLAN_ALIAS).getId() },
+ { getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
+ { getTransferContainer(TRANSFERS_ALIAS).getId() },
{ getContentService().getNodeRefByPath(getAdminUser().getUsername(), getAdminUser().getPassword(), "/Sites/rm/documentLibrary/Holds") },
{ recordCategory.getId() },
- { closedFolder.getId() },
{ unfiledContainerFolder.getId() },
{ testFolder.getNodeRef() }
};
@@ -154,8 +156,8 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
subcategoryRecordFolder = createFolder(subCategory.getId(), getRandomName("recordFolder"));
unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE);
- closedFolder = createFolder(recordCategory.getId(), getRandomName("closedFolder"));
- closeFolder(closedFolder.getId());
+ closedRecordFolder = createFolder(recordCategory.getId(), getRandomName("closedRecordFolder"));
+ closeFolder(closedRecordFolder.getId());
STEP("Create rm users with different permissions on the record category");
userFillingPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory, ROLE_RM_POWER_USER, PERMISSION_FILING);
@@ -163,6 +165,15 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
ROLE_RM_POWER_USER, PERMISSION_READ_RECORDS);
}
+ @BeforeMethod(alwaysRun = true)
+ public void createDocument() throws Exception
+ {
+ STEP("Create a document in the collaboration site");
+ testFile = dataContent.usingSite(publicSite)
+ .usingAdmin()
+ .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ }
+
/**
* Given I am calling the "declare as record" action
* And I am not providing a location parameter value
@@ -173,11 +184,6 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
@Test
public void declareAndFileNoLocationUsingActionsAPI() throws Exception
{
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite)
- .usingUser(userReadOnlyPermission)
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
-
STEP("Declare document as record without providing a location parameter value using v1 actions api");
getRestAPIFactory().getActionsAPI(userReadOnlyPermission).declareAsRecord(testFile);
@@ -198,11 +204,6 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
@Test
public void declareAndFileToValidLocationUsingActionsAPI() throws Exception
{
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite)
- .usingAdmin()
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
-
STEP("Declare document as record with a location parameter value");
getRestAPIFactory().getActionsAPI(userFillingPermission).declareAndFile(testFile,
Utility.buildPath(recordCategory.getName(), recordFolder.getName()));
@@ -224,11 +225,6 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
@Test (dataProvider = "invalidDestinationPaths")
public void declareAndFileToInvalidLocationUsingActionsAPI(String containerPath, String expectedException) throws Exception
{
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite)
- .usingAdmin()
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
-
STEP("Declare document as record with an invalid location parameter value");
getRestAPIFactory().getActionsAPI().declareAndFile(testFile, containerPath);
assertStatusCode(ACCEPTED);
@@ -253,11 +249,6 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
@Test
public void declareAndFileToValidLocationUsingFilesAPI() throws Exception
{
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite)
- .usingAdmin()
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
-
STEP("Declare document as record with a location parameter value");
Record record = getRestAPIFactory().getFilesAPI(userFillingPermission)
.usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
@@ -280,16 +271,14 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
@Test (dataProvider = "invalidDestinationIds")
public void declareAndFileToInvalidLocationUsingFilesAPI(String containerID) throws Exception
{
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite)
- .usingAdmin()
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
-
STEP("Declare document as record with an invalid location parameter value");
getRestAPIFactory().getFilesAPI()
.usingParams(String.format("%s=%s", PARENT_ID_PARAM, containerID))
.declareAsRecord(testFile.getNodeRefWithoutVersion());
assertStatusCode(BAD_REQUEST);
+ getRestAPIFactory().getRmRestWrapper()
+ .assertLastError()
+ .containsSummary("is not valid for this endpoint. Expected nodeType is:{http://www.alfresco.org/model/recordsmanagement/1.0}recordFolder");
STEP("Check that the file is not a record");
assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
@@ -298,16 +287,12 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
/**
* Given I am an user with read only permissions on a record folder
* When I declare and file a record to the record folder
- * Then I receive an error indicating that I have attempted to declare and file a document into an invalid record folder
+ * Then I receive an error indicating that the access is denied
* And the document is not declared as a record
*/
@Test
public void declareAndFileByUserWithReadOnlyPermission() throws Exception
{
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite).usingAdmin()
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
-
STEP("Declare document as record with a record folder as location parameter");
getRestAPIFactory().getFilesAPI(userReadOnlyPermission)
.usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
@@ -321,7 +306,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
/**
* Given I am a non RM user
* When I declare and file a record to the record folder
- * Then I receive an error indicating that I have attempted to declare and file a document into an invalid record folder
+ * Then I receive an error indicating that the access is denied
* And the document is not declared as a record
*/
@Test
@@ -329,11 +314,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{
STEP("Create an user with no rm rights");
UserModel nonRMUser = getDataUser().createRandomTestUser();
- getDataUser().addUserToSite(nonRMUser, publicSite, UserRole.SiteContributor);
-
- STEP("Create a document in the collaboration site");
- FileModel testFile = dataContent.usingSite(publicSite).usingUser(nonRMUser)
- .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ getDataUser().addUserToSite(nonRMUser, publicSite, UserRole.SiteCollaborator);
STEP("Declare document as record with a record folder as location parameter");
getRestAPIFactory().getFilesAPI(nonRMUser)
@@ -345,6 +326,48 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
}
+ /**
+ * Given I declare a record using the v1 API
+ * When I provide a nonexistent record folder in the location parameter
+ * Then I receive an error indicating that the record folder does not exist
+ * And the document is not declared as a record
+ */
+ @Test
+ public void declareAndFileToNonexistentRecordFolderUsingFilesAPI() throws Exception
+ {
+ STEP("Declare document as record with a nonexistent location parameter value");
+ getRestAPIFactory().getFilesAPI()
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, "nonexistent"))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
+ assertStatusCode(NOT_FOUND);
+
+ STEP("Check that the file is not a record");
+ assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
+ }
+
+
+ /**
+ * Given I declare a record using the v1 API
+ * When I provide a closed record folder in the location parameter
+ * Then I receive an error indicating that the record folder is closed
+ * And the document is not declared as a record
+ */
+ @Test
+ public void declareAndFileToClosedRecordFolderUsingFilesAPI() throws Exception
+ {
+ STEP("Declare document as record with a closed location parameter value");
+ getRestAPIFactory().getFilesAPI()
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, closedRecordFolder.getId()))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
+ assertStatusCode(UNPROCESSABLE_ENTITY);
+ getRestAPIFactory().getRmRestWrapper()
+ .assertLastError()
+ .containsSummary(CLOSED_RECORD_FOLDER_EXC);
+
+ STEP("Check that the file is not a record");
+ assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
+ }
+
/**
* Given I declare a record using the v1 API
* When I provide a location parameter
From ba3acb3eed7747c37267fc7e8211938f43098850 Mon Sep 17 00:00:00 2001
From: cagache
Date: Thu, 16 May 2019 10:54:58 +0300
Subject: [PATCH 23/25] Added test for declaring and file a record into a held
record folder
---
.../rest/v0/RMRolesAndActionsAPI.java | 167 +++++++++++-------
.../DeclareAndFileDocumentAsRecordTests.java | 35 +++-
2 files changed, 138 insertions(+), 64 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java
index 2cc343a50a..94e0b25269 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java
@@ -30,6 +30,7 @@ import static org.alfresco.dataprep.AlfrescoHttpClient.MIME_TYPE_JSON;
import static org.alfresco.rest.core.v0.APIUtils.ISO_INSTANT_FORMATTER;
import static org.apache.http.HttpStatus.SC_OK;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
@@ -47,6 +48,7 @@ import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.dataprep.UserService;
import org.alfresco.rest.core.v0.BaseAPI;
import org.alfresco.rest.core.v0.RMEvents;
+import org.alfresco.utility.Utility;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.http.HttpResponse;
@@ -72,6 +74,8 @@ import org.springframework.stereotype.Component;
@Component
public class RMRolesAndActionsAPI extends BaseAPI
{
+ public static final String HOLDS_CONTAINER = "Holds";
+
/** The URI to view the configured roles and capabilities. */
private static final String RM_ROLES = "{0}rma/admin/rmroles";
/** The URI for REST requests about a particular configured role. */
@@ -82,6 +86,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
private static final Logger LOGGER = LoggerFactory.getLogger(RMRolesAndActionsAPI.class);
private static final String MOVE_ACTIONS_API = "action/rm-move-to/site/rm/documentLibrary/{0}";
private static final String CREATE_HOLDS_API = "{0}type/rma:hold/formprocessor";
+ /** The URI to view the configured roles and capabilities. */
+ private static final String RM_HOLDS_API = "{0}rma/holds";
/** http client factory */
@Autowired
@@ -101,7 +107,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
public Set getConfiguredRoles(String adminUser, String adminPassword)
{
// Using "is=true" includes the in-place readers and writers.
- JSONObject jsonObject = doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject("data");
+ final JSONObject jsonObject = doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject(
+ "data");
return jsonObject.toMap().keySet();
}
@@ -115,11 +122,31 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public Set getCapabilitiesForRole(String adminUser, String adminPassword, String role)
{
- JSONObject jsonObject = doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject("data");
+ final JSONObject jsonObject = doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject(
+ "data");
assertTrue("Could not find role '" + role + "' in " + jsonObject.keySet(), jsonObject.has(role));
return jsonObject.getJSONObject(role).getJSONObject("capabilities").keySet();
}
+ /**
+ * Creates the body for PUT/POST Roles API requests
+ *
+ * @param roleName the role name
+ * @param roleDisplayLabel a human-readable label for the role
+ * @param capabilities a list of capabilities for the role
+ * @return
+ */
+ private JSONObject roleRequestBody(String roleName, String roleDisplayLabel, Set capabilities)
+ {
+ final JSONObject requestBody = new JSONObject();
+ requestBody.put("name", roleName);
+ requestBody.put("displayLabel", roleDisplayLabel);
+ final JSONArray capabilitiesArray = new JSONArray();
+ capabilities.forEach(capabilitiesArray::put);
+ requestBody.put("capabilities", capabilitiesArray);
+ return requestBody;
+ }
+
/**
* Create a new RM role.
*
@@ -131,13 +158,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public void createRole(String adminUser, String adminPassword, String roleName, String roleDisplayLabel, Set capabilities)
{
- JSONObject requestBody = new JSONObject();
- requestBody.put("name", roleName);
- requestBody.put("displayLabel", roleDisplayLabel);
- JSONArray capabilitiesArray = new JSONArray();
- capabilities.forEach(capabilitiesArray::put);
- requestBody.put("capabilities", capabilitiesArray);
- doPostJsonRequest(adminUser, adminPassword, HttpStatus.SC_OK, requestBody, RM_ROLES);
+ doPostJsonRequest(adminUser, adminPassword, HttpStatus.SC_OK, roleRequestBody(roleName, roleDisplayLabel, capabilities),
+ RM_ROLES);
}
/**
@@ -151,13 +173,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public void updateRole(String adminUser, String adminPassword, String roleName, String roleDisplayLabel, Set capabilities)
{
- JSONObject requestBody = new JSONObject();
- requestBody.put("name", roleName);
- requestBody.put("displayLabel", roleDisplayLabel);
- JSONArray capabilitiesArray = new JSONArray();
- capabilities.forEach(capabilitiesArray::put);
- requestBody.put("capabilities", capabilitiesArray);
- doPutJsonRequest(adminUser, adminPassword, HttpStatus.SC_OK, requestBody, RM_ROLES_ROLE, roleName);
+ doPutJsonRequest(adminUser, adminPassword, HttpStatus.SC_OK, roleRequestBody(roleName, roleDisplayLabel, capabilities),
+ RM_ROLES_ROLE, roleName);
}
/**
@@ -170,8 +187,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
public void deleteRole(String adminUser, String adminPassword, String roleName)
{
doDeleteRequest(adminUser, adminPassword, MessageFormat.format(RM_ROLES_ROLE, "{0}", roleName));
- boolean success = !getConfiguredRoles(adminUser, adminPassword).contains(roleName);
- assertTrue("Failed to delete role " + roleName + " with " + adminUser, success);
+ assertFalse("Failed to delete role " + roleName + " with " + adminUser,
+ getConfiguredRoles(adminUser, adminPassword).contains(roleName));
}
/**
@@ -270,7 +287,7 @@ public class RMRolesAndActionsAPI extends BaseAPI
}
catch (JSONException | IOException e)
{
- e.printStackTrace();
+ LOGGER.error(e.toString());
}
finally
{
@@ -308,16 +325,40 @@ public class RMRolesAndActionsAPI extends BaseAPI
}
/**
- * Perform an action on the record folder
+ * Perform an action on the given content
*
* @param user the user executing the action
* @param password the user's password
* @param contentName the content name
* @return The HTTP response.
*/
- public HttpResponse executeAction(String user, String password, String contentName, RM_ACTIONS rm_action)
+ public HttpResponse executeAction(String user, String password, String contentName, RM_ACTIONS action)
{
- return executeAction(user, password, contentName, rm_action, null);
+ return executeAction(user, password, contentName, action, null);
+ }
+
+ /**
+ * Creates the body for Actions API requests
+ *
+ * @param user the user executing the action
+ * @param password the user's password
+ * @param contentName the content on which the action is executed
+ * @param action the action executed
+ * @param actionsParams the request parameters
+ * @return the JSONObject created
+ */
+ private JSONObject actionsRequestBody(String user, String password, String contentName, RM_ACTIONS action,
+ JSONObject actionsParams)
+ {
+ final String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName);
+ final JSONObject requestParams = new JSONObject();
+ requestParams.put("name", action.getAction());
+ requestParams.put("nodeRef", recNodeRef);
+ if (actionsParams != null)
+ {
+ requestParams.put("params", actionsParams);
+ }
+ return requestParams;
}
/**
@@ -331,19 +372,12 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public HttpResponse executeAction(String user, String password, String contentName, RM_ACTIONS action, ZonedDateTime date)
{
- String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName);
- JSONObject requestParams = new JSONObject();
- requestParams.put("name", action.getAction());
- requestParams.put("nodeRef", recNodeRef);
+ final JSONObject actionParams = new JSONObject();
if (date != null)
{
- String thisMoment = date.format(ISO_INSTANT_FORMATTER);
- requestParams.put("params", new JSONObject()
- .put("asOfDate", new JSONObject()
- .put("iso8601", thisMoment)
- )
- );
+ actionParams.put("asOfDate", new JSONObject().put("iso8601", ISO_INSTANT_FORMATTER.format(date)));
}
+ final JSONObject requestParams = actionsRequestBody(user, password, contentName, action, actionParams);
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
@@ -359,20 +393,14 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public HttpResponse completeEvent(String user, String password, String nodeName, RMEvents event, Instant date)
{
- String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, nodeName);
- JSONObject requestParams = new JSONObject();
- requestParams.put("name", RM_ACTIONS.COMPLETE_EVENT.getAction());
- requestParams.put("nodeRef", recNodeRef);
date = (date != null) ? date : Instant.now();
- String formattedDate = ISO_INSTANT_FORMATTER.format(date);
- requestParams.put("params", new JSONObject()
- .put("eventName", event.getEventName())
- .put("eventCompletedBy", user)
- .put("eventCompletedAt", new JSONObject()
- .put("iso8601", formattedDate)
- )
- );
-
+ final JSONObject actionParams = new JSONObject().put("eventName", event.getEventName())
+ .put("eventCompletedBy", user)
+ .put("eventCompletedAt", new JSONObject()
+ .put("iso8601", ISO_INSTANT_FORMATTER.format(date))
+ );
+ final JSONObject requestParams = actionsRequestBody(user, password, nodeName, RM_ACTIONS.COMPLETE_EVENT,
+ actionParams);
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
@@ -387,13 +415,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public HttpResponse undoEvent(String user, String password, String contentName, RMEvents event)
{
- String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName);
- JSONObject requestParams = new JSONObject();
- requestParams.put("name", RM_ACTIONS.UNDO_EVENT.getAction());
- requestParams.put("nodeRef", recNodeRef);
- requestParams.put("params", new JSONObject()
- .put("eventName", event.getEventName()));
-
+ final JSONObject requestParams = actionsRequestBody(user, password, contentName, RM_ACTIONS.UNDO_EVENT,
+ new JSONObject().put("eventName", event.getEventName()));
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
@@ -412,8 +435,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
{
item.delete();
}
- boolean success = !(contentService.getFolderObject(contentService.getCMISSession(username, password), siteId, containerName).getChildren().getHasMoreItems());
- assertTrue("Not all items were deleted from " + containerName, success);
+ assertFalse("Not all items were deleted from " + containerName,
+ contentService.getFolderObject(contentService.getCMISSession(username, password), siteId, containerName).getChildren().getHasMoreItems());
}
/**
@@ -426,10 +449,9 @@ public class RMRolesAndActionsAPI extends BaseAPI
*/
public void deleteHold(String username, String password, String holdName)
{
- deleteItem(username, password, "/Holds/" + holdName);
+ deleteItem(username, password, String.format("/%s/%s", HOLDS_CONTAINER, holdName));
}
-
/**
* Util method to create a hold
*
@@ -443,29 +465,50 @@ public class RMRolesAndActionsAPI extends BaseAPI
public HttpResponse createHold(String user, String password, String holdName, String reason, String description)
{
// if the hold already exists don't try to create it again
- String holdsContainerPath = getFilePlanPath() + "/Holds";
- String fullHoldPath = holdsContainerPath + "/" + holdName;
- CmisObject hold = getObjectByPath(user, password, fullHoldPath);
+ final String holdsContainerPath = Utility.buildPath(getFilePlanPath(), HOLDS_CONTAINER);
+ final String fullHoldPath = holdsContainerPath + holdName;
+ final CmisObject hold = getObjectByPath(user, password, fullHoldPath);
if (hold != null)
{
return null;
}
// retrieve the Holds container nodeRef
- String parentNodeRef = getItemNodeRef(user, password, "/Holds");
+ final String parentNodeRef = getItemNodeRef(user, password, "/" + HOLDS_CONTAINER);
- JSONObject requestParams = new JSONObject();
+ final JSONObject requestParams = new JSONObject();
requestParams.put("alf_destination", getNodeRefSpacesStore() + parentNodeRef);
requestParams.put("prop_cm_name", holdName);
requestParams.put("prop_cm_description", description);
requestParams.put("prop_rma_holdReason", reason);
// Make the POST request and throw an assertion error if it fails.
- HttpResponse httpResponse = doPostJsonRequest(user, password, SC_OK, requestParams, CREATE_HOLDS_API);
+ final HttpResponse httpResponse = doPostJsonRequest(user, password, SC_OK, requestParams, CREATE_HOLDS_API);
assertNotNull("Expected object to have been created at " + fullHoldPath,
getObjectByPath(user, password, fullHoldPath));
return httpResponse;
}
+ /**
+ * Adds item (record/ record folder) to the hold
+ *
+ * @param user the user who adds the item to the hold
+ * @param password the user's password
+ * @param itemNodeRef the nodeRef of the item to be added to hold
+ * @param holdName the hold name
+ * @return The HTTP response
+ */
+ public HttpResponse addItemToHold(String user, String password, String itemNodeRef, String holdName)
+ {
+ final JSONArray nodeRefs = new JSONArray().put(getNodeRefSpacesStore() + itemNodeRef);
+ final String holdNodeRef = getItemNodeRef(user, password, String.format("/%s/%s", HOLDS_CONTAINER, holdName));
+ final JSONArray holds = new JSONArray().put(getNodeRefSpacesStore() + holdNodeRef);
+ final JSONObject requestParams = new JSONObject();
+ requestParams.put("nodeRefs", nodeRefs);
+ requestParams.put("holds", holds);
+
+ return doPostJsonRequest(user, password, SC_OK, requestParams, RM_HOLDS_API);
+ }
+
/**
* Updates metadata, can be used on records, folders and categories
*
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
index 0044f48ddb..ca6aaab85a 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
@@ -34,6 +34,7 @@ import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSI
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_POWER_USER;
import static org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI.PARENT_ID_PARAM;
+import static org.alfresco.rest.v0.RMRolesAndActionsAPI.HOLDS_CONTAINER;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.alfresco.utility.report.log.Step.STEP;
@@ -56,6 +57,7 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.util.DockerHelper;
+import org.alfresco.rest.v0.RMRolesAndActionsAPI;
import org.alfresco.rest.v0.service.RoleService;
import org.alfresco.test.AlfrescoTest;
import org.alfresco.utility.Utility;
@@ -84,6 +86,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private final static String INVALID_DESTINATION_PATH_EXC = "Unable to execute create-record action, because the destination path is invalid.";
private final static String DESTINATION_PATH_NOT_RECORD_FOLDER_EXC = "Unable to execute create-record action, because the destination path is not a record folder.";
private final static String CLOSED_RECORD_FOLDER_EXC = "Unable to create record, because container is closed";
+ private final static String HOLD_NAME = "holdName";
private UserModel userFillingPermission, userReadOnlyPermission;
private SiteModel publicSite;
@@ -99,6 +102,9 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
@Autowired
private RoleService roleService;
+ @Autowired
+ private RMRolesAndActionsAPI rmRolesAndActionsAPI;
+
/**
* Invalid destination paths where in-place records can't be filed
*/
@@ -133,7 +139,8 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{ getFilePlan(FILE_PLAN_ALIAS).getId() },
{ getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
{ getTransferContainer(TRANSFERS_ALIAS).getId() },
- { getContentService().getNodeRefByPath(getAdminUser().getUsername(), getAdminUser().getPassword(), "/Sites/rm/documentLibrary/Holds") },
+ { rmRolesAndActionsAPI.getItemNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(),
+ "/" + HOLDS_CONTAINER) },
{ recordCategory.getId() },
{ unfiledContainerFolder.getId() },
{ testFolder.getNodeRef() }
@@ -345,7 +352,6 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
}
-
/**
* Given I declare a record using the v1 API
* When I provide a closed record folder in the location parameter
@@ -368,6 +374,31 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
}
+ /**
+ * Given I declare a record using the v1 API
+ * When I provide a held record folder in the location parameter
+ * Then I receive an error indicating that the record folder is held
+ * And the document is not declared as a record
+ */
+ @Test
+ public void declareAndFileToHeldRecordFolderUsingFilesAPI() throws Exception
+ {
+ RecordCategoryChild heldRecordFolder = createFolder(recordCategory.getId(), getRandomName("heldRecordFolder"));
+ rmRolesAndActionsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME,
+ "hold reason", "hold description");
+ rmRolesAndActionsAPI.addItemToHold(getAdminUser().getUsername(), getAdminUser().getPassword(),
+ heldRecordFolder.getId(), HOLD_NAME);
+
+ STEP("Declare document as record with a frozen location parameter value");
+ getRestAPIFactory().getFilesAPI()
+ .usingParams(String.format("%s=%s", PARENT_ID_PARAM, heldRecordFolder.getId()))
+ .declareAsRecord(testFile.getNodeRefWithoutVersion());
+ assertStatusCode(UNPROCESSABLE_ENTITY);
+
+ STEP("Check that the file is not a record");
+ assertFalse(hasRecordAspect(testFile), "File should not have record aspect");
+ }
+
/**
* Given I declare a record using the v1 API
* When I provide a location parameter
From 8f49086a060d37d94023819b8298f212036ebae8 Mon Sep 17 00:00:00 2001
From: cagache
Date: Thu, 16 May 2019 14:27:13 +0300
Subject: [PATCH 24/25] Updated exception message
---
.../files/DeclareAndFileDocumentAsRecordTests.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
index ca6aaab85a..ab89fe6869 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java
@@ -82,7 +82,7 @@ import org.testng.annotations.Test;
@AlfrescoTest (jira = "RM-6779")
public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{
- private final static String DESTINATION_PATH_NOT_RESOLVED_EXC = "Unable to execute create-record action, because the destination path could not be resolved.";
+ private final static String DESTINATION_PATH_NOT_FOUND_EXC = "Unable to execute create-record action, because the destination path could not be found.";
private final static String INVALID_DESTINATION_PATH_EXC = "Unable to execute create-record action, because the destination path is invalid.";
private final static String DESTINATION_PATH_NOT_RECORD_FOLDER_EXC = "Unable to execute create-record action, because the destination path is not a record folder.";
private final static String CLOSED_RECORD_FOLDER_EXC = "Unable to create record, because container is closed";
@@ -113,18 +113,18 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
{
return new String[][]
{
- { "/", DESTINATION_PATH_NOT_RESOLVED_EXC},
+ { "/", DESTINATION_PATH_NOT_FOUND_EXC },
{ "Unfiled Records", INVALID_DESTINATION_PATH_EXC },
{ "Transfers", INVALID_DESTINATION_PATH_EXC },
{ "Holds", INVALID_DESTINATION_PATH_EXC },
- { "rm/documentlibrary", DESTINATION_PATH_NOT_RESOLVED_EXC },
+ { "rm/documentlibrary", DESTINATION_PATH_NOT_FOUND_EXC },
{ recordCategory.getName(), DESTINATION_PATH_NOT_RECORD_FOLDER_EXC },
// a closed record folder
{ Utility.buildPath(recordCategory.getName(), closedRecordFolder.getName()), CLOSED_RECORD_FOLDER_EXC},
// an arbitrary unfiled records folder
{ "Unfiled Records/" + unfiledContainerFolder.getName(), INVALID_DESTINATION_PATH_EXC },
// a collaboration site folder
- { testFolder.getCmisLocation(), DESTINATION_PATH_NOT_RESOLVED_EXC }
+ { testFolder.getCmisLocation(), DESTINATION_PATH_NOT_FOUND_EXC }
};
}
From 284ea22322d4b042122575718614efe0e0b08354 Mon Sep 17 00:00:00 2001
From: cagache
Date: Mon, 20 May 2019 16:58:35 +0300
Subject: [PATCH 25/25] addressed code review comments
---
.../main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java
index 94e0b25269..2a98261c7e 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java
@@ -465,8 +465,7 @@ public class RMRolesAndActionsAPI extends BaseAPI
public HttpResponse createHold(String user, String password, String holdName, String reason, String description)
{
// if the hold already exists don't try to create it again
- final String holdsContainerPath = Utility.buildPath(getFilePlanPath(), HOLDS_CONTAINER);
- final String fullHoldPath = holdsContainerPath + holdName;
+ final String fullHoldPath = Utility.buildPath(getFilePlanPath(), HOLDS_CONTAINER) + holdName;
final CmisObject hold = getObjectByPath(user, password, fullHoldPath);
if (hold != null)
{