You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2017/07/19 12:29:03 UTC
[2/2] incubator-unomi git commit: UNOMI-116 Salesforce CRM Connector
- Initial commit
UNOMI-116 Salesforce CRM Connector
- Initial commit
Signed-off-by: Serge Huber <sh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/a897ab84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/a897ab84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/a897ab84
Branch: refs/heads/master
Commit: a897ab8437966975a45082cb042c500540c8c0f8
Parents: 139e1b7
Author: Serge Huber <sh...@apache.org>
Authored: Wed Jul 19 14:28:54 2017 +0200
Committer: Serge Huber <sh...@apache.org>
Committed: Wed Jul 19 14:28:54 2017 +0200
----------------------------------------------------------------------
.gitignore | 1 +
extensions/pom.xml | 1 +
extensions/salesforce-connector/README.md | 148 ++++
extensions/salesforce-connector/actions/pom.xml | 49 ++
.../sfdc/actions/CreateOrUpdateLeadAction.java | 42 +
.../actions/UpdateProfileFromLeadAction.java | 43 +
.../cxs/actions/sfdcCreateOrUpdateLead.json | 15 +
.../cxs/actions/sfdcUpdateProfileFromLead.json | 15 +
.../resources/OSGI-INF/blueprint/blueprint.xml | 44 +
.../salesforce-connector/compileWithTests.sh | 20 +
.../salesforce-connector/karaf-kar/pom.xml | 93 +++
.../karaf-kar/src/main/feature/feature.xml | 28 +
extensions/salesforce-connector/pom.xml | 39 +
extensions/salesforce-connector/rest/pom.xml | 132 +++
.../apache/unomi/sfdc/rest/SFDCEndPoint.java | 81 ++
.../resources/OSGI-INF/blueprint/blueprint.xml | 67 ++
.../salesforce-connector/services/pom.xml | 164 ++++
.../unomi/sfdc/services/FieldMapping.java | 35 +
.../apache/unomi/sfdc/services/MappedField.java | 30 +
.../unomi/sfdc/services/SFDCConfiguration.java | 178 ++++
.../apache/unomi/sfdc/services/SFDCService.java | 81 ++
.../apache/unomi/sfdc/services/SFDCSession.java | 71 ++
.../sfdc/services/internal/SFDCServiceImpl.java | 815 +++++++++++++++++++
.../resources/OSGI-INF/blueprint/blueprint.xml | 65 ++
.../main/resources/org.apache.unomi.sfdc.cfg | 26 +
.../services/internal/SFDCServiceImplTest.java | 211 +++++
26 files changed, 2494 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index bf90830..c3e5009 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ maven-metadata-local.xml
GeoLite2-City.mmdb
allCountries.zip
rest/.miredot-offline.json
+/extensions/salesforce-connector/test.properties
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/pom.xml b/extensions/pom.xml
index dea4bc2..07608b3 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -35,6 +35,7 @@
<module>privacy-extension</module>
<module>geonames</module>
<module>router</module>
+ <module>salesforce-connector</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/README.md
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/README.md b/extensions/salesforce-connector/README.md
new file mode 100644
index 0000000..4bd7451
--- /dev/null
+++ b/extensions/salesforce-connector/README.md
@@ -0,0 +1,148 @@
+<!--
+ ~ 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.
+ -->
+
+Unomi Salesforce Connector
+==========================
+
+## Getting started
+
+1. Create a new developer account here:
+
+ https://developer.salesforce.com/signup
+
+2. Create a new Connected App, by going into Setup -> App Manager and click "Create Connected App"
+
+3. In the settings, make sure you do the following:
+
+ Enable OAuth settings -> Activated
+ Enable for device flow -> Activated (no need for a callback URL)
+ Add all the selected OAuth scopes you want (or put all of them)
+ Make sure Require Secret for Web Server flow is activated
+
+4. Make sure you retrieve the following information once you have created the app in the API (Enable OAuth Settings):
+
+ Consumer key
+ Consumer secret (click to see it)
+
+5. You must also retrieve your user's security token, or create it if you don't have one already. To do this simply
+click on your user at the top right, select "Settings", the click on "Reset my security token". You will receive an email
+with the security token.
+
+6. You are now ready to configure the Apache Unomi Salesforce Connector. In the etc/org.apache.unomi.sfdc.cfg file
+change the following settings:
+
+ sfdc.user.username=YOUR_USER_NAME
+ sfdc.user.password=YOUR_PASSWORD
+ sfdc.user.securityToken=YOUR_USER_SECURITY_TOKEN
+ sfdc.consumer.key=CONNECTED_APP_CONSUMER_KEY
+ sfdc.consumer.secret=CONNECTED_APP_SECRET
+
+7. Connected to the Apache Unomi Karaf Shell using :
+
+ ssh -p 8102 karaf@localhost (default password is karaf)
+
+7. Deploy into Apache Unomi using the following commands from the Apache Karaf shell:
+
+ feature:repo-add mvn:org.apache.unomi/unomi-salesforce-connector-karaf-kar/1.2.0-incubating-SNAPSHOT/xml/features
+ feature:install unomi-salesforce-connector-karaf-kar
+
+8. You can then test the connection to Salesforce by accessing the following URLs:
+
+ https://localhost:9443/cxs/sfdc/version
+ https://localhost:9443/cxs/sfdc/limits
+
+ The first URL will give you information about the version of the connector, so this makes it easy to check that the
+ plugin is properly deployed, started and the correct version. The second URL will actually make a request to the
+ Salesforce REST API to retrieve the limits of the Salesforce API.
+
+ Both URLs are password protected by the Apache Unomi (Karaf) password. You can find this user and password information
+ in the etc/users.properties file.
+
+## Upgrading the Salesforce connector
+
+If you followed all the steps in the Getting Started section, you can upgrade the Salesforce connector by using the following steps:
+
+1. Compile the connector using:
+
+ mvn clean install
+
+2. Login to the Unomi Karaf Shell using:
+
+ ssh -p 8102 karaf@localhost (password by default is karaf)
+
+3. Execute the following commands in the Karaf shell
+
+ feature:repo-refresh
+ feature:uninstall unomi-salesforce-connector-karaf-feature
+ feature:install unomi-salesforce-connector-karaf-feature
+
+4. You can then check that the new version is properly deployed by accessing the following URL and checking the build date:
+
+ https://localhost:9443/cxs/sfdc/version
+
+ (if asked for a password it's the same karaf/karaf default)
+
+## Using the Salesforce Workbench for testing REST API
+
+The Salesforce Workbench contains a REST API Explorer that is very useful to test requests. You may find it here :
+
+ https://workbench.developerforce.com/restExplorer.php
+
+## Setting up Streaming Push queries
+
+Using the Salesforce Workbench, you can setting streaming push queries (Queries->Streaming push topics) such as the
+following example:
+
+ Name: LeadUpdates
+ Query : SELECT Id,FirstName,LastName,Email,Company FROM Lead
+
+## Executing the unit tests
+
+Before running the tests, make sure you have completed all the steps above, including the streaming push queries setup.
+
+By default the unit tests will not run as they need proper Salesforce credentials to run. To set this up create a
+properties file like the following one:
+
+test.properties
+
+ #
+ # 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.
+ #
+ sfdc.user.username=YOUR_USER_NAME
+ sfdc.user.password=YOUR_PASSWORD
+ sfdc.user.securityToken=YOUR_USER_SECURITY_TOKEN
+ sfdc.consumer.key=CONNECTED_APP_CONSUMER_KEY
+ sfdc.consumer.secret=CONNECTED_APP_SECRET
+
+and then use the following command line to reference the file:
+
+ mvn clean install -DsfdcProperties=../test.properties
+
+(in case you're wondering the ../ is because the test is located in the services sub-directory)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/actions/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/actions/pom.xml b/extensions/salesforce-connector/actions/pom.xml
new file mode 100644
index 0000000..f0b47b9
--- /dev/null
+++ b/extensions/salesforce-connector/actions/pom.xml
@@ -0,0 +1,49 @@
+<?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>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>unomi-salesforce-connector-actions</artifactId>
+ <name>Apache Unomi :: Extensions :: Salesforce connector :: Rule Actions</name>
+ <description>Rule Actions for the Apache Unomi Context Server extension that integrates with Salesforce</description>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-api</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector-services</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/CreateOrUpdateLeadAction.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/CreateOrUpdateLeadAction.java b/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/CreateOrUpdateLeadAction.java
new file mode 100644
index 0000000..e46ec29
--- /dev/null
+++ b/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/CreateOrUpdateLeadAction.java
@@ -0,0 +1,42 @@
+/*
+ * 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.sfdc.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.sfdc.services.SFDCService;
+
+/**
+ * Creates or updates a Salesforce lead from the corresponding Apache Unomi profile (using a common identifier field,
+ * usually the email address)
+ */
+public class CreateOrUpdateLeadAction implements ActionExecutor {
+
+ private SFDCService sfdcService;
+
+ public void setSfdcService(SFDCService sfdcService) {
+ this.sfdcService = sfdcService;
+ }
+
+ @Override
+ public int execute(Action action, Event event) {
+ sfdcService.createOrUpdateLead(event.getProfile());
+ return EventService.NO_CHANGE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/UpdateProfileFromLeadAction.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/UpdateProfileFromLeadAction.java b/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/UpdateProfileFromLeadAction.java
new file mode 100644
index 0000000..bbbd5c1
--- /dev/null
+++ b/extensions/salesforce-connector/actions/src/main/java/org/apache/unomi/sfdc/actions/UpdateProfileFromLeadAction.java
@@ -0,0 +1,43 @@
+/*
+ * 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.sfdc.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.sfdc.services.SFDCService;
+
+/**
+ * Update an Apache Unomi profile from a corresponding Salesforce Lead with the same common identifier (usually the
+ * email address)
+ */
+public class UpdateProfileFromLeadAction implements ActionExecutor {
+
+ private SFDCService sfdcService;
+
+ public void setSfdcService(SFDCService sfdcService) {
+ this.sfdcService = sfdcService;
+ }
+
+ @Override
+ public int execute(Action action, Event event) {
+ boolean profileUpdated = sfdcService.updateProfileFromLead(event.getProfile());
+ if (profileUpdated) return EventService.PROFILE_UPDATED;
+ return EventService.NO_CHANGE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcCreateOrUpdateLead.json
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcCreateOrUpdateLead.json b/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcCreateOrUpdateLead.json
new file mode 100644
index 0000000..55c7da3
--- /dev/null
+++ b/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcCreateOrUpdateLead.json
@@ -0,0 +1,15 @@
+{
+ "metadata": {
+ "id": "sfdcCreateOrUpdateLeadAction",
+ "name": "sfdcCreateOrUpdateLeadAction",
+ "description": "",
+ "tags": [
+ "demographic",
+ "hidden.availableToEndUser"
+ ],
+ "readOnly": true
+ },
+ "actionExecutor": "sfdcCreateOrUpdateLead",
+ "parameters": [
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcUpdateProfileFromLead.json
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcUpdateProfileFromLead.json b/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcUpdateProfileFromLead.json
new file mode 100644
index 0000000..598edb7
--- /dev/null
+++ b/extensions/salesforce-connector/actions/src/main/resources/META-INF/cxs/actions/sfdcUpdateProfileFromLead.json
@@ -0,0 +1,15 @@
+{
+ "metadata": {
+ "id": "sfdcUpdateProfileFromLeadAction",
+ "name": "sfdcUpdateProfileFromLeadAction",
+ "description": "",
+ "tags": [
+ "demographic",
+ "hidden.availableToEndUser"
+ ],
+ "readOnly": true
+ },
+ "actionExecutor": "sfdcUpdateProfileFromLead",
+ "parameters": [
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/actions/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/actions/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/salesforce-connector/actions/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 0000000..24b61ff
--- /dev/null
+++ b/extensions/salesforce-connector/actions/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,44 @@
+<?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="sfdcService"
+ interface="org.apache.unomi.sfdc.services.SFDCService"/>
+
+ <service auto-export="interfaces">
+ <service-properties>
+ <entry key="actionExecutorId" value="sfdcCreateOrUpdateLead"/>
+ </service-properties>
+ <bean class="org.apache.unomi.sfdc.actions.CreateOrUpdateLeadAction">
+ <property name="sfdcService" ref="sfdcService"/>
+ </bean>
+ </service>
+
+ <service auto-export="interfaces">
+ <service-properties>
+ <entry key="actionExecutorId" value="sfdcUpdateProfileFromLead"/>
+ </service-properties>
+ <bean class="org.apache.unomi.sfdc.actions.UpdateProfileFromLeadAction">
+ <property name="sfdcService" ref="sfdcService"/>
+ </bean>
+ </service>
+
+</blueprint>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/compileWithTests.sh
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/compileWithTests.sh b/extensions/salesforce-connector/compileWithTests.sh
new file mode 100755
index 0000000..5295f7a
--- /dev/null
+++ b/extensions/salesforce-connector/compileWithTests.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+################################################################################
+#
+# 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.
+#
+################################################################################
+mvn clean install -DsfdcProperties=../test.properties
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/karaf-kar/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/karaf-kar/pom.xml b/extensions/salesforce-connector/karaf-kar/pom.xml
new file mode 100644
index 0000000..577f4bf
--- /dev/null
+++ b/extensions/salesforce-connector/karaf-kar/pom.xml
@@ -0,0 +1,93 @@
+<?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>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>unomi-salesforce-connector-karaf-kar</artifactId>
+ <name>Apache Unomi :: Extensions :: Salesforce connector :: Apache Karaf Feature and KAR archive</name>
+ <description>Apache Karaf Feature and KAR archive for the Apache Unomi Context Server extension that integrates with Salesforce</description>
+ <packaging>kar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-api</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-osgi</artifactId>
+ <version>4.4.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient-osgi</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector-services</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector-rest</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector-actions</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</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>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/karaf-kar/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/karaf-kar/src/main/feature/feature.xml b/extensions/salesforce-connector/karaf-kar/src/main/feature/feature.xml
new file mode 100644
index 0000000..252f34e
--- /dev/null
+++ b/extensions/salesforce-connector/karaf-kar/src/main/feature/feature.xml
@@ -0,0 +1,28 @@
+<?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-salesforce-connector-karaf-feature">
+ <feature name="unomi-salesforce-connector-karaf-kar" version="1.0-SNAPSHOT" description="Apache Unomi :: Extensions :: Salesforce connector :: Apache Karaf Feature">
+ <details>Apache Karaf feature for the Apache Unomi Context Server extension that integrates with Salesforce</details>
+ <configfile finalname="/etc/org.apache.unomi.sfdc.cfg">mvn:org.apache.unomi/unomi-salesforce-connector-services/1.0-SNAPSHOT/cfg/sfdccfg</configfile>
+ <bundle start-level="85">mvn:org.apache.httpcomponents/httpcore-osgi/4.4.6</bundle>
+ <bundle start-level="85">mvn:org.apache.httpcomponents/httpclient-osgi/4.5.1</bundle>
+ <bundle start-level="85">mvn:org.apache.unomi/unomi-salesforce-connector-services/1.0-SNAPSHOT</bundle>
+ <bundle start-level="85">mvn:org.apache.unomi/unomi-salesforce-connector-rest/1.0-SNAPSHOT</bundle>
+ <bundle start-level="85">mvn:org.apache.unomi/unomi-salesforce-connector-actions/1.0-SNAPSHOT</bundle>
+ </feature>
+</features>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/pom.xml b/extensions/salesforce-connector/pom.xml
new file mode 100644
index 0000000..da00cf9
--- /dev/null
+++ b/extensions/salesforce-connector/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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-extensions</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>unomi-salesforce-connector</artifactId>
+ <name>Apache Unomi :: Extensions :: Salesforce connector</name>
+ <description>Apache Unomi Context Server extension that integrates with Salesforce</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>services</module>
+ <module>rest</module>
+ <module>actions</module>
+ <module>karaf-kar</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/rest/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/rest/pom.xml b/extensions/salesforce-connector/rest/pom.xml
new file mode 100644
index 0000000..2420cc5
--- /dev/null
+++ b/extensions/salesforce-connector/rest/pom.xml
@@ -0,0 +1,132 @@
+<?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>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>unomi-salesforce-connector-rest</artifactId>
+ <name>Apache Unomi :: Extensions :: Salesforce connector :: REST API</name>
+ <description>REST API for the Apache Unomi Context Server extension that integrates with Salesforce</description>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-api</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector-services</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</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-core</artifactId>
+ <version>${cxf.version}</version>
+ <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.apache.unomi</groupId>
+ <artifactId>unomi-persistence-spi</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <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>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/rest/src/main/java/org/apache/unomi/sfdc/rest/SFDCEndPoint.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/rest/src/main/java/org/apache/unomi/sfdc/rest/SFDCEndPoint.java b/extensions/salesforce-connector/rest/src/main/java/org/apache/unomi/sfdc/rest/SFDCEndPoint.java
new file mode 100644
index 0000000..c7a5c3f
--- /dev/null
+++ b/extensions/salesforce-connector/rest/src/main/java/org/apache/unomi/sfdc/rest/SFDCEndPoint.java
@@ -0,0 +1,81 @@
+/*
+ * 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.sfdc.rest;
+
+import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
+import org.apache.unomi.sfdc.services.SFDCService;
+import org.osgi.framework.BundleContext;
+
+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.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+@WebService
+@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
+@CrossOriginResourceSharing(
+ allowAllOrigins = true,
+ allowCredentials = true
+)
+public class SFDCEndPoint {
+
+ private SFDCService sfdcService;
+ private BundleContext bundleContext;
+
+ public SFDCEndPoint() {
+ System.out.println("Initializing SFDC service endpoint...");
+ }
+
+ @WebMethod(exclude = true)
+ public void setSFDCService(SFDCService sfdcService) {
+ this.sfdcService = sfdcService;
+ }
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ @GET
+ @Path("/version")
+ public Map<String,String> getVersion() {
+ Map<String,String> versionInfo = new HashMap<>();
+ Dictionary<String,String> bundleHeaders = bundleContext.getBundle().getHeaders();
+ Enumeration<String> bundleHeaderKeyEnum = bundleHeaders.keys();
+ while (bundleHeaderKeyEnum.hasMoreElements()) {
+ String bundleHeaderKey = bundleHeaderKeyEnum.nextElement();
+ versionInfo.put(bundleHeaderKey, bundleHeaders.get((bundleHeaderKey)));
+ }
+ return versionInfo;
+ }
+
+ @GET
+ @Path("/limits")
+ public Map<String,Object> getLimits() {
+ return sfdcService.getLimits();
+ }
+
+ public void setSfdcService(SFDCService sfdcService) {
+ this.sfdcService = sfdcService;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/salesforce-connector/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 0000000..30c8a81
--- /dev/null
+++ b/extensions/salesforce-connector/rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,67 @@
+<?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="/sfdc" id="restSFDCService">
+ <jaxrs:providers>
+ <ref component-id="jaxb-provider"/>
+ <ref component-id="cors-filter"/>
+ <ref component-id="jaas-filter"/>
+ </jaxrs:providers>
+
+ <jaxrs:serviceBeans>
+ <ref component-id="sfdcServiceEndPoint"/>
+ </jaxrs:serviceBeans>
+ </jaxrs:server>
+
+ <reference id="sfdcService" interface="org.apache.unomi.sfdc.services.SFDCService"/>
+
+ <bean id="sfdcServiceEndPoint" class="org.apache.unomi.sfdc.rest.SFDCEndPoint">
+ <property name="sfdcService" ref="sfdcService"/>
+ <property name="bundleContext" ref="blueprintBundleContext" />
+ </bean>
+</blueprint>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/services/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/services/pom.xml b/extensions/salesforce-connector/services/pom.xml
new file mode 100644
index 0000000..6508f58
--- /dev/null
+++ b/extensions/salesforce-connector/services/pom.xml
@@ -0,0 +1,164 @@
+<?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>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-salesforce-connector</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>unomi-salesforce-connector-services</artifactId>
+ <name>Apache Unomi :: Extensions :: Salesforce connector :: Service</name>
+ <description>Service implementation for the Apache Unomi Context Server extension that integrates with Salesforce</description>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-api</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-persistence-spi</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-security-cors</artifactId>
+ <version>${cxf.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient-osgi</artifactId>
+ <version>4.5.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-client</artifactId>
+ <version>7.4.4.v20110707</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</artifactId>
+ <version>7.4.4.v20110707</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
+ <version>7.4.4.v20110707</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>7.4.4.v20110707</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>bayeux-api</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-common</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-client</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Unit tests -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.6.6</version>
+ <scope>test</scope>
+ </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>
+ sun.misc;resolution:=optional,
+ net.sf.ehcache;resolution:=optional,
+ net.spy.memcached;resolution:=optional,
+ org.ietf.jgss;resolution:=optional,
+ *
+ </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.sfdc.cfg
+ </file>
+ <type>cfg</type>
+ <classifier>sfdccfg</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/FieldMapping.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/FieldMapping.java b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/FieldMapping.java
new file mode 100644
index 0000000..68420ae
--- /dev/null
+++ b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/FieldMapping.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sfdc.services;
+
+/**
+ * A mapping between two fields
+ */
+public class FieldMapping {
+
+ public enum MappingDirection {
+ LEFT_TO_RIGHT,
+ RIGHT_TO_LEFT,
+ BIDIRECTIONAL
+ }
+
+ private MappedField leftField;
+ private MappedField rightField;
+ private String fieldConverterIdentifier;
+ private MappingDirection mappingDirection;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/MappedField.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/MappedField.java b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/MappedField.java
new file mode 100644
index 0000000..872487d
--- /dev/null
+++ b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/MappedField.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sfdc.services;
+
+/**
+ * A field used in a field mapping
+ */
+public class MappedField {
+
+ private String name;
+ private String type;
+ private boolean readOnly;
+ private String source;
+ private boolean identifier;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCConfiguration.java b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCConfiguration.java
new file mode 100644
index 0000000..fc84579
--- /dev/null
+++ b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCConfiguration.java
@@ -0,0 +1,178 @@
+/*
+ * 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.sfdc.services;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.unomi.api.Item;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * An persistence item that contains the configuration to the Salesforce service.
+ */
+public class SFDCConfiguration extends Item {
+
+ /**
+ * The ImportConfiguration ITEM_TYPE
+ *
+ * @see Item for a discussion of ITEM_TYPE
+ */
+ public static final String ITEM_TYPE = "sfdcConfiguration";
+
+ private String sfdcLoginEndpoint;
+ private String sfdcUserUsername;
+ private String sfdcUserPassword;
+ private String sfdcUserSecurityToken;
+ private String sfdcConsumerKey;
+ private String sfdcConsumerSecret;
+ private String sfdcChannel;
+ private String sfdcFieldMappings;
+ private String sfdcFieldMappingsIdentifier;
+ private long sfdcSessionTimeout = 15 * 60 * 1000L; // 15 minutes by default
+
+ private Map<String, String> unomiToSfdcFieldMappings = new HashMap<>();
+ private Map<String, String> sfdcToUnomiFieldMappings = new HashMap<>();
+
+ private String unomiIdentifierField;
+ private String sfdcIdentifierField;
+
+ public SFDCConfiguration() {
+ }
+
+ public String getSfdcLoginEndpoint() {
+ return sfdcLoginEndpoint;
+ }
+
+ public void setSfdcLoginEndpoint(String sfdcLoginEndpoint) {
+ this.sfdcLoginEndpoint = sfdcLoginEndpoint;
+ }
+
+ public String getSfdcUserUsername() {
+ return sfdcUserUsername;
+ }
+
+ public void setSfdcUserUsername(String sfdcUserUsername) {
+ this.sfdcUserUsername = sfdcUserUsername;
+ }
+
+ public String getSfdcUserPassword() {
+ return sfdcUserPassword;
+ }
+
+ public void setSfdcUserPassword(String sfdcUserPassword) {
+ this.sfdcUserPassword = sfdcUserPassword;
+ }
+
+ public String getSfdcUserSecurityToken() {
+ return sfdcUserSecurityToken;
+ }
+
+ public void setSfdcUserSecurityToken(String sfdcUserSecurityToken) {
+ this.sfdcUserSecurityToken = sfdcUserSecurityToken;
+ }
+
+ public String getSfdcConsumerKey() {
+ return sfdcConsumerKey;
+ }
+
+ public void setSfdcConsumerKey(String sfdcConsumerKey) {
+ this.sfdcConsumerKey = sfdcConsumerKey;
+ }
+
+ public String getSfdcConsumerSecret() {
+ return sfdcConsumerSecret;
+ }
+
+ public void setSfdcConsumerSecret(String sfdcConsumerSecret) {
+ this.sfdcConsumerSecret = sfdcConsumerSecret;
+ }
+
+ public String getSfdcChannel() {
+ return sfdcChannel;
+ }
+
+ public void setSfdcChannel(String sfdcChannel) {
+ this.sfdcChannel = sfdcChannel;
+ }
+
+ public String getSfdcFieldMappings() {
+ return sfdcFieldMappings;
+ }
+
+ public String getSfdcFieldMappingsIdentifier() {
+ return sfdcFieldMappingsIdentifier;
+ }
+
+ public long getSfdcSessionTimeout() {
+ return sfdcSessionTimeout;
+ }
+
+ public void setSfdcSessionTimeout(long sfdcSessionTimeout) {
+ this.sfdcSessionTimeout = sfdcSessionTimeout;
+ }
+
+ public void setSfdcFieldMappings(String sfdcFieldMappings) {
+ this.sfdcFieldMappings = sfdcFieldMappings;
+ String[] mappings = sfdcFieldMappings.split(",");
+ if (mappings != null && mappings.length > 0) {
+ for (String mapping : mappings) {
+ String[] parts = mapping.split("=");
+ if (parts != null && parts.length == 2) {
+ unomiToSfdcFieldMappings.put(parts[0], parts[1]);
+ sfdcToUnomiFieldMappings.put(parts[1], parts[0]);
+ }
+ }
+ }
+ }
+
+ public void setSfdcFieldMappingsIdentifier(String sfdcFieldMappingsIdentifier) {
+ this.sfdcFieldMappingsIdentifier = sfdcFieldMappingsIdentifier;
+ String[] sfdcFieldMappingsIdentifierParts = sfdcFieldMappingsIdentifier.split("=");
+ if (sfdcFieldMappingsIdentifierParts != null && sfdcFieldMappingsIdentifierParts.length == 2) {
+ unomiIdentifierField = sfdcFieldMappingsIdentifierParts[0];
+ sfdcIdentifierField = sfdcFieldMappingsIdentifierParts[1];
+ }
+ }
+
+ public Map<String, String> getUnomiToSfdcFieldMappings() {
+ return unomiToSfdcFieldMappings;
+ }
+
+ public Map<String, String> getSfdcToUnomiFieldMappings() {
+ return sfdcToUnomiFieldMappings;
+ }
+
+ public String getUnomiIdentifierField() {
+ return unomiIdentifierField;
+ }
+
+ public String getSfdcIdentifierField() {
+ return sfdcIdentifierField;
+ }
+
+ public boolean isComplete() {
+ return (!StringUtils.isEmpty(sfdcLoginEndpoint) &&
+ !StringUtils.isEmpty(sfdcUserUsername) &&
+ !StringUtils.isEmpty(sfdcUserPassword) &&
+ !StringUtils.isEmpty(sfdcUserSecurityToken) &&
+ !StringUtils.isEmpty(sfdcConsumerKey) &&
+ !StringUtils.isEmpty(sfdcConsumerSecret) &&
+ !StringUtils.isEmpty(sfdcFieldMappingsIdentifier));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCService.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCService.java b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCService.java
new file mode 100644
index 0000000..ab5041b
--- /dev/null
+++ b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCService.java
@@ -0,0 +1,81 @@
+/*
+ * 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.sfdc.services;
+
+import org.apache.http.HttpException;
+import org.apache.unomi.api.Profile;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Public interface for the Salesforce connector
+ */
+public interface SFDCService {
+
+ /**
+ * Load the configuration from the persistence service (if it exists)
+ * @return an instance of the configuration if it was found, null otherwise
+ */
+ SFDCConfiguration loadConfiguration();
+
+ /**
+ * Save a Salesforce configuration into the persistence service
+ * @param sfdcConfiguration the configuration to persist
+ * @return
+ */
+ boolean saveConfiguration(SFDCConfiguration sfdcConfiguration);
+
+ /**
+ * Login into Salesforce using the configuration passed in the methods arguments.
+ * @param sfdcConfiguration the configuration to use for the login
+ * @return true if the login was successful, false otherwise
+ * @throws HttpException
+ * @throws IOException
+ */
+ boolean login(SFDCConfiguration sfdcConfiguration) throws HttpException, IOException;
+
+ SFDCSession getSFDCSession();
+
+ void logout();
+
+ /**
+ * Create or update a lead based on a Unomi profile.
+ * @param profile
+ * @return a String containing the identifier of the corresponding SFDC lead
+ */
+ String createOrUpdateLead(Profile profile);
+
+ /**
+ * Updates a Unomi profile from a Salesforce lead
+ * @param profile
+ * @return true if the profile was updated, false otherwise.
+ */
+ boolean updateProfileFromLead(Profile profile);
+
+ Set<String> getRecentLeadIds();
+
+ Map<String,Object> getLead(String leadId);
+
+ Map<String,Object> query(String query);
+
+ Set<String> findLeadIdsByIdentifierValue(String identifierFieldValue);
+
+ Map<String,Object> getLimits();
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a897ab84/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCSession.java
----------------------------------------------------------------------
diff --git a/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCSession.java b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCSession.java
new file mode 100644
index 0000000..d8938b3
--- /dev/null
+++ b/extensions/salesforce-connector/services/src/main/java/org/apache/unomi/sfdc/services/SFDCSession.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.unomi.sfdc.services;
+
+/**
+ * Model object that stores Salesforce session data
+ */
+public class SFDCSession {
+ private String sessionId;
+ private String endPoint;
+ private String signature;
+ private String id;
+ private String tokenType;
+ private Long issuedAt;
+ private Long timeout;
+
+ public SFDCSession(String sessionId, String endPoint, String signature, String id, String tokenType, String issuedAt, Long timeout) {
+ this.sessionId = sessionId;
+ this.endPoint = endPoint;
+ this.signature = signature;
+ this.id = id;
+ this.tokenType = tokenType;
+ this.issuedAt = Long.parseLong(issuedAt) * 1000; // value in in seconds, we convert it to milliseconds
+ this.timeout = timeout;
+ }
+
+ public String getSessionId() {
+ return sessionId;
+ }
+
+ public String getEndPoint() {
+ return endPoint;
+ }
+
+ public String getSignature() {
+ return signature;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getTokenType() {
+ return tokenType;
+ }
+
+ public Long getIssuedAt() {
+ return issuedAt;
+ }
+
+ public boolean isExpired() {
+ if (System.currentTimeMillis() < this.issuedAt + this.timeout) {
+ return false;
+ }
+ return true;
+ }
+}