Create an extension to add a visitor to Mailchimp's list.
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/31c3cdcd Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/31c3cdcd Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/31c3cdcd Branch: refs/heads/master Commit: 31c3cdcd96a25619b99764afe5e22a810d3dd101 Parents: 97deed6 Author: Dinesh <[email protected]> Authored: Thu Nov 9 10:28:10 2017 +0100 Committer: Dinesh <[email protected]> Committed: Fri Nov 17 15:06:16 2017 +0100 ---------------------------------------------------------------------- extensions/unomi-mailchimp | 1 - extensions/unomi-mailchimp/core/pom.xml | 50 ++++ .../actions/AddToListsMailchimpAction.java | 40 +++ .../cxs/actions/AddToListsMailchimpAction.json | 20 ++ .../resources/OSGI-INF/blueprint/blueprint.xml | 35 +++ extensions/unomi-mailchimp/karaf-kar/pom.xml | 82 +++++++ .../karaf-kar/src/main/feature/feature.xml | 29 +++ extensions/unomi-mailchimp/pom.xml | 39 +++ extensions/unomi-mailchimp/rest/pom.xml | 118 +++++++++ .../apache/unomi/mailchimp/rest/MCEndPoint.java | 58 +++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 65 +++++ extensions/unomi-mailchimp/services/pom.xml | 118 +++++++++ .../unomi/mailchimp/services/HttpUtils.java | 152 ++++++++++++ .../mailchimp/services/MailchimpService.java | 31 +++ .../services/internal/MailchimpServiceImpl.java | 245 +++++++++++++++++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 45 ++++ .../org.apache.unomi.mailchimpconnector.cfg | 19 ++ 17 files changed, 1146 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/core/pom.xml b/extensions/unomi-mailchimp/core/pom.xml new file mode 100644 index 0000000..2d7daa0 --- /dev/null +++ b/extensions/unomi-mailchimp/core/pom.xml @@ -0,0 +1,50 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + + <artifactId>unomi-mailchimp-connector-core</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: Core</name> + <description>A connector between Unomi and Mailchimp API</description> + <packaging>bundle</packaging> + + <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-mailchimp-connector-services</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + </dependencies> + + +</project> diff --git a/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java b/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java new file mode 100644 index 0000000..0f60942 --- /dev/null +++ b/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java @@ -0,0 +1,40 @@ +/* + * 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.mailchimp.actions; + +import org.apache.unomi.api.Event; +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.mailchimp.services.MailchimpService; + +public class AddToListsMailchimpAction implements ActionExecutor { + private MailchimpService mailchimpService; + + public void setMailchimpService(MailchimpService mailchimpService) { + this.mailchimpService = mailchimpService; + } + + @Override + public int execute(Action action, Event event) { + if (mailchimpService.executePostAddToMCList(event.getProfile(), action)) + return EventService.PROFILE_UPDATED; + else + return EventService.NO_CHANGE; + } +} diff --git a/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json b/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json new file mode 100644 index 0000000..3fc3a28 --- /dev/null +++ b/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json @@ -0,0 +1,20 @@ +{ + "metadata": { + "id": "addToListsMailchimpAction", + "name": "Add To user to Mailchimp Lists Action", + "description": "Add the user with his name and email to a Mailchimp list", + "systemTags": [ + "event", + "availableToEndUser" + ], + "readOnly": true + }, + "actionExecutor": "addToListsMailchimp", + "parameters": [ + { + "id": "listIdentifier", + "type": "string", + "multivalued": false + } + ] +} diff --git a/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..1020ce1 --- /dev/null +++ b/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,35 @@ +<?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="mailchimpService" + interface="org.apache.unomi.mailchimp.services.MailchimpService"/> + + <service auto-export="interfaces"> + <service-properties> + <entry key="actionExecutorId" value="addToListsMailchimp"/> + </service-properties> + + <bean class="org.apache.unomi.mailchimp.actions.AddToListsMailchimpAction"> + <property name="mailchimpService" ref="mailchimpService"/> + </bean> + </service> +</blueprint> diff --git a/extensions/unomi-mailchimp/karaf-kar/pom.xml b/extensions/unomi-mailchimp/karaf-kar/pom.xml new file mode 100644 index 0000000..bc3eafb --- /dev/null +++ b/extensions/unomi-mailchimp/karaf-kar/pom.xml @@ -0,0 +1,82 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-mailchimp-connector-karaf-kar</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: Apache Karaf Feature and KAR archive</name> + <description>This is a simple Apache Unomi plugin.</description> + <packaging>kar</packaging> + + + <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-mailchimp-connector-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector-core</artifactId> + <version>${project.version}</version> + </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>85</startLevel> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml b/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml new file mode 100644 index 0000000..aec4106 --- /dev/null +++ b/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + ~ 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. + --> +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="unomi-mailchimp-connector-karaf-feature"> + <feature name="unomi-mailchimp-connector-karaf-kar" version="${project.version}" + description="Apache Unomi :: Extensions :: Mailchimp Connector :: Apache Karaf Feature"> + <details>Connect external service by Mailchimp</details> + <configfile finalname="/etc/org.apache.unomi.mailchimpconnector.cfg">mvn:org.apache.unomi/unomi-mailchimp-connector-services/1.3.0-incubating-SNAPSHOT/cfg/mailchimpconnectorcfg</configfile> + <bundle start-level="90">mvn:org.apache.unomi/unomi-mailchimp-connector-services/${project.version}</bundle> + <bundle start-level="90">mvn:org.apache.unomi/unomi-mailchimp-connector-rest/${project.version}</bundle> + <bundle start-level="90">mvn:org.apache.unomi/unomi-mailchimp-connector-core/${project.version}</bundle> + </feature> +</features> + + diff --git a/extensions/unomi-mailchimp/pom.xml b/extensions/unomi-mailchimp/pom.xml new file mode 100644 index 0000000..0553f35 --- /dev/null +++ b/extensions/unomi-mailchimp/pom.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. + --> + +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + 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.unomi</groupId> + <artifactId>unomi-extensions</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + + <artifactId>unomi-mailchimp-connector</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector</name> + <description>Connector with the Mailchimp API service</description> + <packaging>pom</packaging> + + <modules> + <module>services</module> + <module>rest</module> + <module>core</module> + <module>karaf-kar</module> + </modules> +</project> diff --git a/extensions/unomi-mailchimp/rest/pom.xml b/extensions/unomi-mailchimp/rest/pom.xml new file mode 100644 index 0000000..631ce59 --- /dev/null +++ b/extensions/unomi-mailchimp/rest/pom.xml @@ -0,0 +1,118 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-mailchimp-connector-rest</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: REST API</name> + <description>REST API for the Apache Unomi Context Server extension that integrates with Mailchimp</description> + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-security-cors</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector-services</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <version>1.4</version> + <configuration> + <format>{0}-{1,date,short}-{1,time,short}</format> + <items> + <item>scmVersion</item> + <item>timestamp</item> + </items> + </configuration> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>create</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Implementation-Build>${buildNumber}</Implementation-Build> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java b/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java new file mode 100644 index 0000000..38114e9 --- /dev/null +++ b/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java @@ -0,0 +1,58 @@ +/* + * 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.mailchimp.rest; + +import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing; +import org.apache.unomi.mailchimp.services.MailchimpService; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.List; + + +@WebService +@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") +@CrossOriginResourceSharing( + allowAllOrigins = true, + allowCredentials = true +) +public class MCEndPoint { + + private MailchimpService mailchimpService; + + public MCEndPoint() { + System.out.println("Initializing MCEndPoint service endpoint..."); + } + + @WebMethod(exclude = true) + public void setMailChimpService(MailchimpService mailchimpService) { + this.mailchimpService = mailchimpService; + } + + @GET + @Path("/getMailchimpLists") + public List<HashMap<String, String>> executeListMailchimpList() { + return mailchimpService.executeGetAllLists(); + } + +} + diff --git a/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..cf5839c --- /dev/null +++ b/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.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. + --> + +<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + 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"> + <bean id="cors-filter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/> + <bean id="jacksonMapper" class="org.apache.unomi.persistence.spi.CustomObjectMapper"/> + <bean id="jaxb-provider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"> + <argument index="0" ref="jacksonMapper" type="com.fasterxml.jackson.databind.ObjectMapper "/> + <argument index="1" type="com.fasterxml.jackson.jaxrs.cfg.Annotations[]"> + <array> + <value>JACKSON</value> + <value>JAXB</value> + </array> + </argument> + </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"/> + <!-- Activate this if you want to force a redirect if auth is missing, by default it will trigger a 403 which + is usually preferred --> + <!--property name="redirectURI" value="/login.jsp"/--> + </bean> + + <jaxrs:server address="/mc" id="restMCService"> + <jaxrs:providers> + <ref component-id="jaxb-provider"/> + <ref component-id="cors-filter"/> + <ref component-id="jaas-filter"/> + </jaxrs:providers> + + <jaxrs:serviceBeans> + <ref component-id="mCEndPoint"/> + </jaxrs:serviceBeans> + </jaxrs:server> + + <reference id="mailChimpService" interface="org.apache.unomi.mailchimp.services.MailchimpService"/> + + <bean id="mCEndPoint" class="org.apache.unomi.mailchimp.rest.MCEndPoint"> + <property name="mailChimpService" ref="mailChimpService"/> + </bean> +</blueprint> diff --git a/extensions/unomi-mailchimp/services/pom.xml b/extensions/unomi-mailchimp/services/pom.xml new file mode 100644 index 0000000..fb125db --- /dev/null +++ b/extensions/unomi-mailchimp/services/pom.xml @@ -0,0 +1,118 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-mailchimp-connector-services</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: Services</name> + <description>Service implementation for the Apache Unomi Context Server extension that integrates with Mailchimp + </description> + + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>${project.version}</version> + <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> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20160810</version> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang --> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + </dependencies> + + <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> + * + </Import-Package> + </instructions> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file> + src/main/resources/org.apache.unomi.mailchimpconnector.cfg + </file> + <type>cfg</type> + <classifier>mailchimpconnectorcfg</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> + + + + + diff --git a/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/HttpUtils.java b/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/HttpUtils.java new file mode 100644 index 0000000..d85a35e --- /dev/null +++ b/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/HttpUtils.java @@ -0,0 +1,152 @@ +/* + * 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.mailchimp.services; + + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Map; + +/** + * Created by dsalhotra on 27/06/2017. + */ +public class HttpUtils { + + private static Logger logger = LoggerFactory.getLogger(HttpUtils.class); + + + public static JsonNode doPostHttp(CloseableHttpClient request, String url, Map<String, String> headers, + JSONObject body) { + + + + AbstractHttpEntity entity; + JsonNode jsonNode = null; + HttpPost httpPost = new HttpPost(url); + + try { + entity = new ByteArrayEntity(body.toString().getBytes("UTF8")); + + CloseableHttpResponse response = null; + + + entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); + + try { + httpPost.setEntity(entity); + try { + for (String key : headers.keySet()) { + httpPost.addHeader(key, headers.get(key)); + } + response = request.execute(httpPost); + HttpEntity entityResponse = response.getEntity(); + String responseString; + try { + responseString = EntityUtils.toString(entityResponse); + ObjectMapper objectMapper = new ObjectMapper(); + try { + jsonNode = objectMapper.readTree(responseString); + } catch (IOException e) { + logger.info(e.getMessage(), e); + } + } catch (IOException e) { + logger.info(e.getMessage(), e); + } + } catch (IOException e) { + logger.info(e.getMessage(), e); + } + + } finally { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + logger.info(e.getMessage(), e); + } + } + + } catch (UnsupportedEncodingException e) { + logger.info(e.getMessage(), e); + return null; + } + return jsonNode; + } + + + public static JsonNode doGetHttp(CloseableHttpClient request, String + url, Map<String, String> headers) { + HttpGet httpGet = new HttpGet(url); + + for (String key : headers.keySet()) { + httpGet.addHeader(key, headers.get(key)); + } + JsonNode jsonNode = null; + CloseableHttpResponse response = null; + try { + response = request.execute(httpGet); + if (response != null) { + HttpEntity entity = response.getEntity(); + String responseString; + if (entity != null) { + try { + responseString = EntityUtils.toString(entity); + ObjectMapper objectMapper = new ObjectMapper(); + jsonNode = objectMapper.readTree(responseString); + } catch (IOException e) { + logger.info("Error : With the API json response.", e.getMessage()); + } + } + } + } catch (IOException e) { + logger.info("Error : With the Http Request execution. Wrong parameters given", e + .getMessage()); + } finally { + if (response != null) { + EntityUtils.consumeQuietly(response.getEntity()); + } + } + return jsonNode; + } + + public static CloseableHttpClient initHttpClient() { + return HttpClients.createDefault(); + } + +} + + + + + diff --git a/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/MailchimpService.java b/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/MailchimpService.java new file mode 100644 index 0000000..5466578 --- /dev/null +++ b/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/MailchimpService.java @@ -0,0 +1,31 @@ +/* + * 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.mailchimp.services; + + +import org.apache.unomi.api.Profile; +import org.apache.unomi.api.actions.Action; + +import java.util.HashMap; +import java.util.List; + +public interface MailchimpService { + List<HashMap<String, String>> executeGetAllLists(); + boolean executePostAddToMCList(Profile profile, Action action); + +} diff --git a/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/internal/MailchimpServiceImpl.java b/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/internal/MailchimpServiceImpl.java new file mode 100644 index 0000000..e777277 --- /dev/null +++ b/extensions/unomi-mailchimp/services/src/main/java/org/apache/unomi/mailchimp/services/internal/MailchimpServiceImpl.java @@ -0,0 +1,245 @@ +/* + * 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.mailchimp.services.internal; + +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.unomi.api.Profile; +import org.apache.unomi.api.actions.Action; +import org.apache.unomi.mailchimp.services.HttpUtils; +import org.apache.unomi.mailchimp.services.MailchimpService; +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class MailchimpServiceImpl implements MailchimpService { + + private static Logger logger = LoggerFactory.getLogger(MailchimpServiceImpl.class); + private String headerAuthorizationPassword; + private String urlList; + private String url; + private CloseableHttpClient httpClient; + private HashMap<String, String> headers = new HashMap(); + private JsonNode response; + + + + + public void setHeaderAuthorizationPassword(String headerAuthorizationPassword) { + this.headerAuthorizationPassword = headerAuthorizationPassword; + } + + public void setUrlList(String urlList) { + this.urlList = urlList; + } + + + private boolean isConfigured(){ + if (headerAuthorizationPassword != null && urlList != null){ + return true; + } + else{ + return false; + } + } + /*** + *Initialization of the HttpClient + * @return httpClient + */ + private CloseableHttpClient initHttpUtils() { + + if (httpClient == null) { + httpClient = HttpUtils.initHttpClient(); + } + return httpClient; + } + + /*** + * Add the headers request into a HashMap + * @return headers + */ + + + private HashMap<String, String> addHeaders() { + headers.put("Accept", "application/json"); + headers.put("Authorization", "apikey " + headerAuthorizationPassword); + return headers; + } + + /*** + * Build the request Url + * @return String + */ + private String urlBuilder() { + return "https://us16.api.mailchimp.com/3.0/lists"; + } + + /** + * Build custom Url with parameter + * + * @param otherParameter + * @return String + */ + private String urlBuilder(String otherParameter) { + return urlBuilder() + "/" + otherParameter; + } + + + /*** + * Get All lists available on Mailchimp + * @return List of Mailchimp's list + */ + @Override + public List<HashMap<String, String>> executeGetAllLists() { + if (!isConfigured()){ + return null; + } + initHttpUtils(); + response = executeRequestDoGet(); + return extractInfoListsMc(response); + } + + /*** + * Execute Get type requests + * @return JsonNode the response + */ + private JsonNode executeRequestDoGet() { + url = urlBuilder(); + addHeaders(); + return HttpUtils.doGetHttp(httpClient, url, headers); + } + + /** + * @param rawResponse the response from the API + * @return Mailchimp's lists with the id and the name. + */ + private List<HashMap<String, String>> extractInfoListsMc(JsonNode rawResponse) { + List<HashMap<String, String>> mcLists = new ArrayList<>(); + if (rawResponse.has("lists")) { + + + for (JsonNode list : rawResponse.get("lists")) { + + if (list.has("id") && list.has("name")) { + HashMap<String, String> mcListInfo = new HashMap<>(); + mcListInfo.put("id", list.get("id").asText()); + mcListInfo.put("name", list.get("name").asText()); + + mcLists.add(mcListInfo); + } else { + + logger.info("API Response doesn't contains the info" + rawResponse.asText()); + } + } + } + + return mcLists; + } + + /** + * @param action, the selected list from the rule is stocked in the action + * @param profile the current user + */ + @Override + public boolean executePostAddToMCList(Profile profile, Action action) { + initHttpUtils(); + if (!isConfigured()){ + logger.info("Failed : No Update, APIKEY not configured"); + return false; + } + String listIdentifier = (String) action.getParameterValues().get("listIdentifier"); + response = executeRequestDoPost(profile, listIdentifier); + if (response != null) { + if (response.has("errors") && response.get("errors").elements().hasNext() && response.get("errors") + .elements().next().has("error")) { + + logger.info("Error :" + response.get("errors") + .elements().next().get("error")); + return false; + } else { + + logger.info("Success User has been inserted"); + return true; + } + } else { + logger.info("Failed : No Update"); + return false; + + } + } + + /*** + * Execute Post type requests + * @param profile profile info, first name, last name and mail + * @param urlList list of Mailchimp + * @return raw response form the API, in JsonNode + */ + + private JsonNode executeRequestDoPost(Profile profile, String urlList) { + url = urlBuilder(urlList); + JSONObject body = CreateBodyPostAddMCList(profile); + + // body is null if the visitor has no email or fist name or last name + if (body != null) + return HttpUtils.doPostHttp(httpClient, url, headers, body); + return null; + } + + /** + * Create the body which will be sent + * + * @param profile the current user + * @return The body to send to the request + */ + private JSONObject CreateBodyPostAddMCList(Profile profile) { + + if (profile.getProperty("firstName") == null || profile.getProperty("lastName") == null || profile + .getProperty("email") == null) { + logger.info("Error to get Profile's info"); + return null; + } + + String firstName = profile.getProperty("firstName").toString(); + String lastName = profile.getProperty("lastName").toString(); + String email = profile.getProperty("email").toString(); + addHeaders(); + + JSONObject nameStruct = new JSONObject(); + JSONObject userData = new JSONObject(); + JSONArray dataMember = new JSONArray(); + JSONObject dataMembers = new JSONObject(); + + nameStruct.put("FNAME", firstName); + nameStruct.put("LNAME", lastName); + userData.put("merge_fields", nameStruct); + userData.put("email_type", "html"); + userData.put("email_address", email); + userData.put("status", "subscribed"); + dataMember.put(userData); + dataMembers.put("members", dataMember); + + return dataMembers; + } + + +} diff --git a/extensions/unomi-mailchimp/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/unomi-mailchimp/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..2a447fc --- /dev/null +++ b/extensions/unomi-mailchimp/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,45 @@ +<?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="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"> + + <cm:property-placeholder persistent-id="org.apache.unomi.mailchimpconnector" update-strategy="reload"> + <cm:default-properties> + + <cm:property name="mailchimpConnector.headers.authorization.password" value=""/> + <cm:property name="mailchimpConnector.url.list" value=""/> + </cm:default-properties> + </cm:property-placeholder> + + + <bean id="mailchimpServiceImpl" class="org.apache.unomi.mailchimp.services.internal.MailchimpServiceImpl"> + <property name="headerAuthorizationPassword" value="${mailchimpConnector.headers.authorization.password}"/> + <property name="urlList" value="${mailchimpConnector.url.list}"/> + + </bean> + + <service id="mailchimpService" ref="mailchimpServiceImpl" auto-export="interfaces"/> +</blueprint> + + + + diff --git a/extensions/unomi-mailchimp/services/src/main/resources/org.apache.unomi.mailchimpconnector.cfg b/extensions/unomi-mailchimp/services/src/main/resources/org.apache.unomi.mailchimpconnector.cfg new file mode 100644 index 0000000..6299855 --- /dev/null +++ b/extensions/unomi-mailchimp/services/src/main/resources/org.apache.unomi.mailchimpconnector.cfg @@ -0,0 +1,19 @@ +# +# 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. +# +mailchimpConnector.headers.accept=application/json +mailchimpConnector.headers.authorization.password= +mailchimpConnector.url.list= http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/core/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/core/pom.xml b/extensions/unomi-mailchimp/core/pom.xml new file mode 100644 index 0000000..2d7daa0 --- /dev/null +++ b/extensions/unomi-mailchimp/core/pom.xml @@ -0,0 +1,50 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + + <artifactId>unomi-mailchimp-connector-core</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: Core</name> + <description>A connector between Unomi and Mailchimp API</description> + <packaging>bundle</packaging> + + <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-mailchimp-connector-services</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + </dependencies> + + +</project> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java b/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java new file mode 100644 index 0000000..0f60942 --- /dev/null +++ b/extensions/unomi-mailchimp/core/src/main/java/org/apache/unomi/mailchimp/actions/AddToListsMailchimpAction.java @@ -0,0 +1,40 @@ +/* + * 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.mailchimp.actions; + +import org.apache.unomi.api.Event; +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.mailchimp.services.MailchimpService; + +public class AddToListsMailchimpAction implements ActionExecutor { + private MailchimpService mailchimpService; + + public void setMailchimpService(MailchimpService mailchimpService) { + this.mailchimpService = mailchimpService; + } + + @Override + public int execute(Action action, Event event) { + if (mailchimpService.executePostAddToMCList(event.getProfile(), action)) + return EventService.PROFILE_UPDATED; + else + return EventService.NO_CHANGE; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json b/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json new file mode 100644 index 0000000..3fc3a28 --- /dev/null +++ b/extensions/unomi-mailchimp/core/src/main/resources/META-INF/cxs/actions/AddToListsMailchimpAction.json @@ -0,0 +1,20 @@ +{ + "metadata": { + "id": "addToListsMailchimpAction", + "name": "Add To user to Mailchimp Lists Action", + "description": "Add the user with his name and email to a Mailchimp list", + "systemTags": [ + "event", + "availableToEndUser" + ], + "readOnly": true + }, + "actionExecutor": "addToListsMailchimp", + "parameters": [ + { + "id": "listIdentifier", + "type": "string", + "multivalued": false + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..1020ce1 --- /dev/null +++ b/extensions/unomi-mailchimp/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,35 @@ +<?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="mailchimpService" + interface="org.apache.unomi.mailchimp.services.MailchimpService"/> + + <service auto-export="interfaces"> + <service-properties> + <entry key="actionExecutorId" value="addToListsMailchimp"/> + </service-properties> + + <bean class="org.apache.unomi.mailchimp.actions.AddToListsMailchimpAction"> + <property name="mailchimpService" ref="mailchimpService"/> + </bean> + </service> +</blueprint> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/karaf-kar/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/karaf-kar/pom.xml b/extensions/unomi-mailchimp/karaf-kar/pom.xml new file mode 100644 index 0000000..bc3eafb --- /dev/null +++ b/extensions/unomi-mailchimp/karaf-kar/pom.xml @@ -0,0 +1,82 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-mailchimp-connector-karaf-kar</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: Apache Karaf Feature and KAR archive</name> + <description>This is a simple Apache Unomi plugin.</description> + <packaging>kar</packaging> + + + <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-mailchimp-connector-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector-core</artifactId> + <version>${project.version}</version> + </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>85</startLevel> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml b/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml new file mode 100644 index 0000000..aec4106 --- /dev/null +++ b/extensions/unomi-mailchimp/karaf-kar/src/main/feature/feature.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + ~ 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. + --> +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="unomi-mailchimp-connector-karaf-feature"> + <feature name="unomi-mailchimp-connector-karaf-kar" version="${project.version}" + description="Apache Unomi :: Extensions :: Mailchimp Connector :: Apache Karaf Feature"> + <details>Connect external service by Mailchimp</details> + <configfile finalname="/etc/org.apache.unomi.mailchimpconnector.cfg">mvn:org.apache.unomi/unomi-mailchimp-connector-services/1.3.0-incubating-SNAPSHOT/cfg/mailchimpconnectorcfg</configfile> + <bundle start-level="90">mvn:org.apache.unomi/unomi-mailchimp-connector-services/${project.version}</bundle> + <bundle start-level="90">mvn:org.apache.unomi/unomi-mailchimp-connector-rest/${project.version}</bundle> + <bundle start-level="90">mvn:org.apache.unomi/unomi-mailchimp-connector-core/${project.version}</bundle> + </feature> +</features> + + http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/pom.xml b/extensions/unomi-mailchimp/pom.xml new file mode 100644 index 0000000..0553f35 --- /dev/null +++ b/extensions/unomi-mailchimp/pom.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. + --> + +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + 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.unomi</groupId> + <artifactId>unomi-extensions</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + + <artifactId>unomi-mailchimp-connector</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector</name> + <description>Connector with the Mailchimp API service</description> + <packaging>pom</packaging> + + <modules> + <module>services</module> + <module>rest</module> + <module>core</module> + <module>karaf-kar</module> + </modules> +</project> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/rest/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/rest/pom.xml b/extensions/unomi-mailchimp/rest/pom.xml new file mode 100644 index 0000000..631ce59 --- /dev/null +++ b/extensions/unomi-mailchimp/rest/pom.xml @@ -0,0 +1,118 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-mailchimp-connector-rest</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: REST API</name> + <description>REST API for the Apache Unomi Context Server extension that integrates with Mailchimp</description> + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-security-cors</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector-services</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <version>1.4</version> + <configuration> + <format>{0}-{1,date,short}-{1,time,short}</format> + <items> + <item>scmVersion</item> + <item>timestamp</item> + </items> + </configuration> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>create</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Implementation-Build>${buildNumber}</Implementation-Build> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java b/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java new file mode 100644 index 0000000..38114e9 --- /dev/null +++ b/extensions/unomi-mailchimp/rest/src/main/java/org/apache/unomi/mailchimp/rest/MCEndPoint.java @@ -0,0 +1,58 @@ +/* + * 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.mailchimp.rest; + +import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing; +import org.apache.unomi.mailchimp.services.MailchimpService; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.List; + + +@WebService +@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") +@CrossOriginResourceSharing( + allowAllOrigins = true, + allowCredentials = true +) +public class MCEndPoint { + + private MailchimpService mailchimpService; + + public MCEndPoint() { + System.out.println("Initializing MCEndPoint service endpoint..."); + } + + @WebMethod(exclude = true) + public void setMailChimpService(MailchimpService mailchimpService) { + this.mailchimpService = mailchimpService; + } + + @GET + @Path("/getMailchimpLists") + public List<HashMap<String, String>> executeListMailchimpList() { + return mailchimpService.executeGetAllLists(); + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..cf5839c --- /dev/null +++ b/extensions/unomi-mailchimp/rest/src/main/resources/OSGI-INF/blueprint/blueprint.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. + --> + +<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + 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"> + <bean id="cors-filter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/> + <bean id="jacksonMapper" class="org.apache.unomi.persistence.spi.CustomObjectMapper"/> + <bean id="jaxb-provider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"> + <argument index="0" ref="jacksonMapper" type="com.fasterxml.jackson.databind.ObjectMapper "/> + <argument index="1" type="com.fasterxml.jackson.jaxrs.cfg.Annotations[]"> + <array> + <value>JACKSON</value> + <value>JAXB</value> + </array> + </argument> + </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"/> + <!-- Activate this if you want to force a redirect if auth is missing, by default it will trigger a 403 which + is usually preferred --> + <!--property name="redirectURI" value="/login.jsp"/--> + </bean> + + <jaxrs:server address="/mc" id="restMCService"> + <jaxrs:providers> + <ref component-id="jaxb-provider"/> + <ref component-id="cors-filter"/> + <ref component-id="jaas-filter"/> + </jaxrs:providers> + + <jaxrs:serviceBeans> + <ref component-id="mCEndPoint"/> + </jaxrs:serviceBeans> + </jaxrs:server> + + <reference id="mailChimpService" interface="org.apache.unomi.mailchimp.services.MailchimpService"/> + + <bean id="mCEndPoint" class="org.apache.unomi.mailchimp.rest.MCEndPoint"> + <property name="mailChimpService" ref="mailChimpService"/> + </bean> +</blueprint> http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/31c3cdcd/extensions/unomi-mailchimp/services/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/unomi-mailchimp b/extensions/unomi-mailchimp deleted file mode 160000 index a4f82e2..0000000 --- a/extensions/unomi-mailchimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f82e27c034207e53e920769af096dee67a3be7 diff --git a/extensions/unomi-mailchimp/services/pom.xml b/extensions/unomi-mailchimp/services/pom.xml new file mode 100644 index 0000000..fb125db --- /dev/null +++ b/extensions/unomi-mailchimp/services/pom.xml @@ -0,0 +1,118 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-mailchimp-connector</artifactId> + <version>1.3.0-incubating-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>unomi-mailchimp-connector-services</artifactId> + <name>Apache Unomi :: Extensions :: Mailchimp Beta Connector :: Services</name> + <description>Service implementation for the Apache Unomi Context Server extension that integrates with Mailchimp + </description> + + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.unomi</groupId> + <artifactId>unomi-api</artifactId> + <version>${project.version}</version> + <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> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20160810</version> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang --> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + </dependencies> + + <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> + * + </Import-Package> + </instructions> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file> + src/main/resources/org.apache.unomi.mailchimpconnector.cfg + </file> + <type>cfg</type> + <classifier>mailchimpconnectorcfg</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> + + + + +
