This is an automated email from the ASF dual-hosted git repository. jeremyross pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 65f2065 camel-salesforce: Document apexCall operation 65f2065 is described below commit 65f20650430657de9b7145c2b3fa50cd645492c6 Author: Jeremy Ross <jeremy.g.r...@gmail.com> AuthorDate: Thu Dec 16 12:20:26 2021 -0600 camel-salesforce: Document apexCall operation --- .../src/main/docs/salesforce-component.adoc | 111 +++++++++++++-------- 1 file changed, 70 insertions(+), 41 deletions(-) diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc index 189a51b..d6a5f3f 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc +++ b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc @@ -380,47 +380,6 @@ The https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/c is a good fit to better know the subtleties of implementing a change data capture integration application. The dynamic nature of change event body fields, high level replication steps as well as security considerations could be of interest. -== Examples - -=== Uploading a document to a ContentWorkspace - -Create the ContentVersion in Java, using a Processor instance: - -[source,java] ----- -public class ContentProcessor implements Processor { - public void process(Exchange exchange) throws Exception { - Message message = exchange.getIn(); - - ContentVersion cv = new ContentVersion(); - ContentWorkspace cw = getWorkspace(exchange); - cv.setFirstPublishLocationId(cw.getId()); - cv.setTitle("test document"); - cv.setPathOnClient("test_doc.html"); - byte[] document = message.getBody(byte[].class); - ObjectMapper mapper = new ObjectMapper(); - String enc = mapper.convertValue(document, String.class); - cv.setVersionDataUrl(enc); - message.setBody(cv); - } - - protected ContentWorkspace getWorkSpace(Exchange exchange) { - // Look up the content workspace somehow, maybe use enrich() to add it to a - // header that can be extracted here - .... - } -} ----- - -Give the output from the processor to the Salesforce component: - -[source,java] ----- -from("file:///home/camel/library") - .to(new ContentProcessor()) // convert bytes from the file into a ContentVersion SObject - // for the salesforce component - .to("salesforce:createSObject"); ----- == Using Salesforce Limits API @@ -450,6 +409,36 @@ from("direct:querySalesforce") .endChoice() ---- +== Invoking Apex REST endpoints + +You can https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_intro.htm[expose your Apex class and methods] +so that external applications can access your code and your application through the REST architecture. + +The URI format for invoking Apex REST is: + +---- +salesforce:apexCall[/yourApexRestUrl][?options] +---- + +You can supply the apexUrl either in the endpoint (see above), or as the `apexUrl` option as listed in the table below. +In either case the Apex URL can contain placeholders in the format of `{headerName}`. E.g., for the Apex URL `MyApexClass/{id}`, +the value of the header named `id` will be used to replace the placeholder. + +|=== +| Parameter | Type | Description| Default| Required + +| request body | `Map<String, Object>` if `GET`, otherwise `String` or `InputStream`| In the case of a `GET`, the body (`Map` instance) +is transformed into query parameters. For other HTTP methods, the body is used for the HTTP body. | | +| `apexUrl` | `String` | The portion of the endpoint URL after `https://instance.salesforce.com/services/apexrest/`, e.g., 'MyApexClass/' | | +| `apexMethod` | `String` | The HTTP method (e.g. `GET`, `POST`) to use. | `GET` | +| `rawPayload` | `Boolean` | If true, Camel will not serialize the request or response bodies. | false | +| Header: `apexQueryParam.[paramName]` | Object | Headers that override apex parameters passed in the endpoint. | false | +| `sObjectName` | `String` | Name of sObject (e.g. `Merchandise__c`) used to deserialize the response | false | +| `sObjectClass` | `String` | Fully qualified class name used to deserialize the response | false | +|=== + + + == Working with approvals All the properties are named exactly the same as in the Salesforce REST API prefixed with `approval.`. You can set @@ -799,6 +788,46 @@ send null values to salesforce, use the `fieldsToNull` property, as follows: accountSObject.getFieldsToNull().add("Site"); ---- +== Uploading a document to a ContentWorkspace + +Create the ContentVersion in Java, using a Processor instance: + +[source,java] +---- +public class ContentProcessor implements Processor { + public void process(Exchange exchange) throws Exception { + Message message = exchange.getIn(); + + ContentVersion cv = new ContentVersion(); + ContentWorkspace cw = getWorkspace(exchange); + cv.setFirstPublishLocationId(cw.getId()); + cv.setTitle("test document"); + cv.setPathOnClient("test_doc.html"); + byte[] document = message.getBody(byte[].class); + ObjectMapper mapper = new ObjectMapper(); + String enc = mapper.convertValue(document, String.class); + cv.setVersionDataUrl(enc); + message.setBody(cv); + } + + protected ContentWorkspace getWorkSpace(Exchange exchange) { + // Look up the content workspace somehow, maybe use enrich() to add it to a + // header that can be extracted here + .... + } +} +---- + +Give the output from the processor to the Salesforce component: + +[source,java] +---- +from("file:///home/camel/library") + .to(new ContentProcessor()) // convert bytes from the file into a ContentVersion SObject + // for the salesforce component + .to("salesforce:createSObject"); +---- + == Generating SOQL query strings `org.apache.camel.component.salesforce.api.utils.QueryHelper` contains helper