Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 96 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.salesforce.einsteinbot</groupId>
<artifactId>einstein-bot-sdk-java</artifactId>
<version>3.0.9-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>einstein-bot-sdk-java</name>
<description>Java SDK to interact with Einstein Bots Runtime.
Expand All @@ -27,17 +27,17 @@
<maven-javadoc-plugin.version>3.5.0</maven-javadoc-plugin.version>
<maven-release-plugin.version>3.0.0</maven-release-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
<swagger-core-version>2.1.7</swagger-core-version>
<jackson-version>2.15.0</jackson-version>
<jackson-annotations-version>2.15.0</jackson-annotations-version>
<javax-annotation-version>1.3.2</javax-annotation-version>
<spring-boot-starter-webflux-version>3.3.8</spring-boot-starter-webflux-version>
<jackson-databind-nullable-version>0.2.10</jackson-databind-nullable-version>
<swagger-core-version>2.2.25</swagger-core-version>
<jackson-version>2.21.0</jackson-version>
<jackson-annotations-version>2.21</jackson-annotations-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>
<spring-boot-starter-webflux-version>4.0.5</spring-boot-starter-webflux-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<einstein-bot-openapi-codegen-version>7.10.4</einstein-bot-openapi-codegen-version>
<junit-jupiter-version>5.5.2</junit-jupiter-version>
<spring-reactor-test-version>3.7.2</spring-reactor-test-version>
<spring-reactor-core-version>3.7.2</spring-reactor-core-version>
<junit-jupiter-version>5.11.4</junit-jupiter-version>
<spring-reactor-test-version>3.7.6</spring-reactor-test-version>
<spring-reactor-core-version>3.7.6</spring-reactor-core-version>
<openapi-generator-version>7.10.0</openapi-generator-version>

<!-- Runtime follows a fixed naming convention for all API versions
Expand Down Expand Up @@ -84,6 +84,29 @@
<tag>HEAD</tag>
</scm>

<!-- repositories: resolves dependencies (e.g. Jackson 2.21) directly from Maven Central.
pluginRepositories: resolves build plugins (e.g. central-publishing-maven-plugin) from Maven Central.
Not needed for CI (GitHub Actions uses Maven Central by default).
But needed for local builds behind corporate Nexus proxy that may not cache newer artifacts. -->
<repositories>
Comment thread
theanubhava marked this conversation as resolved.
<repository>
<id>maven-central-direct</id>
<url>https://repo.maven.apache.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>maven-central-plugins</id>
<url>https://repo.maven.apache.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</pluginRepository>
</pluginRepositories>


