You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/10/13 14:27:07 UTC
[camel] 02/02: CAMEL-16484: camel-dropbox - Bump to Dropbox 5.4.2
This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch CAMEL-16484/dropbox-v5
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3713489e8c40bfaa245180f4257a242f4cfd72b7
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Thu Oct 13 16:26:24 2022 +0200
CAMEL-16484: camel-dropbox - Bump to Dropbox 5.4.2
---
camel-dependencies/pom.xml | 2 +-
.../apache/camel/component/dropbox/dropbox.json | 2 +-
.../src/main/docs/dropbox-component.adoc | 9 +-
.../dropbox/DropboxComponentVerifierExtension.java | 5 +-
.../component/dropbox/DropboxConfiguration.java | 2 +-
.../component/dropbox/core/DropboxAPIFacade.java | 109 +++++++++------------
.../component/dropbox/dto/DropboxSearchResult.java | 8 +-
.../consumer/DropboxScheduledPollConsumer.java | 4 +-
.../DropboxScheduledPollSearchConsumer.java | 10 +-
.../integration/producer/DropboxGetProducer.java | 4 +-
.../integration/producer/DropboxProducer.java | 8 +-
.../integration/producer/DropboxPutProducer.java | 4 +-
.../producer/DropboxSearchProducer.java | 10 +-
.../dropbox/integration/DropboxTestSupport.java | 17 ++--
parent/pom.xml | 2 +-
15 files changed, 88 insertions(+), 108 deletions(-)
diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 0650428be3a..7961773bdec 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -174,7 +174,7 @@
<dnsjava-version>3.5.1</dnsjava-version>
<docker-java-version>3.2.13</docker-java-version>
<dozer-version>6.5.2</dozer-version>
- <dropbox-version>3.2.0</dropbox-version>
+ <dropbox-version>5.4.2</dropbox-version>
<eddsa-version>0.3.0</eddsa-version>
<egit-github-core-version>2.1.5</egit-github-core-version>
<ehcache3-version>3.10.1</ehcache3-version>
diff --git a/components/camel-dropbox/src/generated/resources/org/apache/camel/component/dropbox/dropbox.json b/components/camel-dropbox/src/generated/resources/org/apache/camel/component/dropbox/dropbox.json
index 03f023a154c..626adb07be2 100644
--- a/components/camel-dropbox/src/generated/resources/org/apache/camel/component/dropbox/dropbox.json
+++ b/components/camel-dropbox/src/generated/resources/org/apache/camel/component/dropbox/dropbox.json
@@ -53,7 +53,7 @@
"newRemotePath": { "kind": "parameter", "displayName": "New Remote Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "Destination file or folder" },
"uploadMode": { "kind": "parameter", "displayName": "Upload Mode", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.dropbox.util.DropboxUploadMode", "enum": [ "add", "force" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "Which mode to upload. in case of add the new fi [...]
"lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may other [...]
- "client": { "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.dropbox.core.v2.DbxClientV2", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "To use an existing DbxClient instance as DropBox client." },
+ "client": { "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.dropbox.core.v2.DbxClientV2", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "To use an existing DbxClient instance as Dropbox client." },
"accessToken": { "kind": "parameter", "displayName": "Access Token", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "The access token to make API requests for a specific Dropbox user" },
"apiKey": { "kind": "parameter", "displayName": "Api Key", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "The apiKey to make API requests for a specific Dropbox user" },
"apiSecret": { "kind": "parameter", "displayName": "Api Secret", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dropbox.DropboxConfiguration", "configurationField": "configuration", "description": "The apiSecret to make API requests for a specific Dropbox user" },
diff --git a/components/camel-dropbox/src/main/docs/dropbox-component.adoc b/components/camel-dropbox/src/main/docs/dropbox-component.adoc
index c62480acb8d..608a49f9c3a 100644
--- a/components/camel-dropbox/src/main/docs/dropbox-component.adoc
+++ b/components/camel-dropbox/src/main/docs/dropbox-component.adoc
@@ -335,13 +335,8 @@ The following objects are set on message body result:
|===
|Object type |Description
-|`List<DbxEntry>` |list of file path founded. For more information on this object refer to
-Dropbox documentation,
+|`List<com.dropbox.core.v2.files.SearchMatchV2>` |list of file path founded. For more information on this object refer to
+https://javadoc.io/doc/com.dropbox.core/dropbox-core-sdk/latest/com/dropbox/core/v2/files/SearchMatchV2.html[Dropbox documentation].
|===
-
-
-
-
-
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java
index cd3bc740b83..a993eec2902 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java
@@ -64,10 +64,11 @@ public class DropboxComponentVerifierExtension extends DefaultComponentVerifierE
try {
// Create Dropbox client
- DbxRequestConfig config = new DbxRequestConfig(clientId, Locale.getDefault().toString());
+ DbxRequestConfig config = DbxRequestConfig.newBuilder(clientId)
+ .withUserLocaleFrom(Locale.getDefault())
+ .build();
DbxClientV2 client = new DbxClientV2(config, token);
client.users().getCurrentAccount();
- client = null;
} catch (Exception e) {
builder.error(ResultErrorBuilder
.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION,
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxConfiguration.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxConfiguration.java
index 45dd768de62..67020218fe9 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxConfiguration.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxConfiguration.java
@@ -74,7 +74,7 @@ public class DropboxConfiguration {
private DbxClientV2 client;
/**
- * To use an existing DbxClient instance as DropBox client.
+ * To use an existing DbxClient instance as Dropbox client.
*/
public void setClient(DbxClientV2 client) {
this.client = client;
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java
index a168f29b756..9a4da2686e2 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java
@@ -23,10 +23,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.AbstractMap;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
import com.dropbox.core.DbxDownloader;
@@ -36,8 +34,8 @@ import com.dropbox.core.v2.files.FileMetadata;
import com.dropbox.core.v2.files.ListFolderErrorException;
import com.dropbox.core.v2.files.ListFolderResult;
import com.dropbox.core.v2.files.Metadata;
-import com.dropbox.core.v2.files.SearchMatch;
-import com.dropbox.core.v2.files.SearchResult;
+import com.dropbox.core.v2.files.SearchOptions;
+import com.dropbox.core.v2.files.SearchV2Result;
import com.dropbox.core.v2.files.WriteMode;
import org.apache.camel.Exchange;
import org.apache.camel.component.dropbox.dto.DropboxDelResult;
@@ -50,7 +48,6 @@ import org.apache.camel.component.dropbox.util.DropboxException;
import org.apache.camel.component.dropbox.util.DropboxResultCode;
import org.apache.camel.component.dropbox.util.DropboxUploadMode;
import org.apache.camel.support.builder.OutputStreamBuilder;
-import org.apache.camel.util.IOHelper;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -83,7 +80,7 @@ public final class DropboxAPIFacade {
* case a file with the same name already exists on dropbox. in case of "force" the file
* already existing with the same name will be overridden.
* @return a result object reporting for each remote path the result of the operation.
- * @throws DropboxException
+ * @throws DropboxException if an error occurs
*/
public DropboxFileUploadResult put(String localPath, String remotePath, DropboxUploadMode mode) throws DropboxException {
// in case the remote path is not specified, the remotePath = localPath
@@ -114,10 +111,8 @@ public final class DropboxAPIFacade {
}
// in case the entry not exists on dropbox check if the filename
// should be appended
- if (!isPresent) {
- if (dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) {
- dropboxPath = dropboxPath + fileLocalPath.getName();
- }
+ if (!isPresent && dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) {
+ dropboxPath = dropboxPath + fileLocalPath.getName();
}
LOG.debug("Uploading: {},{}", fileLocalPath, dropboxPath);
@@ -192,10 +187,8 @@ public final class DropboxAPIFacade {
// in case the entry not exists on dropbox check if the filename should
// be appended
- if (!isPresent) {
- if (dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) {
- dropboxPath = dropboxPath + name;
- }
+ if (!isPresent && dropboxPath.endsWith(DropboxConstants.DROPBOX_FILE_SEPARATOR)) {
+ dropboxPath = dropboxPath + name;
}
LOG.debug("Uploading message body: {}", dropboxPath);
@@ -215,87 +208,69 @@ public final class DropboxAPIFacade {
}
private FileMetadata putSingleFile(File inputFile, String dropboxPath, DropboxUploadMode mode) throws Exception {
- FileInputStream inputStream = new FileInputStream(inputFile);
- FileMetadata uploadedFile;
- try {
+ try (FileInputStream inputStream = new FileInputStream(inputFile)) {
WriteMode uploadMode;
if (mode == DropboxUploadMode.force) {
uploadMode = WriteMode.OVERWRITE;
} else {
uploadMode = WriteMode.ADD;
}
- uploadedFile = client.files().uploadBuilder(dropboxPath).withMode(uploadMode).uploadAndFinish(inputStream,
+ return client.files().uploadBuilder(dropboxPath).withMode(uploadMode).uploadAndFinish(inputStream,
inputFile.length());
- return uploadedFile;
- } finally {
- IOHelper.close(inputStream);
}
}
private FileMetadata putSingleBody(Exchange exchange, String dropboxPath, DropboxUploadMode mode) throws Exception {
byte[] data = exchange.getIn().getMandatoryBody(byte[].class);
- InputStream is = new ByteArrayInputStream(data);
- try {
- FileMetadata uploadedFile;
- WriteMode uploadMode;
+ try (InputStream is = new ByteArrayInputStream(data)) {
+ final WriteMode uploadMode;
if (mode == DropboxUploadMode.force) {
uploadMode = WriteMode.OVERWRITE;
} else {
uploadMode = WriteMode.ADD;
}
- uploadedFile = client.files().uploadBuilder(dropboxPath).withMode(uploadMode).uploadAndFinish(is, data.length);
- return uploadedFile;
- } finally {
- IOHelper.close(is);
+ return client.files().uploadBuilder(dropboxPath).withMode(uploadMode).uploadAndFinish(is, data.length);
}
}
/**
- * Search inside a remote path including its sub directories. The query param can be null.
+ * Search inside a remote path including its subdirectories. The query param can be null.
*
* @param remotePath the remote path where starting the search from
* @param query a space-separated list of substrings to search for. A file matches only if it contains
* all the substrings
* @return a result object containing all the files found.
- * @throws DropboxException
+ * @throws DropboxException if an error occurs
*/
public DropboxSearchResult search(String remotePath, String query) throws DropboxException {
- SearchResult listing;
- List<SearchMatch> searchMatches;
if (query == null) {
LOG.debug("Search no query");
- try {
- listing = client.files().search(remotePath, null);
- searchMatches = listing.getMatches();
- return new DropboxSearchResult(searchMatches);
- } catch (DbxException e) {
- throw new DropboxException(remotePath + " does not exist or cannot obtain metadata", e);
- }
} else {
LOG.debug("Search by query: {}", query);
- try {
- listing = client.files().search(remotePath, query);
- searchMatches = listing.getMatches();
- return new DropboxSearchResult(searchMatches);
- } catch (DbxException e) {
- throw new DropboxException(remotePath + " does not exist or cannot obtain metadata", e);
- }
+ }
+ try {
+ SearchV2Result listing = client.files().searchV2Builder(query)
+ .withOptions(SearchOptions.newBuilder().withPath(remotePath).build())
+ .start();
+ return new DropboxSearchResult(listing.getMatches());
+ } catch (DbxException e) {
+ throw new DropboxException(String.format("%s does not exist or cannot obtain metadata", remotePath), e);
}
}
/**
- * Delete every files and subdirectories inside the remote directory. In case the remotePath is a file, delete the
+ * Delete every file and subdirectory inside the remote directory. In case the remotePath is a file, delete the
* file.
*
* @param remotePath the remote location to delete
* @return a result object with the result of the delete operation.
- * @throws DropboxException
+ * @throws DropboxException if an error occurs
*/
public DropboxDelResult del(String remotePath) throws DropboxException {
try {
client.files().deleteV2(remotePath);
} catch (DbxException e) {
- throw new DropboxException(remotePath + " does not exist or cannot obtain metadata", e);
+ throw new DropboxException(String.format("%s does not exist or cannot obtain metadata", remotePath), e);
}
return new DropboxDelResult(remotePath);
}
@@ -306,7 +281,7 @@ public final class DropboxAPIFacade {
* @param remotePath the existing remote path to be renamed
* @param newRemotePath the new remote path substituting the old one
* @return a result object with the result of the move operation.
- * @throws DropboxException
+ * @throws DropboxException if an error occurs
*/
public DropboxMoveResult move(String remotePath, String newRemotePath) throws DropboxException {
try {
@@ -323,7 +298,7 @@ public final class DropboxAPIFacade {
* @param remotePath the remote path where to download from
* @return a result object with the content (ByteArrayOutputStream) of every files inside the
* remote path.
- * @throws DropboxException
+ * @throws DropboxException if an error occurs
*/
public DropboxFileDownloadResult get(String remotePath) throws DropboxException {
return new DropboxFileDownloadResult(downloadFilesInFolder(remotePath));
@@ -334,18 +309,24 @@ public final class DropboxAPIFacade {
ListFolderResult folderResult = client.files().listFolder(path.equals("/") ? "" : path);
Map<String, Object> returnMap = new LinkedHashMap<>();
for (Metadata entry : folderResult.getEntries()) {
- returnMap.put(entry.getPathDisplay(), downloadSingleFile(entry.getPathDisplay()).getValue());
+ Map.Entry<String, Object> singleFile = downloadSingleFile(entry.getPathDisplay());
+ if (singleFile == null) {
+ continue;
+ }
+ returnMap.put(entry.getPathDisplay(), singleFile.getValue());
}
return returnMap;
} catch (ListFolderErrorException e) {
- try {
- DbxDownloader<FileMetadata> listing = client.files().download(path);
+ try (DbxDownloader<FileMetadata> listing = client.files().download(path)) {
if (listing == null) {
- return Collections.emptyMap();
+ return Map.of();
} else {
LOG.debug("downloading a single file...");
Map.Entry<String, Object> entry = downloadSingleFile(path);
- return Collections.singletonMap(entry.getKey(), entry.getValue());
+ if (entry == null) {
+ return Map.of();
+ }
+ return Map.of(entry.getKey(), entry.getValue());
}
} catch (DbxException dbxException) {
throw new DropboxException(dbxException);
@@ -356,16 +337,14 @@ public final class DropboxAPIFacade {
}
private Map.Entry<String, Object> downloadSingleFile(String path) throws DropboxException {
- try {
- OutputStreamBuilder target = OutputStreamBuilder.withExchange(exchange);
- DbxDownloader<FileMetadata> downloadedFile = client.files().download(path);
- if (downloadedFile != null) {
- downloadedFile.download(target);
- LOG.debug("downloaded path={}", path);
- return new AbstractMap.SimpleEntry<>(path, target.build());
- } else {
+ try (OutputStreamBuilder target = OutputStreamBuilder.withExchange(exchange);
+ DbxDownloader<FileMetadata> downloadedFile = client.files().download(path)) {
+ if (downloadedFile == null) {
return null;
}
+ downloadedFile.download(target);
+ LOG.debug("downloaded path={}", path);
+ return new AbstractMap.SimpleEntry<>(path, target.build());
} catch (DbxException e) {
throw new DropboxException(path + " does not exist or cannot obtain metadata", e);
} catch (IOException e) {
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxSearchResult.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxSearchResult.java
index ce54a6f8841..cab9f9abaa5 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxSearchResult.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxSearchResult.java
@@ -20,17 +20,17 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import com.dropbox.core.v2.files.SearchMatch;
+import com.dropbox.core.v2.files.SearchMatchV2;
public class DropboxSearchResult {
- private final List<SearchMatch> found;
+ private final List<SearchMatchV2> found;
- public DropboxSearchResult(List<SearchMatch> found) {
+ public DropboxSearchResult(List<SearchMatchV2> found) {
this.found = new ArrayList<>(found);
}
- public List<SearchMatch> getFound() {
+ public List<SearchMatchV2> getFound() {
return Collections.unmodifiableList(found);
}
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollConsumer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollConsumer.java
index 36f82524e5c..91e328fc9ca 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollConsumer.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollConsumer.java
@@ -47,7 +47,7 @@ public abstract class DropboxScheduledPollConsumer extends ScheduledPollConsumer
//create dropbox client
configuration.createClient();
- LOG.debug("Consumer DropBox client created");
+ LOG.debug("Consumer Dropbox client created");
}
super.doStart();
@@ -61,7 +61,7 @@ public abstract class DropboxScheduledPollConsumer extends ScheduledPollConsumer
if (configuration.getClient() == null) {
configuration.setClient(null);
- LOG.debug("Consumer DropBox client deleted");
+ LOG.debug("Consumer Dropbox client deleted");
}
super.doStop();
}
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollSearchConsumer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollSearchConsumer.java
index 0e2beadf3a0..7a92cb82a5e 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollSearchConsumer.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollSearchConsumer.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dropbox.integration.consumer;
-import com.dropbox.core.v2.files.SearchMatch;
+import com.dropbox.core.v2.files.Metadata;
+import com.dropbox.core.v2.files.SearchMatchV2;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.dropbox.DropboxConfiguration;
@@ -45,9 +46,10 @@ public class DropboxScheduledPollSearchConsumer extends DropboxScheduledPollCons
.search(configuration.getRemotePath(), configuration.getQuery());
StringBuilder fileExtracted = new StringBuilder();
- for (SearchMatch entry : result.getFound()) {
- fileExtracted.append(entry.getMetadata().getName()).append("-").append(entry.getMetadata().getPathDisplay())
- .append("\n");
+ for (SearchMatchV2 entry : result.getFound()) {
+ Metadata metadata = entry.getMetadata().getMetadataValue();
+ fileExtracted.append(metadata.getName()).append('-').append(metadata.getPathDisplay())
+ .append('\n');
}
exchange.getIn().setHeader(DropboxConstants.FOUND_FILES, fileExtracted.toString());
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxGetProducer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxGetProducer.java
index 457d0a40c9a..95ae5337c0a 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxGetProducer.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxGetProducer.java
@@ -30,7 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DropboxGetProducer extends DropboxProducer {
- private static final transient Logger LOG = LoggerFactory.getLogger(DropboxGetProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DropboxGetProducer.class);
public DropboxGetProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
super(endpoint, configuration);
@@ -53,7 +53,7 @@ public class DropboxGetProducer extends DropboxProducer {
} else {
StringBuilder pathsExtracted = new StringBuilder();
for (Map.Entry<String, Object> entry : map.entrySet()) {
- pathsExtracted.append(entry.getKey()).append("\n");
+ pathsExtracted.append(entry.getKey()).append('\n');
}
exchange.getIn().setHeader(DropboxConstants.DOWNLOADED_FILES, pathsExtracted.toString());
exchange.getIn().setBody(map);
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducer.java
index ce7599fae98..8aa07605095 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducer.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducer.java
@@ -24,12 +24,12 @@ import org.slf4j.LoggerFactory;
public abstract class DropboxProducer extends DefaultProducer {
- private static final transient Logger LOG = LoggerFactory.getLogger(DropboxProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DropboxProducer.class);
protected final DropboxEndpoint endpoint;
protected final DropboxConfiguration configuration;
- public DropboxProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ protected DropboxProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
super(endpoint);
this.endpoint = endpoint;
this.configuration = configuration;
@@ -41,7 +41,7 @@ public abstract class DropboxProducer extends DefaultProducer {
//create dropbox client
configuration.createClient();
- LOG.debug("Producer DropBox client created");
+ LOG.debug("Producer Dropbox client created");
}
super.doStart();
@@ -52,7 +52,7 @@ public abstract class DropboxProducer extends DefaultProducer {
if (configuration.getClient() == null) {
configuration.setClient(null);
- LOG.debug("Producer DropBox client deleted");
+ LOG.debug("Producer Dropbox client deleted");
}
super.doStop();
}
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxPutProducer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxPutProducer.java
index 03cbc54e176..b551f18629a 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxPutProducer.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxPutProducer.java
@@ -32,7 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DropboxPutProducer extends DropboxProducer {
- private static final transient Logger LOG = LoggerFactory.getLogger(DropboxPutProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DropboxPutProducer.class);
public DropboxPutProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
super(endpoint, configuration);
@@ -59,7 +59,7 @@ public class DropboxPutProducer extends DropboxProducer {
} else {
StringBuilder pathsExtracted = new StringBuilder();
for (Map.Entry<String, DropboxResultCode> entry : map.entrySet()) {
- pathsExtracted.append(entry.getKey()).append("\n");
+ pathsExtracted.append(entry.getKey()).append('\n');
}
exchange.getIn().setHeader(DropboxConstants.UPLOADED_FILES, pathsExtracted.toString());
exchange.getIn().setBody(map);
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxSearchProducer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxSearchProducer.java
index e0847c1bc82..8823be60942 100644
--- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxSearchProducer.java
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxSearchProducer.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dropbox.integration.producer;
-import com.dropbox.core.v2.files.SearchMatch;
+import com.dropbox.core.v2.files.Metadata;
+import com.dropbox.core.v2.files.SearchMatchV2;
import org.apache.camel.Exchange;
import org.apache.camel.component.dropbox.DropboxConfiguration;
import org.apache.camel.component.dropbox.DropboxEndpoint;
@@ -43,9 +44,10 @@ public class DropboxSearchProducer extends DropboxProducer {
.search(remotePath, query);
StringBuilder fileExtracted = new StringBuilder();
- for (SearchMatch entry : result.getFound()) {
- fileExtracted.append(entry.getMetadata().getName()).append("-").append(entry.getMetadata().getPathDisplay())
- .append("\n");
+ for (SearchMatchV2 entry : result.getFound()) {
+ Metadata metadataValue = entry.getMetadata().getMetadataValue();
+ fileExtracted.append(metadataValue.getName()).append('-').append(metadataValue.getPathDisplay())
+ .append('\n');
}
exchange.getIn().setHeader(DropboxConstants.FOUND_FILES, fileExtracted.toString());
exchange.getIn().setBody(result.getFound());
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java
index 4664a6b684b..01963ca4471 100644
--- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java
@@ -45,7 +45,7 @@ public class DropboxTestSupport extends CamelTestSupport {
protected String refreshToken;
protected Long expireIn;
- private DbxClientV2 client;
+ private final DbxClientV2 client;
protected DropboxTestSupport() {
properties = loadProperties();
@@ -91,12 +91,12 @@ public class DropboxTestSupport extends CamelTestSupport {
try {
removeDir(name);
} finally {
- client.files().createFolder(name);
+ client.files().createFolderV2(name);
}
}
protected void removeDir(String name) throws DbxException {
- client.files().delete(name);
+ client.files().deleteV2(name);
}
protected void createFile(String fileName, String content) throws IOException {
@@ -113,12 +113,13 @@ public class DropboxTestSupport extends CamelTestSupport {
}
protected String getFileContent(String path) throws DbxException, IOException {
- ByteArrayOutputStream target = new ByteArrayOutputStream();
- DbxDownloader<FileMetadata> downloadedFile = client.files().download(path);
- if (downloadedFile != null) {
- downloadedFile.download(target);
+ try (ByteArrayOutputStream target = new ByteArrayOutputStream();
+ DbxDownloader<FileMetadata> downloadedFile = client.files().download(path)) {
+ if (downloadedFile != null) {
+ downloadedFile.download(target);
+ }
+ return target.toString();
}
- return new String(target.toByteArray());
}
@Override
diff --git a/parent/pom.xml b/parent/pom.xml
index a0bd149591e..065670bb149 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -153,7 +153,7 @@
<djl-tensorflow-native-version>2.4.1</djl-tensorflow-native-version>
<docker-java-version>3.2.13</docker-java-version>
<dozer-version>6.5.2</dozer-version>
- <dropbox-version>3.2.0</dropbox-version>
+ <dropbox-version>5.4.2</dropbox-version>
<debezium-version>1.9.6.Final</debezium-version>
<debezium-mysql-connector-version>8.0.28</debezium-mysql-connector-version>
<eddsa-version>0.3.0</eddsa-version>