You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by ma...@apache.org on 2015/12/04 14:01:35 UTC

syncope git commit: Added delete all propagation tasks and bugfix on delete propagation, SYNCOPE-158

Repository: syncope
Updated Branches:
  refs/heads/master 2080b51c5 -> fa91567d7


Added delete all propagation tasks and bugfix on delete propagation, SYNCOPE-158


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/fa91567d
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/fa91567d
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/fa91567d

Branch: refs/heads/master
Commit: fa91567d71b7e62cbb4c88a3ad9a70e2de7bd97d
Parents: 2080b51
Author: massi <ma...@tirasa.net>
Authored: Fri Dec 4 14:00:44 2015 +0100
Committer: massi <ma...@tirasa.net>
Committed: Fri Dec 4 14:00:59 2015 +0100

----------------------------------------------------------------------
 .../client/cli/commands/task/TaskCommand.java   |  4 ++
 .../cli/commands/task/TaskDeleteAllProp.java    | 66 ++++++++++++++++++++
 .../commands/task/TaskSyncopeOperations.java    |  6 +-
 .../cli/src/main/resources/messages.properties  |  2 +-
 4 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/fa91567d/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskCommand.java
index 074e17c..903cbfc 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskCommand.java
@@ -58,6 +58,9 @@ public class TaskCommand extends AbstractCommand {
             case DELETE:
                 new TaskDelete(input).delete();
                 break;
+            case DELETE_PROP_TASK:
+                new TaskDeleteAllProp(input).delete();
+                break;
             case DELETE_EXECUTION:
                 new TaskExecutionDelete(input).delete();
                 break;
@@ -87,6 +90,7 @@ public class TaskCommand extends AbstractCommand {
         READ("--read"),
         READ_EXECUTION("--read-execution"),
         DELETE("--delete"),
+        DELETE_PROP_TASK("--delete-all-prop"),
         DELETE_EXECUTION("--delete-execution"),
         EXECUTE("--execute");
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/fa91567d/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskDeleteAllProp.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskDeleteAllProp.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskDeleteAllProp.java
new file mode 100644
index 0000000..4f41428
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskDeleteAllProp.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.task;
+
+import javax.xml.ws.WebServiceException;
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.AbstractTaskTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TaskDeleteAllProp extends AbstractTaskCommand {
+
+    private static final Logger LOG = LoggerFactory.getLogger(TaskDeleteAllProp.class);
+
+    private static final String DELETE_HELP_MESSAGE = "task --delete-all-prop";
+
+    private final Input input;
+
+    public TaskDeleteAllProp(final Input input) {
+        this.input = input;
+    }
+
+    public void delete() {
+
+        if (input.parameterNumber() == 0) {
+            for (final AbstractTaskTO taskTO : taskSyncopeOperations.listPropagationTask()) {
+                final String taskId = String.valueOf(taskTO.getKey());
+                try {
+                    taskSyncopeOperations.delete(taskId);
+                    taskResultManager.deletedMessage("Task", taskId);
+                } catch (final WebServiceException | SyncopeClientException ex) {
+                    LOG.error("Error deleting task", ex);
+                    if (ex.getMessage().startsWith("NotFound")) {
+                        taskResultManager.notFoundError("Task", taskId);
+                    } else if (ex.getMessage().startsWith("DataIntegrityViolation")) {
+                        taskResultManager.genericError("You cannot delete task " + taskId);
+                    } else {
+                        taskResultManager.genericError(ex.getMessage());
+                    }
+                } catch (final NumberFormatException ex) {
+                    LOG.error("Error deleting task", ex);
+                    taskResultManager.notBooleanDeletedError("task", taskId);
+                }
+            }
+        } else {
+            taskResultManager.commandOptionError(DELETE_HELP_MESSAGE);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/fa91567d/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskSyncopeOperations.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskSyncopeOperations.java
index 8937e71..8a2ec62 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskSyncopeOperations.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskSyncopeOperations.java
@@ -44,12 +44,16 @@ public class TaskSyncopeOperations {
     }
 
     public void delete(final String taskId) {
-        taskService.read(Long.valueOf(taskId));
+        taskService.delete(Long.valueOf(taskId));
     }
 
     public List<AbstractTaskTO> list(final String type) {
         return taskService.list(new TaskQuery.Builder().type(TaskType.valueOf(type)).build()).getResult();
     }
+    
+    public List<AbstractTaskTO> listPropagationTask() {
+        return taskService.list(new TaskQuery.Builder().type(TaskType.PROPAGATION).build()).getResult();
+    }
 
     public TaskExecTO readExecution(final String executionId) {
         return taskService.readExecution(Long.valueOf(executionId));

http://git-wip-us.apache.org/repos/asf/syncope/blob/fa91567d/client/cli/src/main/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/cli/src/main/resources/messages.properties b/client/cli/src/main/resources/messages.properties
index 4bf32ef..acd35ab 100644
--- a/client/cli/src/main/resources/messages.properties
+++ b/client/cli/src/main/resources/messages.properties
@@ -29,6 +29,6 @@ report.help.message=\nUsage: report [options]\n  Options:\n    --help \n    --de
 resource.help.message=\nUsage: resource [options]\n  Options:\n    --help \n    --details \n    --list \n    --read \n       Syntax: --read {RESOURCE-NAME} {RESOURCE-NAME} [...]\n    --delete \n       Syntax: --delete {RESOURCE-NAME} {RESOURCE-NAME} [...]\n
 role.help.message=\nUsage: role [options]\n  Options:\n    --help \n    --details \n    --list \n    --read \n       Syntax: --read {ROLE-ID} {ROLE-ID} [...]\n    --delete \n       Syntax: --delete {ROLE-ID} {ROLE-ID} [...]\n
 schema.help.message=\nUsage: schema [options]\n  Options:\n    --help \n    --details \n    --list-all\n    --list-plain\n    --list-derived\n    --list-virtual\n    --read {SCHEMA-TYPE} {SCHEMA-KEY}\n        Schema type: PLAIN / DERIVED / VIRTUAL\n    --delete {SCHEMA-TYPE} {SCHEMA-KEY}\n        Schema type: PLAIN / DERIVED / VIRTUAL\n
-task.help.message=\nUsage: task [options]\n  Options:\n    --help \n    --details\n    --list\n       Syntax: --list {TASK-TYPE} \n          Task type: NOTIFICATION / PROPAGATION / PUSH / SCHEDULED / SYNCHRONIZATION\n    --list-running-jobs \n    --list-scheduled-jobs \n    --read \n       Syntax: --read {TASK-ID} {TASK-ID} [...]\n    --read-execution \n       Syntax: --read-execution {TASK-EXEC-ID} {TASK-EXEC-ID} [...]\n    --delete \n       Syntax: --delete {TASK-ID} {TASK-ID} [...]\n    --delete-execution \n       Syntax: --delete-execution {TASK-EXEC-ID} {TASK-EXEC-ID} [...]\n    --execute \n       Syntax: --execute {TASK-ID} {DRY-RUN}\n          Dry run: true / false\n
+task.help.message=\nUsage: task [options]\n  Options:\n    --help \n    --details\n    --list\n       Syntax: --list {TASK-TYPE} \n          Task type: NOTIFICATION / PROPAGATION / PUSH / SCHEDULED / SYNCHRONIZATION\n    --list-running-jobs \n    --list-scheduled-jobs \n    --read \n       Syntax: --read {TASK-ID} {TASK-ID} [...]\n    --read-execution \n       Syntax: --read-execution {TASK-EXEC-ID} {TASK-EXEC-ID} [...]\n    --delete \n       Syntax: --delete {TASK-ID} {TASK-ID} [...]\n    --delete-all-prop\n    --delete-execution \n       Syntax: --delete-execution {TASK-EXEC-ID} {TASK-EXEC-ID} [...]\n    --execute \n       Syntax: --execute {TASK-ID} {DRY-RUN}\n          Dry run: true / false\n
 user.help.message=\nUsage: user [options]\n  Options:\n    --help \n    --details \n    --list \n    --get-user-key\n       Syntax: --get-user-key {USERNAME}\n    --get-username\n       Syntax: --get-username {USER-ID}\n    --read-by-userid \n       Syntax: --read-by-userid {USER-ID} {USER-ID} [...]\n    --read-by-username\n       Syntax: --read-by-username {USERNAME} {USERNAME} [...]\n    --search-by-attribute \n       Syntax: --search-by-attribute {REALM} {ATTR-NAME}={ATTR-VALUE}\n    --search-by-role \n       Syntax: --search-by-role {REALM} {ROLE-NAME}\n    --search-by-resource \n       Syntax: --search-by-resource {REALM} {RESOURCE-NAME}\n    --delete \n       Syntax: --delete {USER-ID} {USER-ID} [...]\n    --delete-all \n       Syntax: --delete-all {REALM}\n    --delete-by-attribute \n       Syntax: --delete-by-attribute {REALM} {ATTR-NAME}={ATTR-VALUE}\n
 workflow.help.message=\nUsage: workflow [options]\n  Options:\n    --help \n    --export-diagram {ANY-TYPE-KIND}\n        Any type kind: ANY_OBJECT / USER / GROUP\n    --export-definition {ANY-TYPE-KIND}\n        Any type kind: ANY_OBJECT / USER / GROUP\n