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
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
- uses: actions/cache@v2
with:
Expand All @@ -29,9 +29,9 @@ jobs:
- name: Run build steps and generate coverage report with Maven
run: |
mvn verify javadoc:javadoc jacoco:report -Pcoverage -B -V
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1
with:
file: ./**/target/site/jacoco/jacoco.xml
name: codecov
fail_ci_if_error: true
# - name: Upload coverage report to Codecov
# uses: codecov/codecov-action@v1
# with:
# file: ./**/target/site/jacoco/jacoco.xml
# name: codecov
# fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .sonar.settings
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Settings for sonar scan
gdc.java_version=openjdk-11
gdc.java_version=openjdk-17
41 changes: 28 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>gooddata-rest-common</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>GoodData REST Common Library</description>
<url>https://github.com/gooddata/gooddata-rest-common</url>

<parent>
<groupId>com.gooddata</groupId>
<artifactId>gooddata-parent</artifactId>
<version>3.1.0</version>
<version>4.0.0</version>
</parent>

<licenses>
Expand Down Expand Up @@ -39,10 +39,10 @@
</developers>

<properties>
<jackson.version>2.13.3</jackson.version>
<jackson.databind.version>2.13.3</jackson.databind.version>
<spring.version>5.3.21</spring.version>
<json-unit.version>2.35.0</json-unit.version>
<jackson.version>2.15.3</jackson.version>
<jackson.databind.version>2.15.3</jackson.databind.version>
<spring.version>6.0.23</spring.version>
<json-unit.version>2.38.0</json-unit.version>
</properties>

<build>
Expand All @@ -53,7 +53,7 @@
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.13.1</version>
<version>3.0.2</version>
<executions>
<execution>
<goals>
Expand All @@ -74,7 +74,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.11</version>
<executions>
<execution>
<id>jacoco-prepare-agent</id>
Expand Down Expand Up @@ -117,13 +117,28 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.0.13</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>3.0.13</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
Expand Down Expand Up @@ -165,7 +180,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.15.0</version>
</dependency>

<dependency>
Expand All @@ -177,7 +192,7 @@
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.3-groovy-2.5</version>
<version>2.4-M1-groovy-4.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -187,9 +202,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>2.5.14</version>
<version>4.0.17</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/com/gooddata/sdk/common/UriPrefixer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,15 @@ public URI mergeUris(String uri) {
notEmpty(uri, "uri");
return mergeUris(URI.create(uri));
}
}

/**
* Prefix the given URI with the URI prefix.
*
* @param uri the URI to prefix
* @return the prefixed URI
*/
public URI prefixUri(URI uri) {
return mergeUris(uri); // Use existing merging logic
}

}

This file was deleted.

63 changes: 63 additions & 0 deletions src/main/java/com/gooddata/sdk/common/UriPrefixingWebClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2004-2017, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.sdk.common;

import org.springframework.http.HttpMethod;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;

import static com.gooddata.sdk.common.util.Validate.notNull;

/**
* Factory for creating HTTP requests using WebClient.
* The factory allows you to specify hostname and port for Spring REST client which by default requires absolute URI.
*/
public class UriPrefixingWebClient {

private final WebClient webClient;
private final UriPrefixer prefixer;

/**
* Create an instance that uses the given {@link WebClient.Builder}
* and URI prefix for all HTTP requests.
*
* @param webClientBuilder the WebClient builder
* @param uriPrefix the URI for setting hostname and port of all HTTP requests
*/
public UriPrefixingWebClient(final WebClient.Builder webClientBuilder, final URI uriPrefix) {
this(webClientBuilder, new UriPrefixer(uriPrefix));
}

/**
* Create an instance that uses the given {@link WebClient.Builder}
* and URI prefix for all HTTP requests.
*
* @param webClientBuilder the WebClient builder
* @param uri the URI for setting hostname and port of all HTTP requests
*/
public UriPrefixingWebClient(final WebClient.Builder webClientBuilder, final String uri) {
this(webClientBuilder, URI.create(uri));
}

private UriPrefixingWebClient(final WebClient.Builder webClientBuilder, final UriPrefixer prefixer) {
this.webClient = notNull(webClientBuilder, "webClientBuilder").build();
this.prefixer = notNull(prefixer, "prefixer");
}

/**
* Create a request with the given path and HTTP method.
*
* @param path the path for the HTTP request
* @param httpMethod the HTTP method (e.g., GET, POST)
* @return the WebClient.RequestHeadersSpec to customize and execute the request
*/
public WebClient.RequestHeadersSpec<?> createRequest(final String path, final HttpMethod httpMethod) {
final URI prefixedUri = prefixer.prefixUri(URI.create(path));
return webClient.method(httpMethod).uri(prefixedUri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand Down Expand Up @@ -38,7 +39,7 @@ public ErrorStructure deserialize(JsonParser jp, DeserializationContext ctxt) th
clazz = DefaultDeserializerErrorStructure.class;
}
} else {
throw ctxt.mappingException("Unknown type of ErrorStructure");
throw JsonMappingException.from(ctxt, "Unknown type of ErrorStructure");
}

final JsonParser nextParser = tokenBuffer.asParser();
Expand Down

This file was deleted.

Loading
Loading