Skip to content

Commit 157584e

Browse files
committed
Updated sources
1 parent 415b2ad commit 157584e

42 files changed

Lines changed: 770 additions & 187 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ hs_err_pid*
1515
**/target
1616
target
1717
build
18+
19+
.settings/
20+
.classpath
21+
.project

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.7</version>
40+
<version>18.11</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.7.jar
53+
* target/groupdocs-viewer-cloud-18.11.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.7</version>
8+
<version>18.11</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>

resources/email/outlook/sample.pst

265 KB
Binary file not shown.

resources/image/nasa.cgm

98.4 KB
Binary file not shown.

resources/print/print.pcl

681 KB
Binary file not shown.

resources/print/sample.ps

197 Bytes
Binary file not shown.

resources/project/mpp/sample.mpp

283 KB
Binary file not shown.

src/main/java/com/groupdocs/cloud/viewer/api/ViewerApi.java

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,59 +27,53 @@
2727

2828
package com.groupdocs.cloud.viewer.api;
2929

30-
import com.groupdocs.cloud.viewer.client.ApiCallback;
31-
import com.groupdocs.cloud.viewer.client.ApiClient;
32-
import com.groupdocs.cloud.viewer.client.ApiException;
33-
import com.groupdocs.cloud.viewer.client.ApiResponse;
34-
import com.groupdocs.cloud.viewer.client.Configuration;
35-
import com.groupdocs.cloud.viewer.client.Pair;
36-
import com.groupdocs.cloud.viewer.client.ProgressRequestBody;
37-
import com.groupdocs.cloud.viewer.client.ProgressResponseBody;
38-
39-
import com.google.gson.reflect.TypeToken;
40-
41-
import java.io.IOException;
42-
43-
44-
import com.groupdocs.cloud.viewer.model.AttachmentCollection;
45-
import com.groupdocs.cloud.viewer.model.DocumentInfo;
46-
import com.groupdocs.cloud.viewer.model.DocumentInfoOptions;
4730
import java.io.File;
48-
import com.groupdocs.cloud.viewer.model.FontCollection;
49-
import com.groupdocs.cloud.viewer.model.FormatCollection;
50-
import com.groupdocs.cloud.viewer.model.HtmlAttachmentPageCollection;
51-
import com.groupdocs.cloud.viewer.model.HtmlOptions;
52-
import com.groupdocs.cloud.viewer.model.HtmlPageCollection;
53-
import com.groupdocs.cloud.viewer.model.ImageAttachmentPageCollection;
54-
import com.groupdocs.cloud.viewer.model.ImageOptions;
55-
import com.groupdocs.cloud.viewer.model.ImagePageCollection;
56-
import com.groupdocs.cloud.viewer.model.PageInfoCollection;
57-
import com.groupdocs.cloud.viewer.model.PdfFileInfo;
58-
import com.groupdocs.cloud.viewer.model.PdfFileOptions;
59-
import com.groupdocs.cloud.viewer.model.TransformOptionsBase;
60-
import com.groupdocs.cloud.viewer.model.requests.*;
61-
31+
import java.io.IOException;
6232
import java.lang.reflect.Type;
6333
import java.util.ArrayList;
6434
import java.util.HashMap;
6535
import java.util.List;
6636
import java.util.Map;
6737

