Skip to content

Commit

Permalink
658 - SF
Browse files Browse the repository at this point in the history
  • Loading branch information
ivicac committed Sep 19, 2024
1 parent 9b4a2e0 commit 3cc10f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,12 @@ private DropboxUploadFileAction() {
public static Object perform(
Parameters inputParameters, Parameters connectionParameters, ActionContext actionContext) {

String destination = inputParameters.getRequiredString(PATH);

String headerJson = actionContext.json(json -> {
Map<String, Object> ime = Map.of(
AUTORENAME, inputParameters.getBoolean(AUTORENAME),
"mode", "add",
MUTE, inputParameters.getBoolean(MUTE),
PATH,
(destination.endsWith("/") ? destination : destination + "/")
+ inputParameters.getRequiredString(FILENAME),
PATH, getPath(inputParameters, inputParameters.getRequiredString(PATH)),
STRICT_CONFLICT, inputParameters.getBoolean(STRICT_CONFLICT));
return json.write(ime);
});
Expand All @@ -158,4 +154,9 @@ public static Object perform(
.execute()
.getBody(new TypeReference<>() {});
}

private static String getPath(Parameters inputParameters, String destination) {
return (destination.endsWith("/")
? destination : destination + "/") + inputParameters.getRequiredString(FILENAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ HttpClient createHttpClient(
try {
SSLContext sslContext = SSLContext.getInstance("TLS");

sslContext.init(null, new TrustManager[] {
new UnauthorizedCertsX509ExtendedTrustManager()
}, null);
sslContext.init(
null, new TrustManager[] {
new UnauthorizedCertsX509ExtendedTrustManager()
},
null);

builder.sslContext(sslContext);
} catch (Exception e) {
Expand Down Expand Up @@ -236,8 +238,7 @@ HttpRequest createHTTPRequest(
Map<String, List<String>> queryParameters, Body body, String componentName,
ComponentConnection componentConnection, Context context) {

HttpRequest.Builder httpRequestBuilder = HttpRequest
.newBuilder()
HttpRequest.Builder httpRequestBuilder = HttpRequest.newBuilder()
.method(requestMethod.name(), createBodyPublisher(body));

for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
Expand Down Expand Up @@ -449,8 +450,7 @@ private BodyPublisher getStringBodyPublisher(Body body) {
Object content = body.getContent();

return MoreBodyPublishers.ofMediaType(
BodyPublishers.ofString(content.toString()),
MediaType.parse(body.getMimeType()));
BodyPublishers.ofString(content.toString()), MediaType.parse(body.getMimeType()));
}

private BodyPublisher getXmlBodyPublisher(Body body) {
Expand Down Expand Up @@ -493,7 +493,7 @@ private FileEntry storeBinaryResponseBody(
return new FileEntryImpl(filesFileStorage.storeFileContent(filename, httpResponseBody));
}

private class ResponseImpl implements Response {
private static class ResponseImpl implements Response {

private final Map<String, List<String>> headers;
private final Object body;
Expand Down Expand Up @@ -550,6 +550,7 @@ public int getStatusCode() {
}

private static class UnauthorizedCertsX509ExtendedTrustManager extends X509ExtendedTrustManager {

public X509Certificate[] getAcceptedIssuers() {
return null;
}
Expand Down

0 comments on commit 3cc10f7

Please sign in to comment.