diff --git a/rest-openapi/README.adoc b/rest-openapi/README.adoc index bf74d5472..b35d97ba2 100644 --- a/rest-openapi/README.adoc +++ b/rest-openapi/README.adoc @@ -25,7 +25,7 @@ You should see the following output when the application is launched: [source,text] ---- ... -[INFO] --- spring-boot-maven-plugin:1.5.10.RELEASE:run (default-cli) @ camel-example-spring-boot-rest-openapi --- +[INFO] --- spring-boot:4.1.1:run (default-cli) @ camel-example-spring-boot-rest-openapi --- [...] . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ @@ -33,12 +33,14 @@ You should see the following output when the application is launched: \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ - :: Spring Boot :: (v2.0.0.RELEASE) -[...] -2017-03-05 14:55:44.032 INFO 15312 --- [ main] o.a.camel.spring.SpringCamelContext : Total 4 routes, of which 4 are started. -2017-03-05 14:55:44.034 INFO 15312 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.22.0-SNAPSHOT (CamelContext: camel-1) started in 0.614 seconds -2017-03-05 14:55:44.131 INFO 15312 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http) -2017-03-05 14:55:44.140 INFO 15312 --- [ main] o.a.c.example.springboot.Application : Started Application in 6.265 seconds (JVM running for 21.092) + + :: Spring Boot :: (v4.1.1) + +2026-09-04T10:13:59.681+02:00 INFO 26229 --- [ main] o.s.boot.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/' +2026-09-04T10:13:59.872+02:00 INFO 26229 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.23.0-SNAPSHOT (MyCamel) is starting +2026-09-04T10:13:59.913+02:00 INFO 26229 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup (total:4 rest-dsl:4) +2026-09-04T10:13:59.913+02:00 INFO 26229 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.23.0-SNAPSHOT (MyCamel) started in 41ms (build:0ms init:0ms start:41ms boot:586ms) +2026-09-04T10:13:59.915+02:00 INFO 26229 --- [ main] o.a.c.example.springboot.Application : Started Application in 1.476 seconds (process running for 1.63) ---- After the Spring Boot application is started, you can open the following URL in your web browser to access the REST endpoint and retrieve a list of users: http://localhost:8080/api/users @@ -77,7 +79,7 @@ The Spring Boot application can be stopped pressing `[CTRL] + [C]` in the shell. === Actuator -The actuator is available at: `http://localhost:8080/actuator/` such as metrics for Prometheus: `http://localhost:8080/actuator/prometheus`. +The actuator is available at: `http://localhost:8080/actuator` such as metrics for Prometheus: `http://localhost:8080/actuator/prometheus`. === Help and contributions diff --git a/twitter-salesforce/README.adoc b/twitter-salesforce/README.adoc index 0cc460652..6ddf5d6c0 100644 --- a/twitter-salesforce/README.adoc +++ b/twitter-salesforce/README.adoc @@ -8,20 +8,26 @@ as a contact in Salesforce. === Configuring Twitter -This example is already configured using a testing purpose twitter -account named `cameltweet'. And therefore the example is ready to run -out of the box. +This example ships with the keys and tokens of a long-standing testing +Twitter/X account named `cameltweet`, used only to let the example show +a complete, working configuration; they are not a working credential you +can rely on. They predate Twitter/X's 2023 API overhaul and are very +likely no longer valid, and even if they were, they are for a shared +testing account, not something to build on. -This account is only for testing purpose, and should not be used in your -custom applications. For that you need to setup and use your own twitter -account. +You must self-provision your own Twitter/X developer app and use its +consumer key/secret and access token/secret in place of the values in +`+application.properties+` before this example will actually run. === Configuring Salesforce -This example uses Camels own test Salesforce developer account, you -would most likely want to sign up with your own Developer account at -https://developer.salesforce.com/. After you have done that, you’ll need -to create a Connected Application for your integration. +This example ships with `+clientId+`/`+clientSecret+` values for a Camel +test Salesforce developer account, included only to show what a filled-in +configuration looks like. As with the Twitter/X keys above, self-provision +your own Salesforce Developer account at +https://developer.salesforce.com/ for anything beyond reading this +example, and follow the steps below to create your own Connected +Application for your integration. To do this after logging in to your Salesforce Developer account, navigate to _Apps_ located under _Build_ and then _Create_, there you @@ -89,6 +95,18 @@ to use the `+camel-salesforce-maven-plugin+` and specify the desired DTO in org.codehaus.mojo build-helper-maven-plugin + 3.0.0 add-source diff --git a/twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java b/twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java index 2f57362dd..6a1be0d96 100644 --- a/twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java +++ b/twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java @@ -16,10 +16,8 @@ */ package org.apache.camel.example.mention; -import java.lang.Class; -import java.lang.reflect.Method; -import org.apache.camel.salesforce.draftdto.Contact; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.example.mention.dto.Contact; import org.springframework.stereotype.Component; import twitter4j.v1.Status; import twitter4j.v1.User; @@ -34,22 +32,11 @@ public void configure() throws Exception { .process(exchange -> { Status status = exchange.getIn().getBody(Status.class); User user = status.getUser(); - String name = user.getName(); - String screenName = user.getScreenName(); - Class contact = null; - if (Class.forName("org.apache.camel.salesforce.dto.Contact") != null) { - contact = Class.forName("org.apache.camel.salesforce.dto.Contact"); - } else { - contact = Contact.class; - } - - Object contactObject = contact.getDeclaredConstructor().newInstance(); - Method setLastName = contact.getMethod("setLastName", String.class); - Method setTwitterScreenName__c = contact.getMethod("setTwitterScreenName__c", String.class); - setLastName.invoke(contactObject, name); - setTwitterScreenName__c.invoke(contactObject, screenName); - exchange.getIn().setBody(contactObject); + Contact contact = new Contact(); + contact.setLastName(user.getName()); + contact.setTwitterScreenName__c(user.getScreenName()); + exchange.getIn().setBody(contact); }) .to("salesforce:upsertSObject?sObjectIdName=TwitterScreenName__c") .log("SObject ID: ${body?.id}"); diff --git a/twitter-salesforce/src/main/java/org/apache/camel/example/mention/dto/Contact.java b/twitter-salesforce/src/main/java/org/apache/camel/example/mention/dto/Contact.java new file mode 100644 index 000000000..f795d3688 --- /dev/null +++ b/twitter-salesforce/src/main/java/org/apache/camel/example/mention/dto/Contact.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.example.mention.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase; + +/** + * Minimal, hand-maintained stand-in for the Salesforce {@code Contact} DTO that + * {@code camel-salesforce-maven-plugin} would otherwise generate from a live org (see the + * {@code generate-salesforce-dto} Maven profile). It only carries the fields this example + * actually sets, so the module builds and runs without needing Salesforce credentials at + * build time. + */ +public class Contact extends AbstractSObjectBase { + + private String lastName; + private String twitterScreenNameC; + + public Contact() { + getAttributes().setType("Contact"); + } + + // Salesforce field API names are case-sensitive (LastName, TwitterScreenName__c); without + // @JsonProperty, Jackson would decapitalize the leading letter of the bean-derived property + // name and silently send the wrong field names to the Salesforce REST API. + @JsonProperty("LastName") + public String getLastName() { + return lastName; + } + + @JsonProperty("LastName") + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @JsonProperty("TwitterScreenName__c") + public String getTwitterScreenName__c() { + return twitterScreenNameC; + } + + @JsonProperty("TwitterScreenName__c") + public void setTwitterScreenName__c(String twitterScreenNameC) { + this.twitterScreenNameC = twitterScreenNameC; + } + +} diff --git a/twitter-salesforce/src/main/java/org/apache/camel/salesforce/draftdto/Contact.java b/twitter-salesforce/src/main/java/org/apache/camel/salesforce/draftdto/Contact.java deleted file mode 100644 index 4d46cf358..000000000 --- a/twitter-salesforce/src/main/java/org/apache/camel/salesforce/draftdto/Contact.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.apache.camel.salesforce.draftdto; - -public abstract class Contact { - public abstract void setLastName(String LastName); - public abstract void setTwitterScreenName__c(String TwitterScreenName__c); -}