Merge branch 'feature/RM-5457_AutomateAC' into feature/RM-5458_Tests_Prevent_FolderClassification

# Conflicts:
#	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/module/alfresco-rm-enterprise-repo/messages/classified-content/classified-content.properties
This commit is contained in:
Rodica Sutu
2017-10-06 10:34:23 +03:00
7 changed files with 155 additions and 6 deletions

View File

@@ -15,7 +15,7 @@
<maven.build.sourceVersion>1.8</maven.build.sourceVersion>
<alfresco.rm.share>alfresco-rm-community-share</alfresco.rm.share>
<alfresco.rm.repo>alfresco-rm-community-repo</alfresco.rm.repo>
<tas.restapi.version>5.2.0-9</tas.restapi.version>
<tas.restapi.version>5.2.0-10</tas.restapi.version>
<fluent.json.version>2.0.0</fluent.json.version>
</properties>

View File

@@ -26,11 +26,12 @@
*/
package org.alfresco.rest.rm.community.model.common;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.alfresco.utility.model.TestModel;
/**
* POJO for owner parameter
@@ -43,6 +44,7 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
//@NoArgsConstructor
//@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class Owner extends TestModel
{

View File

@@ -30,7 +30,10 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.IRestModel;
import org.alfresco.rest.core.assertion.ModelAssertion;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.model.RestNodeModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
@@ -51,7 +54,7 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Record extends TestModel
public class Record extends TestModel implements IRestModel<RestNodeModel>
{
public final static String CONTENT_NODE_TYPE = "cm:content";
@@ -102,4 +105,25 @@ public class Record extends TestModel
@JsonProperty
private Path path;
@Override
public ModelAssertion<RestNodeModel> assertThat()
{
return new ModelAssertion<RestNodeModel>(this);
}
@Override
public ModelAssertion<RestNodeModel> and()
{
return assertThat();
}
@JsonProperty (value = "entry")
RestNodeModel model;
@Override
public RestNodeModel onModel()
{
return model;
}
}

View File

@@ -114,6 +114,35 @@ public class RecordsAPI extends BaseAPI
}
/**
* Reject the record given as parameter
*
* @param user the user declaring the document as record
* @param password the user's password
* @param recordName the record name
* @param reason reject reason
* @return true if the action completed successfully
*/
public boolean rejectRecord(String user, String password, String recordName, String reason)
{
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
try
{
JSONObject requestParams = new JSONObject();
requestParams.put("name", "reject");
requestParams.put("nodeRef", recNodeRef);
requestParams.put("params",new JSONObject()
.put("reason",reason));
return doPostJsonRequest(user, password, requestParams, RM_ACTIONS_API);
}
catch (JSONException error)
{
LOGGER.error("Unable to extract response parameter", error);
}
return false;
}
/**
* Declare document version as record
*

View File

@@ -27,7 +27,6 @@
package org.alfresco.rest.rm.community.base;
import static lombok.AccessLevel.PROTECTED;
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
@@ -39,8 +38,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_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.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
@@ -54,10 +51,12 @@ import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.alfresco.dataprep.ContentService;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestAPIFactory;
import org.alfresco.rest.model.RestNodeModel;
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.model.record.Record;
@@ -77,6 +76,7 @@ import org.alfresco.rest.search.SearchNodeModel;
import org.alfresco.rest.search.SearchRequest;
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.ContentModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.UserModel;
@@ -615,4 +615,39 @@ public class BaseRMRestTest extends RestTest
}
return names;
}
/**
* Helper method to return site document library content model
*
* @return ContentModel
* @throws Exception
*/
public ContentModel getDocumentLibrary(UserModel usermodel, SiteModel testSite) throws Exception
{
ContentModel siteModel = new ContentModel();
siteModel.setNodeRef(testSite.getGuid());
restClient.authenticateUser(usermodel);
List<RestNodeModel> nodes = restClient.withCoreAPI().usingNode(siteModel)
.listChildren().getEntries().stream().collect(Collectors.toList());
ContentModel documentLibrary = new ContentModel();
documentLibrary.setName(nodes.get(0).onModel().getName());
documentLibrary.setNodeRef(nodes.get(0).onModel().getId());
return documentLibrary;
}
/**
* Helper method to create a Content Model
*
* @return ContentModel
* @throws Exception
*/
public ContentModel toContentModel(String nodeId)
{
ContentModel node = new ContentModel();
node.setNodeRef(nodeId);
return node;
}
}

View File

@@ -0,0 +1,56 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.utils;
import org.alfresco.rest.model.RestNodeBodyMoveCopyModel;
/**
* Utility class for core components models
*
* @author Rodica Sutu
* @since 2.6
*/
public class CoreUtil
{
private CoreUtil()
{
// Intentionally blank
}
/**
* Creates a body model for move/copy with the given the target node id
*
* @param nodeId The node id
* @return The {@link RestNodeBodyMoveCopyModel} with for the given node id
*/
public static RestNodeBodyMoveCopyModel createBodyForMoveCopy(String nodeId)
{
RestNodeBodyMoveCopyModel moveDestinationInfo = new RestNodeBodyMoveCopyModel();
moveDestinationInfo.setTargetParentId(nodeId);
return moveDestinationInfo;
}
}

View File

@@ -70,6 +70,7 @@ import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.DocumentLinkService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -147,6 +148,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected ActionService actionService;
protected OwnableService ownableService;
protected VersionService versionService;
protected DocumentLinkService documentLinkService;
/** RM Services */
protected DispositionService dispositionService;
@@ -388,6 +390,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
actionService = (ActionService)applicationContext.getBean("ActionService");
ownableService = (OwnableService)applicationContext.getBean("OwnableService");
versionService = (VersionService)applicationContext.getBean("VersionService");
documentLinkService = (DocumentLinkService)applicationContext.getBean("DocumentLinkService");
// Get RM services
dispositionService = (DispositionService)applicationContext.getBean("DispositionService");