Skip to content

Commit 60eef20

Browse files
committed
Move all apache related code out
1 parent 2b2bebc commit 60eef20

25 files changed

Lines changed: 853 additions & 234 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.sap.cloud.sdk.datamodel</groupId>
8+
<artifactId>openapi-parent</artifactId>
9+
<version>5.27.0-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>openapi-core-apache</artifactId>
12+
<name>Data Model - OpenAPI Services - Apache Core</name>
13+
<description>Generic OpenAPI API Core Wrapper for Apache client</description>
14+
<url>https://sap.github.io/cloud-sdk/docs/java/getting-started</url>
15+
<organization>
16+
<name>SAP SE</name>
17+
<url>https://www.sap.com</url>
18+
</organization>
19+
<licenses>
20+
<license>
21+
<name>The Apache Software License, Version 2.0</name>
22+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
23+
</license>
24+
</licenses>
25+
<developers>
26+
<developer>
27+
<name>SAP</name>
28+
<email>cloudsdk@sap.com</email>
29+
<organization>SAP SE</organization>
30+
<organizationUrl>https://www.sap.com</organizationUrl>
31+
</developer>
32+
</developers>
33+
<dependencies>
34+
<dependency>
35+
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
36+
<artifactId>cloudplatform-connectivity</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
40+
<artifactId>connectivity-apache-httpclient5</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.apache.httpcomponents.client5</groupId>
44+
<artifactId>httpclient5</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.apache.httpcomponents.core5</groupId>
48+
<artifactId>httpcore5</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.fasterxml.jackson.core</groupId>
52+
<artifactId>jackson-core</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>com.fasterxml.jackson.core</groupId>
56+
<artifactId>jackson-databind</artifactId>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.fasterxml.jackson.core</groupId>
60+
<artifactId>jackson-annotations</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>com.fasterxml.jackson.datatype</groupId>
64+
<artifactId>jackson-datatype-jsr310</artifactId>
65+
</dependency>
66+
<!-- scope "provided" -->
67+
<dependency>
68+
<groupId>org.projectlombok</groupId>
69+
<artifactId>lombok</artifactId>
70+
<scope>provided</scope>
71+
</dependency>
72+
<!-- scope "test" -->
73+
<dependency>
74+
<groupId>org.junit.jupiter</groupId>
75+
<artifactId>junit-jupiter-api</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.assertj</groupId>
80+
<artifactId>assertj-core</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.wiremock</groupId>
85+
<artifactId>wiremock</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.junit.jupiter</groupId>
90+
<artifactId>junit-jupiter-params</artifactId>
91+
<scope>test</scope>
92+
</dependency>
93+
</dependencies>
94+
</project>

datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiClient.java renamed to datamodel/openapi/openapi-core-apache/src/main/java/com/sap/cloud/sdk/services/openapi/apache/apiclient/ApiClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* Do not edit the class manually.
1111
*/
1212

13-
package com.sap.cloud.sdk.services.openapi.apache;
13+
package com.sap.cloud.sdk.services.openapi.apache.apiclient;
1414

15-
import static com.sap.cloud.sdk.services.openapi.apache.DefaultApiResponseHandler.isJsonMime;
15+
import static com.sap.cloud.sdk.services.openapi.apache.apiclient.DefaultApiResponseHandler.isJsonMime;
1616
import static lombok.AccessLevel.PRIVATE;
1717

1818
import java.io.File;
@@ -60,8 +60,8 @@
6060
import com.google.common.annotations.Beta;
6161
import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor;
6262
import com.sap.cloud.sdk.cloudplatform.connectivity.Destination;
63-
import com.sap.cloud.sdk.services.openapi.apiclient.RFC3339DateFormat;
64-
import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException;
63+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException;
64+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiResponseListener;
6565

6666
import lombok.AllArgsConstructor;
6767
import lombok.EqualsAndHashCode;

datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/BaseApi.java renamed to datamodel/openapi/openapi-core-apache/src/main/java/com/sap/cloud/sdk/services/openapi/apache/apiclient/BaseApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Do not edit the class manually.
1111
*/
1212

13-
package com.sap.cloud.sdk.services.openapi.apache;
13+
package com.sap.cloud.sdk.services.openapi.apache.apiclient;
1414

1515
import javax.annotation.Nonnull;
1616

datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/DefaultApiResponseHandler.java renamed to datamodel/openapi/openapi-core-apache/src/main/java/com/sap/cloud/sdk/services/openapi/apache/apiclient/DefaultApiResponseHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Do not edit the class manually.
1111
*/
1212

13-
package com.sap.cloud.sdk.services.openapi.apache;
13+
package com.sap.cloud.sdk.services.openapi.apache.apiclient;
1414

1515
import java.io.File;
1616
import java.io.IOException;
@@ -43,7 +43,9 @@
4343

4444
import com.fasterxml.jackson.core.type.TypeReference;
4545
import com.fasterxml.jackson.databind.ObjectMapper;
46-
import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException;
46+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException;
47+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiResponse;
48+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiResponseListener;
4749

4850
import lombok.RequiredArgsConstructor;
4951

datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Pair.java renamed to datamodel/openapi/openapi-core-apache/src/main/java/com/sap/cloud/sdk/services/openapi/apache/apiclient/Pair.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Do not edit the class manually.
1111
*/
1212

13-
package com.sap.cloud.sdk.services.openapi.apache;
13+
package com.sap.cloud.sdk.services.openapi.apache.apiclient;
1414

