Introduction

When you have to integrate SalesForce in your Spring Application Context, Apache Camel Context, or something similar, you will need simple POJO based task-executing components to achieve the integration. The Task components explained here are to fulfill those requirements. So, you can configure these components easily in your context configuration.

In this article, each Task Component configuration is configured as Spring Bean configuration for easier understanding.

SalesForceClient component can be configured in Spring Beans Configuration like the following example:

  <bean id="salesForceConnectionInfo" class="org.onehippo.forge.sforcecomps.client.rest.SalesForceConnectionInfo">
    <property name="clientId" value="3MVG9lKcPoNINVBJSoQsNCD.HHDdbugPsNXwwyFbgb47KWa_PTv" />
    <property name="clientSecret" value="5678471853609579508" />
    <property name="username" value="tester@onehippo.org" />
    <property name="password" value="password" />
    <property name="securityToken" value="hhWVl82SHphnA50OTBt2DAZk" />
  </bean>
  
  <bean id="salesForceRestClient" 
        class="org.onehippo.forge.sforcecomps.client.rest.SalesForceRestClient"
        init-method="establishAccessToken">
    <property name="connectionInfo" ref="salesForceConnectionInfo" />
  </bean>
      

SalesForceRecordCreator Task Component

Properties for SalesForceRecordCreator Task Component

Property Type Description Example value Default value
client org.onehippo.forge.sforcecomps.client.rest.SalesForceRestClient
baseResourcePath java.lang.String Base Resource Path where the record should exist under. /sobjects/Account
createOrUpdate boolean The flag whether 'createOrUpdate' option is used. If this is true, the operation can update the existing record. Otherwise, the operation will only create a record. true false

Execution Operation(s) for SalesForceRecordCreator Task Component

Operation Input Type(s) Return Type(s) Description Example Input values Example Output values
perform java.lang.String java.lang.String Perform record creation under the base resource path from a record string in JSON. When successful, it returns a JSON string with ID and errors/success information. {"Name":"test"} {"id":"001E000000BCFtiIAH","errors":[],"success":true}

Example Spring Configuration for SalesForceRecordCreator Task Component

  <bean id="salesForceRecordCreator" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordCreator">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
    <property name="createOrUpdate" value="false" />
  </bean>
        

Example Camel Route Configuration for SalesForceRecordCreator Task Component

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
  xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean id="salesForceRecordCreator" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordCreator">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
    <property name="createOrUpdate" value="false" />
  </bean>
  
  <camelContext xmlns="http://camel.apache.org/schema/spring">
    
    <route>
      <!-- invoker is supposed to call this route URI with JSON string message. -->
      <from uri="direct:test" />
      <to uri="bean:salesForceRecordCreator" />
    </route>
    
  </camelContext>

</beans>
        

SalesForceRecordRetriever Task Component

Properties for SalesForceRecordRetriever Task Component

Property Type Description Example value Default value
client org.onehippo.forge.sforcecomps.client.rest.SalesForceRestClient SalesForceRestClient object
baseResourcePath java.lang.String Base Resource Path which can be prepended to the input resource path on the operation. /sobjects/Account

Execution Operation(s) for SalesForceRecordRetriever Task Component

Operation Input Type(s) Return Type(s) Description Example Input values Example Output values
perform java.lang.String java.lang.String Perform record creation under the base resource path from a record string in JSON. When successful, it returns a JSON string containing the record. /001E000000BCFtiIAH/ {"attributes":{"type":"Account","url":"/services/data/v20.0/sobjects/Account/001E000000BCFtiIAH"}, "Id":"001E000000BCFtiIAH","IsDeleted":false,"MasterRecordId":null,"Name":"test","Type":null, "ParentId":null,"BillingStreet":null,"BillingCity":null,"BillingState":null,"BillingPostalCode":null, "BillingCountry":null,"ShippingStreet":null,"ShippingCity":null,"ShippingState":null, "ShippingPostalCode":null,"ShippingCountry":null,"Phone":null,"Fax":null,"AccountNumber":null, "Website":null,"Sic":null,"Industry":null,"AnnualRevenue":null,"NumberOfEmployees":null, "Ownership":null,"TickerSymbol":null,"Description":null,"Rating":null,"Site":null, "OwnerId":"005E0000000Qei6IAC","CreatedDate":"2011-06-15T01:09:56.000+0000", "CreatedById":"005E0000000Qei6IAC","LastModifiedDate":"2011-06-15T01:09:56.000+0000", "LastModifiedById":"005E0000000Qei6IAC","SystemModstamp":"2011-06-15T01:09:56.000+0000", "LastActivityDate":null,"CustomerPriority__c":null,"SLA__c":null,"Active__c":null, "NumberofLocations__c":null,"UpsellOpportunity__c":null,"SLASerialNumber__c":null, "SLAExpirationDate__c":null}

