Repository: syncope Updated Branches: refs/heads/master 1b325bb8e -> 31dc4a280
SYNCOPE-909 - Consolidate update functionality Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/31dc4a28 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/31dc4a28 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/31dc4a28 Branch: refs/heads/master Commit: 31dc4a2806628ac45d33fd8cdb39b8ebabc237e7 Parents: 377ce23 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Wed Jul 27 15:46:45 2016 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Wed Jul 27 16:21:34 2016 +0100 ---------------------------------------------------------------------- .../processor/AnyObjectUpdateProcessor.java | 70 --------------- .../camel/processor/GroupUpdateProcessor.java | 70 --------------- .../camel/processor/UpdateProcessor.java | 92 ++++++++++++++++++++ .../camel/processor/UserUpdateProcessor.java | 61 ------------- .../src/main/resources/anyObjectRoutes.xml | 4 +- .../src/main/resources/groupRoutes.xml | 4 +- .../src/main/resources/userRoutes.xml | 2 +- 7 files changed, 97 insertions(+), 206 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java deleted file mode 100644 index b42e34e..0000000 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java +++ /dev/null @@ -1,70 +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.patch.AnyObjectPatch; -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.VirAttrHandler; -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 AnyObjectUpdateProcessor implements Processor { - - @Autowired - protected PropagationManager propagationManager; - - @Autowired - protected PropagationTaskExecutor taskExecutor; - - @Autowired - protected VirAttrHandler virtAttrHandler; - - @SuppressWarnings("unchecked") - @Override - public void process(final Exchange exchange) { - WorkflowResult<String> updated = (WorkflowResult<String>) exchange.getIn().getBody(); - AnyObjectPatch anyObjectPatch = exchange.getProperty("anyPatch", AnyObjectPatch.class); - Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class); - Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class); - - List<PropagationTask> tasks = propagationManager.getUpdateTasks( - AnyTypeKind.ANY_OBJECT, - updated.getResult(), - false, - null, - updated.getPropByRes(), - anyObjectPatch.getVirAttrs(), - excludedResources); - PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync); - - exchange.getOut().setBody(new ImmutablePair<>(updated.getResult(), propagationReporter.getStatuses())); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java deleted file mode 100644 index ebc84a5..0000000 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java +++ /dev/null @@ -1,70 +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.patch.GroupPatch; -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.VirAttrHandler; -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 GroupUpdateProcessor implements Processor { - - @Autowired - protected PropagationManager propagationManager; - - @Autowired - protected PropagationTaskExecutor taskExecutor; - - @Autowired - protected VirAttrHandler virtAttrHandler; - - @SuppressWarnings("unchecked") - @Override - public void process(final Exchange exchange) { - WorkflowResult<String> updated = (WorkflowResult<String>) exchange.getIn().getBody(); - GroupPatch groupPatch = exchange.getProperty("anyPatch", GroupPatch.class); - Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class); - Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class); - - List<PropagationTask> tasks = propagationManager.getUpdateTasks( - AnyTypeKind.GROUP, - updated.getResult(), - false, - null, - updated.getPropByRes(), - groupPatch.getVirAttrs(), - excludedResources); - PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync); - - exchange.getOut().setBody(new ImmutablePair<>(updated.getResult(), propagationReporter.getStatuses())); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UpdateProcessor.java new file mode 100644 index 0000000..aca3371 --- /dev/null +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UpdateProcessor.java @@ -0,0 +1,92 @@ +/* + * 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.patch.AnyObjectPatch; +import org.apache.syncope.common.lib.patch.AnyPatch; +import org.apache.syncope.common.lib.patch.UserPatch; +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.VirAttrHandler; +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 UpdateProcessor implements Processor { + + @Autowired + protected PropagationManager propagationManager; + + @Autowired + protected PropagationTaskExecutor taskExecutor; + + @Autowired + protected VirAttrHandler virtAttrHandler; + + @Override + @SuppressWarnings("unchecked") + public void process(final Exchange exchange) { + if ((exchange.getIn().getBody() instanceof WorkflowResult)) { + Object actual = exchange.getProperty("actual"); + Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class); + Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class); + + if (actual instanceof UserPatch) { + WorkflowResult<Pair<UserPatch, Boolean>> updated = + (WorkflowResult<Pair<UserPatch, Boolean>>) exchange.getIn().getBody(); + + List<PropagationTask> tasks = propagationManager.getUserUpdateTasks(updated); + PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync); + + exchange.getOut().setBody(new ImmutablePair<>( + updated.getResult().getKey().getKey(), propagationReporter.getStatuses())); + } else if (actual instanceof AnyPatch) { + WorkflowResult<String> updated = (WorkflowResult<String>) exchange.getIn().getBody(); + + AnyTypeKind anyTypeKind = AnyTypeKind.GROUP; + if (actual instanceof AnyObjectPatch) { + anyTypeKind = AnyTypeKind.ANY_OBJECT; + } + + List<PropagationTask> tasks = propagationManager.getUpdateTasks( + anyTypeKind, + updated.getResult(), + false, + null, + updated.getPropByRes(), + ((AnyPatch) actual).getVirAttrs(), + excludedResources); + PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync); + + exchange.getOut().setBody(new ImmutablePair<>(updated.getResult(), propagationReporter.getStatuses())); + } + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java deleted file mode 100644 index 219f680..0000000 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java +++ /dev/null @@ -1,61 +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 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.patch.UserPatch; -import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; -import org.apache.syncope.core.provisioning.api.VirAttrHandler; -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 UserUpdateProcessor implements Processor { - - @Autowired - protected PropagationManager propagationManager; - - @Autowired - protected PropagationTaskExecutor taskExecutor; - - @Autowired - protected VirAttrHandler virtAttrHandler; - - @Override - @SuppressWarnings("unchecked") - public void process(final Exchange exchange) { - WorkflowResult<Pair<UserPatch, Boolean>> updated = - (WorkflowResult<Pair<UserPatch, Boolean>>) exchange.getIn().getBody(); - Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class); - - List<PropagationTask> tasks = propagationManager.getUserUpdateTasks(updated); - PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync); - - exchange.getOut().setBody(new ImmutablePair<>( - updated.getResult().getKey().getKey(), propagationReporter.getStatuses())); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/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 d4e56e4..5c23f9e 100644 --- a/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml +++ b/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml @@ -40,12 +40,12 @@ under the License. <route id="updateAnyObject"> <from uri="direct:updateAnyObject"/> - <setProperty propertyName="anyPatch"> + <setProperty propertyName="actual"> <simple>${body}</simple> </setProperty> <doTry> <bean ref="awfAdapter" method="update(${body})"/> - <process ref="anyObjectUpdateProcessor"/> + <process ref="updateProcessor"/> <to uri="direct:updateAnyObjectPort"/> <doCatch> <exception>java.lang.RuntimeException</exception> http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/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 c71b590..c76fa61 100644 --- a/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml +++ b/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml @@ -59,12 +59,12 @@ under the License. <route id="updateGroup"> <from uri="direct:updateGroup"/> - <setProperty propertyName="anyPatch"> + <setProperty propertyName="actual"> <simple>${body}</simple> </setProperty> <doTry> <bean ref="gwfAdapter" method="update(${body})"/> - <process ref="groupUpdateProcessor"/> + <process ref="updateProcessor"/> <to uri="direct:updateGroupPort"/> <doCatch> <exception>java.lang.RuntimeException</exception> http://git-wip-us.apache.org/repos/asf/syncope/blob/31dc4a28/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 7936129..aa86463 100644 --- a/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml +++ b/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml @@ -46,7 +46,7 @@ under the License. </setProperty> <doTry> <bean ref="uwfAdapter" method="update(${body})"/> - <process ref="userUpdateProcessor"/> + <process ref="updateProcessor"/> <to uri="direct:updatePort"/> <doCatch> <exception>java.lang.RuntimeException</exception>