1515
import javax.annotation.Nonnull;
1616

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.sap.cloud.sdk.services.openapi.apache.apiclient;
2+
3+
import java.text.DateFormat;
4+
import java.text.DecimalFormat;
5+
import java.text.FieldPosition;
6+
import java.text.ParsePosition;
7+
import java.util.Date;
8+
import java.util.GregorianCalendar;
9+
import java.util.TimeZone;
10+
11+
import javax.annotation.Nonnull;
12+
import javax.annotation.Nullable;
13+
14+
import com.fasterxml.jackson.databind.util.StdDateFormat;
15+
16+
/**
17+
* Date format according to the <a href="https://www.rfc-editor.org/rfc/rfc3339">RFC3339</a>.
18+
*/
19+
public class RFC3339DateFormat extends DateFormat
20+
{
21+
private static final long serialVersionUID = 1L;
22+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
23+
24+
private final StdDateFormat fmt = new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true);
25+
26+
/**
27+
* Default constructor
28+
*/
29+
public RFC3339DateFormat()
30+
{
31+
calendar = new GregorianCalendar();
32+
numberFormat = new DecimalFormat();
33+
}
34+
35+
@Override
36+
@Nonnull
37+
public Date parse( @Nonnull final String source )
38+
{
39+
return parse(source, new ParsePosition(0));
40+
}
41+
42+
@Override
43+
@Nonnull
44+
public Date parse( @Nonnull final String source, @Nonnull final ParsePosition pos )
45+
{
46+
return fmt.parse(source, pos);
47+
}
48+
49+
@Override
50+
@Nonnull
51+
public StringBuffer format(
52+
@Nonnull final Date date,
53+
@Nonnull final StringBuffer toAppendTo,
54+
@Nullable final FieldPosition fieldPosition )
55+
{
56+
return fmt.format(date, toAppendTo, fieldPosition);
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.sap.cloud.sdk.services.openapi.apache.core;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
import javax.annotation.Nonnull;
7+
import javax.annotation.Nullable;
8+
9+
import lombok.Getter;
10+
import lombok.Setter;
11+
import lombok.experimental.Accessors;
12+
13+
/**
14+
* Thrown if an error occurs during the invocation of a OpenAPI service.
15+
*/
16+
@Accessors( fluent = true )
17+
@Getter
18+
@Setter
19+
public class OpenApiRequestException extends RuntimeException
20+
{
21+
private static final long serialVersionUID = -8248392392632616674L;
22+
23+
@Nullable
24+
private Integer statusCode;
25+
@Nullable
26+
private transient Map<String, List<String>> responseHeaders;
27+
@Nullable
28+
private transient String responseBody;
29+
30+
/**
31+
* Thrown if an error occurs during the invocation of a OpenAPI service.
32+
*
33+
* @param message
34+
* The message of this exception
35+
*/
36+
public OpenApiRequestException( @Nonnull final String message )
37+
{
38+
super(message);
39+
}
40+
41+
/**
42+
* Thrown if an error occurs during the invocation of a OpenAPI service.
43+
*
44+
* @param message
45+
* The message of this exception
46+
* @param cause
47+
* The cause of this exception
48+
*/
49+
public OpenApiRequestException( @Nonnull final String message, @Nonnull final Throwable cause )
50+
{
51+
super(message, cause);
52+
}
53+
54+
/**
55+
* Thrown if an error occurs during the invocation of a OpenAPI service.
56+
*
57+
* @param cause
58+
* The cause of this exception
59+
*/
60+
public OpenApiRequestException( @Nonnull final Throwable cause )
61+
{
62+
super(cause);
63+
}
64+
}

datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/OpenApiResponse.java renamed to datamodel/openapi/openapi-core-apache/src/main/java/com/sap/cloud/sdk/services/openapi/apache/core/OpenApiResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.cloud.sdk.services.openapi.apache;
1+
package com.sap.cloud.sdk.services.openapi.apache.core;
22

33
import java.util.List;
44
import java.util.Map;

datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/OpenApiResponseListener.java renamed to datamodel/openapi/openapi-core-apache/src/main/java/com/sap/cloud/sdk/services/openapi/apache/core/OpenApiResponseListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.cloud.sdk.services.openapi.apache;
1+
package com.sap.cloud.sdk.services.openapi.apache.core;
22

33
import javax.annotation.Nonnull;
44

datamodel/openapi/openapi-core/src/test/java/com/sap/cloud/sdk/services/openapi/apiclient/ApacheApiClientResponseHandlingTest.java renamed to datamodel/openapi/openapi-core-apache/src/test/java/com/sap/cloud/sdk/services/openapi/apache/apiclient/ApacheApiClientResponseHandlingTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.cloud.sdk.services.openapi.apiclient;
1+
package com.sap.cloud.sdk.services.openapi.apache.apiclient;
22

33
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
44
import static com.github.tomakehurst.wiremock.client.WireMock.get;
@@ -20,11 +20,8 @@
2020
import com.fasterxml.jackson.core.type.TypeReference;
2121
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
2222
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
23-
import com.sap.cloud.sdk.services.openapi.apache.ApiClient;
24-
import com.sap.cloud.sdk.services.openapi.apache.BaseApi;
25-
import com.sap.cloud.sdk.services.openapi.apache.OpenApiResponse;
26-
import com.sap.cloud.sdk.services.openapi.apache.Pair;
27-
import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException;
23+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException;
24+
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiResponse;
2825

2926
import lombok.Data;
3027

0 commit comments

Comments
 (0)