Repository: incubator-unomi Updated Branches: refs/heads/feature-DMF-1343 63debd5fc -> 7c36249b7 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-karaf-feature/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/router/router-karaf-feature/pom.xml b/extensions/router/router-karaf-feature/pom.xml new file mode 100644 index 0000000..8a8e62c --- /dev/null +++ b/extensions/router/router-karaf-feature/pom.xml @@ -0,0 +1,157 @@ +<?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"> + <parent> + <artifactId>unomi-router</artifactId> + <groupId>org.apache.unomi</groupId> + <version>1.2.0-incubating-dmf_1343-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-router-karaf-feature</artifactId> + <name>Apache Unomi :: Extensions :: Router :: Apache Karaf Feature</name> + <description>Apache Karaf feature for the Apache Unomi Context Server extension</description> + <packaging>feature</packaging> + <dependencies> + <dependency> + <groupId>org.apache.servicemix.bundles</groupId> + <artifactId>org.apache.servicemix.bundles.jsch</artifactId> + <version>0.1.54_1</version> + </dependency> + <dependency> + <groupId>commons-net</groupId> + <artifactId>commons-net</artifactId> + <version>3.5</version> + </dependency> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>kafka-clients</artifactId> + <version>0.10.1.0</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-blueprint</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jackson</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-http-common</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-servlet</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-ftp</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-stream</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-kafka</artifactId> + <version>${camel.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-security-cors</artifactId> + <version>${cxf.version}</version> + </dependency> + + <!-- UNOMI ROUTER Modules Dependencies --> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-persistence-spi</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-service</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient-osgi</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore-osgi</artifactId> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <includeTransitiveDependency>false</includeTransitiveDependency> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <configuration> + <startLevel>90</startLevel> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-rest/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/router/router-rest/pom.xml b/extensions/router/router-rest/pom.xml new file mode 100644 index 0000000..e39e919 --- /dev/null +++ b/extensions/router/router-rest/pom.xml @@ -0,0 +1,75 @@ +<?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"> + <parent> + <artifactId>unomi-router</artifactId> + <groupId>org.apache.unomi</groupId> + <version>1.2.0-incubating-dmf_1343-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-router-rest</artifactId> + <name>Apache Unomi :: Extensions :: Router :: REST API</name> + <description>Router REST API</description> + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>2.0.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-security-cors</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient-osgi</artifactId> + <type>bundle</type> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore-osgi</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java ---------------------------------------------------------------------- diff --git a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java new file mode 100644 index 0000000..42670b2 --- /dev/null +++ b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java @@ -0,0 +1,176 @@ +/* + * 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.unomi.router.rest; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.unomi.router.api.ImportConfiguration; +import org.apache.unomi.router.api.services.ImportConfigurationService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +/** + * A JAX-RS endpoint to manage {@link org.apache.unomi.router.api.ImportConfiguration}s. + */ +@WebService +@CrossOriginResourceSharing( + allowAllOrigins = true, + allowCredentials = true +) +public class ImportConfigurationServiceEndPoint { + + private static final Logger logger = LoggerFactory.getLogger(ImportConfigurationServiceEndPoint.class.getName()); + private final String CONFIG_TYPE_RECURRENT = "recurrent"; + + private ImportConfigurationService importConfigurationService; + private String uploadDir; + private String serverPort; + + public ImportConfigurationServiceEndPoint () { + logger.info("Initializing import configuration service endpoint..."); + } + + @WebMethod(exclude = true) + public void setImportConfigurationService(ImportConfigurationService importConfigurationService) { + this.importConfigurationService = importConfigurationService; + } + + @WebMethod(exclude = true) + public void setUploadDir(String uploadDir) { + this.uploadDir = uploadDir; + } + + @WebMethod(exclude = true) + public void setServerPort(String serverPort) { + this.serverPort = serverPort; + } + + /** + * Retrieves all the import configurations. + * + * @return all the import configurations. + */ + @GET + @Path("/") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public List<ImportConfiguration> getImportConfigurations() { + return importConfigurationService.getImportConfigurations(); + } + + /** + * Retrieves an import configuration by id. + * + * @return the import configuration that matches the given id. + */ + @GET + @Path("/{configId}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public ImportConfiguration getImportConfiguration(@PathParam("configId") String configId) { + return importConfigurationService.load(configId); + } + + /** + * Delete an import configuration by id. + * + * @return the deleted import configuration. + */ + @DELETE + @Path("/{configId}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public void deleteImportConfiguration(@PathParam("configId") String configId) { + importConfigurationService.delete(configId); + } + + + + /** + * Save the given import configuration. + * + * @return the import configuration saved. + */ + @POST + @Path("/") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public ImportConfiguration saveImportConfiguration(ImportConfiguration importConfiguration) { + ImportConfiguration importConfigSaved = importConfigurationService.save(importConfiguration); + if(CONFIG_TYPE_RECURRENT.equals(importConfigSaved.getConfigType())) { + CloseableHttpClient httpClient = HttpClients.createDefault(); + try { + HttpPut httpPut = new HttpPut("http://localhost:"+serverPort+"/importConfigAdmin/"); + StringEntity input = new StringEntity(new ObjectMapper().writeValueAsString(importConfigSaved)); + input.setContentType(MediaType.APPLICATION_JSON); + httpPut.setEntity(input); + + HttpResponse response = httpClient.execute(httpPut); + + if (response.getStatusLine().getStatusCode() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatusLine().getStatusCode()); + } + } catch (IOException e) { + logger.warn("Unable to update Camel route [{}]", importConfiguration.getItemId()); + } + } + return importConfigSaved; + } + + /** + * Save/Update the given import configuration. + * Prepare the file to be processed with Camel routes + * @return OK / NOK Http Code. + */ + @POST + @Path("/oneshot") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response processOneshotImportConfigurationCSV(@Multipart(value = "importConfigId") String importConfigId, @Multipart(value = "file") Attachment file) { + try { + java.nio.file.Path path = Paths.get(uploadDir+importConfigId+".csv"); + Files.deleteIfExists(path); + InputStream in = file.getObject(InputStream.class); + + Files.copy(in, path); + + } catch (IOException e) { + e.printStackTrace(); + return Response.serverError().build(); + } + return Response.ok().build(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..8728a7f --- /dev/null +++ b/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,80 @@ +<?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. + --> + +<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" + xmlns:cxf="http://cxf.apache.org/blueprint/core" xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs" + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd + http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd + http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd + http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd"> + <cm:property-placeholder persistent-id="org.apache.unomi.router" update-strategy="reload"> + <cm:default-properties> + <cm:property name="import.oneshot.uploadDir" value="/tmp/oneshot_import_configs/"/> + </cm:default-properties> + </cm:property-placeholder> + + <cm:property-placeholder persistent-id="org.apache.unomi.cluster" + update-strategy="reload" placeholder-prefix="${cluster."> + <cm:default-properties> + <cm:property name="cluster.contextserver.port" value="8181"/> + </cm:default-properties> + </cm:property-placeholder> + + <cxf:bus id="cxsServiceBus"> + <cxf:features> + <cxf:logging/> + </cxf:features> + </cxf:bus> + + <bean id="cors-filter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/> + <bean id="jacksonMapper" class="com.fasterxml.jackson.databind.ObjectMapper"/> + <bean id="json-provider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"> + <argument index="0" ref="jacksonMapper" type="com.fasterxml.jackson.databind.ObjectMapper"/> + </bean> + <bean id="jaas-filter" class="org.apache.cxf.jaxrs.security.JAASAuthenticationFilter"> + <!-- Name of the JAAS Context --> + <property name="contextName" value="karaf"/> + <!-- Hint to the filter on how to have Principals representing users and roles separated + while initializing a SecurityContext --> + <property name="rolePrefix" value="ROLE_"/> + <property name="realmName" value="cxs"/> + </bean> + + <jaxrs:server address="/importConfiguration" id="restImportConfigurationService"> + <jaxrs:providers> + <ref component-id="json-provider"/> + <ref component-id="cors-filter"/> + <ref component-id="jaas-filter"/> + </jaxrs:providers> + + <jaxrs:serviceBeans> + <ref component-id="importConfigurationServiceEndPoint"/> + </jaxrs:serviceBeans> + </jaxrs:server> + + <reference id="importConfigurationService" interface="org.apache.unomi.router.api.services.ImportConfigurationService"/> + + <bean id="importConfigurationServiceEndPoint" class="org.apache.unomi.router.rest.ImportConfigurationServiceEndPoint"> + <property name="importConfigurationService" ref="importConfigurationService"/> + <property name="uploadDir" value="${import.oneshot.uploadDir}"/> + <property name="serverPort" value="${cluster.contextserver.port}"/> + </bean> + +</blueprint> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-service/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/router/router-service/pom.xml b/extensions/router/router-service/pom.xml new file mode 100644 index 0000000..0aed70e --- /dev/null +++ b/extensions/router/router-service/pom.xml @@ -0,0 +1,104 @@ +<?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"> + <parent> + <artifactId>unomi-router</artifactId> + <groupId>org.apache.unomi</groupId> + <version>1.2.0-incubating-dmf_1343-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-router-service</artifactId> + <name>Apache Unomi :: Extensions :: Router :: Services</name> + <description>Router Services</description> + <packaging>bundle</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> + <Import-Package> + sun.misc;resolution:=optional, + * + </Import-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-persistence-spi</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + </dependencies> + + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java ---------------------------------------------------------------------- diff --git a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java new file mode 100644 index 0000000..a4f6131 --- /dev/null +++ b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java @@ -0,0 +1,114 @@ +/* + * 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.unomi.router.services; + +import org.apache.unomi.router.api.ImportConfiguration; +import org.apache.unomi.router.api.services.ImportConfigurationService; +import org.apache.unomi.persistence.spi.PersistenceService; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.SynchronousBundleListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.UUID; + +/** + * Created by amidani on 28/04/2017. + */ +public class ImportConfigurationServiceImpl implements ImportConfigurationService,SynchronousBundleListener { + + private static final Logger logger = LoggerFactory.getLogger(ImportConfigurationServiceImpl.class.getName()); + + private BundleContext bundleContext; + private PersistenceService persistenceService; + + public ImportConfigurationServiceImpl() { + logger.info("Initializing import configuration service..."); + } + + public void setBundleContext(BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + public void setPersistenceService(PersistenceService persistenceService) { + this.persistenceService = persistenceService; + } + + public void postConstruct() { + logger.debug("postConstruct {" + bundleContext.getBundle() + "}"); + + processBundleStartup(bundleContext); + for (Bundle bundle : bundleContext.getBundles()) { + if (bundle.getBundleContext() != null) { + processBundleStartup(bundle.getBundleContext()); + } + } + bundleContext.addBundleListener(this); + logger.info("Import configuration service initialized."); + } + + public void preDestroy() { + bundleContext.removeBundleListener(this); + logger.info("Import configuration service shutdown."); + } + + private void processBundleStartup(BundleContext bundleContext) { + if (bundleContext == null) { + return; + } + } + + private void processBundleStop(BundleContext bundleContext) { + } + + + @Override + public List<ImportConfiguration> getImportConfigurations() { + return persistenceService.getAllItems(ImportConfiguration.class); + } + + @Override + public ImportConfiguration load(String configId) { + return persistenceService.load(configId, ImportConfiguration.class); + } + + @Override + public ImportConfiguration save(ImportConfiguration importConfiguration) { + if (importConfiguration.getItemId() == null) { + importConfiguration.setItemId(UUID.randomUUID().toString()); + } + if(persistenceService.save(importConfiguration)) { + + } + + return persistenceService.load(importConfiguration.getItemId(), ImportConfiguration.class); + } + + @Override + public void delete(String configId) { + persistenceService.remove(configId, ImportConfiguration.class); + } + + @Override + public void bundleChanged(BundleEvent bundleEvent) { + + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ProfileImportServiceImpl.java ---------------------------------------------------------------------- diff --git a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ProfileImportServiceImpl.java b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ProfileImportServiceImpl.java new file mode 100644 index 0000000..cb1d706 --- /dev/null +++ b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ProfileImportServiceImpl.java @@ -0,0 +1,121 @@ +/* + * 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.unomi.router.services; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.unomi.api.Profile; +import org.apache.unomi.api.services.EventListenerService; +import org.apache.unomi.persistence.spi.PersistenceService; +import org.apache.unomi.router.api.ProfileToImport; +import org.apache.unomi.router.api.services.ProfileImportService; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.SynchronousBundleListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +/** + * Created by amidani on 18/05/2017. + */ +public class ProfileImportServiceImpl implements ProfileImportService, SynchronousBundleListener { + + private static final Logger logger = LoggerFactory.getLogger(ProfileImportServiceImpl.class.getName()); + + private PersistenceService persistenceService; + + private BundleContext bundleContext; + + public void setPersistenceService(PersistenceService persistenceService) { + this.persistenceService = persistenceService; + } + + public void setBundleContext(BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + public void postConstruct() { + logger.debug("postConstruct {" + bundleContext.getBundle() + "}"); + + processBundleStartup(bundleContext); + for (Bundle bundle : bundleContext.getBundles()) { + if (bundle.getBundleContext() != null) { + processBundleStartup(bundle.getBundleContext()); + } + } + bundleContext.addBundleListener(this); + logger.info("Import configuration service initialized."); + } + + public void preDestroy() { + bundleContext.removeBundleListener(this); + logger.info("Import configuration service shutdown."); + } + + private void processBundleStartup(BundleContext bundleContext) { + if (bundleContext == null) { + return; + } + } + + private void processBundleStop(BundleContext bundleContext) { + } + + + public boolean saveMergeDeleteImportedProfile(ProfileToImport profileToImport) throws InvocationTargetException, IllegalAccessException { + logger.debug("Importing profile with ID : {}", profileToImport.getItemId()); + Profile existingProfile = new Profile(); + List<Profile> existingProfiles = persistenceService.query("properties."+profileToImport.getMergingProperty(), (String)profileToImport.getProperties().get(profileToImport.getMergingProperty()), null, Profile.class); + logger.debug("Query existing profile with mergingProperty: {}. Found: {}", profileToImport.getMergingProperty(), existingProfiles.size()); + + //Profile already exist, and import config allow to overwrite profiles + if(existingProfiles.size() == 1) { + existingProfile = existingProfiles.get(0); + if(profileToImport.isProfileToDelete()) { + logger.debug("Profile is to delete!"); + persistenceService.remove(existingProfile.getItemId(), Profile.class); + return true; + } + List<String> propertiesToOverwrite = profileToImport.getPropertiesToOverwrite(); + if(profileToImport.isOverwriteExistingProfiles() && propertiesToOverwrite!=null && propertiesToOverwrite.size() > 0) { // We overwrite only properties marked to overwrite + logger.debug("Properties to overwrite: {}", propertiesToOverwrite); + for(String propName : propertiesToOverwrite) { + existingProfile.getProperties().put(propName, profileToImport.getProperties().get(propName)); + } + } else { //If no property is marked to overwrite we replace the whole properties map + logger.debug("Overwrite all properties"); + existingProfile.setProperties(profileToImport.getProperties()); + } + } else if(existingProfiles.size() == 0) { + logger.debug("New profile to add..."); + BeanUtils.copyProperties(existingProfile, profileToImport); + } else { + logger.warn("{} occurences found for profile with {} = {}. Profile import is skipped", existingProfiles.size(), + profileToImport.getMergingProperty(), profileToImport.getProperties().get(profileToImport.getMergingProperty())); + } + logger.debug("-------------------------------------"); + return persistenceService.save(existingProfile); + } + + @Override + public void bundleChanged(BundleEvent bundleEvent) { + + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..61200f2 --- /dev/null +++ b/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,39 @@ +<?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. + --> + +<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> + + <reference id="persistenceService" interface="org.apache.unomi.persistence.spi.PersistenceService"/> + + <bean id="importConfigurationServiceImpl" class="org.apache.unomi.router.services.ImportConfigurationServiceImpl" + init-method="postConstruct" destroy-method="preDestroy"> + <property name="persistenceService" ref="persistenceService"/> + <property name="bundleContext" ref="blueprintBundleContext"/> + </bean> + <service id="importConfigurationService" ref="importConfigurationServiceImpl" auto-export="interfaces"/> + + <bean id="profileImportServiceImpl" class="org.apache.unomi.router.services.ProfileImportServiceImpl" + init-method="postConstruct" destroy-method="preDestroy"> + <property name="persistenceService" ref="persistenceService"/> + <property name="bundleContext" ref="blueprintBundleContext"/> + </bean> + <service id="profileImportService" ref="profileImportServiceImpl" auto-export="interfaces"/> + +</blueprint> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/itests/pom.xml ---------------------------------------------------------------------- diff --git a/itests/pom.xml b/itests/pom.xml index 6f3724c..55fe567 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.apache.unomi</groupId> <artifactId>unomi-root</artifactId> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>1.2.0-incubating-dmf_1343-SNAPSHOT</version> </parent> <artifactId>unomi-itests</artifactId> <name>Apache Unomi :: Integration Tests</name> @@ -32,19 +32,19 @@ <groupId>org.apache.unomi</groupId> <artifactId>unomi-kar</artifactId> <classifier>features</classifier> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>${project.version}</version> <type>xml</type> </dependency> <dependency> <groupId>org.apache.unomi</groupId> <artifactId>unomi-persistence-spi</artifactId> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.unomi</groupId> <artifactId>unomi-wab</artifactId> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>${project.version}</version> <scope>test</scope> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/package/pom.xml ---------------------------------------------------------------------- diff --git a/package/pom.xml b/package/pom.xml index ae7c17e..2e7e479 100644 --- a/package/pom.xml +++ b/package/pom.xml @@ -269,6 +269,17 @@ </outputDirectory> <destFileName>org.apache.unomi.plugins.mail.cfg</destFileName> </artifactItem> + <artifactItem> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-router-core</artifactId> + <version>${project.version}</version> + <classifier>routercfg</classifier> + <type>cfg</type> + <outputDirectory> + ${project.build.directory}/assembly/etc + </outputDirectory> + <destFileName>org.apache.unomi.router.cfg</destFileName> + </artifactItem> <!-- UNOMI-75 : We install the blueprint core bundle in a different version to fix a problem with offline startup --> <artifactItem> <groupId>org.apache.aries.blueprint</groupId> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/performance-tests/pom.xml ---------------------------------------------------------------------- diff --git a/performance-tests/pom.xml b/performance-tests/pom.xml index 72c7abd..44117fc 100644 --- a/performance-tests/pom.xml +++ b/performance-tests/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.apache.unomi</groupId> <artifactId>unomi-root</artifactId> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>1.2.0-incubating-dmf_1343-SNAPSHOT</version> </parent> <artifactId>unomi-performance-tests</artifactId> <name>Apache Unomi :: Performance Tests</name> @@ -30,7 +30,7 @@ <dependency> <groupId>org.apache.unomi</groupId> <artifactId>unomi-wab</artifactId> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>${project.version}</version> <scope>test</scope> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg index 77eb091..12980e1 100644 --- a/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg +++ b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg @@ -15,7 +15,7 @@ # limitations under the License. # -cluster.name=contextElasticSearch +cluster.name=contextElasticSearch_amidani # The elasticSearchAddresses may be a comma seperated list of host names and ports such as # hostA:9300,hostB:9300 # Note: the port number must be repeated for each host. http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/persistence-elasticsearch/plugins/pom.xml ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/plugins/pom.xml b/persistence-elasticsearch/plugins/pom.xml index 9114ece..57eec00 100644 --- a/persistence-elasticsearch/plugins/pom.xml +++ b/persistence-elasticsearch/plugins/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.unomi</groupId> <artifactId>unomi-persistence-elasticsearch</artifactId> - <version>1.2.0-incubating-SNAPSHOT</version> + <version>1.2.0-incubating-dmf_1343-SNAPSHOT</version> </parent> <artifactId>unomi-persistence-elasticsearch-plugins</artifactId> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/samples/trainingplugin.zip ---------------------------------------------------------------------- diff --git a/samples/trainingplugin.zip b/samples/trainingplugin.zip new file mode 100644 index 0000000..1226fc1 Binary files /dev/null and b/samples/trainingplugin.zip differ http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/samples/trainingplugin/pom.xml ---------------------------------------------------------------------- diff --git a/samples/trainingplugin/pom.xml b/samples/trainingplugin/pom.xml new file mode 100644 index 0000000..34711a7 --- /dev/null +++ b/samples/trainingplugin/pom.xml @@ -0,0 +1,55 @@ +<?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"> + <parent> + <artifactId>samples</artifactId> + <groupId>org.apache.unomi</groupId> + <version>1.2.0-incubating-SNAPSHOT</version> + </parent> + <artifactId>training-plugin</artifactId> + <name>Apache Unomi :: Samples :: Training plugin</name> + <packaging>bundle</packaging> + <description>This is a simple Apache Unomi plugin.</description> + <modelVersion>4.0.0</modelVersion> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>1.2.0-incubating-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java ---------------------------------------------------------------------- diff --git a/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java b/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java new file mode 100644 index 0000000..7f64cbd --- /dev/null +++ b/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.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.unomi.training; + +import org.apache.unomi.api.Event; +import org.apache.unomi.api.Metadata; +import org.apache.unomi.api.Profile; +import org.apache.unomi.api.PropertyType; +import org.apache.unomi.api.actions.Action; +import org.apache.unomi.api.actions.ActionExecutor; +import org.apache.unomi.api.services.EventService; +import org.apache.unomi.api.services.ProfileService; + +import java.util.Collections; + +/** + * Created by amidani on 11/04/2017. + */ +public class TrainedNotificationAction implements ActionExecutor { + + private static final String TRAINED_NB_PROPERTY = "trained"; + private static final String TARGET = "profiles"; + + private ProfileService service; + + public void setProfileService(ProfileService service) { + this.service = service; + } + + @Override + public int execute(Action action, Event event) { + final Profile profile = event.getProfile(); + Integer trained = (Integer) profile.getProperty(TRAINED_NB_PROPERTY); + + if (trained == null) { + // create trained flag property type + PropertyType propertyType = new PropertyType(new Metadata(event.getScope(), TRAINED_NB_PROPERTY, TRAINED_NB_PROPERTY, "Am I trained")); + propertyType.setValueTypeId("boolean"); + propertyType.setTagIds(Collections.singleton("training")); + propertyType.setTarget(TARGET); + service.setPropertyType(propertyType); + } + + profile.setProperty(TRAINED_NB_PROPERTY, true); + return EventService.PROFILE_UPDATED; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/samples/trainingplugin/src/main/resources/META-INF/cxs/actions/trainingNotifAction.json ---------------------------------------------------------------------- diff --git a/samples/trainingplugin/src/main/resources/META-INF/cxs/actions/trainingNotifAction.json b/samples/trainingplugin/src/main/resources/META-INF/cxs/actions/trainingNotifAction.json new file mode 100644 index 0000000..2ac9763 --- /dev/null +++ b/samples/trainingplugin/src/main/resources/META-INF/cxs/actions/trainingNotifAction.json @@ -0,0 +1,13 @@ +{ + "metadata": { + "id": "trainingNotifAction", + "name": "Training Action", + "description": "", + "tags": [ + "event" + ], + "readOnly": true + }, + "actionExecutor": "training", + "parameters": [] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/samples/trainingplugin/src/main/resources/META-INF/cxs/rules/trainedNotification.json ---------------------------------------------------------------------- diff --git a/samples/trainingplugin/src/main/resources/META-INF/cxs/rules/trainedNotification.json b/samples/trainingplugin/src/main/resources/META-INF/cxs/rules/trainedNotification.json new file mode 100644 index 0000000..e098e3e --- /dev/null +++ b/samples/trainingplugin/src/main/resources/META-INF/cxs/rules/trainedNotification.json @@ -0,0 +1,20 @@ +{ + "metadata": { + "id": "smp:trainedRule", + "name": "Trained", + "description": "..." + }, + "raiseEventOnlyOnceForSession": false, + "condition": { + "type": "eventTypeCondition", + "parameterValues": { + "eventTypeId": "trainingEvent" + } + }, + "actions": [ + { + "type": "trainingNotifAction", + "parameterValues": {} + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7c36249b/samples/trainingplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/samples/trainingplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/samples/trainingplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..41764cc --- /dev/null +++ b/samples/trainingplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,34 @@ +<?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. + --> + +<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> + + <reference id="profileService" interface="org.apache.unomi.api.services.ProfileService"/> + + <!-- Action executor --> + <service id="trainingNotifAction" auto-export="interfaces"> + <service-properties> + <entry key="actionExecutorId" value="training"/> + </service-properties> + <bean class="org.apache.unomi.training.TrainedNotificationAction"> + <property name="profileService" ref="profileService"/> + </bean> + </service> +</blueprint>