Skip to content

Commit

Permalink
#409 Fixing deleteTaskWithPath
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrudin committed Jun 4, 2020
1 parent 3d62f20 commit 3f32cee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/main/java/com/marklogic/mgmt/resource/tasks/TaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected String getResourceId(String payload) {
"task-path and task-database, but payload is missing a task-root to determine which existing task is " +
"the same root; payload: " + payload);
}

for (String resourceId : resourceIds) {
String json = getManageClient().getJson(appendGroupId(super.getResourcesPath() + "/" + resourceId + "/properties"));
String thisTaskRoot = payloadParser.getPayloadFieldValue(json, "task-root", false);
Expand Down Expand Up @@ -252,8 +253,17 @@ public void deleteAllTasks() {
deleteAllScheduledTasks();
}

/**
* @param taskPath
*/
@Deprecated(since = "Deprecated since 4.0.2, as the taskPath may not suffice for uniquely identifying a task. " +
"This now assumes a task root of '/' to at least avoid an error being thrown.")
public void deleteTaskWithPath(String taskPath) {
String json = format("{\"task-path\":\"%s\"}", taskPath);
deleteTaskWithPath(taskPath, "/");
}

public void deleteTaskWithPath(String taskPath, String taskRoot) {
String json = format("{\"task-path\":\"%s\", \"task-root\":\"%s\"}", taskPath, taskRoot);
delete(json, "group-id", groupName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public void test() {
assertEquals("query.xqy.json", resources.getFiles().get(0).getName());

TaskManager mgr = new TaskManager(manageClient);
mgr.deleteTaskWithPath(taskPath);
mgr.deleteTaskWithPath(taskPath, "/");
assertFalse(mgr.exists(taskPath));

appConfig.getFirstConfigDir().setBaseDir(exportDir);
deploySampleApp();
assertTrue(mgr.exists(taskPath));

mgr.deleteTaskWithPath(taskPath);
mgr.deleteTaskWithPath(taskPath, "/");
assertFalse(mgr.exists(taskPath));
}
}

0 comments on commit 3f32cee

Please sign in to comment.