Example Spring Configuration for SalesForceRecordRetriever Task Component

  <bean id="salesForceRecordRetriever" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordRetriever">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
  </bean>
        

Example Camel Route Configuration for SalesForceRecordRetriever Task Component

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
  xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean id="salesForceRecordRetriever" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordRetriever">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
  </bean>
  
  <camelContext xmlns="http://camel.apache.org/schema/spring">
    
    <route>
      <!-- invoker is supposed to call this route URI with resource path string message. -->
      <from uri="direct:test" />
      <to uri="bean:salesForceRecordRetriever" />
    </route>
    
  </camelContext>

</beans>
        

SalesForceRecordUpdater Task Component

Properties for SalesForceRecordUpdater Task Component

Property Type Description Example value Default value
client org.onehippo.forge.sforcecomps.client.rest.SalesForceRestClient SalesForceRestClient object
baseResourcePath java.lang.String Base Resource Path where the record exists under. /sobjects/Account

Execution Operation(s) for SalesForceRecordUpdater Task Component

Operation Input Type(s) Return Type(s) Description Example Input values Example Output values
perform java.lang.String java.lang.String Perform record creation under the base resource path from a record string in JSON. When successful, it returns the input JSON string. {"id":"001E000000BCFtiIAH","BillingCity":"San Francisco"} {"id":"001E000000BCFtiIAH","BillingCity":"San Francisco"}

Example Spring Configuration for SalesForceRecordUpdater Task Component

  <bean id="salesForceRecordUpdater" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordUpdater">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
  </bean>
        

Example Camel Route Configuration for SalesForceRecordUpdater Task Component

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
  xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean id="salesForceRecordUpdater" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordUpdater">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
  </bean>
  
  <camelContext xmlns="http://camel.apache.org/schema/spring">
    
    <route>
      <!-- invoker is supposed to call this route URI with JSON string message. -->
      <from uri="direct:test" />
      <to uri="bean:salesForceRecordUpdater" />
    </route>
    
  </camelContext>

</beans>
        

SalesForceRecordDeleter Task Component

Properties for SalesForceRecordDeleter Task Component

Property Type Description Example value Default value
client org.onehippo.forge.sforcecomps.client.rest.SalesForceRestClient SalesForceRestClient object
baseResourcePath java.lang.String Base Resource Path where the record exists under. /sobjects/Account

Execution Operation(s) for SalesForceRecordDeleter Task Component

Operation Input Type(s) Return Type(s) Description Example Input values Example Output values
perform java.lang.String java.lang.String Perform record creation under the base resource path from a record string in JSON. When successful, it returns the input JSON string. {"id":"001E000000BCFtiIAH"} {"id":"001E000000BCFtiIAH"}

Example Spring Configuration for SalesForceRecordDeleter Task Component

  <bean id="salesForceRecordDeleter" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordDeleter">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
  </bean>
        

Example Camel Route Configuration for SalesForceRecordDeleter Task Component

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
  xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean id="salesForceRecordDeleter" class="org.onehippo.forge.sforcecomps.client.task.SalesForceRecordDeleter">
    <property name="client" ref="salesForceRestClient" />
    <property name="baseResourcePath" value="/sobjects/Account" />
  </bean>
  
  <camelContext xmlns="http://camel.apache.org/schema/spring">
    
    <route>
      <!-- invoker is supposed to call this route URI with JSON string message. -->
      <from uri="direct:test" />
      <to uri="bean:salesForceRecordDeleter" />
    </route>
    
  </camelContext>

</beans>