You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/02/12 10:14:15 UTC
[10/54] [abbrv] [partial] syncope git commit: [SYNCOPE-620] Renaming
'server' after 'core',
to provide continuity with older releases (especially for archetype)
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeleteProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeleteProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeleteProcessor.java
new file mode 100644
index 0000000..90a89d7
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeleteProcessor.java
@@ -0,0 +1,105 @@
+/*
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.types.PropagationByResource;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.dao.RoleDAO;
+import org.apache.syncope.core.persistence.api.entity.role.Role;
+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.PropagationException;
+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.apache.syncope.core.workflow.api.RoleWorkflowAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RoleDeleteProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RoleDeleteProcessor.class);
+
+ @Autowired
+ protected RoleWorkflowAdapter rwfAdapter;
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @Autowired
+ protected RoleDAO roleDAO;
+
+ @Override
+ public void process(final Exchange exchange) throws Exception {
+ final List<Role> toBeDeprovisioned = new ArrayList<>();
+
+ Long subjectKey = exchange.getIn().getBody(Long.class);
+ final Role syncopeRole = roleDAO.find(subjectKey);
+
+ if (syncopeRole != null) {
+ toBeDeprovisioned.add(syncopeRole);
+
+ final List<Role> descendants = roleDAO.findDescendants(toBeDeprovisioned.get(0));
+ if (descendants != null) {
+ toBeDeprovisioned.addAll(descendants);
+ }
+ }
+
+ final List<PropagationTask> tasks = new ArrayList<>();
+
+ for (Role role : toBeDeprovisioned) {
+ // Generate propagation tasks for deleting users from role resources, if they are on those resources only
+ // because of the reason being deleted (see SYNCOPE-357)
+ for (Map.Entry<Long, PropagationByResource> entry : roleDAO.findUsersWithIndirectResources(role.
+ getKey()).entrySet()) {
+
+ WorkflowResult<Long> wfResult =
+ new WorkflowResult<>(entry.getKey(), entry.getValue(), Collections.<String>emptySet());
+ tasks.addAll(propagationManager.getUserDeleteTaskIds(wfResult));
+ }
+
+ // Generate propagation tasks for deleting this role from resources
+ tasks.addAll(propagationManager.getRoleDeleteTaskIds(role.getKey()));
+ }
+
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.setProperty("statuses", propagationReporter.getStatuses());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeprovisionProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeprovisionProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeprovisionProcessor.java
new file mode 100644
index 0000000..c0aa4fd
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleDeprovisionProcessor.java
@@ -0,0 +1,78 @@
+/*
+ * 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.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.dao.RoleDAO;
+import org.apache.syncope.core.persistence.api.entity.role.Role;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RoleDeprovisionProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserDeprovisionProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @Autowired
+ protected RoleDAO roleDAO;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ Long roleKey = exchange.getIn().getBody(Long.class);
+ List<String> resources = exchange.getProperty("resources", List.class);
+
+ Role role = roleDAO.authFetch(roleKey);
+
+ Set<String> noPropResourceName = role.getResourceNames();
+ noPropResourceName.removeAll(resources);
+
+ List<PropagationTask> tasks =
+ propagationManager.getRoleDeleteTaskIds(roleKey, new HashSet<>(resources), noPropResourceName);
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.getOut().setBody(propagationReporter.getStatuses());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleUpdateProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleUpdateProcessor.java
new file mode 100644
index 0000000..74e377a
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleUpdateProcessor.java
@@ -0,0 +1,71 @@
+/*
+ * 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.AbstractMap;
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.mod.RoleMod;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+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.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RoleUpdateProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserUpdateProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ WorkflowResult<Long> updated = (WorkflowResult) exchange.getIn().getBody();
+ RoleMod subjectMod = exchange.getProperty("subjectMod", RoleMod.class);
+ Set<String> excludedResource = exchange.getProperty("excludedResources", Set.class);
+
+ List<PropagationTask> tasks = propagationManager.getRoleUpdateTaskIds(updated,
+ subjectMod.getVirAttrsToRemove(), subjectMod.getVirAttrsToUpdate(), excludedResource);
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.getOut().setBody(new AbstractMap.SimpleEntry<>(updated.getResult(), propagationReporter.getStatuses()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java
new file mode 100644
index 0000000..6b63a85
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * 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.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserConfirmPwdResetProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserConfirmPwdResetProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @Override
+ public void process(final Exchange exchange) {
+ User user = exchange.getProperty("user", User.class);
+
+ List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(user, null, null);
+ PropagationReporter propReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propReporter.onPrimaryResourceFailure(tasks);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java
new file mode 100644
index 0000000..34d9a9e
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserCreateProcessor.java
@@ -0,0 +1,76 @@
+/*
+ * 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.AbstractMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+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.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserCreateProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserCreateProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ if ((exchange.getIn().getBody() instanceof WorkflowResult)) {
+
+ WorkflowResult<Map.Entry<Long, Boolean>> created = (WorkflowResult) exchange.getIn().getBody();
+ UserTO actual = exchange.getProperty("actual", UserTO.class);
+ Set<String> excludedResource = exchange.getProperty("excludedResources", Set.class);
+
+ List<PropagationTask> tasks = propagationManager.getUserCreateTaskIds(
+ created, actual.getPassword(), actual.getVirAttrs(), excludedResource, actual.getMemberships());
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource {}", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.getOut().setBody(
+ new AbstractMap.SimpleEntry<>(created.getResult().getKey(), propagationReporter.getStatuses()));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeleteProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeleteProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeleteProcessor.java
new file mode 100644
index 0000000..45474a2
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeleteProcessor.java
@@ -0,0 +1,72 @@
+/*
+ * 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.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserDeleteProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserDeleteProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) throws Exception {
+ Long userKey = (Long) exchange.getIn().getBody();
+ Set<String> excludedResource = exchange.getProperty("excludedResources", Set.class);
+
+ // Note here that we can only notify about "delete", not any other
+ // task defined in workflow process definition: this because this
+ // information could only be available after uwfAdapter.delete(), which
+ // will also effectively remove user from db, thus making virtually
+ // impossible by NotificationManager to fetch required user information
+ List<PropagationTask> tasks = propagationManager.getUserDeleteTaskIds(userKey, excludedResource);
+
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.setProperty("statuses", propagationReporter.getStatuses());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeprovisionProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeprovisionProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeprovisionProcessor.java
new file mode 100644
index 0000000..66cc795
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserDeprovisionProcessor.java
@@ -0,0 +1,78 @@
+/*
+ * 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.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserDeprovisionProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserDeprovisionProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @Autowired
+ protected UserDAO userDAO;
+
+ @Override
+ public void process(final Exchange exchange) {
+ Long userKey = exchange.getIn().getBody(Long.class);
+ @SuppressWarnings("unchecked")
+ List<String> resources = exchange.getProperty("resources", List.class);
+
+ final User user = userDAO.authFetch(userKey);
+
+ final Set<String> noPropResourceName = user.getResourceNames();
+ noPropResourceName.removeAll(resources);
+
+ final List<PropagationTask> tasks =
+ propagationManager.getUserDeleteTaskIds(userKey, new HashSet<>(resources), noPropResourceName);
+ final PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.getOut().setBody(propagationReporter.getStatuses());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInnerSuspendProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInnerSuspendProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInnerSuspendProcessor.java
new file mode 100644
index 0000000..c4d648f
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInnerSuspendProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * 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.AbstractMap.SimpleEntry;
+import java.util.List;
+import java.util.Map;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.mod.UserMod;
+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.PropagationTaskExecutor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserInnerSuspendProcessor implements Processor {
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ WorkflowResult<Long> updated = (WorkflowResult) exchange.getIn().getBody();
+ Boolean propagate = exchange.getProperty("propagate", Boolean.class);
+
+ if (propagate) {
+ UserMod userMod = new UserMod();
+ userMod.setKey(updated.getResult());
+
+ final List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
+ new WorkflowResult<Map.Entry<UserMod, Boolean>>(
+ new SimpleEntry<>(userMod, Boolean.FALSE),
+ updated.getPropByRes(), updated.getPerformedTasks()));
+ taskExecutor.execute(tasks);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java
new file mode 100644
index 0000000..ba6edfb
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java
@@ -0,0 +1,74 @@
+/*
+ * 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.Map;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.syncope.common.lib.mod.UserMod;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserSetStatusInSyncProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserSetStatusInSyncProcessor.class);
+
+ @Autowired
+ protected UserDAO userDAO;
+
+ @Autowired
+ protected UserWorkflowAdapter uwfAdapter;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ WorkflowResult<Map.Entry<UserMod, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody();
+
+ Boolean enabled = exchange.getProperty("enabled", Boolean.class);
+ Long key = exchange.getProperty("key", Long.class);
+
+ if (enabled != null) {
+ User user = userDAO.find(key);
+
+ WorkflowResult<Long> enableUpdate = null;
+ if (user.isSuspended() == null) {
+ enableUpdate = uwfAdapter.activate(key, null);
+ } else if (enabled && user.isSuspended()) {
+ enableUpdate = uwfAdapter.reactivate(key);
+ } else if (!enabled && !user.isSuspended()) {
+ enableUpdate = uwfAdapter.suspend(key);
+ }
+
+ if (enableUpdate != null) {
+ if (enableUpdate.getPropByRes() != null) {
+ updated.getPropByRes().merge(enableUpdate.getPropByRes());
+ updated.getPropByRes().purge();
+ }
+ updated.getPerformedTasks().addAll(enableUpdate.getPerformedTasks());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java
new file mode 100644
index 0000000..5c0366c
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java
@@ -0,0 +1,76 @@
+/*
+ * 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.AbstractMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.mod.StatusMod;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserStatusPropagationProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserStatusPropagationProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ WorkflowResult<Long> updated = (WorkflowResult) exchange.getIn().getBody();
+
+ User user = exchange.getProperty("user", User.class);
+ StatusMod statusMod = exchange.getProperty("statusMod", StatusMod.class);
+
+ Set<String> resourcesToBeExcluded = new HashSet<>(user.getResourceNames());
+ resourcesToBeExcluded.removeAll(statusMod.getResourceNames());
+
+ List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
+ user, statusMod.getType() != StatusMod.ModType.SUSPEND, resourcesToBeExcluded);
+ PropagationReporter propReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ try {
+ taskExecutor.execute(tasks, propReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.getOut().setBody(new AbstractMap.SimpleEntry<>(updated.getResult(), propReporter.getStatuses()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java
new file mode 100644
index 0000000..b7bfcf0
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java
@@ -0,0 +1,73 @@
+/*
+ * 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.AbstractMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.mod.UserMod;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+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.PropagationException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserUpdateInSyncProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserUpdateInSyncProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void process(final Exchange exchange) {
+ WorkflowResult<Map.Entry<UserMod, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody();
+ Set<String> excludedResource = exchange.getProperty("excludedResources", Set.class);
+
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+
+ List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(updated, updated.getResult().getKey().
+ getPassword() != null, excludedResource);
+
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+
+ exchange.getOut().setBody(new AbstractMap.SimpleEntry<>(
+ updated.getResult().getKey().getKey(), propagationReporter.getStatuses()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java
new file mode 100644
index 0000000..600cdf8
--- /dev/null
+++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java
@@ -0,0 +1,105 @@
+/*
+ * 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.AbstractMap;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.mod.MembershipMod;
+import org.apache.syncope.common.lib.mod.UserMod;
+import org.apache.syncope.common.lib.types.PropagationByResource;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+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.PropagationException;
+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.apache.syncope.core.provisioning.java.VirAttrHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserUpdateProcessor implements Processor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserUpdateProcessor.class);
+
+ @Autowired
+ protected PropagationManager propagationManager;
+
+ @Autowired
+ protected PropagationTaskExecutor taskExecutor;
+
+ @Autowired
+ protected VirAttrHandler virtAttrHandler;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void process(final Exchange exchange) {
+ WorkflowResult<Map.Entry<UserMod, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody();
+ UserMod actual = exchange.getProperty("actual", UserMod.class);
+ boolean removeMemberships = exchange.getProperty("removeMemberships", boolean.class);
+
+ List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(updated);
+ if (tasks.isEmpty()) {
+ // SYNCOPE-459: take care of user virtual attributes ...
+ final PropagationByResource propByResVirAttr = virtAttrHandler.fillVirtual(
+ updated.getResult().getKey().getKey(),
+ actual.getVirAttrsToRemove(),
+ actual.getVirAttrsToUpdate());
+ // SYNCOPE-501: update only virtual attributes (if any of them changed), password propagation is
+ // not required, take care also of membership virtual attributes
+ boolean addOrUpdateMemberships = false;
+ for (MembershipMod membershipMod : actual.getMembershipsToAdd()) {
+ if (!virtAttrHandler.fillMembershipVirtual(
+ updated.getResult().getKey().getKey(),
+ membershipMod.getRole(),
+ null,
+ membershipMod.getVirAttrsToRemove(),
+ membershipMod.getVirAttrsToUpdate(),
+ false).isEmpty()) {
+
+ addOrUpdateMemberships = true;
+ }
+ }
+ tasks.addAll(!propByResVirAttr.isEmpty() || addOrUpdateMemberships || removeMemberships
+ ? propagationManager.getUserUpdateTaskIds(updated, false, null)
+ : Collections.<PropagationTask>emptyList());
+ }
+
+ PropagationReporter propagationReporter =
+ ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+ if (!tasks.isEmpty()) {
+ try {
+ taskExecutor.execute(tasks, propagationReporter);
+ } catch (PropagationException e) {
+ LOG.error("Error propagation primary resource", e);
+ propagationReporter.onPrimaryResourceFailure(tasks);
+ }
+ }
+
+ exchange.getOut().setBody(new AbstractMap.SimpleEntry<>(
+ updated.getResult().getKey().getKey(), propagationReporter.getStatuses()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/AbstractCamelProvisioningManager.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/AbstractCamelProvisioningManager.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/AbstractCamelProvisioningManager.java
deleted file mode 100644
index 843e817..0000000
--- a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/AbstractCamelProvisioningManager.java
+++ /dev/null
@@ -1,103 +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.server.provisioning.camel;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.PollingConsumer;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.impl.DefaultExchange;
-import org.apache.camel.impl.DefaultMessage;
-import org.apache.camel.model.RoutesDefinition;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.syncope.server.persistence.api.dao.CamelRouteDAO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-abstract class AbstractCamelProvisioningManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractCamelProvisioningManager.class);
-
- @Autowired
- protected CamelRouteDAO routeDAO;
-
- @Autowired
- protected SyncopeCamelContext contextFactory;
-
- protected SpringCamelContext camelContext;
-
- protected RoutesDefinition routes;
-
- protected final Map<String, PollingConsumer> consumerMap = new HashMap<>();
-
- protected final List<String> knownURIs = new ArrayList<>();
-
- protected SpringCamelContext getContext() {
- return contextFactory.getContext();
- }
-
- protected void sendMessage(final String uri, final Object obj) {
- Exchange exchange = new DefaultExchange(getContext());
-
- DefaultMessage message = new DefaultMessage();
- message.setBody(obj);
- exchange.setIn(message);
-
- ProducerTemplate template = getContext().createProducerTemplate();
- template.send(uri, exchange);
- }
-
- protected void sendMessage(final String uri, final Object obj, final Map<String, Object> properties) {
- Exchange exchange = new DefaultExchange(getContext());
-
- for (Map.Entry<String, Object> property : properties.entrySet()) {
- exchange.setProperty(property.getKey(), property.getValue());
- LOG.debug("Added property {}", property.getKey());
- }
-
- DefaultMessage message = new DefaultMessage();
- message.setBody(obj);
- exchange.setIn(message);
- ProducerTemplate template = getContext().createProducerTemplate();
- template.send(uri, exchange);
- }
-
- protected PollingConsumer getConsumer(String uri) {
- if (!knownURIs.contains(uri)) {
- knownURIs.add(uri);
- Endpoint endpoint = getContext().getEndpoint(uri);
- PollingConsumer pollingConsumer = null;
- try {
- pollingConsumer = endpoint.createPollingConsumer();
- consumerMap.put(uri, pollingConsumer);
- pollingConsumer.start();
- } catch (Exception ex) {
- LOG.error("Unexpected error in Consumer creation ", ex);
- }
- return pollingConsumer;
- } else {
- return consumerMap.get(uri);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelRoleProvisioningManager.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelRoleProvisioningManager.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelRoleProvisioningManager.java
deleted file mode 100644
index 73703f1..0000000
--- a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelRoleProvisioningManager.java
+++ /dev/null
@@ -1,174 +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.server.provisioning.camel;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.PollingConsumer;
-import org.apache.syncope.common.lib.mod.RoleMod;
-import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.RoleTO;
-import org.apache.syncope.server.provisioning.api.RoleProvisioningManager;
-import org.apache.syncope.server.provisioning.api.propagation.PropagationException;
-
-public class CamelRoleProvisioningManager extends AbstractCamelProvisioningManager implements RoleProvisioningManager {
-
- @Override
- public Map.Entry<Long, List<PropagationStatus>> create(final RoleTO subject) {
- return create(subject, Collections.<String>emptySet());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> create(final RoleTO roleTO, final Set<String> excludedResources) {
- PollingConsumer pollingConsumer = getConsumer("direct:createRolePort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("excludedResources", excludedResources);
-
- sendMessage("direct:createRole", roleTO, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> create(final RoleTO roleTO, final Map<Long, String> roleOwnerMap,
- final Set<String> excludedResources) throws PropagationException {
-
- PollingConsumer pollingConsumer = getConsumer("direct:createRoleInSyncPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("roleOwnerMap", roleOwnerMap);
- props.put("excludedResources", excludedResources);
-
- sendMessage("direct:createRoleInSync", roleTO, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- public Map.Entry<Long, List<PropagationStatus>> update(final RoleMod subjectMod) {
- return update(subjectMod, Collections.<String>emptySet());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> update(
- final RoleMod subjectMod, final Set<String> excludedResources) {
-
- PollingConsumer pollingConsumer = getConsumer("direct:updateRolePort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("excludedResources", excludedResources);
-
- sendMessage("direct:updateRole", subjectMod, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<PropagationStatus> delete(final Long roleKey) {
- PollingConsumer pollingConsumer = getConsumer("direct:deleteRolePort");
-
- sendMessage("direct:deleteRole", roleKey);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(List.class);
- }
-
- @Override
- public Long unlink(final RoleMod roleMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:unlinkRolePort");
-
- sendMessage("direct:unlinkRole", roleMod);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Long.class);
- }
-
- @Override
- public Long link(final RoleMod roleMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:linkRolePort");
-
- sendMessage("direct:linkRole", roleMod);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Long.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<PropagationStatus> deprovision(final Long roleKey, Collection<String> resources) {
- PollingConsumer pollingConsumer = getConsumer("direct:deprovisionRolePort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("resources", resources);
-
- sendMessage("direct:deprovisionRole", roleKey, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(List.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelUserProvisioningManager.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelUserProvisioningManager.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelUserProvisioningManager.java
deleted file mode 100644
index 2c5afc5..0000000
--- a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/CamelUserProvisioningManager.java
+++ /dev/null
@@ -1,342 +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.server.provisioning.camel;
-
-import java.util.AbstractMap;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.PollingConsumer;
-import org.apache.syncope.common.lib.mod.StatusMod;
-import org.apache.syncope.common.lib.mod.UserMod;
-import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.PropagationByResource;
-import org.apache.syncope.server.persistence.api.entity.user.User;
-import org.apache.syncope.server.provisioning.api.UserProvisioningManager;
-import org.apache.syncope.server.provisioning.api.WorkflowResult;
-import org.apache.syncope.server.provisioning.api.sync.ProvisioningResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CamelUserProvisioningManager extends AbstractCamelProvisioningManager implements UserProvisioningManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(CamelUserProvisioningManager.class);
-
- @Override
- public Map.Entry<Long, List<PropagationStatus>> create(final UserTO userTO) {
- return create(userTO, true, false, null, Collections.<String>emptySet());
- }
-
- @Override
- public Map.Entry<Long, List<PropagationStatus>> create(final UserTO userTO, boolean storePassword) {
- return create(userTO, storePassword, false, null, Collections.<String>emptySet());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> create(final UserTO userTO, final boolean storePassword,
- boolean disablePwdPolicyCheck, Boolean enabled, Set<String> excludedResources) {
-
- PollingConsumer pollingConsumer = getConsumer("direct:createPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("storePassword", storePassword);
- props.put("disablePwdPolicyCheck", disablePwdPolicyCheck);
- props.put("enabled", enabled);
- props.put("excludedResources", excludedResources);
-
- sendMessage("direct:createUser", userTO, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- public Map.Entry<Long, List<PropagationStatus>> update(final UserMod userMod) {
- return update(userMod, false);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> update(UserMod userMod, boolean removeMemberships) {
- PollingConsumer pollingConsumer = getConsumer("direct:updatePort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("removeMemberships", removeMemberships);
-
- sendMessage("direct:updateUser", userMod, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- public List<PropagationStatus> delete(final Long userKey) {
- return delete(userKey, Collections.<String>emptySet());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<PropagationStatus> delete(final Long userKey, final Set<String> excludedResources) {
- PollingConsumer pollingConsumer = getConsumer("direct:deletePort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("excludedResources", excludedResources);
-
- sendMessage("direct:deleteUser", userKey, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(List.class);
- }
-
- @Override
- public Long unlink(final UserMod userMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:unlinkPort");
-
- sendMessage("direct:unlinkUser", userMod);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- exchange.getIn().setBody((exchange.getIn().getBody(UserMod.class).getKey()));
- return exchange.getIn().getBody(Long.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> activate(final User user, final StatusMod statusMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("token", statusMod.getToken());
- props.put("user", user);
- props.put("statusMod", statusMod);
-
- if (statusMod.isOnSyncope()) {
- sendMessage("direct:activateUser", user.getKey(), props);
- } else {
- WorkflowResult<Long> updated =
- new WorkflowResult<>(user.getKey(), null, statusMod.getType().name().toLowerCase());
- sendMessage("direct:userStatusPropagation", updated, props);
- }
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> reactivate(final User user, final StatusMod statusMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("user", user);
- props.put("statusMod", statusMod);
-
- if (statusMod.isOnSyncope()) {
- sendMessage("direct:reactivateUser", user.getKey(), props);
- } else {
- WorkflowResult<Long> updated =
- new WorkflowResult<>(user.getKey(), null, statusMod.getType().name().toLowerCase());
- sendMessage("direct:userStatusPropagation", updated, props);
- }
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> suspend(final User user, final StatusMod statusMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("user", user);
- props.put("statusMod", statusMod);
-
- if (statusMod.isOnSyncope()) {
- sendMessage("direct:suspendUser", user.getKey(), props);
- } else {
- WorkflowResult<Long> updated =
- new WorkflowResult<>(user.getKey(), null, statusMod.getType().name().toLowerCase());
- sendMessage("direct:userStatusPropagation", updated, props);
- }
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- public Long link(final UserMod subjectMod) {
- PollingConsumer pollingConsumer = getConsumer("direct:linkPort");
-
- sendMessage("direct:linkUser", subjectMod);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- exchange.getIn().setBody((exchange.getIn().getBody(UserMod.class).getKey()));
- return exchange.getIn().getBody(Long.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<PropagationStatus> deprovision(final Long user, final Collection<String> resources) {
- PollingConsumer pollingConsumer = getConsumer("direct:deprovisionPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("resources", resources);
-
- sendMessage("direct:deprovisionUser", user, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
-
- return exchange.getIn().getBody(List.class);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map.Entry<Long, List<PropagationStatus>> update(
- final UserMod userMod, final Long key, final ProvisioningResult result,
- final Boolean enabled, final Set<String> excludedResources) {
-
- PollingConsumer pollingConsumer = getConsumer("direct:updateInSyncPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("key", key);
- props.put("result", result);
- props.put("enabled", enabled);
- props.put("excludedResources", excludedResources);
-
- sendMessage("direct:updateUserInSync", userMod, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- Exception e;
- if ((e = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT)) != null) {
- LOG.error("Update of user {} failed, trying to sync its status anyway (if configured)", key, e);
-
- result.setStatus(ProvisioningResult.Status.FAILURE);
- result.setMessage("Update failed, trying to sync status anyway (if configured)\n" + e.getMessage());
-
- WorkflowResult<Map.Entry<UserMod, Boolean>> updated = new WorkflowResult<Map.Entry<UserMod, Boolean>>(
- new AbstractMap.SimpleEntry<>(userMod, false), new PropagationByResource(),
- new HashSet<String>());
- sendMessage("direct:userInSync", updated, props);
- exchange = pollingConsumer.receive();
- }
-
- return exchange.getIn().getBody(Map.Entry.class);
- }
-
- @Override
- public void innerSuspend(final User user, final boolean propagate) {
- PollingConsumer pollingConsumer = getConsumer("direct:innerSuspendUserPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("propagate", propagate);
-
- sendMessage("direct:innerSuspendUser", user, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
- }
-
- @Override
- public void requestPasswordReset(final Long userKey) {
- PollingConsumer pollingConsumer = getConsumer("direct:requestPwdResetPort");
-
- sendMessage("direct:requestPwdReset", userKey);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
- }
-
- @Override
- public void confirmPasswordReset(final User user, final String token, final String password) {
- PollingConsumer pollingConsumer = getConsumer("direct:confirmPwdResetPort");
-
- Map<String, Object> props = new HashMap<>();
- props.put("user", user);
- props.put("userKey", user.getKey());
- props.put("token", token);
- props.put("password", password);
-
- sendMessage("direct:confirmPwdReset", user, props);
-
- Exchange exchange = pollingConsumer.receive();
-
- if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
- throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/SyncopeCamelContext.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/SyncopeCamelContext.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/SyncopeCamelContext.java
deleted file mode 100644
index 02c82cb..0000000
--- a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/SyncopeCamelContext.java
+++ /dev/null
@@ -1,123 +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.server.provisioning.camel;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import org.apache.camel.model.Constants;
-import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.commons.io.IOUtils;
-import org.apache.syncope.server.misc.spring.ApplicationContextProvider;
-import org.apache.syncope.server.persistence.api.dao.CamelRouteDAO;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.w3c.dom.Node;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSInput;
-import org.w3c.dom.ls.LSParser;
-
-@Component
-public class SyncopeCamelContext {
-
- private static final Logger LOG = LoggerFactory.getLogger(SyncopeCamelContext.class);
-
- @Autowired
- private CamelRouteDAO routeDAO;
-
- private SpringCamelContext camelContext = null;
-
- public SpringCamelContext getContext() {
- synchronized (this) {
- if (camelContext == null) {
- camelContext = new SpringCamelContext(ApplicationContextProvider.getApplicationContext());
- }
- }
-
- if (camelContext.getRouteDefinitions().isEmpty()) {
- List<CamelRoute> routes = routeDAO.findAll();
- LOG.debug("{} route(s) are going to be loaded ", routes.size());
- loadContext(routes);
- try {
- camelContext.start();
- } catch (Exception e) {
- LOG.error("While starting Camel context", e);
- }
- }
-
- return camelContext;
- }
-
- private void loadContext(final List<CamelRoute> routes) {
- try {
- DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
- DOMImplementationLS domImpl = (DOMImplementationLS) reg.getDOMImplementation("LS");
- LSParser parser = domImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
-
- JAXBContext jaxbContext = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- List<RouteDefinition> routeDefs = new ArrayList<>();
- for (CamelRoute route : routes) {
- InputStream input = null;
- try {
- input = IOUtils.toInputStream(route.getContent());
- LSInput lsinput = domImpl.createLSInput();
- lsinput.setByteStream(input);
-
- Node routeElement = parser.parse(lsinput).getDocumentElement();
- routeDefs.add(unmarshaller.unmarshal(routeElement, RouteDefinition.class).getValue());
- } finally {
- IOUtils.closeQuietly(input);
- }
- }
- camelContext.addRouteDefinitions(routeDefs);
- } catch (Exception e) {
- LOG.error("While loading Camel context {}", e);
- }
- }
-
- public void updateContext(final String routeKey) {
- if (camelContext == null) {
- getContext();
- } else {
- if (!camelContext.getRouteDefinitions().isEmpty()) {
- camelContext.getRouteDefinitions().remove(camelContext.getRouteDefinition(routeKey));
- loadContext(Collections.singletonList(routeDAO.find(routeKey)));
- }
- }
- }
-
- public void restartContext() {
- try {
- camelContext.stop();
- camelContext.start();
- } catch (Exception e) {
- LOG.error("While restarting Camel context", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/data/CamelRouteDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/data/CamelRouteDataBinderImpl.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/data/CamelRouteDataBinderImpl.java
deleted file mode 100644
index c271d65..0000000
--- a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/data/CamelRouteDataBinderImpl.java
+++ /dev/null
@@ -1,48 +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.server.provisioning.camel.data;
-
-import org.apache.syncope.common.lib.to.CamelRouteTO;
-import org.apache.syncope.server.misc.spring.BeanUtils;
-import org.apache.syncope.server.persistence.api.dao.CamelRouteDAO;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-import org.apache.syncope.server.provisioning.api.data.CamelRouteDataBinder;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class CamelRouteDataBinderImpl implements CamelRouteDataBinder {
-
- @Autowired
- private CamelRouteDAO routeDAO;
-
- @Override
- public CamelRouteTO getRouteTO(final CamelRoute route) {
- CamelRouteTO routeTO = new CamelRouteTO();
- BeanUtils.copyProperties(route, routeTO);
- return routeTO;
- }
-
- @Override
- public void update(final CamelRoute route, final CamelRouteTO routeTO) {
- route.setContent(routeTO.getContent());
- routeDAO.save(route);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/processor/RoleCreateInSyncProcessor.java
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/processor/RoleCreateInSyncProcessor.java b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/processor/RoleCreateInSyncProcessor.java
deleted file mode 100644
index aaced42..0000000
--- a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/processor/RoleCreateInSyncProcessor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.syncope.server.provisioning.camel.processor;
-
-/*
- * 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.
- */
-import java.util.AbstractMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.to.AttrTO;
-import org.apache.syncope.common.lib.to.RoleTO;
-import org.apache.syncope.server.misc.security.AuthContextUtil;
-import org.apache.syncope.server.persistence.api.RoleEntitlementUtil;
-import org.apache.syncope.server.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.server.provisioning.api.WorkflowResult;
-import org.apache.syncope.server.provisioning.api.propagation.PropagationManager;
-import org.apache.syncope.server.provisioning.api.propagation.PropagationTaskExecutor;
-import org.springframework.stereotype.Component;
-
-@Component
-public class RoleCreateInSyncProcessor implements Processor {
-
- @Autowired
- protected PropagationManager propagationManager;
-
- @Autowired
- protected PropagationTaskExecutor taskExecutor;
-
- @Override
- @SuppressWarnings("unchecked")
- public void process(final Exchange exchange) {
- WorkflowResult<Long> created = (WorkflowResult) exchange.getIn().getBody();
-
- RoleTO actual = exchange.getProperty("subject", RoleTO.class);
- Map<Long, String> roleOwnerMap = exchange.getProperty("roleOwnerMap", Map.class);
- Set<String> excludedResource = exchange.getProperty("excludedResources", Set.class);
-
- AttrTO roleOwner = actual.getPlainAttrMap().get(StringUtils.EMPTY);
- if (roleOwner != null) {
- roleOwnerMap.put(created.getResult(), roleOwner.getValues().iterator().next());
- }
-
- AuthContextUtil.extendAuthContext(
- created.getResult(), RoleEntitlementUtil.getEntitlementNameFromRoleKey(created.getResult()));
-
- List<PropagationTask> tasks = propagationManager.getRoleCreateTaskIds(
- created, actual.getVirAttrs(), excludedResource);
-
- taskExecutor.execute(tasks);
-
- exchange.getOut().setBody(new AbstractMap.SimpleEntry<>(created.getResult(), null));
- }
-}