Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 3f32cee

Browse files
committed
#409 Fixing deleteTaskWithPath
1 parent 3d62f20 commit 3f32cee

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/main/java/com/marklogic/mgmt/resource/tasks/TaskManager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected String getResourceId(String payload) {
6565
"task-path and task-database, but payload is missing a task-root to determine which existing task is " +
6666
"the same root; payload: " + payload);
6767
}
68+
6869
for (String resourceId : resourceIds) {
6970
String json = getManageClient().getJson(appendGroupId(super.getResourcesPath() + "/" + resourceId + "/properties"));
7071
String thisTaskRoot = payloadParser.getPayloadFieldValue(json, "task-root", false);
@@ -252,8 +253,17 @@ public void deleteAllTasks() {
252253
deleteAllScheduledTasks();
253254
}
254255

256+
/**
257+
* @param taskPath
258+
*/
259+
@Deprecated(since = "Deprecated since 4.0.2, as the taskPath may not suffice for uniquely identifying a task. " +
260+
"This now assumes a task root of '/' to at least avoid an error being thrown.")
255261
public void deleteTaskWithPath(String taskPath) {
256-
String json = format("{\"task-path\":\"%s\"}", taskPath);
262+
deleteTaskWithPath(taskPath, "/");
263+
}
264+
265+
public void deleteTaskWithPath(String taskPath, String taskRoot) {
266+
String json = format("{\"task-path\":\"%s\", \"task-root\":\"%s\"}", taskPath, taskRoot);
257267
delete(json, "group-id", groupName);
258268
}
259269

src/test/java/com/marklogic/appdeployer/export/ExportTasksTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public void test() {
3030
assertEquals("query.xqy.json", resources.getFiles().get(0).getName());
3131

3232
TaskManager mgr = new TaskManager(manageClient);
33-
mgr.deleteTaskWithPath(taskPath);
33+
mgr.deleteTaskWithPath(taskPath, "/");
3434
assertFalse(mgr.exists(taskPath));
3535

3636
appConfig.getFirstConfigDir().setBaseDir(exportDir);
3737
deploySampleApp();
3838
assertTrue(mgr.exists(taskPath));
3939

40-
mgr.deleteTaskWithPath(taskPath);
40+
mgr.deleteTaskWithPath(taskPath, "/");
4141
assertFalse(mgr.exists(taskPath));
4242
}
4343
}

0 commit comments

Comments
 (0)