38+
import com.google.gson.reflect.TypeToken;
39+
import com.groupdocs.cloud.viewer.client.*;
40+
import com.groupdocs.cloud.viewer.model.*;
41+
import com.groupdocs.cloud.viewer.model.requests.*;
42+
6843
public class ViewerApi {
6944
private ApiClient apiClient;
7045

46+
/**
47+
* Initializes new instance of ViewerApi
48+
* @param appSid Application identifier (App SID)
49+
* @param appKey Application private key (App Key)
50+
*/
7151
public ViewerApi(String appSid, String appKey) {
7252
this(new Configuration(appSid, appKey));
7353
}
7454

55+
/**
56+
* Initializes new instance of ViewerApi
57+
* @param configuration Configuration The configuration
58+
*/
7559
public ViewerApi(Configuration configuration) {
7660
this.apiClient = new ApiClient(configuration);
7761
}
7862

63+
/**
64+
* Gets ApiClient
65+
*
66+
* @return ApiClient The Api client
67+
*/
7968
public ApiClient getApiClient() {
8069
return apiClient;
8170
}
8271

72+
/**
73+
* Sets ApiClient
74+
*
75+
* @param apiClient The Api client
76+
*/
8377
public void setApiClient(ApiClient apiClient) {
8478
this.apiClient = apiClient;
8579
}

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

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import com.groupdocs.cloud.viewer.client.auth.Authentication;
6464
import com.groupdocs.cloud.viewer.client.auth.OAuth;
6565
import com.groupdocs.cloud.viewer.model.ApiError;
66+
import com.groupdocs.cloud.viewer.model.AuthError;
6667

6768
public class ApiClient {
6869
private Configuration configuration = null;
@@ -96,10 +97,13 @@ public ApiClient(Configuration configuration) {
9697
this.json = new JSON();
9798

9899
// Set default User-Agent.
99-
setUserAgent("java-sdk/18.7");
100+
setUserAgent("java-sdk/18.11");
100101

101102
// Set connection timeout
102103
setConnectTimeout(configuration.getTimeout());
104+
105+
// Set read timeout
106+
setReadTimeout(configuration.getTimeout());
103107

104108
// Setup authentications (key: authentication name, value: authentication).
105109
this.authentications = new HashMap<String, Authentication>();
@@ -112,7 +116,7 @@ public ApiClient(Configuration configuration) {
112116
}
113117

114118
/**
115-
* Get server URL, default value is https://api.groupdocs.cloud/v1
119+
* Get server URL, default value is http://api.groupdocs.cloud/v1
116120
*
117121
* @return Server URL
118122
*/
@@ -657,10 +661,8 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
657661
return (T) respBody;
658662
} else {
659663
throw new ApiException(
660-
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
661-
response.code(),
662-
response.headers().toMultimap(),
663-
respBody);
664+
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
665+
response.code());
664666
}
665667
}
666668

@@ -849,28 +851,45 @@ public <T> T handleResponse(Response response, Type returnType) throws ApiExcept
849851
try {
850852
response.body().close();
851853
} catch (IOException e) {
852-
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
854+
throw new ApiException(response.message(), response.code());
853855
}
854856
}
855857
return null;
856858
} else {
857859
return deserialize(response, returnType);
858860
}
859861
} else {
860-
String respBody = null;
861-
ApiError apiError = null;
862862
if (response.body() != null) {
863+
String respBody;
864+
863865
try {
864-
apiError = deserialize(response, ApiError.class);
865-
} catch (ApiException e) {
866-
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
866+
respBody = response.body().string();
867+
} catch (Exception e) {
868+
throw new ApiException(response.message(), response.code());
867869
}
868-
869-
if(apiError != null && apiError.getError() != null){
870-
throw new ApiException(apiError.getError().getMessage(), response.code(), response.headers().toMultimap(), respBody);
871-
}
872-
}
873-
throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody);
870+
871+
ApiError apiError = null;
872+
try {
873+
apiError = json.deserialize(respBody, ApiError.class);
874+
} catch (Exception e) {
875+
//NOTE: ignore
876+
}
877+
if(apiError != null && apiError.getError() != null) {
878+
throw new ApiException(apiError.getError().getMessage(), response.code());
879+
}
880+
881+
AuthError authError = null;
882+
try {
883+
authError = json.deserialize(respBody, AuthError.class);
884+
} catch (Exception e) {
885+
//NOTE: ignore
886+
}
887+
if(authError != null && authError.getErrorMessage() != null) {
888+
throw new ApiException(authError.getErrorMessage(), response.code());
889+
}
890+
}
891+
892+
throw new ApiException(response.message(), response.code());
874893
}
875894
}
876895

0 commit comments

Comments
 (0)