mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Delete hold using RM Actions API
This commit is contained in:
@@ -38,6 +38,7 @@ import org.alfresco.rest.core.v0.APIUtils;
|
||||
import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldEntry;
|
||||
import org.alfresco.rest.rm.community.util.PojoUtility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.ParseException;
|
||||
import org.json.JSONArray;
|
||||
@@ -144,7 +145,36 @@ public class HoldsAPI extends BaseAPI
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes hold
|
||||
* Deletes hold using RM Actions API and expect action to be successful
|
||||
*
|
||||
* @param user the user who does the request
|
||||
* @param holdNodeRef the hold node ref
|
||||
* @return The HTTP Response or throws AssertionError if the request is not successful.
|
||||
*/
|
||||
public HttpResponse deleteHold(UserModel user, String holdNodeRef)
|
||||
{
|
||||
return deleteHold(user.getUsername(), user.getPassword(), holdNodeRef, SC_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes hold using RM Actions API and expect a specific status code
|
||||
*
|
||||
* @param username user's username
|
||||
* @param password its password
|
||||
* @param holdNodeRef the hold node ref
|
||||
* @return The HTTP Response or throws AssertionError if the returned status code is not as expected.
|
||||
*/
|
||||
public HttpResponse deleteHold(String username, String password, String holdNodeRef, int expectedStatusCode)
|
||||
{
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "deleteHold");
|
||||
requestParams.put("nodeRef", getNodeRefSpacesStore() + holdNodeRef);
|
||||
|
||||
return doPostJsonRequest(username, password, expectedStatusCode, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes hold using cmis
|
||||
*
|
||||
* @param username user's username
|
||||
* @param password its password
|
||||
|
@@ -32,9 +32,8 @@ import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.DELETE_HOLD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||
import static org.testng.AssertJUnit.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -100,12 +99,13 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
||||
public void deleteHoldEventIsAudited()
|
||||
{
|
||||
STEP("Create a new hold.");
|
||||
holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION);
|
||||
String holdRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2,
|
||||
HOLD_REASON, HOLD_DESCRIPTION);
|
||||
|
||||
rmAuditService.clearAuditLog();
|
||||
|
||||
STEP("Delete the created hold.");
|
||||
holdsAPI.deleteHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2);
|
||||
holdsAPI.deleteHold(rmAdmin, holdRef);
|
||||
|
||||
STEP("Check the audit log contains the entry for the deleted hold with the hold details.");
|
||||
rmAuditService.checkAuditLogForEvent(getAdminUser(), DELETE_HOLD, rmAdmin, HOLD2,
|
||||
@@ -118,13 +118,12 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
||||
* Then the delete hold event isn't audited
|
||||
*/
|
||||
@Test
|
||||
public void unsuccessfulDeleteHoldIsNotAudited() throws Exception
|
||||
public void unsuccessfulDeleteHoldIsNotAudited()
|
||||
{
|
||||
rmAuditService.clearAuditLog();
|
||||
|
||||
STEP("Try to delete a hold by an user with no Read permissions over the hold.");
|
||||
getRestAPIFactory().getNodeAPI(rmManager, toContentModel(holdNodeRef)).deleteNode(holdNodeRef);
|
||||
assertStatusCode(FORBIDDEN);
|
||||
holdsAPI.deleteHold(rmManager.getUsername(), rmManager.getPassword(), holdNodeRef, SC_INTERNAL_SERVER_ERROR);
|
||||
|
||||
STEP("Check the audit log doesn't contain the entry for the unsuccessful delete hold.");
|
||||
assertTrue("The list of events should not contain Delete Hold entry ",
|
||||
@@ -140,12 +139,13 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
||||
public void deleteHoldAuditEntryNotVisible()
|
||||
{
|
||||
STEP("Create a new hold.");
|
||||
holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION);
|
||||
String holdRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON,
|
||||
HOLD_DESCRIPTION);
|
||||
|
||||
rmAuditService.clearAuditLog();
|
||||
|
||||
STEP("Delete the created hold.");
|
||||
holdsAPI.deleteHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2);
|
||||
holdsAPI.deleteHold(rmAdmin, holdRef);
|
||||
|
||||
STEP("Check that an user with no Read permissions over the hold can't see the entry for the delete hold event.");
|
||||
assertTrue("The list of events should not contain Delete Hold entry ",
|
||||
|
Reference in New Issue
Block a user