http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/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 new file mode 100644 index 0000000..125b17f --- /dev/null +++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/SyncopeCamelContext.java @@ -0,0 +1,134 @@ +/* + * 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.ByteArrayInputStream; +import java.io.InputStream; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +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.common.lib.SyncopeConstants; +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.Document; +import org.w3c.dom.Node; + +@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(routeDAO, routes); + try { + camelContext.start(); + } catch (Exception e) { + LOG.error("While starting Camel context", e); + } + } + + return camelContext; + } + + public void loadContext(final CamelRouteDAO routeDAO, final List<CamelRoute> routes) { + try { + DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + JAXBContext jaxbContext = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + List<RouteDefinition> routeDefs = new ArrayList<>(); + for (CamelRoute route : routes) { + InputStream is = null; + try { + is = new ByteArrayInputStream( + URLDecoder.decode(route.getContent(), SyncopeConstants.DEFAULT_ENCODING).getBytes()); + Document doc = dBuilder.parse(is); + doc.getDocumentElement().normalize(); + Node routeEl = doc.getElementsByTagName("route").item(0); + JAXBElement<RouteDefinition> obj = unmarshaller.unmarshal(routeEl, RouteDefinition.class); + routeDefs.add(obj.getValue()); + } finally { + IOUtils.closeQuietly(is); + } + } + camelContext.addRouteDefinitions(routeDefs); + } catch (Exception e) { + LOG.error("While loading Camel context {}", e); + } + } + + public void reloadContext() { + if (camelContext == null) { + getContext(); + } else { + if (!camelContext.getRouteDefinitions().isEmpty()) { + try { + camelContext.removeRouteDefinitions(new ArrayList<>(camelContext.getRouteDefinitions())); + } catch (Exception e) { + LOG.error("While clearing Camel context {}", e); + } + } + + loadContext(routeDAO, new ArrayList<>(routeDAO.findAll())); + } + } + + public void reloadContext(final String routeKey) { + if (camelContext == null) { + getContext(); + } else { + if (!camelContext.getRouteDefinitions().isEmpty()) { + camelContext.getRouteDefinitions().remove(camelContext.getRouteDefinition(routeKey)); + loadContext(routeDAO, Collections.singletonList(routeDAO.find(routeKey))); + } + } + } + + public List<RouteDefinition> getDefinitions() { + return camelContext.getRouteDefinitions(); + } +}
http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/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 new file mode 100644 index 0000000..c271d65 --- /dev/null +++ b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/server/provisioning/camel/data/CamelRouteDataBinderImpl.java @@ -0,0 +1,48 @@ +/* + * 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/dae87ef8/syncope620/ext/camel/provisioning-camel/src/main/resources/provisioning.properties ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/provisioning-camel/src/main/resources/provisioning.properties b/syncope620/ext/camel/provisioning-camel/src/main/resources/provisioning.properties new file mode 100644 index 0000000..b51dbee --- /dev/null +++ b/syncope620/ext/camel/provisioning-camel/src/main/resources/provisioning.properties @@ -0,0 +1,18 @@ +# 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. +userProvisioningManager=org.apache.syncope.server.provisioning.camel.CamelUserProvisioningManager +roleProvisioningManager=org.apache.syncope.server.provisioning.camel.CamelRoleProvisioningManager http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/camel/provisioning-camel/src/main/resources/roleRoutes.xml ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/provisioning-camel/src/main/resources/roleRoutes.xml b/syncope620/ext/camel/provisioning-camel/src/main/resources/roleRoutes.xml new file mode 100644 index 0000000..827d16e --- /dev/null +++ b/syncope620/ext/camel/provisioning-camel/src/main/resources/roleRoutes.xml @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<routes> + + <!-- + The default routes define each task involved in user creation: + main operations consist in user workflow creation and its propagation. + --> + <!-- + CREATE ROLE + --> + + <route id="createRole"> + <from uri="direct:createRole"/> + <setProperty propertyName="subject"> + <simple>${body}</simple> + </setProperty> + <doTry> + <bean ref="rwfAdapter" method="create(${body})"/> + <process ref="defaultRoleCreatePropagation" /> + <to uri="direct:createRolePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:createRolePort"/> + </doCatch> + </doTry> + </route> + + <!-- + CREATE ROLE SYNC + --> + <route id="createRoleSync"> + <from uri="direct:createRoleSync"/> + <setProperty propertyName="subject"> + <simple>${body}</simple> + </setProperty> + <doTry> + <bean ref="rwfAdapter" method="create(${body})"/> + <process ref="defaultRoleCreateSyncPropagation" /> + <to uri="direct:createRoleSyncPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:createRoleSyncPort"/> + </doCatch> + </doTry> + </route> + + + <!-- + UPDATE ROLE + --> + <route id="updateRole"> + <from uri="direct:updateRole"/> + <setProperty propertyName="subjectMod"> + <simple>${body}</simple> + </setProperty> + <doTry> + <bean ref="rwfAdapter" method="update(${body})"/> + <process ref="defaultRoleUpdatePropagation" /> + <to uri="direct:updateRolePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:updateRolePort"/> + </doCatch> + </doTry> + </route> + + <!-- + DELETE ROLE + --> + <route id="deleteRole"> + <from uri="direct:deleteRole"/> + <doTry> + <process ref="defaultRoleDeletePropagation" /> + <bean ref="rwfAdapter" method="delete(${body})"/> + <setBody> + <simple>${property.statuses}</simple> + </setBody> + <to uri="direct:deleteRolePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:deleteRolePort"/> + </doCatch> + </doTry> + </route> + + <!-- + UNLINK USER + --> + <route id="unlinkRole"> + <from uri="direct:unlinkRole"/> + <doTry> + <bean ref="rwfAdapter" method="update(${body})"/> + <setBody> + <simple>${body.getResult}</simple> + </setBody> + <to uri="direct:unlinkRolePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:unlinkRolePort"/> + </doCatch> + </doTry> + </route> + + <!-- + LINK USER + --> + + <route id="linkRole"> + <from uri="direct:linkRole"/> + <doTry> + <bean ref="rwfAdapter" method="update(${body})"/> + <setBody> + <simple>${body.getResult}</simple> + </setBody> + <to uri="direct:linkRolePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:linkRolePort"/> + </doCatch> + </doTry> + </route> + + <!-- + DEPROVISION ROLE + --> + <route id="deprovisionRole"> + <from uri="direct:deprovisionRole"/> + <process ref="defaultRoleDeprovisionPropagation" /> + <to uri="direct:deprovisionRolePort"/> + </route> + +</routes> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml b/syncope620/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml new file mode 100644 index 0000000..d62ab76 --- /dev/null +++ b/syncope620/ext/camel/provisioning-camel/src/main/resources/userRoutes.xml @@ -0,0 +1,304 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<routes> + + <!-- + The default routes define each task involved in user creation: + main operations consist in user workflow creation and its propagation. + --> + <!-- + CREATE USER + This is the entry point of the route and is involved in accepting + the UserTO. When it arrives, the user workflow is created. If the + creation is successfull, the result is sent to propagation, otherwise + if an exception was raised, the exception has to be returned to the + caller. The property actual allows to store the received UserTO in + order to use it later. + --> + + <route id="createUser"> + <from uri="direct:createUser"/> + <setProperty propertyName="actual"> + <simple>${body}</simple> + </setProperty> + <doTry> + <bean ref="uwfAdapter" method="create(${body},${property.disablePwdPolicyCheck}, + ${property.enabled},${property.storePassword})"/> + <process ref="defaultUserCreatePropagation" /> + <to uri="direct:createPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:createPort"/> + </doCatch> + </doTry> + </route> + + <!-- + The propagation route deals with propagation of created user. In this + case we used a custom processor to perform this task: it means that + a custom java class contains the propagation strategy. + --> + + <!-- + UPDATE USER + --> + <route id="updateUser"> + <from uri="direct:updateUser"/> + <setProperty propertyName="actual"> + <simple>${body}</simple> + </setProperty> + <doTry> + <bean ref="uwfAdapter" method="update(${body})"/> + <process ref="defaultUserUpdatePropagation" /> + <to uri="direct:updatePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:updatePort"/> + </doCatch> + </doTry> + </route> + + + + <!-- + UPDATE SYNC USER + --> + <route id="updateSyncUser"> + <from uri="direct:updateSyncUser"/> + <doTry> + <bean ref="uwfAdapter" method="update(${body})"/> + <to uri="direct:syncUserStatus"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:updateSyncPort"/> + </doCatch> + </doTry> + </route> + + <route id="syncUserStatus"> + <from uri="direct:syncUserStatus"/> + <process ref="userStatusOnSync" /> + <process ref="defaultUserUpdateInSyncPropagation" /> + <to uri="direct:updateSyncPort"/> + </route> + <!-- + DELETE USER + --> + <route id="deleteUser"> + <from uri="direct:deleteUser"/> + <doTry> + <process ref="defaultUserDeletePropagation" /> + <bean ref="uwfAdapter" method="delete(${body})"/> + <setBody> + <simple>${property.statuses}</simple> + </setBody> + <to uri="direct:deletePort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:deletePort"/> + </doCatch> + </doTry> + </route> + + <!-- + UNLINK USER + --> + <route id="unlinkUser"> + <from uri="direct:unlinkUser"/> + <doTry> + <bean ref="uwfAdapter" method="update(${body})"/> + <setBody> + <simple>${body.getResult.getKey}</simple> + </setBody> + <to uri="direct:unlinkPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:unlinkPort"/> + </doCatch> + </doTry> + </route> + + <!-- + LINK USER + --> + + <route id="linkUser"> + <from uri="direct:linkUser"/> + <doTry> + <bean ref="uwfAdapter" method="update(${body})"/> + <setBody> + <simple>${body.getResult.getKey}</simple> + </setBody> + <to uri="direct:linkPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:linkPort"/> + </doCatch> + </doTry> + </route> + + <!-- + ACTIVATE USER + --> + <route id="activateUser"> + <from uri="direct:activateUser"/> + <doTry> + <bean ref="uwfAdapter" method="activate(${body}, ${property.token})"/> + <to uri="direct:statusUser"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:statusPort"/> + </doCatch> + </doTry> + </route> + <!-- + REACTIVATE USER + --> + <route id="reactivateUser"> + <from uri="direct:reactivateUser"/> + <doTry> + <bean ref="uwfAdapter" method="reactivate(${body})"/> + <to uri="direct:statusUser"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:statusPort"/> + </doCatch> + </doTry> + </route> + <!-- + SUSPEND USER + --> + <route id="suspendUser"> + <from uri="direct:suspendUser"/> + <doTry> + <bean ref="uwfAdapter" method="suspend(${body})"/> + <to uri="direct:statusUser"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:statusPort"/> + </doCatch> + </doTry> + </route> + + <!-- + STATUS PROPAGATION + --> + + <route id="statusUser"> + <from uri="direct:statusUser"/> + <process ref="defaultUserStatusPropagation" /> + <to uri="direct:statusPort"/> + </route> + + + <!-- + DEPROVISION USER + --> + <route id="deprovisionUser"> + <from uri="direct:deprovisionUser"/> + <process ref="defaultUserDeprovisionPropagation" /> + <to uri="direct:deprovisionPort"/> + </route> + + <!-- + SUSPEND USER AFTER POLICY VIOLATION + --> + + <route id="suspendUserWF"> + <from uri="direct:suspendUserWF"/> + <doTry> + <bean ref="uwfAdapter" method="suspend(${body})"/> + <process ref="defaultUserWFSuspendPropagation"/> + <to uri="direct:suspendWFPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:suspendWFPort"/> + </doCatch> + </doTry> + </route> + + <!-- + REQUEST PASSWORD RESET ROUTE + --> + + <route id="requestPwdReset"> + <from uri="direct:requestPwdReset"/> + <doTry> + <bean ref="uwfAdapter" method="requestPasswordReset(${body})"/> + <to uri="direct:requestPwdResetPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:requestPwdResetPort"/> + </doCatch> + </doTry> + </route> + <!-- + CONFIRM PASSWORD RESET + --> + <route id="confirmPwdReset"> + <from uri="direct:confirmPwdReset"/> + <doTry> + <bean ref="uwfAdapter" method="confirmPasswordReset(${property.userId},${property.token},${property.password})"/> + <process ref="defaultUserConfirmPwdResetPropagation" /> + <to uri="direct:confirmPwdResetPort"/> + <doCatch> + <exception>java.lang.RuntimeException</exception> + <handled> + <constant>false</constant> + </handled> + <to uri="direct:confirmPwdResetPort"/> + </doCatch> + </doTry> + </route> + +</routes> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/camel/rest-api/pom.xml ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/rest-api/pom.xml b/syncope620/ext/camel/rest-api/pom.xml new file mode 100644 index 0000000..a2b2397 --- /dev/null +++ b/syncope620/ext/camel/rest-api/pom.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.syncope.ext</groupId> + <artifactId>syncope-ext-camel</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <name>Apache Syncope Extensions: Camel REST API</name> + <description>Apache Syncope Extensions: Camel REST API</description> + <groupId>org.apache.syncope.ext.camel</groupId> + <artifactId>syncope-ext-camel-rest-api</artifactId> + <packaging>jar</packaging> + + <properties> + <rootpom.basedir>${basedir}/../../..</rootpom.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.syncope.common</groupId> + <artifactId>syncope-common-rest-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.syncope.ext.camel</groupId> + <artifactId>syncope-ext-camel-common-lib</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/camel/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/CamelRouteService.java ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/CamelRouteService.java b/syncope620/ext/camel/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/CamelRouteService.java new file mode 100644 index 0000000..d16b812 --- /dev/null +++ b/syncope620/ext/camel/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/CamelRouteService.java @@ -0,0 +1,51 @@ +/* + * 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.common.rest.api.service; + +import java.util.List; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.apache.syncope.common.lib.to.CamelRouteTO; +import org.apache.syncope.common.lib.types.SubjectType; + +@Path("camelRoutes") +public interface CamelRouteService extends JAXRSService { + + @GET + @Path("{subjectType}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + List<CamelRouteTO> list(@NotNull @PathParam("subjectType") SubjectType subjectType); + + @GET + @Path("{key}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + CamelRouteTO read(@PathParam("key") String key); + + @PUT + @Path("{key}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + void update(@PathParam("key") String key, CamelRouteTO route); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/camel/rest-cxf/pom.xml ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/rest-cxf/pom.xml b/syncope620/ext/camel/rest-cxf/pom.xml new file mode 100644 index 0000000..acae2fe --- /dev/null +++ b/syncope620/ext/camel/rest-cxf/pom.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.syncope.ext</groupId> + <artifactId>syncope-ext-camel</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <name>Apache Syncope Extensions: Camel REST CXF</name> + <description>Apache Syncope Extensions: Camel REST CXF</description> + <groupId>org.apache.syncope.ext.camel</groupId> + <artifactId>syncope-ext-camel-rest-cxf</artifactId> + <packaging>jar</packaging> + + <properties> + <rootpom.basedir>${basedir}/../../..</rootpom.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.syncope.server</groupId> + <artifactId>syncope-server-rest-cxf</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.syncope.ext.camel</groupId> + <artifactId>syncope-ext-camel-rest-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.syncope.ext.camel</groupId> + <artifactId>syncope-ext-camel-logic</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/camel/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/CamelRouteServiceImpl.java ---------------------------------------------------------------------- diff --git a/syncope620/ext/camel/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/CamelRouteServiceImpl.java b/syncope620/ext/camel/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/CamelRouteServiceImpl.java new file mode 100644 index 0000000..2d85376 --- /dev/null +++ b/syncope620/ext/camel/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/CamelRouteServiceImpl.java @@ -0,0 +1,51 @@ +/* + * 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.rest.cxf.service; + +import java.util.List; +import org.apache.syncope.common.lib.to.CamelRouteTO; +import org.apache.syncope.common.lib.types.SubjectType; +import org.apache.syncope.common.rest.api.service.CamelRouteService; +import org.apache.syncope.server.logic.CamelRouteLogic; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class CamelRouteServiceImpl extends AbstractServiceImpl implements CamelRouteService { + + @Autowired + private CamelRouteLogic logic; + + @Override + public List<CamelRouteTO> list(final SubjectType subjectType) { + return logic.list(subjectType); + } + + @Override + public CamelRouteTO read(final String key) { + return logic.read(key); + } + + @Override + public void update(final String key, final CamelRouteTO route) { + route.setKey(key); + logic.update(route); + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/ext/pom.xml ---------------------------------------------------------------------- diff --git a/syncope620/ext/pom.xml b/syncope620/ext/pom.xml new file mode 100644 index 0000000..cecf9a4 --- /dev/null +++ b/syncope620/ext/pom.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.syncope</groupId> + <artifactId>syncope</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <name>Apache Syncope Extensions</name> + <description>Apache Syncope Extensions</description> + <groupId>org.apache.syncope</groupId> + <artifactId>syncope-ext</artifactId> + <packaging>pom</packaging> + + <modules> + <module>camel</module> + </modules> + +</project> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/fit/reference/src/main/resources/serverContext.xml ---------------------------------------------------------------------- diff --git a/syncope620/fit/reference/src/main/resources/serverContext.xml b/syncope620/fit/reference/src/main/resources/serverContext.xml index 8ab1eb1..7bf75a1 100644 --- a/syncope620/fit/reference/src/main/resources/serverContext.xml +++ b/syncope620/fit/reference/src/main/resources/serverContext.xml @@ -34,6 +34,7 @@ under the License. <value>file:${conf.directory}/mail.properties</value> <value>file:${conf.directory}/logic.properties</value> <value>file:${conf.directory}/workflow.properties</value> + <value>file:${conf.directory}/provisioning.properties</value> </list> </property> </bean> @@ -46,6 +47,7 @@ under the License. <value>classpath:mail.properties</value> <value>classpath:logic.properties</value> <value>classpath:workflow.properties</value> + <value>classpath:provisioning.properties</value> </list> </property> </bean> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/pom.xml ---------------------------------------------------------------------- diff --git a/syncope620/pom.xml b/syncope620/pom.xml index d911dd8..73c067f 100644 --- a/syncope620/pom.xml +++ b/syncope620/pom.xml @@ -322,6 +322,8 @@ under the License. <cxf.version>3.0.3</cxf.version> + <camel.version>2.14.1</camel.version> + <jackson.version>2.4.5</jackson.version> <spring.version>4.1.4.RELEASE</spring.version> @@ -476,6 +478,24 @@ under the License. </dependency> <!-- /CXF --> + <!-- Camel --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-script</artifactId> + <version>${camel.version}</version> + </dependency> + <!-- /Camel --> + <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-jdbc</artifactId> @@ -1183,5 +1203,7 @@ under the License. <module>server</module> <module>client</module> <module>fit</module> + <module>ext</module> </modules> + </project> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/logic/src/test/resources/logicTest.xml ---------------------------------------------------------------------- diff --git a/syncope620/server/logic/src/test/resources/logicTest.xml b/syncope620/server/logic/src/test/resources/logicTest.xml index afb8730..0ad2585 100644 --- a/syncope620/server/logic/src/test/resources/logicTest.xml +++ b/syncope620/server/logic/src/test/resources/logicTest.xml @@ -31,6 +31,7 @@ under the License. <value>classpath:mail.properties</value> <value>classpath:logic.properties</value> <value>classpath:workflow.properties</value> + <value>classpath:provisioning.properties</value> </list> </property> <property name="ignoreResourceNotFound" value="true"/> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultRoleProvisioningManager.java ---------------------------------------------------------------------- diff --git a/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultRoleProvisioningManager.java b/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultRoleProvisioningManager.java index 06f205b..31a5704 100644 --- a/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultRoleProvisioningManager.java +++ b/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultRoleProvisioningManager.java @@ -48,9 +48,7 @@ import org.apache.syncope.server.provisioning.api.propagation.PropagationTaskExe import org.apache.syncope.server.misc.security.AuthContextUtil; import org.apache.syncope.server.misc.spring.ApplicationContextProvider; import org.apache.syncope.server.workflow.api.RoleWorkflowAdapter; -import org.springframework.stereotype.Component; -@Component public class DefaultRoleProvisioningManager implements RoleProvisioningManager { private static final Logger LOG = LoggerFactory.getLogger(RoleProvisioningManager.class); http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultUserProvisioningManager.java ---------------------------------------------------------------------- diff --git a/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultUserProvisioningManager.java b/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultUserProvisioningManager.java index 3c4225e..85a489b 100644 --- a/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultUserProvisioningManager.java +++ b/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/DefaultUserProvisioningManager.java @@ -46,9 +46,7 @@ import org.apache.syncope.server.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 DefaultUserProvisioningManager implements UserProvisioningManager { private static final Logger LOG = LoggerFactory.getLogger(UserProvisioningManager.class); http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/data/ResourceDataBinderImpl.java ---------------------------------------------------------------------- diff --git a/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/data/ResourceDataBinderImpl.java b/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/data/ResourceDataBinderImpl.java index 791b037..da646cc 100644 --- a/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/data/ResourceDataBinderImpl.java +++ b/syncope620/server/provisioning-java/src/main/java/org/apache/syncope/server/provisioning/java/data/ResourceDataBinderImpl.java @@ -48,7 +48,6 @@ import org.apache.syncope.server.persistence.api.entity.role.RMappingItem; import org.apache.syncope.server.persistence.api.entity.user.UMapping; import org.apache.syncope.server.persistence.api.entity.user.UMappingItem; import org.apache.syncope.server.provisioning.api.ConnectorRegistry; -import org.apache.syncope.server.provisioning.java.ConnectorManager; import org.apache.syncope.server.misc.jexl.JexlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/provisioning-java/src/main/resources/provisioning.properties ---------------------------------------------------------------------- diff --git a/syncope620/server/provisioning-java/src/main/resources/provisioning.properties b/syncope620/server/provisioning-java/src/main/resources/provisioning.properties new file mode 100644 index 0000000..2ed4d0d --- /dev/null +++ b/syncope620/server/provisioning-java/src/main/resources/provisioning.properties @@ -0,0 +1,18 @@ +# 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. +userProvisioningManager=org.apache.syncope.server.provisioning.java.DefaultUserProvisioningManager +roleProvisioningManager=org.apache.syncope.server.provisioning.java.DefaultRoleProvisioningManager http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/provisioning-java/src/main/resources/provisioningContext.xml ---------------------------------------------------------------------- diff --git a/syncope620/server/provisioning-java/src/main/resources/provisioningContext.xml b/syncope620/server/provisioning-java/src/main/resources/provisioningContext.xml index 3b4301e..72f6664 100644 --- a/syncope620/server/provisioning-java/src/main/resources/provisioningContext.xml +++ b/syncope620/server/provisioning-java/src/main/resources/provisioningContext.xml @@ -31,6 +31,9 @@ under the License. <task:annotation-driven executor="connectorExecutor"/> <task:executor id="connectorExecutor" pool-size="10"/> + <bean class="${userProvisioningManager}"/> + <bean class="${roleProvisioningManager}"/> + <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false" depends-on="nonJPAdbInitializer"> <property name="autoStartup" value="true"/> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/provisioning-java/src/test/resources/provisioningTest.xml ---------------------------------------------------------------------- diff --git a/syncope620/server/provisioning-java/src/test/resources/provisioningTest.xml b/syncope620/server/provisioning-java/src/test/resources/provisioningTest.xml index 398f3fc..a63d665 100644 --- a/syncope620/server/provisioning-java/src/test/resources/provisioningTest.xml +++ b/syncope620/server/provisioning-java/src/test/resources/provisioningTest.xml @@ -30,6 +30,7 @@ under the License. <value>classpath:connid.properties</value> <value>classpath:mail.properties</value> <value>classpath:workflow.properties</value> + <value>classpath:provisioning.properties</value> </list> </property> <property name="ignoreResourceNotFound" value="true"/> http://git-wip-us.apache.org/repos/asf/syncope/blob/dae87ef8/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/WorkflowServiceImpl.java ---------------------------------------------------------------------- diff --git a/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/WorkflowServiceImpl.java b/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/WorkflowServiceImpl.java index 2cdc0d1..233d47b 100644 --- a/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/WorkflowServiceImpl.java +++ b/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/WorkflowServiceImpl.java @@ -20,7 +20,6 @@ package org.apache.syncope.server.rest.cxf.service; import java.io.IOException; import java.io.OutputStream; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; @@ -38,25 +37,6 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow private WorkflowLogic logic; @Override - public Response getOptions(final SubjectType kind) { - String key; - String value; - if (kind == SubjectType.USER) { - key = RESTHeaders.ACTIVITI_USER_ENABLED; - value = "false"; //Boolean.toString(ActivitiDetector.isActivitiEnabledForUsers()); - } else { - key = RESTHeaders.ACTIVITI_ROLE_ENABLED; - value = "false"; //Boolean.toString(ActivitiDetector.isActivitiEnabledForRoles()); - } - - Response.ResponseBuilder builder = Response.ok().header(HttpHeaders.ALLOW, OPTIONS_ALLOW); - if (key != null && value != null) { - builder.header(key, value); - } - return builder.build(); - } - - @Override public Response exportDefinition(final SubjectType kind) { final MediaType accept = messageContext.getHttpHeaders().getAcceptableMediaTypes().contains(MediaType.APPLICATION_JSON_TYPE)
