Skip to content

Commit 0b5da64

Browse files
Merge pull request #2 from kaferi/master
PDFCLOUD-418, PDFCLOUD-419 Fix HTTPS connection
2 parents af2b1e5 + f7711f0 commit 0b5da64

File tree

5 files changed

+100
-166
lines changed

5 files changed

+100
-166
lines changed

.swagger-codegen-ignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ docs/*.*
2525
src/main/java/com/aspose/asposecloudpdfandroid/auth/*.*
2626
.gitignore
2727
git_push.sh
28-
gradlew.bat
2928
README.md
3029

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ apply plugin: 'idea'
2020
apply plugin: 'eclipse'
2121

2222
group = 'com.aspose'
23-
version = '18.4.0'
23+
version = '18.4.1'
2424

2525
buildscript {
2626
repositories {
@@ -43,7 +43,7 @@ apply plugin: 'com.novoda.bintray-release'
4343

4444
android {
4545
compileSdkVersion 27
46-
buildToolsVersion '27.0.1'
46+
buildToolsVersion '27.0.3'
4747
defaultConfig {
4848
minSdkVersion 19
4949
targetSdkVersion 27
@@ -96,7 +96,7 @@ dependencies {
9696
publish {
9797
groupId = 'com.aspose'
9898
artifactId = 'aspose-cloud-pdf-android'
99-
publishVersion = '18.4.0'
99+
publishVersion = '18.4.1'
100100
desc = 'Aspose.PDF for Cloud is a REST API for creating and editing PDF files. It can also be used to convert PDF files to different formats like DOC, HTML, XPS, TIFF and many more. Aspose.Pdf for Cloud gives you control: create PDFs from scratch or from HTML, XML, template, database, XPS or an image. Render PDFs to image formats such as JPEG, PNG, GIF, BMP, TIFF and many others. Aspose.Pdf for Cloud helps you manipulate elements of a PDF file like text, annotations, watermarks, signatures, bookmarks, stamps and so on. Its REST API also allows you to manage PDF pages by using features like merging, splitting, and inserting. Add images to a PDF file or convert PDF pages to images.'
101101
licences = ['MIT']
102102
website = 'https://products.aspose.cloud/pdf/cloud'

gradlew.bat

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12+
set DEFAULT_JVM_OPTS=
13+
14+
set DIRNAME=%~dp0
15+
if "%DIRNAME%" == "" set DIRNAME=.
16+
set APP_BASE_NAME=%~n0
17+
set APP_HOME=%DIRNAME%
18+
19+
@rem Find java.exe
20+
if defined JAVA_HOME goto findJavaFromJavaHome
21+
22+
set JAVA_EXE=java.exe
23+
%JAVA_EXE% -version >NUL 2>&1
24+
if "%ERRORLEVEL%" == "0" goto init
25+
26+
echo.
27+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28+
echo.
29+
echo Please set the JAVA_HOME variable in your environment to match the
30+
echo location of your Java installation.
31+
32+
goto fail
33+
34+
:findJavaFromJavaHome
35+
set JAVA_HOME=%JAVA_HOME:"=%
36+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37+
38+
if exist "%JAVA_EXE%" goto init
39+
40+
echo.
41+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42+
echo.
43+
echo Please set the JAVA_HOME variable in your environment to match the
44+
echo location of your Java installation.
45+
46+
goto fail
47+
48+
:init
49+
@rem Get command-line arguments, handling Windows variants
50+
51+
if not "%OS%" == "Windows_NT" goto win9xME_args
52+
if "%@eval[2+2]" == "4" goto 4NT_args
53+
54+
:win9xME_args
55+
@rem Slurp the command line arguments.
56+
set CMD_LINE_ARGS=
57+
set _SKIP=2
58+
59+
:win9xME_args_slurp
60+
if "x%~1" == "x" goto execute
61+
62+
set CMD_LINE_ARGS=%*
63+
goto execute
64+
65+
:4NT_args
66+
@rem Get arguments from the 4NT Shell from JP Software
67+
set CMD_LINE_ARGS=%$
68+
69+
:execute
70+
@rem Setup the command line
71+
72+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
74+
@rem Execute Gradle
75+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76+
77+
:end
78+
@rem End local scope for the variables with windows NT shell
79+
if "%ERRORLEVEL%"=="0" goto mainEnd
80+
81+
:fail
82+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83+
rem the _cmd.exe /c_ return code!
84+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85+
exit /b 1
86+
87+
:mainEnd
88+
if "%OS%"=="Windows_NT" endlocal
89+
90+
:omega

src/main/java/com/aspose/asposecloudpdfandroid/ApiClient.java

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ public class ApiClient {
8282
*/
8383
public ApiClient() {
8484
httpClient = new OkHttpClient();
85-
85+
// PDFCLOUD-419
86+
httpClient.setProtocols(Arrays.asList(Protocol.HTTP_1_1));
87+
8688

8789
json = new JSON();
8890

8991
// Set default User-Agent.
9092
setUserAgent("aspose pdf java sdk");
93+
94+
// PDFCLOUD-418 Set default Connect Timeout
95+
setConnectTimeout(5 * 60 * 1000);
9196
}
9297