<distributionManagement>
<repository>
<id>central</id>
Expand Down Expand Up @@ -149,6 +172,55 @@
<fileMask>${api-spec-yaml-file}</fileMask>
</configuration>
</execution>
<!-- TODO: Remove these 3 patches once forcedotcom/einstein-bot-openapi-codegen is upgraded to
support openapi-generator 7.22+ with useSpringBoot4=true for WebClient.
Current custom codegen (7.10.4) is pinned to generator 7.10.0 which generates
Spring 6 API calls (entrySet, containsKey, fromHttpUrl) removed in Spring 7. -->
<execution>
<id>fix-generated-headers-entrySet</id>
<phase>process-sources</phase>
<goals>
<goal>find-and-replace</goal>
</goals>
<configuration>
<replacementType>file-contents</replacementType>
<baseDir>target/generated-sources/openapi</baseDir>
<findRegex>: headers\.entrySet\(\)</findRegex>
Comment thread
theanubhava marked this conversation as resolved.
<replaceValue>: headers.headerSet()</replaceValue>
<recursive>true</recursive>
<fileMask>ApiClient.java</fileMask>
</configuration>
</execution>
<execution>
<id>fix-generated-headers-containsKey</id>
<phase>process-sources</phase>
<goals>
<goal>find-and-replace</goal>
</goals>
<configuration>
<replacementType>file-contents</replacementType>
<baseDir>target/generated-sources/openapi</baseDir>
<findRegex>defaultHeaders\.containsKey\(</findRegex>
<replaceValue>defaultHeaders.containsHeader(</replaceValue>
<recursive>true</recursive>
<fileMask>ApiClient.java</fileMask>
</configuration>
</execution>
<execution>
<id>fix-generated-fromHttpUrl</id>
<phase>process-sources</phase>
<goals>
<goal>find-and-replace</goal>
</goals>
<configuration>
<replacementType>file-contents</replacementType>
<baseDir>target/generated-sources/openapi</baseDir>
<findRegex>\.fromHttpUrl\(</findRegex>
<replaceValue>.fromUriString(</replaceValue>
<recursive>true</recursive>
<fileMask>ApiClient.java</fileMask>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand All @@ -164,6 +236,9 @@
<inputSpec>${project.basedir}/src/main/resources/${api-spec-yaml-file}</inputSpec>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
<!-- Required for Jakarta namespace generation. No useSpringBoot4 flag exists
for WebClient generator yet (only RestTemplate in openapi generator v7.22+.)
Ref line 175 TODO comment in this pom.xml. -->
<useSpringBoot3>true</useSpringBoot3>
<useJakartaEe>true</useJakartaEe>
<dateLibrary>java8</dateLibrary>
Expand Down Expand Up @@ -287,9 +362,9 @@
</build>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${javax-annotation-version}</version>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -307,6 +382,11 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
Expand Down Expand Up @@ -338,13 +418,13 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.115.Final</version>
<version>4.2.10.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>4.1.115.Final</version>
<version>4.2.10.Final</version>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
Expand All @@ -355,7 +435,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.9.0</version>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static Builder with() {
}

public static BotHttpHeaders fromSpringHttpHeaders(HttpHeaders httpHeaders) {
return new BotHttpHeaders(httpHeaders.entrySet());
return new BotHttpHeaders(httpHeaders.headerSet());
}

public String getRequestIdHeaderAsCSV() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public static BotResponse fromResponseEnvelopeResponseEntity(
ResponseEntity<ResponseEnvelope> responseEntity) {
responseEntity.getHeaders();
return BotResponse.with(responseEntity.getBody(),
responseEntity.getStatusCodeValue(),
responseEntity.getStatusCode().value(),
fromSpringHttpHeaders(responseEntity.getHeaders()));
}

public static BotResponse fromChatMessageResponseEnvelopeResponseEntity(
ResponseEntity<ChatMessageResponseEnvelope> responseEntity, String sessionId) {
ResponseEnvelope responseEnvelope = buildResponseEnvelope(sessionId, responseEntity.getBody());
return BotResponse.with(responseEnvelope,
responseEntity.getStatusCodeValue(),
responseEntity.getStatusCode().value(),
fromSpringHttpHeaders(responseEntity.getHeaders()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import java.util.TimeZone;
import java.util.UUID;
import java.util.stream.Collectors;
import org.openapitools.jackson.nullable.JsonNullableModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import org.openapitools.jackson.nullable.JsonNullableModule;
import org.springframework.http.HttpHeaders;

/**
Expand Down Expand Up @@ -137,7 +137,7 @@ public static DateFormat createDefaultDateFormat() {
}

public static Map<String, List<String>> maskAuthorizationHeader(HttpHeaders headers){
return headers.entrySet()
return headers.headerSet()
.stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static Mono<Error> buildErrorFromClientResponseBodyString(ReactiveHttpIn
Mono<String> bodyString = BodyExtractors.toMono(String.class).
extract(clientResponse, context);
return bodyString.map(errorMessage -> new Error()
.status(response.getRawStatusCode())
.status(response.getStatusCode().value())
.message("This Response content type is not 'application/json', " +
"See the 'error' field for actual error returned by the server.")
.error(errorMessage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,21 @@ private HttpEntity<String> createHttpEntityForRequest(HttpHeaders requestHeaders

private String createStartSessionUrl() {
return UriComponentsBuilder
.fromHttpUrl(RUNTIME_URL)
.fromUriString(RUNTIME_URL)
.path(START_SESSION_URI)
.buildAndExpand(botId).toString();
}

private String createContinueSessionUrl(String sessionId) {
return UriComponentsBuilder
.fromHttpUrl(RUNTIME_URL)
.fromUriString(RUNTIME_URL)
.path(SEND_MESSAGE_URI)
.buildAndExpand(sessionId).toString();
}

private String createEndSessionUrl(String sessionId) {
return UriComponentsBuilder
.fromHttpUrl(RUNTIME_URL)
.fromUriString(RUNTIME_URL)
.path(END_SESSION_URI)
.buildAndExpand(sessionId).toString();
}
Expand Down