[SYNCOPE-1262] Remove matrix parameters - OpenApi wins :-(
authorFrancesco Chicchiriccò <ilgrosso@apache.org>
Tue, 13 Feb 2018 16:01:43 +0000 (17:01 +0100)
committerFrancesco Chicchiriccò <ilgrosso@apache.org>
Tue, 13 Feb 2018 16:01:43 +0000 (17:01 +0100)
73 files changed:
client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyRead.java
client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicySyncopeOperations.java
client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskRead.java
client/cli/src/main/java/org/apache/syncope/client/cli/commands/task/TaskSyncopeOperations.java
client/cli/src/main/resources/messages.properties
client/console/src/main/java/org/apache/syncope/client/console/policies/AccountPolicyDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PasswordPolicyDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PullPolicyDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/policies/PullPolicyModalPanel.java
client/console/src/main/java/org/apache/syncope/client/console/rest/PolicyRestClient.java
client/console/src/main/java/org/apache/syncope/client/console/rest/TaskRestClient.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/NotificationTaskDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/PropagationTaskDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/ProvisioningTaskDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/PullTaskDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/PushTaskDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskWizardBuilder.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTasks.java
client/console/src/main/java/org/apache/syncope/client/console/widgets/JobWidget.java
common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyQuery.java
common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/TaskQuery.java
common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/PolicyService.java
common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/TaskService.java
core/logic/src/main/java/org/apache/syncope/core/logic/PolicyLogic.java
core/logic/src/main/java/org/apache/syncope/core/logic/TaskLogic.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ExternalResourceDAO.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RealmDAO.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccountPolicy.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PasswordPolicy.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/Policy.java [moved from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Policy.java with 88% similarity]
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PolicyUtils.java [new file with mode: 0644]
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PolicyUtilsFactory.java [new file with mode: 0644]
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PullPolicy.java
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PushPolicy.java
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARealmDAO.java
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/AbstractPolicy.java
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAPolicyUtils.java [new file with mode: 0644]
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAPolicyUtilsFactory.java [new file with mode: 0644]
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/EntityValidationListener.java
core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PolicyTest.java
core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/PolicyDataBinder.java
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java
core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/PolicyServiceImpl.java
core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/TaskServiceImpl.java
ext/swagger-ui/pom.xml
fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/IdentityRecertificationITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/ImplementationITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/MultitenancyITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/PolicyITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/PropagationTaskITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/RealmITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/SchedTaskITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/SwaggerITCase.java [deleted file]
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserIssuesITCase.java

index 5b50a69..26ee655 100644 (file)
 package org.apache.syncope.client.cli.commands.policy;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import javax.xml.ws.WebServiceException;
 import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.client.cli.util.CommandUtils;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.policy.PolicyTO;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,7 +34,8 @@ public class PolicyRead extends AbstractPolicyCommand {
 
     private static final Logger LOG = LoggerFactory.getLogger(PolicyRead.class);
 
-    private static final String READ_HELP_MESSAGE = "policy --read {POLICY-KEY} {POLICY-KEY} [...]";
+    private static final String READ_HELP_MESSAGE = "policy --read {POLICY-TYPE} {POLICY-KEY}\n"
+            + "   Policy type:  ACCOUNT / PASSWORD / PULL / PUSH";
 
     private final Input input;
 
@@ -40,24 +44,26 @@ public class PolicyRead extends AbstractPolicyCommand {
     }
 
     public void read() {
-        if (input.parameterNumber() >= 1) {
-            final List<PolicyTO> policyTOs = new ArrayList<>();
-            for (final String parameter : input.getParameters()) {
-                try {
-                    policyTOs.add(policySyncopeOperations.read(parameter));
-                } catch (final NumberFormatException ex) {
-                    LOG.error("Error reading policy", ex);
-                    policyResultManager.notBooleanDeletedError("policy", parameter);
-                } catch (final WebServiceException | SyncopeClientException ex) {
-                    LOG.error("Error reading policy", ex);
-                    if (ex.getMessage().startsWith("NotFound")) {
-                        policyResultManager.notFoundError("Policy", parameter);
-                    } else {
-                        policyResultManager.genericError(ex.getMessage());
-                    }
+        if (input.parameterNumber() >= 2) {
+            final String[] parameters = Arrays.copyOfRange(input.getParameters(), 1, input.parameterNumber());
+            try {
+                final List<PolicyTO> policyTOs = new ArrayList<>();
+                for (final String parameter : parameters) {
+                    policyTOs.add(policySyncopeOperations.read(input.firstParameter(), parameter));
                 }
+                policyResultManager.printPolicies(policyTOs);
+            } catch (final SyncopeClientException | WebServiceException ex) {
+                LOG.error("Error reading policy", ex);
+                if (ex.getMessage().startsWith("NotFound")) {
+                    policyResultManager.notFoundError("Policy", parameters[0]);
+                } else {
+                    policyResultManager.genericError(ex.getMessage());
+                }
+            } catch (final IllegalArgumentException ex) {
+                LOG.error("Error reading policy", ex);
+                policyResultManager.typeNotValidError(
+                        "policy", input.firstParameter(), CommandUtils.fromEnumToArray(PolicyType.class));
             }
-            policyResultManager.printPolicies(policyTOs);
         } else {
             policyResultManager.commandOptionError(READ_HELP_MESSAGE);
         }
index 9bfad75..f738ad9 100644 (file)
@@ -28,8 +28,8 @@ public class PolicySyncopeOperations {
 
     private final PolicyService policyService = SyncopeServices.get(PolicyService.class);
 
-    public <T extends PolicyTO> T read(final String policyKey) {
-        return policyService.read(policyKey);
+    public <T extends PolicyTO> T read(final String type, final String policyKey) {
+        return policyService.read(PolicyType.valueOf(type), policyKey);
     }
 
     public <T extends PolicyTO> List<T> list(final String policyType) {
@@ -37,6 +37,6 @@ public class PolicySyncopeOperations {
     }
 
     public void delete(final String policyKey) {
-        policyService.delete(policyKey);
+        policyService.delete(null, policyKey);
     }
 }
index 0c05681..be5221a 100644 (file)
 package org.apache.syncope.client.cli.commands.task;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import javax.xml.ws.WebServiceException;
 import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.client.cli.util.CommandUtils;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.TaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,7 +34,8 @@ public class TaskRead extends AbstractTaskCommand {
 
     private static final Logger LOG = LoggerFactory.getLogger(TaskRead.class);
 
-    private static final String READ_HELP_MESSAGE = "task --read {TASK-KEY} {TASK-KEY} [...]";
+    private static final String READ_HELP_MESSAGE = "task --read {TASK-TYPE} {TASK-KEY}\n"
+            + "   Task type:  PROPAGATION / NOTIFICATION / SCHEDULED / PULL / PUSH";
 
     private final Input input;
 
@@ -40,25 +44,26 @@ public class TaskRead extends AbstractTaskCommand {
     }
 
     public void read() {
-        if (input.parameterNumber() >= 1) {
-            final List<TaskTO> taskTOs = new ArrayList<>();
-            for (final String parameter : input.getParameters()) {
-                try {
-                    taskTOs.add(taskSyncopeOperations.read(parameter));
-                } catch (final NumberFormatException ex) {
-                    LOG.error("Error reading task", ex);
-                    taskResultManager.notBooleanDeletedError("task", parameter);
-                } catch (final SyncopeClientException | WebServiceException ex) {
-                    LOG.error("Error reading task", ex);
-                    if (ex.getMessage().startsWith("NotFound")) {
-                        taskResultManager.notFoundError("Task", parameter);
-                    } else {
-                        taskResultManager.genericError(ex.getMessage());
-                    }
-                    break;
+        if (input.parameterNumber() >= 2) {
+            final String[] parameters = Arrays.copyOfRange(input.getParameters(), 1, input.parameterNumber());
+            try {
+                final List<TaskTO> taskTOs = new ArrayList<>();
+                for (final String parameter : parameters) {
+                    taskTOs.add(taskSyncopeOperations.read(input.firstParameter(), parameter));
                 }
+                taskResultManager.printTasks(taskTOs);
+            } catch (final SyncopeClientException | WebServiceException ex) {
+                LOG.error("Error reading task", ex);
+                if (ex.getMessage().startsWith("NotFound")) {
+                    taskResultManager.notFoundError("Task", parameters[0]);
+                } else {
+                    taskResultManager.genericError(ex.getMessage());
+                }
+            } catch (final IllegalArgumentException ex) {
+                LOG.error("Error reading task", ex);
+                taskResultManager.typeNotValidError(
+                        "task", input.firstParameter(), CommandUtils.fromEnumToArray(TaskType.class));
             }
-            taskResultManager.printTasks(taskTOs);
         } else {
             taskResultManager.commandOptionError(READ_HELP_MESSAGE);
         }
index ad94a4f..48fd7c6 100644 (file)
@@ -36,12 +36,12 @@ public class TaskSyncopeOperations {
         return taskService.listJobs();
     }
 
-    public <T extends TaskTO> T read(final String taskKey) {
-        return taskService.read(taskKey, true);
+    public <T extends TaskTO> T read(final String type, final String taskKey) {
+        return taskService.read(TaskType.valueOf(type), taskKey, true);
     }
 
     public void delete(final String taskKey) {
-        taskService.delete(taskKey);
+        taskService.delete(null, taskKey);
     }
 
     public List<TaskTO> list(final String type) {
index 0e47a36..48cdc15 100644 (file)
@@ -22,14 +22,14 @@ entitlement.help.message=\nUsage: entitlement [options]\n  Options:\n    --help
 group.help.message=\nUsage: group [options]\n  Options:\n    --help \n    --details \n    --list \n    --read \n       Syntax: --read {GROUP-KEY} {GROUP-KEY} [...]\n    --read-attr-by-schema-type {GROUP-KEY} {SCHEMA-TYPE}\n       Schema type: PLAIN / DERIVED / VIRTUAL\n    --read-attr-by-schema {GROUP-KEY} {SCHEMA-TYPE} {SCHEMA-KEY}\n       Schema type: PLAIN / DERIVED / VIRTUAL\n    --delete \n       Syntax: --delete {GROUP-KEY} {GROUP-KEY} [...]\n
 logger.help.message=\nUsage: logger [options]\n  Options:\n    --help \n    --details \n    --list \n    --read \n       Syntax: --read {LOG-NAME} {LOG-NAME} [...]\n    --update \n       Syntax: --update {LOG-NAME}={LOG-LEVEL} {LOG-NAME}={LOG-LEVEL} [...]\n    --update-all \n       Syntax: --update-all {LOG-LEVEL} \n    --create \n       Syntax: --create {LOG-NAME}={LOG-LEVEL} {LOG-NAME}={LOG-LEVEL} [...]\n    --delete \n       Syntax: --delete {LOG-NAME} {LOG-NAME} [...]\n
 notification.help.message=\nUsage: notification [options]\n  Options:\n    --help \n    --list \n    --read \n       Syntax: --read {NOTIFICATION-KEY} \n    --delete \n       Syntax: --delete {NOTIFICATION-KEY}\n
-policy.help.message=\nUsage: policy [options]\n  Options:\n    --help \n    --details \n    --list \n       Syntax: --list-policy {POLICY-TYPE} \n          Policy type: ACCOUNT / PASSWORD / PULL / PUSH\n    --read \n       Syntax: --read {POLICY-KEY} {POLICY-KEY} [...]\n    --delete \n       Syntax: --delete {POLICY-KEY} {POLICY-KEY} [...]\n
+policy.help.message=\nUsage: policy [options]\n  Options:\n    --help \n    --details \n    --list \n       Syntax: --list-policy {POLICY-TYPE} \n          Policy type: ACCOUNT / PASSWORD / PULL / PUSH\n    --read \n       Syntax: --read {POLICY-TYPE} {POLICY-KEY}\n   Policy type:  ACCOUNT / PASSWORD / PULL / PUSH\n    --delete \n       Syntax: --delete {POLICY-KEY} {POLICY-KEY} [...]\n
 question.help.message=\nUsage: question [options]\n  Options:\n    --help \n    --list \n    --read \n       Syntax: --read {QUESTION-KEY} {QUESTION-KEY} [...]\n    --delete \n       Syntax: --delete {QUESTION-KEY} {QUESTION-KEY} [...]\n
 realm.help.message=\nUsage: realm [options]\n  Options:\n    --help \n    --details \n    --list \n
 report.help.message=\nUsage: report [options]\n  Options:\n    --help \n    --details\n    --list \n    --list-jobs \n    --read \n       Syntax: --read {REPORT-KEY} {REPORT-KEY} [...] \n    --delete \n       Syntax: --delete {REPORT-KEY} {REPORT-KEY} [...]\n    --execute \n       Syntax: --execute {REPORT-KEY} \n    --delete-execution \n       Syntax: --delete-execution {EXECUTION-KEY} {EXECUTION-KEY} [...]\n    --export-execution-result \n       Syntax: --export-execution-result {EXECUTION-KEY} {EXECUTION-KEY} [...] {FORMAT}\n          Format: CSV / HTML / PDF / XML / RTF\n
 resource.help.message=\nUsage: resource [options]\n  Options:\n    --help \n    --details \n    --list \n    --read \n       Syntax: --read {RESOURCE-KEY} {RESOURCE-KEY} [...]\n    --delete \n       Syntax: --delete {RESOURCE-KEY} {RESOURCE-KEY} [...]\n
 role.help.message=\nUsage: role [options]\n  Options:\n    --help \n    --details \n    --list \n    --read \n       Syntax: --read {ROLE-KEY} {ROLE-KEY} [...]\n    --delete \n       Syntax: --delete {ROLE-KEY} {ROLE-KEY} [...]\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 / PULL\n    --list-running-jobs \n    --list-scheduled-jobs \n    --read \n       Syntax: --read {TASK-KEY} {TASK-KEY} [...]\n    --delete \n       Syntax: --delete {TASK-KEY} {TASK-KEY} [...]\n    --delete-all-prop\n    --delete-execution \n       Syntax: --delete-execution {TASK-EXEC-KEY} {TASK-EXEC-KEY} [...]\n    --execute \n       Syntax: --execute {TASK-KEY} {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 / PULL\n    --list-running-jobs \n    --list-scheduled-jobs \n    --read \n       Syntax: --read {TASK-TYPE} {TASK-KEY}\n   Task type:  PROPAGATION / NOTIFICATION / SCHEDULED / PULL / PUSH\n    --delete \n       Syntax: --delete {TASK-KEY} {TASK-KEY} [...]\n    --delete-all-prop\n    --delete-execution \n       Syntax: --delete-execution {TASK-EXEC-KEY} {TASK-EXEC-KEY} [...]\n    --execute \n       Syntax: --execute {TASK-KEY} {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-KEY}\n    --read-by-userkey \n       Syntax: --read-by-userkey {USER-KEY} {USER-KEY} [...]\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-KEY}\n    --search-by-resource \n       Syntax: --search-by-resource {REALM} {RESOURCE-KEY}\n    --delete \n       Syntax: --delete {USER-KEY} {USER-KEY} [...]\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
 migrate.help.message=\nUsage: migrate [options]\n  Options:\n    --help \n    --conf {SRC} {DST}\n        Syncope 1.2.X content.xml SRC absolute path\n        Syncope 2.0.X *Content.xml DST absolute path\n
index dd89ea1..a51acaa 100644 (file)
@@ -45,7 +45,8 @@ public class AccountPolicyDirectoryPanel extends PolicyDirectoryPanel<AccountPol
     public AccountPolicyDirectoryPanel(final String id, final PageReference pageRef) {
         super(id, PolicyType.ACCOUNT, pageRef);
 
-        this.addNewItemPanelBuilder(new PolicyModalPanelBuilder<>(new AccountPolicyTO(), modal, pageRef), true);
+        this.addNewItemPanelBuilder(new PolicyModalPanelBuilder<>(
+                PolicyType.ACCOUNT, new AccountPolicyTO(), modal, pageRef), true);
         MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.POLICY_CREATE);
 
         initResultTable();
index 32fce97..3aa8be4 100644 (file)
@@ -45,7 +45,7 @@ public class PasswordPolicyDirectoryPanel extends PolicyDirectoryPanel<PasswordP
         super(id, PolicyType.PASSWORD, pageRef);
 
         this.addNewItemPanelBuilder(
-                new PolicyModalPanelBuilder<>(new PasswordPolicyTO(), modal, pageRef), true);
+                new PolicyModalPanelBuilder<>(PolicyType.PASSWORD, new PasswordPolicyTO(), modal, pageRef), true);
         MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.POLICY_CREATE);
 
         initResultTable();
index d4b41f6..ab029ef 100644 (file)
@@ -79,11 +79,11 @@ public abstract class PolicyDirectoryPanel<T extends PolicyTO>
 
     protected final BaseModal<T> policySpecModal = new BaseModal<>("outer");
 
-    private final PolicyType policyType;
+    private final PolicyType type;
 
     public PolicyDirectoryPanel(final String id, final PolicyType policyType, final PageReference pageRef) {
         super(id, pageRef, true);
-        this.policyType = policyType;
+        this.type = policyType;
         this.restClient = new PolicyRestClient();
 
         ruleCompositionModal.size(Modal.Size.Large);
@@ -143,7 +143,7 @@ public abstract class PolicyDirectoryPanel<T extends PolicyTO>
             public void onClick(final AjaxRequestTarget target, final PolicyTO ignore) {
                 send(PolicyDirectoryPanel.this, Broadcast.EXACT,
                         new AjaxWizard.EditItemActionEvent<>(
-                                restClient.getPolicy(model.getObject().getKey()), target));
+                                restClient.getPolicy(type, model.getObject().getKey()), target));
             }
         }, ActionLink.ActionType.EDIT, StandardEntitlement.POLICY_UPDATE);
 
@@ -170,7 +170,7 @@ public abstract class PolicyDirectoryPanel<T extends PolicyTO>
             public void onClick(final AjaxRequestTarget target, final PolicyTO ignore) {
                 final T policyTO = model.getObject();
                 try {
-                    restClient.delete(policyTO.getKey());
+                    restClient.delete(type, policyTO.getKey());
                     SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                     target.add(container);
                 } catch (SyncopeClientException e) {
@@ -221,14 +221,14 @@ public abstract class PolicyDirectoryPanel<T extends PolicyTO>
 
         @Override
         public Iterator<T> iterator(final long first, final long count) {
-            List<T> list = restClient.getPolicies(policyType);
+            List<T> list = restClient.getPolicies(type);
             Collections.sort(list, comparator);
             return list.subList((int) first, (int) first + (int) count).iterator();
         }
 
         @Override
         public long size() {
-            return restClient.getPolicies(policyType).size();
+            return restClient.getPolicies(type).size();
         }
 
         @Override
index 75ddd09..0eac09c 100644 (file)
@@ -46,6 +46,7 @@ import org.apache.syncope.common.lib.policy.PasswordPolicyTO;
 import org.apache.syncope.common.lib.policy.PullPolicyTO;
 import org.apache.syncope.common.lib.to.EntityTO;
 import org.apache.syncope.common.lib.types.ConflictResolutionAction;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.wicket.Component;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -62,10 +63,15 @@ public class PolicyModalPanelBuilder<T extends PolicyTO> extends AbstractModalPa
 
     private final BaseModal<T> modal;
 
+    private final PolicyType type;
+
     private final PolicyRestClient restClient = new PolicyRestClient();
 
-    public PolicyModalPanelBuilder(final T policyTO, final BaseModal<T> modal, final PageReference pageRef) {
+    public PolicyModalPanelBuilder(
+            final PolicyType type, final T policyTO, final BaseModal<T> modal, final PageReference pageRef) {
+
         super(policyTO, pageRef);
+        this.type = type;
         this.modal = modal;
     }
 
@@ -156,9 +162,9 @@ public class PolicyModalPanelBuilder<T extends PolicyTO> extends AbstractModalPa
         public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
             try {
                 if (policyTO.getKey() == null) {
-                    restClient.createPolicy(policyTO);
+                    restClient.createPolicy(type, policyTO);
                 } else {
-                    restClient.updatePolicy(policyTO);
+                    restClient.updatePolicy(type, policyTO);
                 }
                 SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                 Profile.this.modal.close(target);
index 6d0bfd5..150c359 100644 (file)
@@ -80,6 +80,8 @@ public class PolicyRuleDirectoryPanel<T extends PolicyTO> extends DirectoryPanel
 
     private final BaseModal<T> baseModal;
 
+    private final PolicyType type;
+
     private final String policy;
 
     protected PolicyRuleDirectoryPanel(
@@ -89,6 +91,7 @@ public class PolicyRuleDirectoryPanel<T extends PolicyTO> extends DirectoryPanel
         disableCheckBoxes();
 
         this.baseModal = baseModal;
+        this.type = type;
         this.policy = policy;
         this.restClient = new PolicyRestClient();
 
@@ -157,10 +160,10 @@ public class PolicyRuleDirectoryPanel<T extends PolicyTO> extends DirectoryPanel
             public void onClick(final AjaxRequestTarget target, final PolicyRuleWrapper ignore) {
                 RuleConf rule = model.getObject().getConf();
                 try {
-                    T actual = restClient.getPolicy(policy);
+                    T actual = restClient.getPolicy(type, policy);
                     if (actual instanceof ComposablePolicy) {
                         ((ComposablePolicy) actual).getRules().remove(model.getObject().getImplementationKey());
-                        restClient.updatePolicy(actual);
+                        restClient.updatePolicy(type, actual);
 
                         SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                         customActionOnFinishCallback(target);
@@ -251,7 +254,7 @@ public class PolicyRuleDirectoryPanel<T extends PolicyTO> extends DirectoryPanel
 
         @Override
         public Iterator<PolicyRuleWrapper> iterator(final long first, final long count) {
-            final T actual = restClient.getPolicy(policy);
+            final T actual = restClient.getPolicy(type, policy);
 
             List<PolicyRuleWrapper> rules = actual instanceof ComposablePolicy
                     ? getPolicyRuleWrappers((ComposablePolicy) actual)
@@ -263,7 +266,7 @@ public class PolicyRuleDirectoryPanel<T extends PolicyTO> extends DirectoryPanel
 
         @Override
         public long size() {
-            final T actual = restClient.getPolicy(policy);
+            final T actual = restClient.getPolicy(type, policy);
             return actual instanceof ComposablePolicy
                     ? getPolicyRuleWrappers((ComposablePolicy) actual).size()
                     : 0;
index baf2c51..eb93982 100644 (file)
@@ -73,7 +73,7 @@ public class PolicyRuleWizardBuilder extends AjaxWizardBuilder<PolicyRuleWrapper
 
     @Override
     protected Serializable onApplyInternal(final PolicyRuleWrapper modelObject) {
-        PolicyTO policyTO = restClient.getPolicy(policy);
+        PolicyTO policyTO = restClient.getPolicy(type, policy);
 
         ComposablePolicy composable;
         if (policyTO instanceof ComposablePolicy) {
@@ -96,7 +96,7 @@ public class PolicyRuleWizardBuilder extends AjaxWizardBuilder<PolicyRuleWrapper
             composable.getRules().add(modelObject.getImplementationKey());
         }
 
-        restClient.updatePolicy(policyTO);
+        restClient.updatePolicy(type, policyTO);
         return modelObject;
     }
 
index 735aa24..e0c49a4 100644 (file)
@@ -46,7 +46,7 @@ public class PullPolicyDirectoryPanel extends PolicyDirectoryPanel<PullPolicyTO>
         final PullPolicyTO defaultItem = new PullPolicyTO();
 
         this.addNewItemPanelBuilder(
-                new PolicyModalPanelBuilder<>(defaultItem, modal, pageRef), true);
+                new PolicyModalPanelBuilder<>(PolicyType.PULL, defaultItem, modal, pageRef), true);
         MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.POLICY_CREATE);
 
         initResultTable();
index 23a2283..b265caf 100644 (file)
@@ -47,6 +47,7 @@ import org.apache.syncope.common.lib.to.ImplementationTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.SchemaType;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -146,7 +147,7 @@ public class PullPolicyModalPanel extends AbstractModalPanel<PullPolicyTO> {
                     }
                 }
             });
-            restClient.updatePolicy(getItem());
+            restClient.updatePolicy(PolicyType.PULL, getItem());
 
             SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
             this.modal.close(target);
index 6b0619e..c6446c8 100644 (file)
@@ -34,10 +34,10 @@ public class PolicyRestClient extends BaseRestClient {
 
     private static final long serialVersionUID = -1392090291817187902L;
 
-    public <T extends PolicyTO> T getPolicy(final String key) {
+    public <T extends PolicyTO> T getPolicy(final PolicyType type, final String key) {
         T policy = null;
         try {
-            policy = getService(PolicyService.class).read(key);
+            policy = getService(PolicyService.class).read(type, key);
         } catch (Exception e) {
             LOG.warn("No policy found for id {}", key, e);
         }
@@ -58,16 +58,16 @@ public class PolicyRestClient extends BaseRestClient {
         return res;
     }
 
-    public <T extends PolicyTO> void createPolicy(final T policy) {
-        getService(PolicyService.class).create(policy);
+    public <T extends PolicyTO> void createPolicy(final PolicyType type, final T policy) {
+        getService(PolicyService.class).create(type, policy);
     }
 
-    public <T extends PolicyTO> void updatePolicy(final T policy) {
-        getService(PolicyService.class).update(policy);
+    public <T extends PolicyTO> void updatePolicy(final PolicyType type, final T policy) {
+        getService(PolicyService.class).update(type, policy);
     }
 
-    public void delete(final String key) {
-        getService(PolicyService.class).delete(key);
+    public void delete(final PolicyType type, final String key) {
+        getService(PolicyService.class).delete(type, key);
     }
 
     private class PolicyComparator implements Comparator<PolicyTO>, Serializable {
index ced4689..d184085 100644 (file)
@@ -183,19 +183,19 @@ public class TaskRestClient extends BaseRestClient implements ExecutionRestClien
     }
 
     public PropagationTaskTO readPropagationTask(final String taskKey) {
-        return getService(TaskService.class).read(taskKey, false);
+        return getService(TaskService.class).read(TaskType.PROPAGATION, taskKey, false);
     }
 
     public NotificationTaskTO readNotificationTask(final String taskKey) {
-        return getService(TaskService.class).read(taskKey, false);
+        return getService(TaskService.class).read(TaskType.NOTIFICATION, taskKey, false);
     }
 
-    public <T extends SchedTaskTO> T readSchedTask(final Class<T> reference, final String taskKey) {
-        return getService(TaskService.class).read(taskKey, false);
+    public <T extends TaskTO> T readTask(final TaskType type, final String taskKey) {
+        return getService(TaskService.class).read(type, taskKey, false);
     }
 
-    public void delete(final String taskKey, final Class<? extends TaskTO> taskToClass) {
-        getService(TaskService.class).delete(taskKey);
+    public void delete(final TaskType type, final String taskKey) {
+        getService(TaskService.class).delete(type, taskKey);
     }
 
     @Override
@@ -218,12 +218,12 @@ public class TaskRestClient extends BaseRestClient implements ExecutionRestClien
         return getService(TaskService.class).listRecentExecutions(max);
     }
 
-    public void create(final SchedTaskTO taskTO) {
-        getService(TaskService.class).create(taskTO);
+    public void create(final TaskType type, final SchedTaskTO taskTO) {
+        getService(TaskService.class).create(type, taskTO);
     }
 
-    public void update(final SchedTaskTO taskTO) {
-        getService(TaskService.class).update(taskTO);
+    public void update(final TaskType type, final SchedTaskTO taskTO) {
+        getService(TaskService.class).update(type, taskTO);
     }
 
     public BulkActionResult bulkAction(final BulkAction action) {
index 5cd47c7..a0bc61f 100644 (file)
@@ -160,7 +160,7 @@ public abstract class NotificationTaskDirectoryPanel
             @Override
             public void onClick(final AjaxRequestTarget target, final NotificationTaskTO modelObject) {
                 try {
-                    restClient.delete(taskTO.getKey(), NotificationTaskTO.class);
+                    restClient.delete(TaskType.NOTIFICATION, taskTO.getKey());
                     updateResultTable(target);
                     SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                     target.add(container);
index ba3b122..ae30e66 100644 (file)
@@ -167,7 +167,7 @@ public abstract class PropagationTaskDirectoryPanel
             @Override
             public void onClick(final AjaxRequestTarget target, final PropagationTaskTO modelObject) {
                 try {
-                    restClient.delete(taskTO.getKey(), PropagationTaskTO.class);
+                    restClient.delete(TaskType.PROPAGATION, taskTO.getKey());
                     SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                     target.add(container);
                     PropagationTaskDirectoryPanel.this.getTogglePanel().close(target);
index 2ae10aa..07c2ef3 100644 (file)
@@ -51,10 +51,12 @@ public abstract class ProvisioningTaskDirectoryPanel<T extends ProvisioningTaskT
     protected ProvisioningTaskDirectoryPanel(
             final BaseModal<?> baseModal,
             final MultilevelPanel multiLevelPanelRef,
+            final TaskType taskType,
             final Class<T> reference,
             final String resource,
             final PageReference pageRef) {
-        super(baseModal, multiLevelPanelRef, reference, pageRef);
+
+        super(baseModal, multiLevelPanelRef, taskType, reference, pageRef);
         this.resource = resource;
 
         this.schedTaskTO.setResource(resource);
index 9af1251..a0329d8 100644 (file)
@@ -39,7 +39,8 @@ public abstract class PullTaskDirectoryPanel extends ProvisioningTaskDirectoryPa
             final MultilevelPanel multiLevelPanelRef,
             final String resource,
             final PageReference pageRef) {
-        super(baseModal, multiLevelPanelRef, PullTaskTO.class, resource, pageRef);
+
+        super(baseModal, multiLevelPanelRef, TaskType.PULL, PullTaskTO.class, resource, pageRef);
     }
 
     @Override
index 440b0e2..ac2dd0b 100644 (file)
@@ -37,7 +37,7 @@ public abstract class PushTaskDirectoryPanel extends ProvisioningTaskDirectoryPa
             final MultilevelPanel multiLevelPanelRef,
             final String resource,
             final PageReference pageRef) {
-        super(baseModal, multiLevelPanelRef, PushTaskTO.class, resource, pageRef);
+        super(baseModal, multiLevelPanelRef, TaskType.PUSH, PushTaskTO.class, resource, pageRef);
     }
 
     @Override
index 5135193..824b778 100644 (file)
@@ -72,6 +72,8 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
 
     private static final long serialVersionUID = 4984337552918213290L;
 
+    protected TaskType taskType;
+
     protected final Class<T> reference;
 
     protected T schedTaskTO;
@@ -83,9 +85,12 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
     protected SchedTaskDirectoryPanel(
             final BaseModal<?> baseModal,
             final MultilevelPanel multiLevelPanelRef,
+            final TaskType taskType,
             final Class<T> reference,
             final PageReference pageRef) {
+
         super(baseModal, multiLevelPanelRef, pageRef);
+        this.taskType = taskType;
         this.reference = reference;
 
         try {
@@ -94,7 +99,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
             LOG.error("Falure instantiating task", e);
         }
 
-        this.addNewItemPanelBuilder(new SchedTaskWizardBuilder<>(schedTaskTO, pageRef), true);
+        this.addNewItemPanelBuilder(new SchedTaskWizardBuilder<>(taskType, schedTaskTO, pageRef), true);
 
         MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.TASK_CREATE);
 
@@ -115,7 +120,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
                     final TemplatableTO targetObject, final String type, final AnyTO anyTO) {
 
                 targetObject.getTemplates().put(type, anyTO);
-                new TaskRestClient().update(SchedTaskTO.class.cast(targetObject));
+                new TaskRestClient().update(taskType, SchedTaskTO.class.cast(targetObject));
                 return targetObject;
             }
         };
@@ -203,7 +208,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
                 SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
                 send(SchedTaskDirectoryPanel.this, Broadcast.EXACT,
                         new AjaxWizard.EditItemActionEvent<>(
-                                restClient.readSchedTask(reference, model.getObject().getKey()),
+                                restClient.readTask(taskType, model.getObject().getKey()),
                                 target).setResourceModel(
                                 new StringResourceModel("inner.task.edit",
                                         SchedTaskDirectoryPanel.this,
@@ -252,7 +257,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
             @Override
             public void onClick(final AjaxRequestTarget target, final T ignore) {
                 try {
-                    restClient.delete(taskTO.getKey(), reference);
+                    restClient.delete(taskType, taskTO.getKey());
                     SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                     target.add(container);
                     SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
@@ -287,7 +292,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
 
     @Override
     protected SchedTasksProvider<T> dataProvider() {
-        return new SchedTasksProvider<>(reference, TaskType.SCHEDULED, rows);
+        return new SchedTasksProvider<>(reference, taskType, rows);
     }
 
     protected class SchedTasksProvider<T extends SchedTaskTO> extends TaskDataProvider<T> {
index ef58d82..8efd140 100644 (file)
@@ -42,6 +42,7 @@ import org.apache.syncope.common.lib.to.RealmTO;
 import org.apache.syncope.common.lib.types.ImplementationType;
 import org.apache.syncope.common.lib.types.MatchingRule;
 import org.apache.syncope.common.lib.types.PullMode;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.lib.types.UnmatchingRule;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -61,6 +62,8 @@ public class SchedTaskWizardBuilder<T extends SchedTaskTO> extends AjaxWizardBui
 
     private final ImplementationRestClient implRestClient = new ImplementationRestClient();
 
+    private final TaskType type;
+
     private PushTaskWrapper wrapper;
 
     private CrontabPanel crontabPanel;
@@ -79,8 +82,9 @@ public class SchedTaskWizardBuilder<T extends SchedTaskTO> extends AjaxWizardBui
         }
     };
 
-    public SchedTaskWizardBuilder(final T taskTO, final PageReference pageRef) {
+    public SchedTaskWizardBuilder(final TaskType type, final T taskTO, final PageReference pageRef) {
         super(taskTO, pageRef);
+        this.type = type;
     }
 
     @Override
@@ -91,9 +95,9 @@ public class SchedTaskWizardBuilder<T extends SchedTaskTO> extends AjaxWizardBui
 
         modelObject.setCronExpression(crontabPanel.getCronExpression());
         if (modelObject.getKey() == null) {
-            taskRestClient.create(modelObject);
+            taskRestClient.create(type, modelObject);
         } else {
-            taskRestClient.update(modelObject);
+            taskRestClient.update(type, modelObject);
         }
         return modelObject;
     }
index d0e8907..562d632 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.syncope.client.console.panels.MultilevelPanel;
 import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
 import org.apache.syncope.common.lib.to.AnyTO;
 import org.apache.syncope.common.lib.to.SchedTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.model.Model;
@@ -39,7 +40,7 @@ public class SchedTasks extends AbstractTasks {
         add(mlp);
 
         mlp.setFirstLevel(new SchedTaskDirectoryPanel<SchedTaskTO>(
-                baseModal, mlp, SchedTaskTO.class, pageReference) {
+                baseModal, mlp, TaskType.SCHEDULED, SchedTaskTO.class, pageReference) {
 
             private static final long serialVersionUID = -2195387360323687302L;
 
index ba77916..5e4a9d5 100644 (file)
@@ -53,9 +53,10 @@ import org.apache.syncope.common.lib.to.ExecTO;
 import org.apache.syncope.common.lib.to.JobTO;
 import org.apache.syncope.common.lib.to.ReportTO;
 import org.apache.syncope.common.lib.to.ProvisioningTaskTO;
-import org.apache.syncope.common.lib.to.SchedTaskTO;
+import org.apache.syncope.common.lib.to.PullTaskTO;
 import org.apache.syncope.common.lib.types.JobType;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
@@ -352,8 +353,7 @@ public class JobWidget extends BaseWidget {
                         final IModel<JobTO> rowModel) {
 
                     JobTO jobTO = rowModel.getObject();
-                    JobActionPanel panel =
-                            new JobActionPanel(componentId, jobTO, JobWidget.this, pageRef);
+                    JobActionPanel panel = new JobActionPanel(componentId, jobTO, JobWidget.this, pageRef);
                     MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.ENABLE,
                             String.format("%s,%s%s,%s",
                                     StandardEntitlement.TASK_EXECUTE,
@@ -405,11 +405,18 @@ public class JobWidget extends BaseWidget {
                             break;
 
                         case TASK:
-                            ProvisioningTaskTO schedTaskTO = new TaskRestClient().
-                                    readSchedTask(ProvisioningTaskTO.class, jobTO.getRefKey());
-
-                            SchedTaskWizardBuilder<SchedTaskTO> swb =
-                                    new SchedTaskWizardBuilder<>(schedTaskTO, pageRef);
+                            ProvisioningTaskTO schedTaskTO;
+                            try {
+                                schedTaskTO = new TaskRestClient().readTask(TaskType.PULL, jobTO.getRefKey());
+                            } catch (Exception e) {
+                                LOG.debug("Failed to read {} as {}, attempting {}",
+                                        jobTO.getRefKey(), TaskType.PULL, TaskType.PUSH, e);
+                                schedTaskTO = new TaskRestClient().readTask(TaskType.PUSH, jobTO.getRefKey());
+                            }
+
+                            SchedTaskWizardBuilder<ProvisioningTaskTO> swb =
+                                    new SchedTaskWizardBuilder<>(schedTaskTO instanceof PullTaskTO
+                                            ? TaskType.PULL : TaskType.PUSH, schedTaskTO, pageRef);
                             swb.setEventSink(AvailableJobsPanel.this);
 
                             target.add(jobModal.setContent(swb.build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT)));
index 1ce1233..aad9157 100644 (file)
@@ -19,7 +19,6 @@
 package org.apache.syncope.common.rest.api.beans;
 
 import javax.ws.rs.DefaultValue;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.QueryParam;
 import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.rest.api.service.JAXRSService;
@@ -63,7 +62,7 @@ public class AnyQuery extends AbstractQuery {
     }
 
     @DefaultValue(SyncopeConstants.ROOT_REALM)
-    @MatrixParam("realm")
+    @QueryParam("realm")
     public void setRealm(final String realm) {
         this.realm = realm;
     }
index dc74d26..c96d7b2 100644 (file)
@@ -21,7 +21,7 @@ package org.apache.syncope.common.rest.api.beans;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 import javax.ws.rs.DefaultValue;
-import javax.ws.rs.MatrixParam;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.TaskType;
@@ -86,7 +86,7 @@ public class TaskQuery extends AbstractQuery {
     }
 
     @NotNull
-    @MatrixParam("type")
+    @PathParam("type")
     public void setType(final TaskType type) {
         this.type = type;
     }
index 25c3993..40e65ac 100644 (file)
@@ -26,7 +26,6 @@ import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -50,14 +49,15 @@ public interface PolicyService extends JAXRSService {
     /**
      * Returns the policy matching the given key.
      *
+     * @param type policy type
      * @param key key of requested policy
      * @param <T> response type (extending PolicyTO)
      * @return policy with matching id
      */
     @GET
-    @Path("{key}")
+    @Path("{type}/{key}")
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    <T extends PolicyTO> T read(@NotNull @PathParam("key") String key);
+    <T extends PolicyTO> T read(@NotNull @PathParam("type") PolicyType type, @NotNull @PathParam("key") String key);
 
     /**
      * Returns a list of policies of the matching type.
@@ -67,41 +67,46 @@ public interface PolicyService extends JAXRSService {
      * @return list of policies with matching type
      */
     @GET
+    @Path("{type}")
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    <T extends PolicyTO> List<T> list(@NotNull @MatrixParam("type") PolicyType type);
+    <T extends PolicyTO> List<T> list(@NotNull @PathParam("type") PolicyType type);
 
     /**
      * Create a new policy.
      *
+     * @param type policy type
      * @param policyTO Policy to be created (needs to match type)
      * @return Response object featuring Location header of created policy
      */
     @POST
+    @Path("{type}")
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    Response create(@NotNull PolicyTO policyTO);
+    Response create(@NotNull @PathParam("type") PolicyType type, @NotNull PolicyTO policyTO);
 
     /**
      * Updates policy matching the given key.
      *
+     * @param type policy type
      * @param policyTO Policy to replace existing policy
      * @return an empty response if operation was successful
      */
     @PUT
-    @Path("{key}")
+    @Path("{type}/{key}")
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    Response update(@NotNull PolicyTO policyTO);
+    Response update(@NotNull @PathParam("type") PolicyType type, @NotNull PolicyTO policyTO);
 
     /**
      * Delete policy matching the given key.
      *
+     * @param type policy type
      * @param key key of policy to be deleted
      * @return an empty response if operation was successful
      */
     @DELETE
-    @Path("{key}")
+    @Path("{type}/{key}")
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    Response delete(@NotNull @PathParam("key") String key);
+    Response delete(@NotNull @PathParam("type") PolicyType type, @NotNull @PathParam("key") String key);
 
 }
index ab2990c..c46dec0 100644 (file)
@@ -40,6 +40,7 @@ import org.apache.syncope.common.lib.to.BulkAction;
 import org.apache.syncope.common.lib.to.BulkActionResult;
 import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.to.SchedTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.beans.TaskQuery;
 
 /**
@@ -55,15 +56,17 @@ public interface TaskService extends ExecutableService {
     /**
      * Returns the task matching the given key.
      *
+     * @param type task type
      * @param key key of task to be read
      * @param details whether include executions or not, defaults to true
      * @param <T> type of taskTO
      * @return task with matching id
      */
     @GET
-    @Path("{key}")
+    @Path("{type}/{key}")
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     <T extends TaskTO> T read(
+            @NotNull @PathParam("type") TaskType type,
             @NotNull @PathParam("key") String key,
             @QueryParam(JAXRSService.PARAM_DETAILS) @DefaultValue("true") boolean details);
 
@@ -75,40 +78,45 @@ public interface TaskService extends ExecutableService {
      * @return paged list of existing tasks matching the given query
      */
     @GET
+    @Path("{type}")
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     <T extends TaskTO> PagedResult<T> list(@BeanParam TaskQuery query);
 
     /**
      * Creates a new task.
      *
+     * @param type task type
      * @param taskTO task to be created
      * @return Response object featuring Location header of created task
      */
     @POST
+    @Path("{type}")
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    Response create(@NotNull SchedTaskTO taskTO);
+    Response create(@NotNull @PathParam("type") TaskType type, @NotNull SchedTaskTO taskTO);
 
     /**
      * Updates the task matching the provided key.
      *
+     * @param type task type
      * @param taskTO updated task to be stored
      * @return an empty response if operation was successful
      */
     @PUT
-    @Path("{key}")
+    @Path("{type}/{key}")
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    Response update(@NotNull TaskTO taskTO);
+    Response update(@NotNull @PathParam("type") TaskType type, @NotNull SchedTaskTO taskTO);
 
     /**
      * Deletes the task matching the provided key.
      *
+     * @param type task type
      * @param key key of task to be deleted
      * @return an empty response if operation was successful
      */
     @DELETE
-    @Path("{key}")
+    @Path("{type}/{key}")
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    Response delete(@NotNull @PathParam("key") String key);
+    Response delete(@NotNull @PathParam("type") TaskType type, @NotNull @PathParam("key") String key);
 
     /**
      * Executes the provided bulk action.
index c03b6bf..2506a90 100644 (file)
@@ -22,16 +22,16 @@ import java.lang.reflect.Method;
 import java.util.List;
 import java.util.stream.Collectors;
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.policy.PolicyTO;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
-import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
-import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
-import org.apache.syncope.core.persistence.api.entity.Policy;
-import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
-import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.PolicyUtils;
+import org.apache.syncope.core.persistence.api.entity.policy.PolicyUtilsFactory;
 import org.apache.syncope.core.provisioning.api.data.PolicyDataBinder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -46,61 +46,78 @@ public class PolicyLogic extends AbstractTransactionalLogic<PolicyTO> {
     @Autowired
     private PolicyDataBinder binder;
 
+    @Autowired
+    private PolicyUtilsFactory policyUtilsFactory;
+
     @PreAuthorize("hasRole('" + StandardEntitlement.POLICY_CREATE + "')")
-    public <T extends PolicyTO> T create(final T policyTO) {
+    public <T extends PolicyTO> T create(final PolicyType type, final T policyTO) {
+        PolicyUtils policyUtils = policyUtilsFactory.getInstance(policyTO);
+        if (policyUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
+            throw sce;
+        }
+
         return binder.getPolicyTO(policyDAO.save(binder.create(policyTO)));
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.POLICY_UPDATE + "')")
-    public PolicyTO update(final PolicyTO policyTO) {
+    public PolicyTO update(final PolicyType type, final PolicyTO policyTO) {
         Policy policy = policyDAO.find(policyTO.getKey());
-        return binder.getPolicyTO(policyDAO.save(binder.update(policy, policyTO)));
-    }
-
-    private Class<? extends Policy> getPolicyClass(final PolicyType policyType) {
-        switch (policyType) {
-            case ACCOUNT:
-                return AccountPolicy.class;
-
-            case PASSWORD:
-                return PasswordPolicy.class;
 
-            case PULL:
-                return PullPolicy.class;
-
-            case PUSH:
-            default:
-                return PushPolicy.class;
+        PolicyUtils policyUtils = policyUtilsFactory.getInstance(policy);
+        if (policyUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
+            throw sce;
         }
+
+        return binder.getPolicyTO(policyDAO.save(binder.update(policy, policyTO)));
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.POLICY_LIST + "')")
     public <T extends PolicyTO> List<T> list(final PolicyType type) {
-        return policyDAO.find(getPolicyClass(type)).stream().
+        PolicyUtils policyUtils = policyUtilsFactory.getInstance(type);
+
+        return policyDAO.find(policyUtils.policyClass()).stream().
                 <T>map(policy -> binder.getPolicyTO(policy)).collect(Collectors.toList());
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.POLICY_READ + "')")
-    public <T extends PolicyTO> T read(final String key) {
+    public <T extends PolicyTO> T read(final PolicyType type, final String key) {
         Policy policy = policyDAO.find(key);
         if (policy == null) {
             throw new NotFoundException("Policy " + key + " not found");
         }
 
+        PolicyUtils policyUtils = policyUtilsFactory.getInstance(policy);
+        if (type != null && policyUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
+            throw sce;
+        }
+
         return binder.getPolicyTO(policy);
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.POLICY_DELETE + "')")
-    public <T extends PolicyTO> T delete(final String key) {
+    public <T extends PolicyTO> T delete(final PolicyType type, final String key) {
         Policy policy = policyDAO.find(key);
         if (policy == null) {
             throw new NotFoundException("Policy " + key + " not found");
         }
 
-        T policyToDelete = binder.getPolicyTO(policy);
+        PolicyUtils policyUtils = policyUtilsFactory.getInstance(policy);
+        if (type != null && policyUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
+            throw sce;
+        }
+
+        T deleted = binder.getPolicyTO(policy);
         policyDAO.delete(policy);
 
-        return policyToDelete;
+        return deleted;
     }
 
     @Override
index 018c3f7..a9ac3d3 100644 (file)
@@ -94,8 +94,13 @@ public class TaskLogic extends AbstractExecutableLogic<TaskTO> {
     private TaskUtilsFactory taskUtilsFactory;
 
     @PreAuthorize("hasRole('" + StandardEntitlement.TASK_CREATE + "')")
-    public <T extends SchedTaskTO> T createSchedTask(final T taskTO) {
+    public <T extends SchedTaskTO> T createSchedTask(final TaskType type, final T taskTO) {
         TaskUtils taskUtils = taskUtilsFactory.getInstance(taskTO);
+        if (taskUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
+            throw sce;
+        }
 
         SchedTask task = binder.createSchedTask(taskTO, taskUtils);
         task = taskDAO.save(task);
@@ -117,13 +122,18 @@ public class TaskLogic extends AbstractExecutableLogic<TaskTO> {
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.TASK_UPDATE + "')")
-    public <T extends SchedTaskTO> T updateSchedTask(final SchedTaskTO taskTO) {
+    public <T extends SchedTaskTO> T updateSchedTask(final TaskType type, final SchedTaskTO taskTO) {
         SchedTask task = taskDAO.find(taskTO.getKey());
         if (task == null) {
             throw new NotFoundException("Task " + taskTO.getKey());
         }
 
         TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
+        if (taskUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
+            throw sce;
+        }
 
         binder.updateSchedTask(task, taskTO, taskUtils);
         task = taskDAO.save(task);
@@ -180,11 +190,19 @@ public class TaskLogic extends AbstractExecutableLogic<TaskTO> {
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')")
-    public <T extends TaskTO> T read(final String key, final boolean details) {
+    public <T extends TaskTO> T read(final TaskType type, final String key, final boolean details) {
         Task task = taskDAO.find(key);
         if (task == null) {
             throw new NotFoundException("Task " + key);
         }
+
+        TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
+        if (type != null && taskUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
+            throw sce;
+        }
+
         return binder.getTaskTO(task, taskUtilsFactory.getInstance(task), details);
     }
 
@@ -261,12 +279,18 @@ public class TaskLogic extends AbstractExecutableLogic<TaskTO> {
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.TASK_DELETE + "')")
-    public <T extends TaskTO> T delete(final String key) {
+    public <T extends TaskTO> T delete(final TaskType type, final String key) {
         Task task = taskDAO.find(key);
         if (task == null) {
             throw new NotFoundException("Task " + key);
         }
+
         TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
+        if (type != null && taskUtils.getType() != type) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
+            sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
+            throw sce;
+        }
 
         T taskToDelete = binder.getTaskTO(task, taskUtils, true);
 
index ea1ceb8..ecde5f1 100644 (file)
@@ -21,7 +21,7 @@ package org.apache.syncope.core.persistence.api.dao;
 import java.util.List;
 import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
index 456850c..e841a3c 100644 (file)
@@ -20,11 +20,11 @@ package org.apache.syncope.core.persistence.api.dao;
 
 import java.util.List;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 
 public interface PolicyDAO extends DAO<Policy> {
 
index c838338..42ba819 100644 (file)
@@ -21,8 +21,8 @@ package org.apache.syncope.core.persistence.api.dao;
 import java.util.List;
 import java.util.regex.Pattern;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.Realm;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 
 public interface RealmDAO extends DAO<Realm> {
index 3fe3c5e..af09b39 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.syncope.core.persistence.api.entity.policy;
 import java.util.List;
 import java.util.Set;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 
 public interface AccountPolicy extends Policy {
index e44eba0..e6575df 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persistence.api.entity.policy;
 
 import java.util.List;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 
 public interface PasswordPolicy extends Policy {
 
@@ -16,7 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.syncope.core.persistence.api.entity;
+package org.apache.syncope.core.persistence.api.entity.policy;
+
+import org.apache.syncope.core.persistence.api.entity.Entity;
 
 public interface Policy extends Entity {
 
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PolicyUtils.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PolicyUtils.java
new file mode 100644 (file)
index 0000000..e712646
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.core.persistence.api.entity.policy;
+
+import org.apache.syncope.common.lib.types.PolicyType;
+
+public interface PolicyUtils {
+
+    PolicyType getType();
+
+    Class<? extends Policy> policyClass();
+}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PolicyUtilsFactory.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/PolicyUtilsFactory.java
new file mode 100644 (file)
index 0000000..e3092c0
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.core.persistence.api.entity.policy;
+
+import org.apache.syncope.common.lib.policy.PolicyTO;
+import org.apache.syncope.common.lib.types.PolicyType;
+
+public interface PolicyUtilsFactory {
+
+    PolicyUtils getInstance(PolicyType type);
+
+    PolicyUtils getInstance(Policy policy);
+
+    PolicyUtils getInstance(Class<? extends PolicyTO> policyClass);
+
+    PolicyUtils getInstance(PolicyTO policyTO);
+}
index 6612fe5..d8d1a69 100644 (file)
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Optional;
 import org.apache.syncope.common.lib.types.ConflictResolutionAction;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 
 public interface PullPolicy extends Policy {
 
index 4365e72..d6819b7 100644 (file)
@@ -19,7 +19,6 @@
 package org.apache.syncope.core.persistence.api.entity.policy;
 
 import org.apache.syncope.common.lib.policy.PushPolicySpec;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 
 public interface PushPolicy extends Policy {
 
index 530b539..3ad39f6 100644 (file)
@@ -42,8 +42,8 @@ import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMappingItem;
index 38d260f..52bca60 100644 (file)
@@ -26,8 +26,8 @@ import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.Realm;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
 import org.apache.syncope.core.persistence.jpa.entity.policy.AbstractPolicy;
index 3594b70..7f90046 100644 (file)
@@ -31,9 +31,9 @@ import org.apache.syncope.core.persistence.api.dao.RealmDAO;
 import org.apache.syncope.core.persistence.api.dao.RoleDAO;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.Realm;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.jpa.entity.JPARealm;
index 0d5b57c..27fcb85 100644 (file)
@@ -22,7 +22,7 @@ import javax.persistence.Entity;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.validation.constraints.NotNull;
-import org.apache.syncope.core.persistence.api.entity.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
 
 @Entity
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAPolicyUtils.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAPolicyUtils.java
new file mode 100644 (file)
index 0000000..d87325e
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.core.persistence.jpa.entity.policy;
+
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.PolicyUtils;
+import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
+
+public class JPAPolicyUtils implements PolicyUtils {
+
+    private final PolicyType type;
+
+    protected JPAPolicyUtils(final PolicyType type) {
+        this.type = type;
+    }
+
+    @Override
+    public PolicyType getType() {
+        return type;
+    }
+
+    @Override
+    public Class<? extends Policy> policyClass() {
+        switch (type) {
+            case ACCOUNT:
+                return AccountPolicy.class;
+
+            case PASSWORD:
+                return PasswordPolicy.class;
+
+            case PULL:
+                return PullPolicy.class;
+
+            case PUSH:
+            default:
+                return PushPolicy.class;
+        }
+    }
+
+}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAPolicyUtilsFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAPolicyUtilsFactory.java
new file mode 100644 (file)
index 0000000..6ecd1d0
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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.core.persistence.jpa.entity.policy;
+
+import org.apache.syncope.common.lib.policy.AccountPolicyTO;
+import org.apache.syncope.common.lib.policy.PasswordPolicyTO;
+import org.apache.syncope.common.lib.policy.PolicyTO;
+import org.apache.syncope.common.lib.policy.PullPolicyTO;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.PolicyUtils;
+import org.apache.syncope.core.persistence.api.entity.policy.PolicyUtilsFactory;
+import org.springframework.stereotype.Component;
+import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
+
+@Component
+public class JPAPolicyUtilsFactory implements PolicyUtilsFactory {
+
+    @Override
+    public PolicyUtils getInstance(final PolicyType type) {
+        return new JPAPolicyUtils(type);
+    }
+
+    @Override
+    public PolicyUtils getInstance(final Policy policy) {
+        PolicyType type;
+        if (policy instanceof AccountPolicy) {
+            type = PolicyType.ACCOUNT;
+        } else if (policy instanceof PasswordPolicy) {
+            type = PolicyType.PASSWORD;
+        } else if (policy instanceof PullPolicy) {
+            type = PolicyType.PULL;
+        } else if (policy instanceof PushPolicy) {
+            type = PolicyType.PUSH;
+        } else {
+            throw new IllegalArgumentException("Invalid policy: " + policy);
+        }
+
+        return getInstance(type);
+    }
+
+    @Override
+    public PolicyUtils getInstance(final Class<? extends PolicyTO> policyClass) {
+        PolicyType type;
+        if (policyClass == AccountPolicyTO.class) {
+            type = PolicyType.ACCOUNT;
+        } else if (policyClass == PasswordPolicyTO.class) {
+            type = PolicyType.PASSWORD;
+        } else if (policyClass == PullPolicyTO.class) {
+            type = PolicyType.PULL;
+        } else {
+            throw new IllegalArgumentException("Invalid PolicyTO class: " + policyClass.getName());
+        }
+
+        return getInstance(type);
+    }
+
+    @Override
+    public PolicyUtils getInstance(final PolicyTO policyTO) {
+        return getInstance(policyTO.getClass());
+    }
+
+}
index 3b46f62..4fde449 100644 (file)
@@ -31,9 +31,9 @@ import org.apache.syncope.core.persistence.api.entity.Any;
 import org.apache.syncope.core.persistence.api.entity.DynMembership;
 import org.apache.syncope.core.persistence.api.entity.Entity;
 import org.apache.syncope.core.persistence.api.entity.GroupableRelatable;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.ProvidedKeyEntity;
 import org.apache.syncope.core.persistence.api.entity.Schema;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.task.Task;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 1301395..2fa7345 100644 (file)
@@ -37,8 +37,8 @@ import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
 import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.CorrelationRule;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
index 3ff922d..6fd25ef 100644 (file)
@@ -19,7 +19,7 @@
 package org.apache.syncope.core.provisioning.api.data;
 
 import org.apache.syncope.common.lib.policy.PolicyTO;
-import org.apache.syncope.core.persistence.api.entity.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 
 public interface PolicyDataBinder {
 
index 4666c11..319690e 100644 (file)
@@ -36,14 +36,14 @@ import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.Realm;
 import org.apache.syncope.core.persistence.api.entity.policy.CorrelationRule;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
 
 @Component
 public class PolicyDataBinderImpl implements PolicyDataBinder {
index d877700..8b006e1 100644 (file)
@@ -35,9 +35,9 @@ import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
 import org.apache.syncope.core.persistence.api.entity.Realm;
+import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.provisioning.api.data.RealmDataBinder;
 import org.slf4j.Logger;
index 2925fc7..c115ca6 100644 (file)
@@ -36,8 +36,8 @@ public class PolicyServiceImpl extends AbstractServiceImpl implements PolicyServ
     private PolicyLogic logic;
 
     @Override
-    public Response create(final PolicyTO policyTO) {
-        PolicyTO policy = logic.create(policyTO);
+    public Response create(final PolicyType type, final PolicyTO policyTO) {
+        PolicyTO policy = logic.create(type, policyTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(policy.getKey()).build();
         return Response.created(location).
                 header(RESTHeaders.RESOURCE_KEY, policy.getKey()).
@@ -45,8 +45,8 @@ public class PolicyServiceImpl extends AbstractServiceImpl implements PolicyServ
     }
 
     @Override
-    public Response delete(final String key) {
-        logic.delete(key);
+    public Response delete(final PolicyType type, final String key) {
+        logic.delete(type, key);
         return Response.noContent().build();
     }
 
@@ -56,13 +56,13 @@ public class PolicyServiceImpl extends AbstractServiceImpl implements PolicyServ
     }
 
     @Override
-    public <T extends PolicyTO> T read(final String key) {
-        return logic.read(key);
+    public <T extends PolicyTO> T read(final PolicyType type, final String key) {
+        return logic.read(type, key);
     }
 
     @Override
-    public Response update(final PolicyTO policyTO) {
-        logic.update(policyTO);
+    public Response update(final PolicyType type, final PolicyTO policyTO) {
+        logic.update(type, policyTO);
         return Response.noContent().build();
     }
 }
index 37067a3..cd24751 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.syncope.common.lib.to.BulkAction;
 import org.apache.syncope.common.lib.to.BulkActionResult;
 import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.to.SchedTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 import org.apache.syncope.common.rest.api.beans.TaskQuery;
 import org.apache.syncope.common.rest.api.service.TaskService;
@@ -48,10 +49,10 @@ public class TaskServiceImpl extends AbstractExecutableService implements TaskSe
     }
 
     @Override
-    public Response create(final SchedTaskTO taskTO) {
+    public Response create(final TaskType type, final SchedTaskTO taskTO) {
         SchedTaskTO createdTask;
         if (taskTO != null) {
-            createdTask = logic.createSchedTask(taskTO);
+            createdTask = logic.createSchedTask(type, taskTO);
         } else {
             throw new BadRequestException();
         }
@@ -63,8 +64,8 @@ public class TaskServiceImpl extends AbstractExecutableService implements TaskSe
     }
 
     @Override
-    public Response delete(final String key) {
-        logic.delete(key);
+    public Response delete(final TaskType type, final String key) {
+        logic.delete(type, key);
         return Response.noContent().build();
     }
 
@@ -85,18 +86,14 @@ public class TaskServiceImpl extends AbstractExecutableService implements TaskSe
     }
 
     @Override
-    public <T extends TaskTO> T read(final String key, final boolean details) {
-        return logic.read(key, details);
+    public <T extends TaskTO> T read(final TaskType type, final String key, final boolean details) {
+        return logic.read(type, key, details);
     }
 
     @Override
-    public Response update(final TaskTO taskTO) {
-        if (taskTO instanceof SchedTaskTO) {
-            logic.updateSchedTask((SchedTaskTO) taskTO);
-            return Response.noContent().build();
-        } else {
-            throw new BadRequestException();
-        }
+    public Response update(final TaskType type, final SchedTaskTO taskTO) {
+        logic.updateSchedTask(type, taskTO);
+        return Response.noContent().build();
     }
 
     @Override
@@ -107,7 +104,7 @@ public class TaskServiceImpl extends AbstractExecutableService implements TaskSe
             case DELETE:
                 for (String key : bulkAction.getTargets()) {
                     try {
-                        result.getResults().put(logic.delete(key).getKey(), BulkActionResult.Status.SUCCESS);
+                        result.getResults().put(logic.delete(null, key).getKey(), BulkActionResult.Status.SUCCESS);
                     } catch (Exception e) {
                         LOG.error("Error performing delete for task {}", key, e);
                         result.getResults().put(key, BulkActionResult.Status.FAILURE);
index be72a97..d4226ec 100644 (file)
@@ -102,29 +102,7 @@ under the License.
           </execution>
         </executions>
       </plugin>
-          
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-antrun-plugin</artifactId>
-        <inherited>true</inherited>
-        <executions>
-          <execution>
-            <id>addMatrixParamSupport</id>
-            <phase>process-resources</phase>
-            <goals>
-              <goal>run</goal>
-            </goals>
-            <configuration>
-              <target>
-                <replace file="${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/swagger-ui-bundle.js"
-                         token="function i(e){var t=e.req,n=e.value,r=e.parameter,i=r.name,o=r.style,a=r.explode,s=(0,h.default)({key:r.name,value:n,style:o||&quot;simple&quot;,explode:a||!1,escape:!1});t.url=t.url.replace(&quot;{&quot;+i+&quot;}&quot;,s)}"
-                         value="function i(e){var t=e.req,r=e.value,n=e.parameter,a=n.name,u=n.style,o=n.explode,i=(0,h.default)({key:n.name,value:r,style:u||&quot;simple&quot;,explode:o||!1,escape:&quot;matrix&quot;===u});&quot;matrix&quot;!==u||!n.explode&amp;&amp;void 0!==n.explode?t.url=t.url.replace(&quot;{&quot;+a+&quot;}&quot;,i):t.url=t.url.concat(i)}"/>
-              </target>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
+         
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
index f6ec448..8466864 100644 (file)
@@ -40,6 +40,7 @@ import org.apache.syncope.common.lib.report.UserReportletConf;
 import org.apache.syncope.common.lib.to.SchedTaskTO;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.core.logic.TaskLogic;
 import org.apache.syncope.core.migration.MigrationPullActions;
 import org.apache.syncope.core.provisioning.java.job.report.AuditReportlet;
@@ -255,7 +256,7 @@ public class ITImplementationLookup implements ImplementationLookup {
                     SchedTaskTO task = new SchedTaskTO();
                     task.setJobDelegate(reindex.getKey());
                     task.setName("Elasticsearch Reindex");
-                    task = taskLogic.createSchedTask(task);
+                    task = taskLogic.createSchedTask(TaskType.SCHEDULED, task);
 
                     taskLogic.execute(task.getKey(), null, false);
 
index 32f350a..08d626b 100644 (file)
@@ -62,6 +62,7 @@ import org.apache.syncope.common.lib.to.RoleTO;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.PatchOperation;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.SchemaType;
 import org.apache.syncope.common.lib.types.TraceLevel;
 import org.apache.syncope.common.rest.api.RESTHeaders;
@@ -487,8 +488,8 @@ public abstract class AbstractITCase {
     }
 
     @SuppressWarnings("unchecked")
-    protected <T extends PolicyTO> T createPolicy(final T policy) {
-        Response response = policyService.create(policy);
+    protected <T extends PolicyTO> T createPolicy(final PolicyType type, final T policy) {
+        Response response = policyService.create(type, policy);
         if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
             Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
             if (ex != null) {
index 5fb9c52..ac7339d 100644 (file)
@@ -38,7 +38,6 @@ import org.apache.syncope.client.cli.commands.entitlement.EntitlementCommand;
 import org.apache.syncope.client.cli.commands.group.GroupCommand;
 import org.apache.syncope.client.cli.commands.install.InstallCommand;
 import org.apache.syncope.client.cli.commands.logger.LoggerCommand;
-import org.apache.syncope.client.cli.commands.policy.PolicyCommand;
 import org.apache.syncope.client.cli.commands.report.ReportCommand;
 import org.apache.syncope.client.cli.commands.role.RoleCommand;
 import org.apache.syncope.client.cli.commands.user.UserCommand;
@@ -264,26 +263,6 @@ public class CLIITCase extends AbstractITCase {
     }
 
     @Test
-    public void policyError() {
-        Process process = null;
-        try {
-            PROCESS_BUILDER.command(getCommand(
-                    new PolicyCommand().getClass().getAnnotation(Command.class).name(),
-                    PolicyCommand.PolicyOptions.READ.getOptionName(),
-                    "wrong"));
-            process = PROCESS_BUILDER.start();
-            final String result = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
-            assertTrue(result.contains("- Policy wrong doesn't exist"));
-        } catch (IOException e) {
-            fail(e.getMessage());
-        } finally {
-            if (process != null) {
-                process.destroy();
-            }
-        }
-    }
-
-    @Test
     public void lastStatements() {
         Process process = null;
         try {
index d59422a..11fbb0b 100644 (file)
@@ -58,6 +58,8 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
 
         private final TaskService taskService;
 
+        private final TaskType type;
+
         private final String taskKey;
 
         private final int maxWaitSeconds;
@@ -65,9 +67,11 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
         private final boolean dryRun;
 
         public ThreadExec(
-                final TaskService taskService, final String taskKey, final int maxWaitSeconds, final boolean dryRun) {
+                final TaskService taskService, final TaskType type, final String taskKey,
+                final int maxWaitSeconds, final boolean dryRun) {
 
             this.taskService = taskService;
+            this.type = type;
             this.taskKey = taskKey;
             this.maxWaitSeconds = maxWaitSeconds;
             this.dryRun = dryRun;
@@ -75,7 +79,7 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
 
         @Override
         public ExecTO call() throws Exception {
-            return execProvisioningTask(taskService, taskKey, maxWaitSeconds, dryRun);
+            return execProvisioningTask(taskService, type, taskKey, maxWaitSeconds, dryRun);
         }
     }
 
@@ -123,10 +127,11 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
         }
     }
 
-    protected static ExecTO execTask(final TaskService taskService, final String taskKey, final String initialStatus,
-            final int maxWaitSeconds, final boolean dryRun) {
+    protected static ExecTO execTask(
+            final TaskService taskService, final TaskType type, final String taskKey,
+            final String initialStatus, final int maxWaitSeconds, final boolean dryRun) {
 
-        TaskTO taskTO = taskService.read(taskKey, true);
+        TaskTO taskTO = taskService.read(type, taskKey, true);
         assertNotNull(taskTO);
         assertNotNull(taskTO.getExecutions());
 
@@ -145,7 +150,7 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
             } catch (InterruptedException e) {
             }
 
-            taskTO = taskService.read(taskTO.getKey(), true);
+            taskTO = taskService.read(type, taskTO.getKey(), true);
 
             assertNotNull(taskTO);
             assertNotNull(taskTO.getExecutions());
@@ -159,25 +164,27 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
     }
 
     public static ExecTO execProvisioningTask(
-            final TaskService taskService, final String taskKey, final int maxWaitSeconds, final boolean dryRun) {
+            final TaskService taskService, final TaskType type, final String taskKey,
+            final int maxWaitSeconds, final boolean dryRun) {
 
-        return execTask(taskService, taskKey, "JOB_FIRED", maxWaitSeconds, dryRun);
+        return execTask(taskService, type, taskKey, "JOB_FIRED", maxWaitSeconds, dryRun);
     }
 
     protected static ExecTO execNotificationTask(
             final TaskService taskService, final String taskKey, final int maxWaitSeconds) {
 
-        return execTask(taskService, taskKey, NotificationJob.Status.SENT.name(), maxWaitSeconds, false);
+        return execTask(taskService, TaskType.NOTIFICATION, taskKey,
+                NotificationJob.Status.SENT.name(), maxWaitSeconds, false);
     }
 
-    protected void execProvisioningTasks(final TaskService taskService,
-            final Set<String> taskKeys, final int maxWaitSeconds, final boolean dryRun) throws Exception {
+    protected void execProvisioningTasks(final TaskService taskService, final TaskType type, final Set<String> taskKeys,
+            final int maxWaitSeconds, final boolean dryRun) throws Exception {
 
         ExecutorService service = Executors.newFixedThreadPool(taskKeys.size());
         List<Future<ExecTO>> futures = new ArrayList<>();
 
         for (String key : taskKeys) {
-            futures.add(service.submit(new ThreadExec(taskService, key, maxWaitSeconds, dryRun)));
+            futures.add(service.submit(new ThreadExec(taskService, type, key, maxWaitSeconds, dryRun)));
             // avoid flooding the test server
             try {
                 Thread.sleep(2000);
index 1b7f931..172d18c 100644 (file)
@@ -85,6 +85,7 @@ import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.ResourceAssociationAction;
 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
 import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.service.GroupService;
 import org.apache.syncope.common.rest.api.service.SyncopeService;
@@ -915,7 +916,7 @@ public class GroupITCase extends AbstractITCase {
             do {
                 Thread.sleep(1000);
 
-                taskTO = taskService.read(exec.getRefKey(), true);
+                taskTO = taskService.read(TaskType.SCHEDULED, exec.getRefKey(), true);
 
                 assertNotNull(taskTO);
                 assertNotNull(taskTO.getExecutions());
index ea43662..54abfeb 100755 (executable)
@@ -25,12 +25,13 @@ import java.util.List;
 import org.apache.syncope.common.lib.to.WorkflowFormPropertyTO;\r
 import org.apache.syncope.common.lib.to.WorkflowFormTO;\r
 import org.junit.jupiter.api.Test;\r
+import org.apache.syncope.common.lib.types.TaskType;\r
 \r
 public class IdentityRecertificationITCase extends AbstractTaskITCase {\r
 \r
     @Test\r
     public void recertification() {\r
-        execTask(taskService, "e95555d2-1b09-42c8-b25b-f4c4ec598989", "JOB_FIRED", 50, false);\r
+        execTask(taskService, TaskType.SCHEDULED, "e95555d2-1b09-42c8-b25b-f4c4ec598989", "JOB_FIRED", 50, false);\r
 \r
         List<WorkflowFormTO> forms = userWorkflowService.getForms();\r
         assertFalse(forms.isEmpty());\r
index b4e243d..109e750 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.syncope.common.lib.to.PullTaskTO;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.service.ImplementationService;
 import org.apache.syncope.fit.AbstractITCase;
 import org.apache.syncope.fit.core.reference.TestPullActions;
@@ -78,15 +79,15 @@ public class ImplementationITCase extends AbstractITCase {
 
         implementationService.create(implementationTO);
 
-        PullTaskTO pullTask = taskService.read(AbstractTaskITCase.PULL_TASK_KEY, false);
+        PullTaskTO pullTask = taskService.read(TaskType.PULL, AbstractTaskITCase.PULL_TASK_KEY, false);
         assertNotNull(pullTask);
 
         int before = pullTask.getActions().size();
 
         pullTask.getActions().add(implementationTO.getKey());
-        taskService.update(pullTask);
+        taskService.update(TaskType.PULL, pullTask);
 
-        pullTask = taskService.read(AbstractTaskITCase.PULL_TASK_KEY, false);
+        pullTask = taskService.read(TaskType.PULL, AbstractTaskITCase.PULL_TASK_KEY, false);
         assertNotNull(pullTask);
 
         int after = pullTask.getActions().size();
@@ -101,7 +102,7 @@ public class ImplementationITCase extends AbstractITCase {
         }
 
         pullTask.getActions().remove(implementationTO.getKey());
-        taskService.update(pullTask);
+        taskService.update(TaskType.PULL, pullTask);
 
         implementationService.delete(implementationTO.getKey());
     }
index a4f6ac5..9e524da 100644 (file)
@@ -49,6 +49,7 @@ import org.apache.syncope.common.lib.types.MappingPurpose;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.service.TaskService;
 import org.apache.syncope.fit.AbstractITCase;
@@ -267,15 +268,16 @@ public class MembershipITCase extends AbstractITCase {
             userService.delete(user.getKey());
 
             // 4. create pull task and execute
-            newTask = taskService.read("7c2242f4-14af-4ab5-af31-cdae23783655", true);
+            newTask = taskService.read(TaskType.PULL, "7c2242f4-14af-4ab5-af31-cdae23783655", true);
             newTask.setResource(newResource.getKey());
             newTask.setDestinationRealm("/even/two");
 
-            Response response = taskService.create(newTask);
+            Response response = taskService.create(TaskType.PULL, newTask);
             newTask = getObject(response.getLocation(), TaskService.class, PullTaskTO.class);
             assertNotNull(newTask);
 
-            ExecTO execution = AbstractTaskITCase.execProvisioningTask(taskService, newTask.getKey(), 50, false);
+            ExecTO execution = AbstractTaskITCase.execProvisioningTask(
+                    taskService, TaskType.PULL, newTask.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             // 5. verify that pulled user has
@@ -292,7 +294,7 @@ public class MembershipITCase extends AbstractITCase {
             fail(e.getMessage());
         } finally {
             if (newTask != null && !"83f7e85d-9774-43fe-adba-ccd856312994".equals(newTask.getKey())) {
-                taskService.delete(newTask.getKey());
+                taskService.delete(TaskType.PULL, newTask.getKey());
             }
             resourceService.delete(newResource.getKey());
         }
index db176df..7f23c31 100644 (file)
@@ -49,6 +49,7 @@ import org.apache.syncope.common.lib.types.MappingPurpose;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.SchemaType;
 import org.apache.syncope.common.lib.types.PullMode;
+import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.beans.SchemaQuery;
 import org.apache.syncope.common.rest.api.service.ConnectorService;
@@ -193,15 +194,15 @@ public class MultitenancyITCase extends AbstractITCase {
             task.setPullMode(PullMode.FULL_RECONCILIATION);
             task.setPerformCreate(true);
 
-            response = adminClient.getService(TaskService.class).create(task);
+            response = adminClient.getService(TaskService.class).create(TaskType.PULL, task);
             assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
-            task = adminClient.getService(TaskService.class).read(
+            task = adminClient.getService(TaskService.class).read(TaskType.PULL,
                     StringUtils.substringAfterLast(response.getLocation().toASCIIString(), "/"), true);
             assertNotNull(resource);
 
             // pull
             ExecTO execution = AbstractTaskITCase.execProvisioningTask(
-                    adminClient.getService(TaskService.class), task.getKey(), 50, false);
+                    adminClient.getService(TaskService.class), TaskType.PULL, task.getKey(), 50, false);
 
             // verify execution status
             String status = execution.getStatus();
index 38832be..8ac0cea 100644 (file)
@@ -64,7 +64,7 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
         assertTrue(verifyMail(sender, subject, created.getRight()));
 
         // verify message body
-        taskTO = taskService.read(taskTO.getKey(), true);
+        taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
         assertNotNull(taskTO);
         assertTrue(taskTO.isExecuted());
         assertNotNull(taskTO.getTextBody());
@@ -108,9 +108,11 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
             int preExecs = taskTO.getExecutions().size();
 
             // 4. verify notification could not be delivered
-            execTask(taskService, taskTO.getKey(), NotificationJob.Status.NOT_SENT.name(), 5, false);
+            execTask(
+                    taskService, TaskType.NOTIFICATION, taskTO.getKey(), NotificationJob.Status.NOT_SENT.name(), 5,
+                    false);
 
-            taskTO = taskService.read(taskTO.getKey(), true);
+            taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
             assertNotNull(taskTO);
             assertFalse(taskTO.isExecuted());
             assertTrue(preExecs <= taskTO.getExecutions().size());
@@ -137,11 +139,11 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
         // generate an execution in order to verify the deletion of a notification task with one or more executions
         execNotificationTask(taskService, taskTO.getKey(), 50);
 
-        taskTO = taskService.read(taskTO.getKey(), true);
+        taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
         assertTrue(taskTO.isExecuted());
         assertFalse(taskTO.getExecutions().isEmpty());
 
-        taskService.delete(taskTO.getKey());
+        taskService.delete(TaskType.NOTIFICATION, taskTO.getKey());
     }
 
     @Test
@@ -161,7 +163,7 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
             execNotificationTask(taskService, taskTO.getKey(), 50);
 
             // 4. verify
-            taskTO = taskService.read(taskTO.getKey(), true);
+            taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
             assertNotNull(taskTO);
             assertTrue(taskTO.isExecuted());
             assertEquals(1, taskTO.getExecutions().size());
@@ -191,7 +193,7 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
         assertTrue(verifyMail(sender, subject, created.getRight()));
 
         // verify that last exec status was updated
-        taskTO = taskService.read(taskTO.getKey(), true);
+        taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
         assertNotNull(taskTO);
         assertTrue(taskTO.isExecuted());
         assertTrue(taskTO.getExecutions().isEmpty());
@@ -214,7 +216,7 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
         assertTrue(verifyMail(sender, subject, created.getRight()));
 
         // verify task
-        taskTO = taskService.read(taskTO.getKey(), true);
+        taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
         assertTrue(taskTO.isExecuted());
         assertNotNull(taskTO);
         assertTrue(taskTO.getRecipients().contains("syncope445@syncope.apache.org"));
index 3afec6d..943ce6a 100644 (file)
@@ -89,7 +89,7 @@ public class PolicyITCase extends AbstractITCase {
 
     @Test
     public void getAccountPolicy() {
-        AccountPolicyTO policyTO = policyService.read("06e2ed52-6966-44aa-a177-a0ca7434201f");
+        AccountPolicyTO policyTO = policyService.read(PolicyType.ACCOUNT, "06e2ed52-6966-44aa-a177-a0ca7434201f");
 
         assertNotNull(policyTO);
         assertTrue(policyTO.getUsedByResources().isEmpty());
@@ -98,7 +98,7 @@ public class PolicyITCase extends AbstractITCase {
 
     @Test
     public void getPasswordPolicy() {
-        PasswordPolicyTO policyTO = policyService.read("986d1236-3ac5-4a19-810c-5ab21d79cba1");
+        PasswordPolicyTO policyTO = policyService.read(PolicyType.PASSWORD, "986d1236-3ac5-4a19-810c-5ab21d79cba1");
 
         assertNotNull(policyTO);
         assertTrue(policyTO.getUsedByResources().contains(RESOURCE_NAME_NOPROPAGATION));
@@ -107,7 +107,7 @@ public class PolicyITCase extends AbstractITCase {
 
     @Test
     public void getPullPolicy() {
-        PullPolicyTO policyTO = policyService.read("66691e96-285f-4464-bc19-e68384ea4c85");
+        PullPolicyTO policyTO = policyService.read(PolicyType.PULL, "66691e96-285f-4464-bc19-e68384ea4c85");
 
         assertNotNull(policyTO);
         assertTrue(policyTO.getUsedByRealms().isEmpty());
@@ -115,20 +115,20 @@ public class PolicyITCase extends AbstractITCase {
 
     @Test
     public void create() throws IOException {
-        PullPolicyTO policyTO = createPolicy(buildPullPolicyTO());
+        PullPolicyTO policyTO = createPolicy(PolicyType.PULL, buildPullPolicyTO());
         assertNotNull(policyTO);
         assertEquals("TestPullRule", policyTO.getCorrelationRules().get(AnyTypeKind.USER.name()));
     }
 
     @Test
     public void update() {
-        PasswordPolicyTO globalPolicy = policyService.read("ce93fcda-dc3a-4369-a7b0-a6108c261c85");
+        PasswordPolicyTO globalPolicy = policyService.read(PolicyType.PASSWORD, "ce93fcda-dc3a-4369-a7b0-a6108c261c85");
 
         PasswordPolicyTO policy = SerializationUtils.clone(globalPolicy);
         policy.setDescription("A simple password policy");
 
         // create a new password policy using the former as a template
-        policy = createPolicy(policy);
+        policy = createPolicy(PolicyType.PASSWORD, policy);
         assertNotNull(policy);
         assertNotEquals("ce93fcda-dc3a-4369-a7b0-a6108c261c85", policy.getKey());
 
@@ -140,8 +140,8 @@ public class PolicyITCase extends AbstractITCase {
         rule.setBody(POJOHelper.serialize(ruleConf));
 
         // update new password policy
-        policyService.update(policy);
-        policy = policyService.read(policy.getKey());
+        policyService.update(PolicyType.PASSWORD, policy);
+        policy = policyService.read(PolicyType.PASSWORD, policy.getKey());
         assertNotNull(policy);
 
         ruleConf = POJOHelper.deserialize(rule.getBody(), DefaultPasswordRuleConf.class);
@@ -153,13 +153,13 @@ public class PolicyITCase extends AbstractITCase {
     public void delete() throws IOException {
         PullPolicyTO policy = buildPullPolicyTO();
 
-        PullPolicyTO policyTO = createPolicy(policy);
+        PullPolicyTO policyTO = createPolicy(PolicyType.PULL, policy);
         assertNotNull(policyTO);
 
-        policyService.delete(policyTO.getKey());
+        policyService.delete(PolicyType.PULL, policyTO.getKey());
 
         try {
-            policyService.read(policyTO.getKey());
+            policyService.read(PolicyType.PULL, policyTO.getKey());
             fail("This should not happen");
         } catch (SyncopeClientException e) {
             assertNotNull(e);
@@ -193,7 +193,7 @@ public class PolicyITCase extends AbstractITCase {
 
         policy.getRules().add(rule.getKey());
 
-        policy = createPolicy(policy);
+        policy = createPolicy(PolicyType.ACCOUNT, policy);
         assertNotNull(policy);
     }
 
@@ -217,7 +217,7 @@ public class PolicyITCase extends AbstractITCase {
 
         policy.getRules().add(rule.getKey());
 
-        policy = createPolicy(policy);
+        policy = createPolicy(PolicyType.ACCOUNT, policy);
         assertNotNull(policy);
     }
 }
index 7ab6b22..f74b224 100644 (file)
@@ -76,7 +76,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
 
     @Test
     public void read() {
-        PropagationTaskTO taskTO = taskService.read("316285cc-ae52-4ea2-a33b-7355e189ac3f", true);
+        PropagationTaskTO taskTO = taskService.read(TaskType.PROPAGATION, "316285cc-ae52-4ea2-a33b-7355e189ac3f", true);
         assertNotNull(taskTO);
         assertNotNull(taskTO.getExecutions());
         assertTrue(taskTO.getExecutions().isEmpty());
@@ -171,12 +171,12 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
         }
 
         // check read
-        PropagationTaskTO task = taskService.read("1e697572-b896-484c-ae7f-0c8f63fcbc6c", false);
+        PropagationTaskTO task = taskService.read(TaskType.PROPAGATION, "1e697572-b896-484c-ae7f-0c8f63fcbc6c", false);
         assertNotNull(task);
         assertEquals("1e697572-b896-484c-ae7f-0c8f63fcbc6c", task.getKey());
         assertTrue(task.getExecutions().isEmpty());
 
-        task = taskService.read("1e697572-b896-484c-ae7f-0c8f63fcbc6c", true);
+        task = taskService.read(TaskType.PROPAGATION, "1e697572-b896-484c-ae7f-0c8f63fcbc6c", true);
         assertNotNull(task);
         assertEquals("1e697572-b896-484c-ae7f-0c8f63fcbc6c", task.getKey());
         assertFalse(task.getExecutions().isEmpty());
index 3e6a4f0..708c2fa 100644 (file)
@@ -73,6 +73,7 @@ import org.apache.syncope.common.lib.types.ConnConfProperty;
 import org.apache.syncope.common.lib.types.ConnectorCapability;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
 import org.apache.syncope.common.lib.types.PullMode;
@@ -119,9 +120,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
         }
         assertNotNull(pullActions);
 
-        PullTaskTO pullTask = taskService.read(PULL_TASK_KEY, true);
+        PullTaskTO pullTask = taskService.read(TaskType.PULL, PULL_TASK_KEY, true);
         pullTask.getActions().add(pullActions.getKey());
-        taskService.update(pullTask);
+        taskService.update(TaskType.PULL, pullTask);
     }
 
     @Test
@@ -160,11 +161,11 @@ public class PullTaskITCase extends AbstractTaskITCase {
         groupTemplate.getResources().add(RESOURCE_NAME_LDAP);
         task.getTemplates().put(AnyTypeKind.GROUP.name(), groupTemplate);
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.PULL, task);
         PullTaskTO actual = getObject(response.getLocation(), TaskService.class, PullTaskTO.class);
         assertNotNull(actual);
 
-        task = taskService.read(actual.getKey(), true);
+        task = taskService.read(TaskType.PULL, actual.getKey(), true);
         assertNotNull(task);
         assertEquals(actual.getKey(), task.getKey());
         assertEquals(actual.getJobDelegate(), task.getJobDelegate());
@@ -229,7 +230,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
                     page(1).size(1).build()).getTotalCount();
             assertNotNull(usersPre);
 
-            ExecTO exec = execProvisioningTask(taskService, PULL_TASK_KEY, 50, false);
+            ExecTO exec = execProvisioningTask(taskService, TaskType.PULL, PULL_TASK_KEY, 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
 
             LOG.debug("Execution of task {}:\n{}", PULL_TASK_KEY, exec);
@@ -297,7 +298,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             Set<String> otherPullTaskKeys = new HashSet<>();
             otherPullTaskKeys.add("feae4e57-15ca-40d9-b973-8b9015efca49");
             otherPullTaskKeys.add("55d5e74b-497e-4bc0-9156-73abef4b9adc");
-            execProvisioningTasks(taskService, otherPullTaskKeys, 50, false);
+            execProvisioningTasks(taskService, TaskType.PULL, otherPullTaskKeys, 50, false);
 
             // Matching --> UNLINK
             assertFalse(userService.read("test9").getResources().contains(RESOURCE_NAME_CSV));
@@ -309,7 +310,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
     @Test
     public void dryRun() {
-        ExecTO execution = execProvisioningTask(taskService, PULL_TASK_KEY, 50, true);
+        ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, PULL_TASK_KEY, 50, true);
         assertEquals("SUCCESS", execution.getStatus());
     }
 
@@ -319,7 +320,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
         try {
             ExecTO execution = execProvisioningTask(
-                    taskService, "83f7e85d-9774-43fe-adba-ccd856312994", 50, false);
+                    taskService, TaskType.PULL, "83f7e85d-9774-43fe-adba-ccd856312994", 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             userTO = userService.read("testuser1");
@@ -332,7 +333,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             // re-execute the same PullTask: now user must be active
             execution = execProvisioningTask(
-                    taskService, "83f7e85d-9774-43fe-adba-ccd856312994", 50, false);
+                    taskService, TaskType.PULL, "83f7e85d-9774-43fe-adba-ccd856312994", 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             userTO = userService.read("testuser1");
@@ -352,7 +353,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
         ldapCleanup();
 
         // 0. pull
-        ExecTO execution = execProvisioningTask(taskService, "1e419ca4-ea81-4493-a14f-28b90113686d", 50, false);
+        ExecTO execution = execProvisioningTask(
+                taskService, TaskType.PULL, "1e419ca4-ea81-4493-a14f-28b90113686d", 50, false);
 
         // 1. verify execution status
         assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
@@ -365,7 +367,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         assertNotNull(matchingGroups);
         assertEquals(1, matchingGroups.getResult().size());
         // SYNCOPE-898
-        PullTaskTO task = taskService.read("1e419ca4-ea81-4493-a14f-28b90113686d", false);
+        PullTaskTO task = taskService.read(TaskType.PULL, "1e419ca4-ea81-4493-a14f-28b90113686d", false);
         assertEquals("/", task.getDestinationRealm());
         assertEquals("/", matchingGroups.getResult().get(0).getRealm());
 
@@ -396,7 +398,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         assertNull(groupTO.getGroupOwner());
 
         // SYNCOPE-317
-        execProvisioningTask(taskService, "1e419ca4-ea81-4493-a14f-28b90113686d", 50, false);
+        execProvisioningTask(taskService, TaskType.PULL, "1e419ca4-ea81-4493-a14f-28b90113686d", 50, false);
 
         // 4. verify that LDAP group membership is propagated as Syncope membership
         int i = 0;
@@ -487,12 +489,12 @@ public class PullTaskITCase extends AbstractTaskITCase {
             }
 
             // ensure that the pull task does not have the DELETE capability (SYNCOPE-923)
-            PullTaskTO pullTask = taskService.read("30cfd653-257b-495f-8665-281281dbcb3d", false);
+            PullTaskTO pullTask = taskService.read(TaskType.PULL, "30cfd653-257b-495f-8665-281281dbcb3d", false);
             assertNotNull(pullTask);
             assertFalse(pullTask.isPerformDelete());
 
             // 4. pull
-            execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+            execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
 
             // 5. verify that printer was re-created in Syncope (implies that location does not start with given prefix,
             // hence PrefixItemTransformer was applied during pull)
@@ -535,16 +537,16 @@ public class PullTaskITCase extends AbstractTaskITCase {
             reconFilterBuilder = getObject(response.getLocation(), ImplementationService.class, ImplementationTO.class);
             assertNotNull(reconFilterBuilder);
 
-            task = taskService.read("7c2242f4-14af-4ab5-af31-cdae23783655", true);
+            task = taskService.read(TaskType.PULL, "7c2242f4-14af-4ab5-af31-cdae23783655", true);
             task.setPullMode(PullMode.FILTERED_RECONCILIATION);
             task.setReconFilterBuilder(reconFilterBuilder.getKey());
-            response = taskService.create(task);
+            response = taskService.create(TaskType.PULL, task);
             task = getObject(response.getLocation(), TaskService.class, PullTaskTO.class);
             assertNotNull(task);
             assertEquals(reconFilterBuilder.getKey(), task.getReconFilterBuilder());
 
             // 3. exec task
-            ExecTO execution = execProvisioningTask(taskService, task.getKey(), 50, false);
+            ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, task.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             // 4. verify that only enabled user was pulled
@@ -561,7 +563,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             jdbcTemplate.execute("DELETE FROM testpull WHERE id = '" + user1OnTestPull + "'");
             jdbcTemplate.execute("DELETE FROM testpull WHERE id = '" + user2OnTestPull + "'");
             if (task != null && !"7c2242f4-14af-4ab5-af31-cdae23783655".equals(task.getKey())) {
-                taskService.delete(task.getKey());
+                taskService.delete(TaskType.PULL, task.getKey());
             }
             if (userTO != null) {
                 userService.delete(userTO.getKey());
@@ -611,7 +613,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             pullTask.setPerformUpdate(true);
             pullTask.setPerformDelete(true);
 
-            response = taskService.create(pullTask);
+            response = taskService.create(TaskType.PULL, pullTask);
             if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
                 throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
             }
@@ -626,7 +628,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
                     + "(1041, 'syncTokenWithErrors2', 'Surname2', "
                     + "false, 'syncTokenWithErrors1@syncope.apache.org', '2015-05-23 13:53:24.293')");
 
-            ExecTO exec = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+            ExecTO exec = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
 
             resForTest = resourceService.read(resForTest.getKey());
@@ -636,7 +638,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
                     + "SET email='syncTokenWithErrors2@syncope.apache.org', lastModification='2016-05-23 13:53:24.293' "
                     + "WHERE ID=1041");
 
-            exec = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+            exec = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
 
             resForTest = resourceService.read(resForTest.getKey());
@@ -695,19 +697,19 @@ public class PullTaskITCase extends AbstractTaskITCase {
             //-----------------------------
 
             // Update pull task
-            PullTaskTO task = taskService.read("81d88f73-d474-4450-9031-605daa4e313f", true);
+            PullTaskTO task = taskService.read(TaskType.PULL, "81d88f73-d474-4450-9031-605daa4e313f", true);
             assertNotNull(task);
 
             task.getTemplates().put(AnyTypeKind.USER.name(), template);
 
-            taskService.update(task);
-            PullTaskTO actual = taskService.read(task.getKey(), true);
+            taskService.update(TaskType.PULL, task);
+            PullTaskTO actual = taskService.read(TaskType.PULL, task.getKey(), true);
             assertNotNull(actual);
             assertEquals(task.getKey(), actual.getKey());
             assertFalse(actual.getTemplates().get(AnyTypeKind.USER.name()).getResources().isEmpty());
             assertFalse(((UserTO) actual.getTemplates().get(AnyTypeKind.USER.name())).getMemberships().isEmpty());
 
-            ExecTO execution = execProvisioningTask(taskService, actual.getKey(), 50, false);
+            ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, actual.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             userTO = userService.read("testuser2");
@@ -732,7 +734,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
                 + "('" + id + "', 'issuesyncope230', 'Surname', false, 'syncope230@syncope.apache.org', NULL)");
 
         // 2. execute PullTask for resource-db-pull (table TESTPULL on external H2)
-        execProvisioningTask(taskService, "7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
+        execProvisioningTask(taskService, TaskType.PULL, "7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
 
         // 3. read e-mail address for user created by the PullTask first execution
         UserTO userTO = userService.read("issuesyncope230");
@@ -744,7 +746,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         jdbcTemplate.execute("UPDATE TESTPULL SET email='updatedSYNCOPE230@syncope.apache.org' WHERE id='" + id + "'");
 
         // 5. re-execute the PullTask
-        execProvisioningTask(taskService, "7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
+        execProvisioningTask(taskService, TaskType.PULL, "7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
 
         // 6. verify that the e-mail was updated
         userTO = userService.read("issuesyncope230");
@@ -777,9 +779,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
         }
         assertNotNull(corrRule);
 
-        PullPolicyTO policyTO = policyService.read("9454b0d7-2610-400a-be82-fc23cf553dd6");
+        PullPolicyTO policyTO = policyService.read(PolicyType.PULL, "9454b0d7-2610-400a-be82-fc23cf553dd6");
         policyTO.getCorrelationRules().put(AnyTypeKind.USER.name(), corrRule.getKey());
-        policyService.update(policyTO);
+        policyService.update(PolicyType.PULL, policyTO);
         // -----------------------------
 
         PullTaskTO task = new PullTaskTO();
@@ -792,7 +794,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         task.setPerformDelete(true);
         task.setPerformUpdate(true);
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.PULL, task);
         task = getObject(response.getLocation(), TaskService.class, PullTaskTO.class);
 
         UserTO userTO = UserITCase.getUniqueSampleTO("s258_1@apache.org");
@@ -814,9 +816,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
         userService.update(userPatch);
 
-        execProvisioningTask(taskService, task.getKey(), 50, false);
+        execProvisioningTask(taskService, TaskType.PULL, task.getKey(), 50, false);
 
-        PullTaskTO executed = taskService.read(task.getKey(), true);
+        PullTaskTO executed = taskService.read(TaskType.PULL, task.getKey(), true);
         assertEquals(1, executed.getExecutions().size());
 
         // asser for just one match
@@ -840,7 +842,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
 
             ExecTO taskExecTO = execProvisioningTask(
-                    taskService, "986867e2-993b-430e-8feb-aa9abb4c1dcd", 50, false);
+                    taskService, TaskType.PULL, "986867e2-993b-430e-8feb-aa9abb4c1dcd", 50, false);
 
             assertNotNull(taskExecTO.getStatus());
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(taskExecTO.getStatus()));
@@ -871,7 +873,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         assertTrue(userTO.getVirAttrs().isEmpty());
 
         // Update pull task
-        PullTaskTO task = taskService.read("38abbf9e-a1a3-40a1-a15f-7d0ac02f47f1", true);
+        PullTaskTO task = taskService.read(TaskType.PULL, "38abbf9e-a1a3-40a1-a15f-7d0ac02f47f1", true);
         assertNotNull(task);
 
         UserTO template = new UserTO();
@@ -881,10 +883,10 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
         task.getTemplates().put(AnyTypeKind.USER.name(), template);
 
-        taskService.update(task);
+        taskService.update(TaskType.PULL, task);
 
         // exec task: one user from CSV will match the user created above and template will be applied
-        execProvisioningTask(taskService, task.getKey(), 50, false);
+        execProvisioningTask(taskService, TaskType.PULL, task.getKey(), 50, false);
 
         // check that template was successfully applied...
         userTO = userService.read(userTO.getKey());
@@ -937,17 +939,17 @@ public class PullTaskITCase extends AbstractTaskITCase {
         pullTask.setPullMode(PullMode.FULL_RECONCILIATION);
         pullTask.setResource(RESOURCE_NAME_TESTDB);
         pullTask.getActions().add(pullActions.getKey());
-        Response taskResponse = taskService.create(pullTask);
+        Response taskResponse = taskService.create(TaskType.PULL, pullTask);
 
         PullTaskTO actual = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
         assertNotNull(actual);
 
-        pullTask = taskService.read(actual.getKey(), true);
+        pullTask = taskService.read(TaskType.PULL, actual.getKey(), true);
         assertNotNull(pullTask);
         assertEquals(actual.getKey(), pullTask.getKey());
         assertEquals(actual.getJobDelegate(), pullTask.getJobDelegate());
 
-        ExecTO execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+        ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
         assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
         // 5. Test the pulled user
@@ -955,7 +957,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         assertNotNull(self);
 
         // 6. Delete PullTask + user
-        taskService.delete(pullTask.getKey());
+        taskService.delete(TaskType.PULL, pullTask.getKey());
         deleteUser(user.getKey());
     }
 
@@ -1026,12 +1028,12 @@ public class PullTaskITCase extends AbstractTaskITCase {
             pullTask.setPullMode(PullMode.FULL_RECONCILIATION);
             pullTask.setResource(RESOURCE_NAME_LDAP);
             pullTask.getActions().add(pullActions.getKey());
-            Response taskResponse = taskService.create(pullTask);
+            Response taskResponse = taskService.create(TaskType.PULL, pullTask);
 
             pullTask = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
             assertNotNull(pullTask);
 
-            ExecTO execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+            ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             // 7. Test the pulled user
@@ -1042,7 +1044,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         } finally {
             // Delete PullTask + user + reset the connector
             if (pullTask != null) {
-                taskService.delete(pullTask.getKey());
+                taskService.delete(TaskType.PULL, pullTask.getKey());
             }
 
             if (resourceConnector != null && property != null) {
@@ -1085,13 +1087,13 @@ public class PullTaskITCase extends AbstractTaskITCase {
             template.getPlainAttrs().add(attrTO("firstname", "'fixed'"));
             pullTask.getTemplates().put(AnyTypeKind.USER.name(), template);
 
-            Response taskResponse = taskService.create(pullTask);
+            Response taskResponse = taskService.create(TaskType.PULL, pullTask);
             pullTask = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
             assertNotNull(pullTask);
             assertFalse(pullTask.getTemplates().isEmpty());
 
             // 3. exec the pull task
-            ExecTO execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+            ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             // the user is successfully pulled...
@@ -1127,7 +1129,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertEquals("pullFromLDAP2@syncope.apache.org", connObject.getAttr("mail").get().getValues().get(0));
 
             // 5. exec the pull task again
-            execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+            execution = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             // the internal is updated...
@@ -1145,7 +1147,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             fail(e.getMessage());
         } finally {
             if (pullTask != null) {
-                taskService.delete(pullTask.getKey());
+                taskService.delete(TaskType.PULL, pullTask.getKey());
             }
 
             if (propagationGroup != null) {
index c46c445..7255ac5 100644 (file)
@@ -79,7 +79,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
     @Test
     public void read() {
         PushTaskTO pushTaskTO = taskService.<PushTaskTO>read(
-                "0bc11a19-6454-45c2-a4e3-ceef84e5d79b", true);
+                TaskType.PUSH, "0bc11a19-6454-45c2-a4e3-ceef84e5d79b", true);
         assertEquals(UnmatchingRule.ASSIGN, pushTaskTO.getUnmatchingRule());
         assertEquals(MatchingRule.UPDATE, pushTaskTO.getMatchingRule());
     }
@@ -105,11 +105,11 @@ public class PushTaskITCase extends AbstractTaskITCase {
                 SyncopeClient.getGroupSearchConditionBuilder().isNotNull("cool").query());
         task.setMatchingRule(MatchingRule.LINK);
 
-        final Response response = taskService.create(task);
+        final Response response = taskService.create(TaskType.PUSH, task);
         final PushTaskTO actual = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
         assertNotNull(actual);
 
-        task = taskService.read(actual.getKey(), true);
+        task = taskService.read(TaskType.PUSH, actual.getKey(), true);
         assertNotNull(task);
         assertEquals(task.getKey(), actual.getKey());
         assertEquals(task.getJobDelegate(), actual.getJobDelegate());
@@ -126,7 +126,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         assertFalse(groupService.read("29f96485-729e-4d31-88a1-6fc60e4677f3").
                 getResources().contains(RESOURCE_NAME_LDAP));
 
-        execProvisioningTask(taskService, "fd905ba5-9d56-4f51-83e2-859096a67b75", 50, false);
+        execProvisioningTask(taskService, TaskType.PUSH, "fd905ba5-9d56-4f51-83e2-859096a67b75", 50, false);
 
         assertNotNull(resourceService.readConnObject(
                 RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), "29f96485-729e-4d31-88a1-6fc60e4677f3"));
@@ -151,7 +151,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         // ------------------------------------------
         // Unmatching --> Assign --> dryRuyn
         // ------------------------------------------
-        execProvisioningTask(taskService, "af558be4-9d2f-4359-bf85-a554e6e90be1", 50, true);
+        execProvisioningTask(taskService, TaskType.PUSH, "af558be4-9d2f-4359-bf85-a554e6e90be1", 50, true);
         assertEquals(0, jdbcTemplate.queryForList("SELECT ID FROM test2 WHERE ID='vivaldi'").size());
         assertFalse(userService.read("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee").
                 getResources().contains(RESOURCE_NAME_TESTDB2));
@@ -162,7 +162,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         pushTaskKeys.add("97f327b6-2eff-4d35-85e8-d581baaab855");
         pushTaskKeys.add("03aa2a04-4881-4573-9117-753f81b04865");
         pushTaskKeys.add("5e5f7c7e-9de7-4c6a-99f1-4df1af959807");
-        execProvisioningTasks(taskService, pushTaskKeys, 50, false);
+        execProvisioningTasks(taskService, TaskType.PUSH, pushTaskKeys, 50, false);
 
         // ------------------------------------------
         // Unatching --> Ignore
@@ -213,7 +213,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         // ------------------------------------------
         // Matching --> Deprovision --> dryRuyn
         // ------------------------------------------
-        execProvisioningTask(taskService, "c46edc3a-a18b-4af2-b707-f4a415507496", 50, true);
+        execProvisioningTask(taskService, TaskType.PUSH, "c46edc3a-a18b-4af2-b707-f4a415507496", 50, true);
         assertTrue(userService.read("1417acbe-cbf6-4277-9372-e75e04f97000").
                 getResources().contains(RESOURCE_NAME_TESTDB2));
         assertEquals(1, jdbcTemplate.queryForList("SELECT ID FROM test2 WHERE ID='rossini'").size());
@@ -224,7 +224,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         pushTaskKeys.add("c46edc3a-a18b-4af2-b707-f4a415507496");
         pushTaskKeys.add("5e5f7c7e-9de7-4c6a-99f1-4df1af959807");
 
-        execProvisioningTasks(taskService, pushTaskKeys, 50, false);
+        execProvisioningTasks(taskService, TaskType.PUSH, pushTaskKeys, 50, false);
 
         // ------------------------------------------
         // Matching --> Deprovision && Ignore
@@ -247,7 +247,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         // ------------------------------------------
         // Matching --> Link
         // ------------------------------------------
-        execProvisioningTask(taskService, "51318433-cce4-4f71-8f45-9534b6c9c819", 50, false);
+        execProvisioningTask(taskService, TaskType.PUSH, "51318433-cce4-4f71-8f45-9534b6c9c819", 50, false);
         assertTrue(userService.read("74cd8ece-715a-44a4-a736-e17b46c4e7e6").
                 getResources().contains(RESOURCE_NAME_TESTDB2));
         assertEquals(1, jdbcTemplate.queryForList("SELECT ID FROM test2 WHERE ID='verdi'").size());
@@ -257,7 +257,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         pushTaskKeys.add("24b1be9c-7e3b-443a-86c9-798ebce5eaf2");
         pushTaskKeys.add("375c7b7f-9e3a-4833-88c9-b7787b0a69f2");
 
-        execProvisioningTasks(taskService, pushTaskKeys, 50, false);
+        execProvisioningTasks(taskService, TaskType.PUSH, pushTaskKeys, 50, false);
 
         // ------------------------------------------
         // Matching --> Unlink && Update
@@ -284,11 +284,11 @@ public class PushTaskITCase extends AbstractTaskITCase {
         task.setPerformDelete(true);
         task.setPerformUpdate(true);
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.PUSH, task);
         PushTaskTO pushTask = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
         assertNotNull(pushTask);
 
-        ExecTO exec = execProvisioningTask(taskService, pushTask.getKey(), 50, false);
+        ExecTO exec = execProvisioningTask(taskService, TaskType.PUSH, pushTask.getKey(), 50, false);
         assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
 
         // 2. check
@@ -371,12 +371,12 @@ public class PushTaskITCase extends AbstractTaskITCase {
             task.getFilters().put(AnyTypeKind.GROUP.name(),
                     SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo(groupTO.getName()).query());
 
-            response = taskService.create(task);
+            response = taskService.create(TaskType.PUSH, task);
             PushTaskTO push = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
             assertNotNull(push);
 
             // execute the new task
-            ExecTO exec = execProvisioningTask(taskService, push.getKey(), 50, false);
+            ExecTO exec = execProvisioningTask(taskService, TaskType.PUSH, push.getKey(), 50, false);
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
         } finally {
             groupService.delete(groupTO.getKey());
@@ -401,7 +401,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         task.setMatchingRule(MatchingRule.IGNORE);
         task.setUnmatchingRule(UnmatchingRule.IGNORE);
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.PUSH, task);
         PushTaskTO actual = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
         assertNotNull(actual);
 
@@ -425,7 +425,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
         notification = getObject(responseNotification.getLocation(), NotificationService.class, NotificationTO.class);
         assertNotNull(notification);
 
-        execProvisioningTask(taskService, actual.getKey(), 50, false);
+        execProvisioningTask(taskService, TaskType.PUSH, actual.getKey(), 50, false);
 
         NotificationTaskTO taskTO = findNotificationTask(notification.getKey(), 50);
         assertNotNull(taskTO);
index 7f2a9cc..1799e88 100644 (file)
@@ -40,6 +40,7 @@ import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 import org.apache.syncope.common.rest.api.service.RealmService;
@@ -144,7 +145,7 @@ public class RealmITCase extends AbstractITCase {
         policy.setDescription("deletingAccountPolicy");
         policy.getRules().add(rule.getKey());
 
-        policy = createPolicy(policy);
+        policy = createPolicy(PolicyType.ACCOUNT, policy);
         assertNotNull(policy);
 
         // 2. create realm with policy assigned
@@ -169,7 +170,7 @@ public class RealmITCase extends AbstractITCase {
         assertEquals(policy.getKey(), actual.getAccountPolicy());
 
         // 3. remove policy
-        policyService.delete(policy.getKey());
+        policyService.delete(PolicyType.ACCOUNT, policy.getKey());
 
         // 4. verify
         actual = getRealm(actual.getFullPath()).get();
index a88327f..358506a 100644 (file)
@@ -72,7 +72,7 @@ public class SchedTaskITCase extends AbstractTaskITCase {
 
     @Test
     public void update() {
-        SchedTaskTO task = taskService.read(SCHED_TASK_KEY, true);
+        SchedTaskTO task = taskService.read(TaskType.SCHEDULED, SCHED_TASK_KEY, true);
         assertNotNull(task);
 
         SchedTaskTO taskMod = new SchedTaskTO();
@@ -80,8 +80,8 @@ public class SchedTaskITCase extends AbstractTaskITCase {
         taskMod.setName(task.getName());
         taskMod.setCronExpression(null);
 
-        taskService.update(taskMod);
-        SchedTaskTO actual = taskService.read(taskMod.getKey(), true);
+        taskService.update(TaskType.SCHEDULED, taskMod);
+        SchedTaskTO actual = taskService.read(TaskType.SCHEDULED, taskMod.getKey(), true);
         assertNotNull(actual);
         assertEquals(task.getKey(), actual.getKey());
         assertNull(actual.getCronExpression());
@@ -97,7 +97,7 @@ public class SchedTaskITCase extends AbstractTaskITCase {
         task.setName("deferred");
         task.setJobDelegate(taskJobDelegate.getKey());
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.SCHEDULED, task);
         task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
         assertNotNull(task);
 
@@ -116,7 +116,7 @@ public class SchedTaskITCase extends AbstractTaskITCase {
             } catch (InterruptedException e) {
             }
 
-            task = taskService.read(task.getKey(), true);
+            task = taskService.read(TaskType.SCHEDULED, task.getKey(), true);
 
             assertNotNull(task);
             assertNotNull(task.getExecutions());
@@ -142,13 +142,13 @@ public class SchedTaskITCase extends AbstractTaskITCase {
         task.setDescription("issueSYNCOPE144 Description");
         task.setJobDelegate(taskJobDelegate.getKey());
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.SCHEDULED, task);
         task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
         assertNotNull(task);
         assertEquals("issueSYNCOPE144", task.getName());
         assertEquals("issueSYNCOPE144 Description", task.getDescription());
 
-        task = taskService.read(task.getKey(), true);
+        task = taskService.read(TaskType.SCHEDULED, task.getKey(), true);
         assertNotNull(task);
         assertEquals("issueSYNCOPE144", task.getName());
         assertEquals("issueSYNCOPE144 Description", task.getDescription());
@@ -156,7 +156,7 @@ public class SchedTaskITCase extends AbstractTaskITCase {
         task.setName("issueSYNCOPE144_2");
         task.setDescription("issueSYNCOPE144 Description_2");
 
-        response = taskService.create(task);
+        response = taskService.create(TaskType.SCHEDULED, task);
         task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
         assertNotNull(task);
         assertEquals("issueSYNCOPE144_2", task.getName());
@@ -176,7 +176,7 @@ public class SchedTaskITCase extends AbstractTaskITCase {
         task.setDescription("issueSYNCOPE660 Description");
         task.setJobDelegate(taskJobDelegate.getKey());
 
-        Response response = taskService.create(task);
+        Response response = taskService.create(TaskType.SCHEDULED, task);
         task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
 
         jobs = taskService.listJobs();
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SwaggerITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SwaggerITCase.java
deleted file mode 100644 (file)
index d928e3c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.fit.core;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.syncope.fit.AbstractITCase;
-import org.junit.jupiter.api.Test;
-
-public class SwaggerITCase extends AbstractITCase {
-
-    @Test
-    public void swagger() throws IOException {
-        WebClient webClient = WebClient.create(ADDRESS + "/swagger.json").accept(MediaType.APPLICATION_JSON_TYPE);
-        Response response = webClient.get();
-        assumeTrue(response.getStatus() == 200);
-
-        JsonNode tree = new ObjectMapper().readTree((InputStream) response.getEntity());
-        assertNotNull(tree);
-
-        JsonNode info = tree.get("info");
-        assertEquals("Apache Syncope", info.get("title").asText());
-
-        assertEquals("/syncope/rest", tree.get("basePath").asText());
-
-        JsonNode tags = tree.get("tags");
-        assertNotNull(tags);
-        assertTrue(tags.isContainerNode());
-
-        JsonNode paths = tree.get("paths");
-        assertNotNull(paths);
-        assertTrue(paths.isContainerNode());
-
-        JsonNode definitions = tree.get("definitions");
-        assertNotNull(definitions);
-        assertTrue(definitions.isContainerNode());
-    }
-}
index 83d41c1..f962361 100644 (file)
@@ -73,6 +73,7 @@ import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
 import org.apache.syncope.common.lib.types.PatchOperation;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.ResourceAssociationAction;
 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
@@ -276,7 +277,7 @@ public class UserITCase extends AbstractITCase {
         assertFalse(tasks.getResult().isEmpty());
 
         String maxKey = tasks.getResult().iterator().next().getKey();
-        PropagationTaskTO taskTO = taskService.read(maxKey, true);
+        PropagationTaskTO taskTO = taskService.read(TaskType.PROPAGATION, maxKey, true);
 
         assertNotNull(taskTO);
         int maxTaskExecutions = taskTO.getExecutions().size();
@@ -324,7 +325,7 @@ public class UserITCase extends AbstractITCase {
         assertEquals(newMaxKey, maxKey);
 
         // get last task
-        taskTO = taskService.read(newMaxKey, true);
+        taskTO = taskService.read(TaskType.PROPAGATION, newMaxKey, true);
 
         assertNotNull(taskTO);
         assertEquals(maxTaskExecutions, taskTO.getExecutions().size());
@@ -680,7 +681,7 @@ public class UserITCase extends AbstractITCase {
         // all update executions have to be registered
         newMaxKey = tasks.getResult().iterator().next().getKey();
 
-        PropagationTaskTO taskTO = taskService.read(newMaxKey, true);
+        PropagationTaskTO taskTO = taskService.read(TaskType.PROPAGATION, newMaxKey, true);
 
         assertNotNull(taskTO);
         assertEquals(1, taskTO.getExecutions().size());
@@ -950,7 +951,7 @@ public class UserITCase extends AbstractITCase {
         AccountPolicyTO accountPolicy = new AccountPolicyTO();
         accountPolicy.setDescription("Account Policy with custom rules");
         accountPolicy.getRules().add(implementationTO.getKey());
-        accountPolicy = createPolicy(accountPolicy);
+        accountPolicy = createPolicy(PolicyType.ACCOUNT, accountPolicy);
         assertNotNull(accountPolicy);
 
         implementationTO = new ImplementationTO();
@@ -964,7 +965,7 @@ public class UserITCase extends AbstractITCase {
         PasswordPolicyTO passwordPolicy = new PasswordPolicyTO();
         passwordPolicy.setDescription("Password Policy with custom rules");
         passwordPolicy.getRules().add(implementationTO.getKey());
-        passwordPolicy = createPolicy(passwordPolicy);
+        passwordPolicy = createPolicy(PolicyType.PASSWORD, passwordPolicy);
         assertNotNull(passwordPolicy);
 
         RealmTO realm = realmService.list("/even/two").get(0);
@@ -1002,8 +1003,8 @@ public class UserITCase extends AbstractITCase {
             realm.setPasswordPolicy(oldPasswordPolicy);
             realmService.update(realm);
 
-            policyService.delete(passwordPolicy.getKey());
-            policyService.delete(accountPolicy.getKey());
+            policyService.delete(PolicyType.PASSWORD, passwordPolicy.getKey());
+            policyService.delete(PolicyType.ACCOUNT, accountPolicy.getKey());
         }
     }
 
index 2a1e944..8ff08a0 100644 (file)
@@ -71,6 +71,7 @@ import org.apache.syncope.common.lib.types.ImplementationEngine;
 import org.apache.syncope.common.lib.types.ImplementationType;
 import org.apache.syncope.common.lib.types.MappingPurpose;
 import org.apache.syncope.common.lib.types.PatchOperation;
+import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 import org.apache.syncope.common.rest.api.service.ImplementationService;
@@ -1228,7 +1229,7 @@ public class UserIssuesITCase extends AbstractITCase {
         passwordPolicy.setDescription("Password Policy for SYNCOPE-626");
         passwordPolicy.getRules().add(rule.getKey());
 
-        passwordPolicy = createPolicy(passwordPolicy);
+        passwordPolicy = createPolicy(PolicyType.PASSWORD, passwordPolicy);
         assertNotNull(passwordPolicy);
 
         RealmTO realm = realmService.list("/even/two").get(0);
@@ -1255,7 +1256,7 @@ public class UserIssuesITCase extends AbstractITCase {
             realm.setPasswordPolicy(oldPasswordPolicy);
             realmService.update(realm);
 
-            policyService.delete(passwordPolicy.getKey());
+            policyService.delete(PolicyType.PASSWORD, passwordPolicy.getKey());
         }
 
     }