Skip to content

Commit 859c4e6

Browse files
Merge branch 'master' into release
2 parents 2a0503b + 6bdb771 commit 859c4e6

File tree

402 files changed

+2342
-3367
lines changed

Some content is hidden

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

402 files changed

+2342
-3367
lines changed

Jenkinsfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
parameters {
2-
string(name: 'branch', defaultValue: 'master', description: 'branch to test')
3-
string(name: 'testServerUrl', defaultValue: 'https://api-qa.aspose.cloud', description: 'server url')
4-
}
1+
properties([
2+
gitLabConnection('gitlab'),
3+
[$class: 'ParametersDefinitionProperty',
4+
parameterDefinitions: [
5+
[$class: 'StringParameterDefinition', name: 'branch', defaultValue: 'master', description: 'the branch to build'],
6+
[$class: 'StringParameterDefinition', name: 'apiUrl', defaultValue: 'https://api-qa.aspose.cloud', description: 'api url'],
7+
[$class: 'BooleanParameterDefinition', name: 'debugMode', defaultValue: 'false', description: 'debug mode']
8+
]
9+
]
10+
])
511

612
def runtests(directory)
713
{
@@ -11,7 +17,7 @@ def runtests(directory)
1117
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-java.git']]])
1218
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
1319
sh 'mkdir -p Settings'
14-
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\", \\"BaseUrl\\": \\"$testServerUrl\\"}" > Settings/servercreds.json'
20+
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\", \\"BaseUrl\\": \\"$apiUrl\\", \\"Debug\\" : \\"$debugMode\\" }}" > Settings/servercreds.json'
1521
}
1622
}
1723

README.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This repository contains Aspose.Words Cloud SDK for Java source code. This SDK a
1414
* Full read & write access to Document Object Model, including sections, paragraphs, text, images, tables, headers/footers and many others
1515

