You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by co...@apache.org on 2016/07/27 15:23:42 UTC

[2/2] syncope git commit: SYNCOPE-909 - Consolidate "Create" functionality

SYNCOPE-909 - Consolidate "Create" functionality


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

Branch: refs/heads/master
Commit: 377ce234bcabd209245e47c706760243c1539db2
Parents: 1b325bb
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Wed Jul 27 14:28:27 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Wed Jul 27 16:21:34 2016 +0100

----------------------------------------------------------------------
 .../processor/AnyObjectCreateProcessor.java     | 64 --------------
 .../camel/processor/CreateProcessor.java        | 91 ++++++++++++++++++++
 .../camel/processor/GroupCreateProcessor.java   | 64 --------------
 .../camel/processor/UserCreateProcessor.java    | 69 ---------------
 .../src/main/resources/anyObjectRoutes.xml      |  4 +-
 .../src/main/resources/groupRoutes.xml          |  4 +-
 .../src/main/resources/userRoutes.xml           |  2 +-
 .../syncope/fit/core/CamelRouteITCase.java      |  4 +-
 8 files changed, 98 insertions(+), 204 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectCreateProcessor.java
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectCreateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectCreateProcessor.java
deleted file mode 100644
index 426ab81..0000000
--- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectCreateProcessor.java
+++ /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.core.provisioning.camel.processor;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.syncope.common.lib.to.AnyObjectTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AnyObjectCreateProcessor implements Processor {
-
-    @Autowired
-    protected PropagationManager propagationManager;
-
-    @Autowired
-    protected PropagationTaskExecutor taskExecutor;
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public void process(final Exchange exchange) {
-        WorkflowResult<String> created = (WorkflowResult<String>) exchange.getIn().getBody();
-        AnyObjectTO any = exchange.getProperty("any", AnyObjectTO.class);
-        Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
-        Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
-
-        List<PropagationTask> tasks = propagationManager.getCreateTasks(
-                AnyTypeKind.ANY_OBJECT,
-                created.getResult(),
-                created.getPropByRes(),
-                any.getVirAttrs(),
-                excludedResources);
-        PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
-
-        exchange.getOut().setBody(new ImmutablePair<>(created.getResult(), propagationReporter.getStatuses()));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/CreateProcessor.java
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/CreateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/CreateProcessor.java
new file mode 100644
index 0000000..494e319
--- /dev/null
+++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/CreateProcessor.java
@@ -0,0 +1,91 @@
+/*
+ * 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.provisioning.camel.processor;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.common.lib.to.AnyObjectTO;
+import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CreateProcessor implements Processor {
+
+    @Autowired
+    protected PropagationManager propagationManager;
+
+    @Autowired
+    protected PropagationTaskExecutor taskExecutor;
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void process(final Exchange exchange) {
+        if ((exchange.getIn().getBody() instanceof WorkflowResult)) {
+            Object actual = exchange.getProperty("actual");
+            Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
+            Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
+            
+            if (actual instanceof UserTO) {
+                WorkflowResult<Pair<String, Boolean>> created =
+                        (WorkflowResult<Pair<String, Boolean>>) exchange.getIn().getBody();
+    
+                List<PropagationTask> tasks = propagationManager.getUserCreateTasks(
+                        created.getResult().getKey(),
+                        ((UserTO) actual).getPassword(),
+                        created.getResult().getValue(),
+                        created.getPropByRes(),
+                        ((UserTO) actual).getVirAttrs(),
+                        excludedResources);
+                PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
+
+                exchange.getOut().setBody(
+                        new ImmutablePair<>(created.getResult().getKey(), propagationReporter.getStatuses()));
+            } else if (actual instanceof AnyTO) {
+                WorkflowResult<String> created = (WorkflowResult<String>) exchange.getIn().getBody();
+
+                AnyTypeKind anyTypeKind = AnyTypeKind.GROUP;
+                if (actual instanceof AnyObjectTO) {
+                    anyTypeKind = AnyTypeKind.ANY_OBJECT;
+                }
+                List<PropagationTask> tasks = propagationManager.getCreateTasks(
+                        anyTypeKind,
+                        created.getResult(),
+                        created.getPropByRes(),
+                        ((AnyTO) actual).getVirAttrs(),
+                        excludedResources);
+                PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
+
+                exchange.getOut().setBody(new ImmutablePair<>(created.getResult(), propagationReporter.getStatuses()));
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupCreateProcessor.java
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupCreateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupCreateProcessor.java
deleted file mode 100644
index c700743..0000000
--- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupCreateProcessor.java
+++ /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.core.provisioning.camel.processor;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class GroupCreateProcessor implements Processor {
-
-    @Autowired
-    protected PropagationManager propagationManager;
-
-    @Autowired
-    protected PropagationTaskExecutor taskExecutor;
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public void process(final Exchange exchange) {
-        WorkflowResult<String> created = (WorkflowResult<String>) exchange.getIn().getBody();
-        GroupTO any = exchange.getProperty("any", GroupTO.class);
-        Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
-        Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
-
-        List<PropagationTask> tasks = propagationManager.getCreateTasks(
-                AnyTypeKind.GROUP,
-                created.getResult(),
-                created.getPropByRes(),
-                any.getVirAttrs(),
-                excludedResources);
-        PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
-
-        exchange.getOut().setBody(new ImmutablePair<>(created.getResult(), propagationReporter.getStatuses()));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java
deleted file mode 100644
index 972b06e..0000000
--- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java
+++ /dev/null
@@ -1,69 +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.core.provisioning.camel.processor;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class UserCreateProcessor implements Processor {
-
-    @Autowired
-    protected PropagationManager propagationManager;
-
-    @Autowired
-    protected PropagationTaskExecutor taskExecutor;
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public void process(final Exchange exchange) {
-        if ((exchange.getIn().getBody() instanceof WorkflowResult)) {
-            WorkflowResult<Pair<String, Boolean>> created =
-                    (WorkflowResult<Pair<String, Boolean>>) exchange.getIn().getBody();
-            UserTO actual = exchange.getProperty("actual", UserTO.class);
-            Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
-            Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
-
-            List<PropagationTask> tasks = propagationManager.getUserCreateTasks(
-                    created.getResult().getKey(),
-                    actual.getPassword(),
-                    created.getResult().getValue(),
-                    created.getPropByRes(),
-                    actual.getVirAttrs(),
-                    excludedResources);
-            PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
-
-            exchange.getOut().setBody(
-                    new ImmutablePair<>(created.getResult().getKey(), propagationReporter.getStatuses()));
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml b/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml
index c0b1fe5..d4e56e4 100644
--- a/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml
+++ b/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml
@@ -21,12 +21,12 @@ under the License.
      
   <route id="createAnyObject">
     <from uri="direct:createAnyObject"/>
-    <setProperty propertyName="any">
+    <setProperty propertyName="actual">
       <simple>${body}</simple>
     </setProperty>
     <doTry>
       <bean ref="awfAdapter" method="create(${body})"/>
-      <process ref="anyObjectCreateProcessor"/>
+      <process ref="createProcessor"/>
       <to uri="direct:createAnyObjectPort"/>
       <doCatch>        
         <exception>java.lang.RuntimeException</exception>

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml b/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml
index d7875dc..c71b590 100644
--- a/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml
+++ b/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml
@@ -21,12 +21,12 @@ under the License.
      
   <route id="createGroup">
     <from uri="direct:createGroup"/>
-    <setProperty propertyName="any">
+    <setProperty propertyName="actual">
       <simple>${body}</simple>
     </setProperty>
     <doTry>
       <bean ref="gwfAdapter" method="create(${body})"/>
-      <process ref="groupCreateProcessor"/>
+      <process ref="createProcessor"/>
       <to uri="direct:createGroupPort"/>
       <doCatch>        
         <exception>java.lang.RuntimeException</exception>

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml
----------------------------------------------------------------------
diff --git a/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml b/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml
index d0d7c77..7936129 100644
--- a/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml
+++ b/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml
@@ -27,7 +27,7 @@ under the License.
     <doTry>
       <bean method="create(${body},${property.disablePwdPolicyCheck},${property.enabled},${property.storePassword})"
             ref="uwfAdapter" />
-      <process ref="userCreateProcessor"/>
+      <process ref="createProcessor"/>
       <to uri="direct:createPort"/>
       <doCatch>        
         <exception>java.lang.RuntimeException</exception>

http://git-wip-us.apache.org/repos/asf/syncope/blob/377ce234/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
index 764fe2c..ce2c638 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
@@ -87,7 +87,7 @@ public class CamelRouteITCase extends AbstractITCase {
                 + "  <doTry>\n"
                 + "    <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n"
                 + "                             ${property.enabled},${property.storePassword})\"/>\n"
-                + "    <process ref=\"userCreateProcessor\" />\n"
+                + "    <process ref=\"createProcessor\" />\n"
                 + "    <to uri=\"direct:createPort\"/>\n"
                 + "    <to uri=\"log:myLog\"/>\n"
                 + "    <doCatch>        \n"
@@ -129,7 +129,7 @@ public class CamelRouteITCase extends AbstractITCase {
                 + "    <doTry>\n"
                 + "      <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n"
                 + "                                     ${property.enabled},${property.storePassword})\"/>\n"
-                + "      <process ref=\"userCreateProcessor\"/>\n"
+                + "      <process ref=\"createProcessor\"/>\n"
                 + "      <to uri=\"direct:createPort\"/>\n"
                 + "      <doCatch>        \n"
                 + "        <exception>java.lang.RuntimeException</exception>\n"