use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project records-management by Alfresco.
the class RMCaveatConfigScriptTest method testDeleteRMConstraint.
/**
* Delete the entire constraint
*
* @throws Exception
*/
public void testDeleteRMConstraint() throws Exception {
/**
* Delete the list to remove any junk then recreate it.
*/
if (caveatConfigService.getRMConstraint(RM_LIST) != null) {
caveatConfigService.deleteRMConstraint(RM_LIST);
}
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Now do a delete
*/
Response response = sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST), Status.STATUS_OK);
/**
* Now delete the list that should have been deleted
*/
// TODO NEED TO THINK ABOUT THIS BEHAVIOUR
// {
// sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + RM_LIST), Status.STATUS_NOT_FOUND);
// }
/**
* Negative test - delete list that does not exist
*/
{
sendRequest(new DeleteRequest(URL_RM_CONSTRAINTS + "/" + "rmc_wibble"), Status.STATUS_NOT_FOUND);
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project records-management by Alfresco.
the class EventRestApiTest method testDeleteRole.
public void testDeleteRole() throws Exception {
String eventName = GUID.generate();
assertFalse(eventService.existsEvent(eventName));
eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL);
assertTrue(eventService.existsEvent(eventName));
sendRequest(new DeleteRequest(GET_EVENTS_URL + "/" + eventName), 200);
assertFalse(eventService.existsEvent(eventName));
// Bad request
sendRequest(new DeleteRequest(GET_EVENTS_URL + "/cheese"), 404);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project alfresco-remote-api by Alfresco.
the class FeedControlTest method deleteFeedControl.
protected void deleteFeedControl(String siteId, String appToolId) throws Exception {
// Unset (delete) feed control
int expectedStatus = 200;
Response response = sendRequest(new DeleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID), expectedStatus);
if (logger.isDebugEnabled()) {
logger.debug(response);
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project alfresco-remote-api by Alfresco.
the class NodeArchiveServiceRestApiTest method testPurgeDeletedItemsAsNonAdminUser.
/**
* This test method purges some deleted nodes from the archive store for the current user.
*/
public void testPurgeDeletedItemsAsNonAdminUser() throws Exception {
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
String deleteUrl = getArchiveUrl(user2_DeletedTestNode.getStoreRef()) + "/" + user2_DeletedTestNode.getId();
// User_One has the nodeRef of the node deleted by User_Two. User_One is
// not an Admin, so he must not be allowed to purge a node which he doesn’t own.
Response rsp = sendRequest(new DeleteRequest(deleteUrl), 403);
assertEquals(403, rsp.getStatus());
// Now User_One gets his own archived node and tries to purge it
JSONObject jsonRsp = getArchivedNodes();
JSONObject dataObj = (JSONObject) jsonRsp.get(DATA);
JSONArray deletedNodesArray = (JSONArray) dataObj.get(AbstractArchivedNodeWebScript.DELETED_NODES);
// User_One deleted only 1 node and he doesn't have permission to see other users' archived data.
assertEquals("Unexpectedly found more than 1 item in the archive store.", 1, deletedNodesArray.length());
JSONObject archivedNode = (JSONObject) deletedNodesArray.get(0);
// So we have identified a specific Node in the archive that we want to delete permanently (purge).
String nodeRefString = archivedNode.getString(AbstractArchivedNodeWebScript.NODEREF);
assertTrue("nodeRef string is invalid", NodeRef.isNodeRef(nodeRefString));
NodeRef nodeRef = new NodeRef(nodeRefString);
// This is its current StoreRef i.e. archive://SpacesStore
deleteUrl = getArchiveUrl(nodeRef.getStoreRef()) + "/" + nodeRef.getId();
// Send the DELETE REST call.
rsp = sendRequest(new DeleteRequest(deleteUrl), 200);
jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
dataObj = jsonRsp.getJSONObject("data");
JSONArray purgedNodesArray = dataObj.getJSONArray(ArchivedNodesDelete.PURGED_NODES);
assertEquals("Only expected one NodeRef to have been purged.", 1, purgedNodesArray.length());
// User_Two is authenticated
AuthenticationUtil.setFullyAuthenticatedUser(USER_TWO);
// Now we'll purge all the nodes in the archive that User_Two owns.
// This should only purge USER_TWO's archived nodes.
String deleteAllUrl = getArchiveUrl(this.nodesOriginalStoreRef);
rsp = sendRequest(new DeleteRequest(deleteAllUrl), 200);
jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
dataObj = jsonRsp.getJSONObject("data");
purgedNodesArray = dataObj.getJSONArray(ArchivedNodesDelete.PURGED_NODES);
// User_Two deleted only 1 node.
assertEquals("Only expected one NodeRef to have been purged.", 1, purgedNodesArray.length());
// Test no other nodes have been deleted by User_Two 'Delete all archived nodes operation'.
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
jsonRsp = getArchivedNodes();
dataObj = (JSONObject) jsonRsp.get(DATA);
assertNotNull("JSON 'data' object was null", dataObj);
deletedNodesArray = (JSONArray) dataObj.get(AbstractArchivedNodeWebScript.DELETED_NODES);
assertNotNull("JSON 'deletedNodesArray' object was null", deletedNodesArray);
assertEquals("There is 1 item in the archive store which was deleted by the Admin.", 1, deletedNodesArray.length());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project alfresco-remote-api by Alfresco.
the class AbstractWorkflowRestApiTest method testWorkflowInstanceDeleteAsAdministrator.
public void testWorkflowInstanceDeleteAsAdministrator() throws Exception {
// Start workflow as USER1
personManager.setUser(USER1);
WorkflowDefinition adhocDef = workflowService.getDefinitionByName(getAdhocWorkflowDefinitionName());
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
params.put(WorkflowModel.ASSOC_ASSIGNEE, personManager.get(USER2));
Date dueDate = new Date();
params.put(WorkflowModel.PROP_DUE_DATE, dueDate);
params.put(WorkflowModel.PROP_PRIORITY, 1);
params.put(WorkflowModel.ASSOC_PACKAGE, packageRef);
params.put(WorkflowModel.PROP_CONTEXT, packageRef);
WorkflowPath adhocPath = workflowService.startWorkflow(adhocDef.getId(), params);
WorkflowTask startTask = workflowService.getTasksForWorkflowPath(adhocPath.getId()).get(0);
startTask = workflowService.endTask(startTask.getId(), null);
WorkflowInstance adhocInstance = startTask.getPath().getInstance();
// Run next request as admin
String admin = authenticationComponent.getDefaultAdministratorUserNames().iterator().next();
AuthenticationUtil.setFullyAuthenticatedUser(admin);
sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + adhocInstance.getId()), Status.STATUS_OK);
WorkflowInstance instance = workflowService.getWorkflowById(adhocInstance.getId());
if (instance != null) {
assertFalse("The deleted workflow is still active!", instance.isActive());
}
List<WorkflowInstance> instances = workflowService.getActiveWorkflows(adhocInstance.getDefinition().getId());
for (WorkflowInstance activeInstance : instances) {
assertFalse(adhocInstance.getId().equals(activeInstance.getId()));
}
}
Aggregations