9398
/**
@@ -586,10 +591,6 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
586591
contentType = "application/json";
587592
}
588593
if (isJsonMime(contentType)) {
589-
590-
//add class names
591-
respBody = addClassNames(respBody, returnType);
592-
593594
return json.deserialize(respBody, returnType);
594595
} else if (returnType.equals(String.class)) {
595596
// Expecting string, return the raw response body.
@@ -1071,67 +1072,6 @@ private void addOAuthAuthentication(Map<String, String> headerParams) throws Api
10711072
throw new ApiException(ex);
10721073
}
10731074
}
1074-
1075-
1076-
/**
1077-
* Add Class name to all Json Objects
1078-
*
1079-
* @param respBody original response json String
1080-
* @param returnType Type of according Response
1081-
*/
1082-
private String addClassNames(String respBody, Type returnType)
1083-
{
1084-
JsonParser jsonParser = new JsonParser();
1085-
JsonObject respJson = jsonParser.parse(respBody).getAsJsonObject();
1086-
addClassName(respJson, returnType);
1087-
return respJson.toString();
1088-
}
1089-
1090-
/**
1091-
* Recursively add Class name to Json Object
1092-
*
1093-
* @param jsonObj JsonObject
1094-
* @param objType Type of according DTO
1095-
*/
1096-
private void addClassName(JsonObject jsonObj, Type objType)
1097-
{
1098-
String fullClassName = ((Class)objType).getName();
1099-
String className = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
1100-
jsonObj.addProperty("_class_name", className);
1101-
1102-
for (String key : jsonObj.keySet())
1103-
{
1104-
if (jsonObj.get(key).isJsonObject())
1105-
{
1106-
try {
1107-
Method method = ((Class) objType).getMethod("get" + key);
1108-
addClassName(jsonObj.get(key).getAsJsonObject(), method.getReturnType());
1109-
} catch (NoSuchMethodException e) {
1110-
e.printStackTrace();
1111-
}
1112-
}
1113-
else if (jsonObj.get(key).isJsonArray())
1114-
{
1115-
try
1116-
{
1117-
Method method = ((Class) objType).getMethod("get" + key);
1118-
ParameterizedType pType = (ParameterizedType) method.getGenericReturnType();
1119-
Class<?> pClass = (Class<?>) pType.getActualTypeArguments()[0];
1120-
1121-
for (JsonElement el : jsonObj.get(key).getAsJsonArray())
1122-
{
1123-
if (el.isJsonObject())
1124-
{
1125-
addClassName(el.getAsJsonObject(), pClass);
1126-
}
1127-
}
1128-
1129-
} catch (NoSuchMethodException e) {
1130-
e.printStackTrace();
1131-
}
1132-
}
1133-
}
1134-
}
11351075

