Skip to content

Commit 0476099

Browse files
author
Vladimir Litvinchik
committed
Update sources
1 parent c2cd362 commit 0476099

14 files changed

Lines changed: 477 additions & 60 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Add following repository and dependency to your project's POM
3737
<dependency>
3838
<groupId>com.groupdocs</groupId>
3939
<artifactId>groupdocs-viewer-cloud</artifactId>
40-
<version>18.5</version>
40+
<version>18.7</version>
4141
<scope>compile</scope>
4242
</dependency>
4343
```
@@ -50,7 +50,7 @@ At first generate the JAR by executing:
5050

5151
Then manually install the following JARs:
5252

53-
* target/groupdocs-viewer-cloud-18.5.jar
53+
* target/groupdocs-viewer-cloud-18.7.jar
5454
* target/lib/*.jar
5555

5656
## Getting Started

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>groupdocs-viewer-cloud</artifactId>
66
<packaging>jar</packaging>
77
<name>groupdocs-viewer-cloud</name>
8-
<version>18.5</version>
8+
<version>18.7</version>
99
<url>https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-java</url>
1010
<description>Java library for communicating with the GroupDocs.Viewer Cloud API</description>
1111
<scm>

src/main/java/com/groupdocs/cloud/viewer/client/ApiClient.java

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,17 @@
6767
public class ApiClient {
6868
private Configuration configuration = null;
6969

70-
private String basePath = null;
70+
private String serverUrl = null;
7171
private boolean debugging = false;
7272
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
7373
private String tempFolderPath = null;
7474

7575
private Map<String, Authentication> authentications;
7676

7777
private DateFormat dateFormat;
78-
private DateFormat datetimeFormat;
79-
private boolean lenientDatetimeFormat;
80-
private int dateLength;
81-
8278
private InputStream sslCaCert;
8379
private boolean verifyingSsl;
80+
8481
private KeyManager[] keyManagers;
8582

8683
private OkHttpClient httpClient;
@@ -93,45 +90,44 @@ public class ApiClient {
9390
*/
9491
public ApiClient(Configuration configuration) {
9592
this.configuration = configuration;
96-
this.basePath = configuration.getBasePath();
97-
93+
this.serverUrl = configuration.getServerUrl();
9894
this.httpClient = new OkHttpClient();
99-
100-
10195
this.verifyingSsl = true;
102-
10396
this.json = new JSON();
10497

10598
// Set default User-Agent.
106-
setUserAgent("Swagger-Codegen/18.5/java");
99+
setUserAgent("java-sdk/18.7");
100+
101+
// Set connection timeout
102+
setConnectTimeout(configuration.getTimeout());
107103

108104
// Setup authentications (key: authentication name, value: authentication).
109105
this.authentications = new HashMap<String, Authentication>();
110-
String tokenUrl = configuration.getBasePath().replace(configuration.getContextPath(), "");
106+
111107
String appSid = configuration.getAppSid();
112108
String appKey = configuration.getAppKey();
113-
this.authentications.put("oauth", new OAuth(tokenUrl, appSid, appKey));
109+
this.authentications.put("oauth", new OAuth(configuration, appSid, appKey));
114110
// Prevent the authentications from being modified.
115111
this.authentications = Collections.unmodifiableMap(authentications);
116112
}
117113

118114
/**
119-
* Get base path
115+
* Get server URL, default value is https://api.groupdocs.cloud/v1
120116
*
121-
* @return Base path
117+
* @return Server URL
122118
*/
123-
public String getBasePath() {
124-
return basePath;
119+
public String getServerUrl() {
120+
return serverUrl;
125121
}
126122

127123
/**
128-
* Set base path
124+
* Set server URL
129125
*
130-
* @param basePath Base path of the URL (e.g https://api.groupdocs.cloud/v1
126+
* @param serverUrl Server URL
131127
* @return An instance of OkHttpClient
132128
*/
133-
public ApiClient setBasePath(String basePath) {
134-
this.basePath = basePath;
129+
public ApiClient setServerUrl(String serverUrl) {
130+
this.serverUrl = serverUrl;
135131
return this;
136132
}
137133

@@ -968,7 +964,7 @@ public Request buildRequest(String path, String method, List<Pair> queryParams,
968964
*/
969965
public String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
970966
final StringBuilder url = new StringBuilder();
971-
url.append(basePath).append(path);
967+
url.append(serverUrl).append(path);
972968

973969
if (queryParams != null && !queryParams.isEmpty()) {
974970
// support (constant) query string in `path`, e.g. "/posts?draft=1"

src/main/java/com/groupdocs/cloud/viewer/client/Configuration.java

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ public class Configuration {
3434

3535
private String appKey = null;
3636

37-
private String basePath = "https://api.groupdocs.cloud/v1";
37+
private String apiVersion = "/v1";
3838

39-
private String contextPath = "/v1";
39+
private String apiBaseUrl = "https://api.groupdocs.cloud";
40+
41+
private int timeout = 60 * 1000;
4042

4143
/**
4244
* Constructor for Configuration
@@ -49,65 +51,83 @@ public Configuration(String appSid, String appKey) {
4951
}
5052

5153
/**
52-
* Application identifier (App SID)
54+
* Gets Application identifier (App SID)
5355
*
5456
* @return Application identifier (App SID)
5557
*/
5658
public String getAppSid() {
5759
return appSid;
5860
}
5961

62+
/**
63+
* Sets application identifier (App SID)
64+
*
65+
* @param appSid Application identifier (App SID)
66+
*/
6067
public void setAppSid(String appSid) {
6168
this.appSid = appSid;
6269
}
6370

6471
/**
65-
* Application private key (App Key)
72+
* Gets Application private key (App Key)
6673
*
6774
* @return Application private key (App Key)
6875
*/
6976
public String getAppKey() {
7077
return appKey;
7178
}
7279

80+
/**
81+
* Sets application private key (App Key)
82+
*
83+
* @param appKey Application private key (App Key)
84+
*/
7385
public void setAppKey(String appKey) {
7486
this.appKey = appKey;
7587
}
7688

7789
/**
78-
* Get base path of the URL (e.g https://api.groupdocs.cloud/v1)
90+
* Gets API base URL, default value is https://api.groupdocs.cloud
91+
*
92+
* @return API base URL
93+
*/
94+
public String getApiBaseUrl() {
95+
return apiBaseUrl;
96+
}
97+
98+
/**
99+
* Sets API base URL
79100
*
80-
* @return Base path
101+
* @param apiBaseUrl API base URL
81102
*/
82-
public String getBasePath() {
83-
return basePath;
103+
public void setApiBaseUrl(String apiBaseUrl) {
104+
this.apiBaseUrl = apiBaseUrl;
84105
}
85106

86107
/**
87-
* Set base path
108+
* Gets connection timeout in miliseconds
88109
*
89-
* @param basePath Base path of the URL (e.g https://api.groupdocs.cloud/v1)
110+
* @return Timeout in miliseconds
90111
*/
91-
public void setBasePath(String basePath) {
92-
this.basePath = basePath;
112+
public int getTimeout() {
113+
return timeout;
93114
}
94115

95116
/**
96-
* Get context path of the URL (e.g /v1)
117+
* Sets connection timeout in miliseconds
97118
*
98-
* @return Context path
119+
* @param timeout Timeout in miliseconds
99120
*/
100-
public String getContextPath() {
101-
return contextPath;
121+
public void setTimeout(int timeout) {
122+
this.timeout = timeout;
102123
}
103124

104125
/**
105-
* Set context path
126+
* Gets Server URL e.g. https://api.groupdocs.cloud/v1
106127
*
107-
* @param contextPath Context path of the URL (e.g /v1)
128+
* @return Server URL
108129
*/
109-
public void setContextPath(String contextPath) {
110-
this.basePath = this.basePath.replace(this.contextPath, contextPath);
111-
this.contextPath = contextPath;
130+
protected String getServerUrl(){
131+
return apiBaseUrl + apiVersion;
112132
}
113133
}

src/main/java/com/groupdocs/cloud/viewer/client/JSON.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ public OffsetDateTime read(JsonReader in) throws IOException {
168168
return null;
169169
default:
170170
String date = in.nextString();
171+
if(date.equals("0001-01-01T00:00:00")) {
172+
return OffsetDateTime.MIN;
173+
}
171174
if (date.endsWith("+0000")) {
172175
date = date.substring(0, date.length()-5) + "Z";
173176
}

src/main/java/com/groupdocs/cloud/viewer/client/auth/OAuth.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
package com.groupdocs.cloud.viewer.client.auth;
2929

3030
import com.groupdocs.cloud.viewer.client.ApiException;
31+
import com.groupdocs.cloud.viewer.client.Configuration;
3132
import com.groupdocs.cloud.viewer.client.JSON;
3233
import com.groupdocs.cloud.viewer.client.Pair;
3334
import com.squareup.okhttp.*;
3435
import com.squareup.okhttp.OkHttpClient;
3536

3637
import java.util.Objects;
38+
import java.util.concurrent.TimeUnit;
3739
import com.google.gson.annotations.SerializedName;
3840
import io.swagger.annotations.ApiModelProperty;
3941

@@ -66,12 +68,14 @@ public synchronized void setAccessToken(String accessToken, String refreshToken,
6668
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
6769
}
6870

69-
public OAuth(String tokenUrl, String appSid, String appKey) {
70-
this.tokenUrl = tokenUrl;
71+
public OAuth(Configuration configuration, String appSid, String appKey) {
72+
this.tokenUrl = configuration.getApiBaseUrl();
7173
this.appSid = appSid;
7274
this.appKey = appKey;
7375

7476
this.httpClient = new OkHttpClient();
77+
this.httpClient.setConnectTimeout(configuration.getTimeout(), TimeUnit.MILLISECONDS);
78+
7579
this.json = new JSON();
7680
}
7781

src/main/java/com/groupdocs/cloud/viewer/model/CadOptions.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.google.gson.annotations.SerializedName;
3434
import com.google.gson.stream.JsonReader;
3535
import com.google.gson.stream.JsonWriter;
36+
import com.groupdocs.cloud.viewer.model.Tile;
3637
import io.swagger.annotations.ApiModel;
3738
import io.swagger.annotations.ApiModelProperty;
3839
import java.io.IOException;
@@ -62,6 +63,9 @@ public class CadOptions {
6263
@SerializedName("layers")
6364
private List<String> layers = null;
6465

66+
@SerializedName("tiles")
67+
private List<Tile> tiles = null;
68+
6569
public CadOptions scaleFactor(Double scaleFactor) {
6670
this.scaleFactor = scaleFactor;
6771
return this;
@@ -178,6 +182,32 @@ public void setLayers(List<String> layers) {
178182
this.layers = layers;
179183
}
180184

185+
public CadOptions tiles(List<Tile> tiles) {
186+
this.tiles = tiles;
187+
return this;
188+
}
189+
190+
public CadOptions addTilesItem(Tile tilesItem) {
191+
if (this.tiles == null) {
192+
this.tiles = new ArrayList<Tile>();
193+
}
194+
this.tiles.add(tilesItem);
195+
return this;
196+
}
197+
198+
/**
199+
* The coordinates of the drawing regions, that should be rendered. Please note, that this option works only for DWG format. When the list is empty, then whole drawing is rendered. When the list contains at least one tile, then ScaleFactor, Width, Height, RenderLayouts and LayoutName properties are ignored.
200+
* @return tiles
201+
**/
202+
@ApiModelProperty(value = "The coordinates of the drawing regions, that should be rendered. Please note, that this option works only for DWG format. When the list is empty, then whole drawing is rendered. When the list contains at least one tile, then ScaleFactor, Width, Height, RenderLayouts and LayoutName properties are ignored. ")
203+
public List<Tile> getTiles() {
204+
return tiles;
205+
}
206+
207+
public void setTiles(List<Tile> tiles) {
208+
this.tiles = tiles;
209+
}
210+
181211

182212
@Override
183213
public boolean equals(java.lang.Object o) {
@@ -193,12 +223,13 @@ public boolean equals(java.lang.Object o) {
193223
Objects.equals(this.height, cadOptions.height) &&
194224
Objects.equals(this.renderLayouts, cadOptions.renderLayouts) &&
195225
Objects.equals(this.layoutName, cadOptions.layoutName) &&
196-
Objects.equals(this.layers, cadOptions.layers);
226+
Objects.equals(this.layers, cadOptions.layers) &&
227+
Objects.equals(this.tiles, cadOptions.tiles);
197228
}
198229

199230
@Override
200231
public int hashCode() {
201-
return Objects.hash(scaleFactor, width, height, renderLayouts, layoutName, layers);
232+
return Objects.hash(scaleFactor, width, height, renderLayouts, layoutName, layers, tiles);
202233
}
203234

204235

@@ -213,6 +244,7 @@ public String toString() {
213244
sb.append(" renderLayouts: ").append(toIndentedString(renderLayouts)).append("\n");
214245
sb.append(" layoutName: ").append(toIndentedString(layoutName)).append("\n");
215246
sb.append(" layers: ").append(toIndentedString(layers)).append("\n");
247+
sb.append(" tiles: ").append(toIndentedString(tiles)).append("\n");
216248
sb.append("}");
217249
return sb.toString();
218250
}

0 commit comments

Comments
 (0)