mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
[APPS-1242] (#985)
* [APPS-1242] * [APPS-1242]-Commenting reduntant changes. * [APPS-1242]-Removed unused code * [APPS-1242]-Removed unused code * [APPS-1242]-Changes with respect to review comments Co-authored-by: shubhamjain10 <shubham.jain@globallogic.com>
This commit is contained in:
@@ -73,4 +73,5 @@ public class RecordFoldersAPI extends BaseAPI
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -114,11 +114,11 @@ 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 user the user declaring the document as record
|
||||
* @param password the user's password
|
||||
* @param expectedStatusCode The expected return status code.
|
||||
* @param recordName the record name
|
||||
* @param reason reject reason
|
||||
* @param recordName the record name
|
||||
* @param reason reject reason
|
||||
* @return The HTTP Response.
|
||||
* @throws AssertionError If the expectedStatusCode was not returned.
|
||||
*/
|
||||
@@ -129,8 +129,8 @@ public class RecordsAPI extends BaseAPI
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "reject");
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
requestParams.put("params",new JSONObject()
|
||||
.put("reason",reason));
|
||||
requestParams.put("params", new JSONObject()
|
||||
.put("reason", reason));
|
||||
|
||||
return doPostJsonRequest(user, password, expectedStatusCode, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
@@ -221,6 +221,7 @@ public class RecordsAPI extends BaseAPI
|
||||
* Uploads an electronic record
|
||||
* <p>
|
||||
* eg. of usage for creating record directly in Unfiled Records : uploadElectronicRecord(getAdminName(), getAdminPassword(), recordPropertiesStringMap, UNFILED_RECORDS_BREADCRUMB, DocumentType.HTML)
|
||||
*
|
||||
* @param username the username
|
||||
* @param password the password
|
||||
* @param properties a map of record properties and their values
|
||||
@@ -241,6 +242,7 @@ public class RecordsAPI extends BaseAPI
|
||||
* <li>eg. of usage in the case in which the record is inside a folder in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, "unfiled records folder");
|
||||
* <li>eg. of usage in the case in which the record is created directly in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, "");
|
||||
* </ul>
|
||||
*
|
||||
* @param username user's username
|
||||
* @param password its password
|
||||
* @param recordName the record name
|
||||
@@ -267,7 +269,7 @@ public class RecordsAPI extends BaseAPI
|
||||
* @param recordName the String with which the record name starts
|
||||
* @return the record object in case it exists, null otherwise
|
||||
*/
|
||||
private CmisObject getRecord(String username, String password, String folderName, String recordName)
|
||||
public CmisObject getRecord(String username, String password, String folderName, String recordName)
|
||||
{
|
||||
for (CmisObject record : contentService.getFolderObject(contentService.getCMISSession(username, password), RM_SITE_ID, folderName).getChildren())
|
||||
{
|
||||
@@ -328,9 +330,9 @@ public class RecordsAPI extends BaseAPI
|
||||
/**
|
||||
* Hide in place record
|
||||
*
|
||||
* @param user the user
|
||||
* @param password the user's password
|
||||
* @param nodeId the in place record node id
|
||||
* @param user the user
|
||||
* @param password the user's password
|
||||
* @param nodeId the in place record node id
|
||||
* @return The HTTP Response.
|
||||
*/
|
||||
public HttpResponse hideRecord(String user, String password, String nodeId)
|
||||
@@ -344,6 +346,7 @@ public class RecordsAPI extends BaseAPI
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, ACTIONS_API);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the record's nodeRef
|
||||
*
|
||||
|
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 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.records;
|
||||
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.core.v0.BaseAPI.RMProperty;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Contains CreateNonElectronicRecords test which checks creation and basic actions(view details, edit, move, copy, delete) on non-electronic records
|
||||
* <p/>
|
||||
* Precondition:
|
||||
* <p/>
|
||||
* RM site created, contains category 1 with folder 1 and folder 2 inside it
|
||||
* <p/>
|
||||
* RM user has RM admin role
|
||||
*
|
||||
* @author Shubham Jain
|
||||
* @Since 7.2.0 M2
|
||||
*/
|
||||
public class CreateNonElectronicRecordsTests extends BaseRMRestTest
|
||||
{
|
||||
private RecordCategory rootCategory;
|
||||
|
||||
private RecordCategoryChild recordFolder;
|
||||
|
||||
/**
|
||||
* data prep services
|
||||
*/
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
|
||||
@Autowired
|
||||
private RecordsAPI recordsAPI;
|
||||
|
||||
private final String TEST_PREFIX = generateTestPrefix(CreateNonElectronicRecordsTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private final String recordName = "RM-2777 record";
|
||||
private final String recordTitle = recordName + " title";
|
||||
private final String recordDescription = recordName + " description";
|
||||
|
||||
|
||||
@BeforeClass (alwaysRun = true)
|
||||
public void preConditions()
|
||||
{
|
||||
STEP("Create RM Site");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
|
||||
STEP("Create root level category");
|
||||
rootCategory = createRootCategory(getRandomName("Category"));
|
||||
|
||||
STEP("Create the record folder inside the rootCategory");
|
||||
recordFolder = createRecordFolder(rootCategory.getId(), getRandomName("Folder"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test v0 methods to create and get non-electronic records.
|
||||
*/
|
||||
@Test
|
||||
@AlfrescoTest (jira = "RM-2777")
|
||||
public void createNonElectronicRecordTest()
|
||||
{
|
||||
STEP("Create a non-electronic record by completing some of the fields");
|
||||
Map<Enum<?>, String> properties = new HashMap<Enum<?>, String>();
|
||||
properties.put(RMProperty.TITLE, recordTitle);
|
||||
properties.put(RMProperty.DESCRIPTION, recordDescription);
|
||||
properties.put(RMProperty.NAME, recordName);
|
||||
properties.put(RMProperty.PHYSICAL_SIZE, "");
|
||||
properties.put(RMProperty.NUMBER_OF_COPIES, "");
|
||||
properties.put(RMProperty.SHELF, "");
|
||||
properties.put(RMProperty.STORAGE_LOCATION, "");
|
||||
properties.put(RMProperty.BOX, "");
|
||||
properties.put(RMProperty.FILE, "");
|
||||
|
||||
recordsAPI.createNonElectronicRecord(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), properties, rootCategory.getName(), recordFolder.getName());
|
||||
|
||||
STEP("Check the non-electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
assertNotNull(recordsAPI.getRecord(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
||||
recordFolder.getName(), recordName));
|
||||
|
||||
}
|
||||
|
||||
@AfterClass (alwaysRun = true)
|
||||
public void deletePreConditions()
|
||||
{
|
||||
STEP("Delete the created rootCategory along with corresponding record folders/records present in it");
|
||||
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(rootCategory.getId());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user