1616
## How to use the SDK?
17-
The complete source code is available in this repository folder. You can either directly use it in your project via source code or get [Maven](https://mvnrepository.com/artifact/com.aspose/aspose-cloud-words) (recommended). For more details, please visit our [documentation website](https://docs.aspose.cloud/display/wordscloud/Available+SDKs).
17+
The complete source code is available in this repository folder. You can either directly use it in your project via source code or get [Maven](https://repository.aspose.cloud/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-words-cloud) (recommended). For more details, please visit our [documentation website](https://docs.aspose.cloud/display/wordscloud/Available+SDKs).
1818

1919
### Prerequisites
2020

@@ -33,15 +33,10 @@ Add this dependency to your project's POM:
3333
</repositories>
3434

3535
<dependencies>
36-
<dependency>
37-
<groupId>com.aspose</groupId>
38-
<artifactId>aspose-cloud-storage</artifactId>
39-
<version>1.0.1</version>
40-
</dependency>
4136
<dependency>
4237
<groupId>com.aspose</groupId>
4338
<artifactId>aspose-words-cloud</artifactId>
44-
<version>18.9.0</version>
39+
<version>20.3.0</version>
4540
</dependency>
4641
</dependencies>
4742
```
@@ -50,32 +45,30 @@ Add this dependency to your project's POM:
5045

5146
```java
5247

53-
import com.aspose.words.*;
54-
import com.aspose.words.auth.*;
55-
import com.aspose.words.model.*;
56-
import com.aspose.words.api.WordsApi;
48+
import com.aspose.words.cloud.ApiException;
49+
import com.aspose.words.cloud.api.WordsApi;
50+
import com.aspose.words.cloud.model.DocumentResponse;
51+
import com.aspose.words.cloud.model.requests.DeleteWatermarkRequest;
5752

58-
import java.io.File;
59-
import java.util.*;
53+
import java.io.IOException;
6054

6155
public class WordsApiExample {
6256

63-
public static void main(String[] args) {
64-
65-
WordsApi wordsApi = new WordsApi();
57+
public static void main(String[] args) throws ApiException, IOException {
58+
// write your code here
59+
WordsApi wordsApi = new WordsApi("appSid", "appKey", null);
6660
String remoteName = "TestDeleteDocumentWatermark.docx";
67-
String remoteFolder = "TestFolder"
68-
DeleteDocumentWatermarkRequest request = new DeleteDocumentWatermarkRequest(remoteName,
61+
String remoteFolder = "TestFolder";
62+
DeleteWatermarkRequest request = new DeleteWatermarkRequest(remoteName,
6963
remoteFolder, null, null, null, null, null, null);
7064

71-
DocumentResponse result = wordsApi.deleteDocumentWatermark(request);
65+
DocumentResponse result = wordsApi.deleteWatermark(request);
7266
}
7367
}
7468

7569
```
7670

77-
[Test](src/test/java/com/aspose/words) contain various examples of using the SDK.
78-
Please put your credentials into [ApiClient](src/main/java/com/aspose/words/ApiClient.java).
71+
[Test](src/test/java/com/aspose/words/cloud) contain various examples of using the SDK.
7972

8073
## Dependencies
8174
- Java 1.7+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<artifactId>aspose-words-cloud</artifactId>
55
<packaging>jar</packaging>
66
<name>AsposeWordsCloud</name>
7-
<version>20.1.0</version>
7+
<version>20.3.0</version>
88
<url>https://www.aspose.cloud/</url>
99
<description>Aspose Words Java SDK</description>
1010
<scm>

src/main/java/com/aspose/words/cloud/ApiCallback.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
package com.aspose.words.cloud;
2929

30-
import java.io.IOException;
31-
3230
import java.util.Map;
3331
import java.util.List;
3432

src/main/java/com/aspose/words/cloud/ApiClient.java

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
*/
2727
package com.aspose.words.cloud;
2828

29-
import com.google.gson.JsonElement;
30-
import com.google.gson.JsonObject;
31-
import com.google.gson.JsonParser;
3229
import com.squareup.okhttp.*;
3330
import com.squareup.okhttp.internal.http.HttpMethod;
3431
import com.squareup.okhttp.logging.HttpLoggingInterceptor;
@@ -37,29 +34,11 @@
3734
import okio.Okio;
3835
import org.threeten.bp.LocalDate;
3936
import org.threeten.bp.OffsetDateTime;
40-
import org.threeten.bp.format.DateTimeFormatter;
41-
42-
import javax.net.ssl.*;
43-
44-
import java.io.Console;
45-
import java.io.File;
46-
import java.io.IOException;
47-
import java.io.InputStream;
48-
import java.io.UnsupportedEncodingException;
49-
import java.lang.reflect.Field;
50-
import java.lang.reflect.Method;
51-
import java.lang.reflect.ParameterizedType;
37+
38+
import java.io.*;
5239
import java.lang.reflect.Type;
5340
import java.net.URLConnection;
5441
import java.net.URLEncoder;
55-
import java.security.GeneralSecurityException;
56-
import java.security.KeyStore;
57-
import java.security.SecureRandom;
58-
import java.security.cert.Certificate;
59-
import java.security.cert.CertificateException;
60-
import java.security.cert.CertificateFactory;
61-
import java.security.cert.X509Certificate;
62-
import java.text.DateFormat;
6342
import java.util.*;
6443
import java.util.Map.Entry;
6544
import java.util.concurrent.TimeUnit;
@@ -71,7 +50,7 @@ public class ApiClient {
7150
private String apiVersion = "v4.0";
7251
private String baseUrl = "https://api.aspose.cloud";
7352
private String basePath = baseUrl + "/" + apiVersion;
74-
private String clientVersion = "19.10.0";
53+
private String clientVersion = "20.3.0";
7554
private boolean debugging = false;
7655
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
7756
private String tempFolderPath = null;
@@ -85,6 +64,15 @@ public class ApiClient {
8564
private String refreshToken;
8665
private String appKey;
8766
private String appSid;
67+
68+
public ApiClient(String appSid, String appKey, String baseUrl) {
69+
this();
70+
this.appSid = appSid;
71+
this.appKey = appKey;
72+
if (baseUrl != null) {
73+
this.setBaseUrl(baseUrl);
74+
}
75+
}
8876

8977
/*
9078
* Constructor for ApiClient
@@ -194,7 +182,7 @@ public ApiClient setBaseUrl(String baseUrl) {
194182
*/
195183
public ApiClient setBasePath(String basePath) {
196184
this.basePath = basePath;
197-
this.baseUrl = basePath.replace("/v4.0", "");
185+
this.baseUrl = basePath.replace("/v1.1", "").replace("/v1", "").replace("/v2", "").replace("/v3", "");
198186
return this;
199187
}
200188

@@ -893,7 +881,7 @@ public <T> T handleResponse(Response response, Type returnType) throws ApiExcept
893881
* @return The HTTP call
894882
* @throws ApiException If fail to serialize the request body object
895883
*/
896-
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
884+
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException, IOException {
897885
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener);
898886

899887
return httpClient.newCall(request);
@@ -914,7 +902,7 @@ public Call buildCall(String path, String method, List<Pair> queryParams, List<P
914902
* @return The HTTP request
915903
* @throws ApiException If fail to serialize the request body object
916904
*/
917-
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
905+
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException, IOException {
918906
addOAuthAuthentication(headerParams);
919907
final String url = buildUrl(path, queryParams, collectionQueryParams);
920908
final Request.Builder reqBuilder = new Request.Builder().url(url);
@@ -1052,12 +1040,12 @@ public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams)
10521040
* @param formParams Form parameters in the form of Map
10531041
* @return RequestBody
10541042
*/
1055-
public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
1043+
public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) throws IOException {
10561044
MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM);
10571045
for (Entry<String, Object> param : formParams.entrySet()) {
1058-
if (param.getValue() instanceof File) {
1059-
File file = (File) param.getValue();
1060-
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
1046+
if (param.getValue() instanceof byte[]) {
1047+
byte[] file = (byte[]) param.getValue();
1048+
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + param.getKey() + "\"");
10611049
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
10621050
mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file));
10631051
}
@@ -1075,8 +1063,8 @@ public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
10751063
* @param file The given file
10761064
* @return The guessed Content-Type
10771065
*/
1078-
public String guessContentTypeFromFile(File file) {
1079-
String contentType = URLConnection.guessContentTypeFromName(file.getName());
1066+
public String guessContentTypeFromFile(byte[] file) throws IOException {
1067+
String contentType = URLConnection.guessContentTypeFromStream(new ByteArrayInputStream(file));
10801068
if (contentType == null) {
10811069
return "application/octet-stream";
10821070
}
@@ -1087,7 +1075,7 @@ public String guessContentTypeFromFile(File file) {
10871075

10881076
/**
10891077
* Request OAuth token
1090-
* @throws ApiException If fails to authorize
1078+
@throw ApiException If authorization is failed
10911079
*/
10921080
public void requestToken() throws ApiException {
10931081
try {
@@ -1131,6 +1119,5 @@ private void addOAuthAuthentication(Map<String, String> headerParams) throws Api
11311119
*/
11321120
private class GetAccessTokenResult {
11331121
public String access_token;
1134-
public String refresh_token;
11351122
}
11361123
}

src/main/java/com/aspose/words/cloud/ApiException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ public ApiException(int code, String message, Map<String, List<String>> response
8585
}
8686

8787
private void setInnerError() {
88-
if (!responseBody.startsWith("{")) return;
88+
if (!responseBody.contains("Error") || !responseBody.startsWith("{")) return;
8989
JsonElement elem = new JsonParser().parse(responseBody);
9090
this.innerError = new JSON().deserialize(
91-
elem.getAsJsonObject().get("Error").toString(),
92-
ApiError.class);
91+
elem.getAsJsonObject().get("Error").toString(),
92+
ApiError.class);
9393
}
94+
9495
/**
9596
* Get the HTTP status code.
9697
*

src/main/java/com/aspose/words/cloud/JSON.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.google.gson.stream.JsonWriter;
3737
import com.google.gson.JsonElement;
3838
import io.gsonfire.GsonFireBuilder;
39-
import io.gsonfire.TypeSelector;
4039
import org.threeten.bp.LocalDate;
4140
import org.threeten.bp.OffsetDateTime;
4241
import org.threeten.bp.ZoneOffset;
@@ -51,12 +50,8 @@
5150
import java.text.DateFormat;
5251
import java.text.ParseException;
5352
import java.text.ParsePosition;
54-
import java.text.SimpleDateFormat;
55-
import java.util.Calendar;
5653
import java.util.Date;
57-
import java.util.GregorianCalendar;
5854
import java.util.Map;
59-
import java.util.HashMap;
6055

6156
public class JSON {
6257
private Gson gson;

0 commit comments

Comments
 (0)