11361076

11371077
/**

src/main/java/com/aspose/asposecloudpdfandroid/JSON.java

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -57,102 +57,7 @@ public class JSON {
5757
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
5858

5959
public static GsonBuilder createGson() {
60-
GsonFireBuilder fireBuilder = new GsonFireBuilder()
61-
.registerTypeSelector(LinkElement.class, new TypeSelector() {
62-
@Override
63-
public Class getClassForElement(JsonElement readElement) {
64-
Map classByDiscriminatorValue = new HashMap();
65-
classByDiscriminatorValue.put("Annotation".toUpperCase(), Annotation.class);
66-
classByDiscriminatorValue.put("Annotations".toUpperCase(), Annotations.class);
67-
classByDiscriminatorValue.put("Attachment".toUpperCase(), Attachment.class);
68-
classByDiscriminatorValue.put("Attachments".toUpperCase(), Attachments.class);
69-
classByDiscriminatorValue.put("Document".toUpperCase(), Document.class);
70-
classByDiscriminatorValue.put("DocumentProperties".toUpperCase(), DocumentProperties.class);
71-
classByDiscriminatorValue.put("DocumentProperty".toUpperCase(), DocumentProperty.class);
72-
classByDiscriminatorValue.put("Field".toUpperCase(), Field.class);
73-
classByDiscriminatorValue.put("Fields".toUpperCase(), Fields.class);
74-
classByDiscriminatorValue.put("Image".toUpperCase(), Image.class);
75-
classByDiscriminatorValue.put("Images".toUpperCase(), Images.class);
76-
classByDiscriminatorValue.put("LinkAnnotation".toUpperCase(), LinkAnnotation.class);
77-
classByDiscriminatorValue.put("LinkAnnotations".toUpperCase(), LinkAnnotations.class);
78-
classByDiscriminatorValue.put("Page".toUpperCase(), Page.class);
79-
classByDiscriminatorValue.put("Pages".toUpperCase(), Pages.class);
80-
classByDiscriminatorValue.put("TextFormat".toUpperCase(), TextFormat.class);
81-
classByDiscriminatorValue.put("TextItem".toUpperCase(), TextItem.class);
82-
classByDiscriminatorValue.put("TextItems".toUpperCase(), TextItems.class);
83-
classByDiscriminatorValue.put("LinkElement".toUpperCase(), LinkElement.class);
84-
return getClassByDiscriminator(
85-
classByDiscriminatorValue,
86-
getDiscriminatorValue(readElement, "_class_name"));
87-
}
88-
})
89-
.registerTypeSelector(SaaSposeResponse.class, new TypeSelector() {
90-
@Override
91-
public Class getClassForElement(JsonElement readElement) {
92-
Map classByDiscriminatorValue = new HashMap();
93-
classByDiscriminatorValue.put("AnnotationResponse".toUpperCase(), AnnotationResponse.class);
94-
classByDiscriminatorValue.put("AnnotationsResponse".toUpperCase(), AnnotationsResponse.class);
95-
classByDiscriminatorValue.put("AttachmentResponse".toUpperCase(), AttachmentResponse.class);
96-
classByDiscriminatorValue.put("AttachmentsResponse".toUpperCase(), AttachmentsResponse.class);
97-
classByDiscriminatorValue.put("DocumentPagesResponse".toUpperCase(), DocumentPagesResponse.class);
98-
classByDiscriminatorValue.put("DocumentPropertiesResponse".toUpperCase(), DocumentPropertiesResponse.class);
99-
classByDiscriminatorValue.put("DocumentPropertyResponse".toUpperCase(), DocumentPropertyResponse.class);
100-
classByDiscriminatorValue.put("DocumentResponse".toUpperCase(), DocumentResponse.class);
101-
classByDiscriminatorValue.put("FieldResponse".toUpperCase(), FieldResponse.class);
102-
classByDiscriminatorValue.put("FieldsResponse".toUpperCase(), FieldsResponse.class);
103-
classByDiscriminatorValue.put("ImageResponse".toUpperCase(), ImageResponse.class);
104-
classByDiscriminatorValue.put("ImagesResponse".toUpperCase(), ImagesResponse.class);
105-
classByDiscriminatorValue.put("LinkAnnotationResponse".toUpperCase(), LinkAnnotationResponse.class);
106-
classByDiscriminatorValue.put("LinkAnnotationsResponse".toUpperCase(), LinkAnnotationsResponse.class);
107-
classByDiscriminatorValue.put("SignatureVerifyResponse".toUpperCase(), SignatureVerifyResponse.class);
108-
classByDiscriminatorValue.put("SplitResultResponse".toUpperCase(), SplitResultResponse.class);
109-
classByDiscriminatorValue.put("TextFormatResponse".toUpperCase(), TextFormatResponse.class);
110-
classByDiscriminatorValue.put("TextItemResponse".toUpperCase(), TextItemResponse.class);
111-
classByDiscriminatorValue.put("TextItemsResponse".toUpperCase(), TextItemsResponse.class);
112-
classByDiscriminatorValue.put("TextRectsResponse".toUpperCase(), TextRectsResponse.class);
113-
classByDiscriminatorValue.put("TextReplaceResponse".toUpperCase(), TextReplaceResponse.class);
114-
classByDiscriminatorValue.put("WordCountResponse".toUpperCase(), WordCountResponse.class);
115-
classByDiscriminatorValue.put("SaaSposeResponse".toUpperCase(), SaaSposeResponse.class);
116-
return getClassByDiscriminator(
117-
classByDiscriminatorValue,
118-
getDiscriminatorValue(readElement, "_class_name"));
119-
}
120-
})
121-
.registerTypeSelector(Link.class, new TypeSelector() {
122-
@Override
123-
public Class getClassForElement(JsonElement readElement) {
124-
Map classByDiscriminatorValue = new HashMap();
125-
classByDiscriminatorValue.put("SplitResultDocument".toUpperCase(), SplitResultDocument.class);
126-
classByDiscriminatorValue.put("Link".toUpperCase(), Link.class);
127-
return getClassByDiscriminator(
128-
classByDiscriminatorValue,
129-
getDiscriminatorValue(readElement, "_class_name"));
130-
}
131-
})
132-
.registerTypeSelector(TextReplace.class, new TypeSelector() {
133-
@Override
134-
public Class getClassForElement(JsonElement readElement) {
135-
Map classByDiscriminatorValue = new HashMap();
136-
classByDiscriminatorValue.put("TextReplaceRequest".toUpperCase(), TextReplaceRequest.class);
137-
classByDiscriminatorValue.put("TextReplace".toUpperCase(), TextReplace.class);
138-
return getClassByDiscriminator(
139-
classByDiscriminatorValue,
140-
getDiscriminatorValue(readElement, "_class_name"));
141-
}
142-
})
143-
.registerTypeSelector(TextReplaceResponse.class, new TypeSelector() {
144-
@Override
145-
public Class getClassForElement(JsonElement readElement) {
146-
Map classByDiscriminatorValue = new HashMap();
147-
classByDiscriminatorValue.put("DocumentTextReplaceResponse".toUpperCase(), DocumentTextReplaceResponse.class);
148-
classByDiscriminatorValue.put("PageTextReplaceResponse".toUpperCase(), PageTextReplaceResponse.class);
149-
classByDiscriminatorValue.put("TextReplaceResponse".toUpperCase(), TextReplaceResponse.class);
150-
return getClassByDiscriminator(
151-
classByDiscriminatorValue,
152-
getDiscriminatorValue(readElement, "_class_name"));
153-
}
154-
})
155-
;
60+
GsonFireBuilder fireBuilder = new GsonFireBuilder();
15661
return fireBuilder.createGsonBuilder();
15762
}
15863

0 commit comments

Comments
 (0)