You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by he...@apache.org on 2014/04/11 11:00:10 UTC
[1/2] DropBox component initial commit. Great thanks to Giovanni for
the contribution.
Repository: camel
Updated Branches:
refs/heads/master 82c7edc1d -> 037f3f091
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultHeader.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultHeader.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultHeader.java
new file mode 100755
index 0000000..531353f
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultHeader.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+public enum DropboxResultHeader {
+ DOWNLOADED_FILE, DOWNLOADED_FILES, UPLOADED_FILE, UPLOADED_FILES, FOUNDED_FILES , DELETED_PATH, MOVED_PATH;
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxUploadMode.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxUploadMode.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxUploadMode.java
new file mode 100755
index 0000000..d20516d
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxUploadMode.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+public enum DropboxUploadMode {
+ add("add"),
+ force("force");
+
+ private final String text;
+
+ private DropboxUploadMode(final String text) {
+ this.text = text;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/validator/DropboxConfigurationValidator.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/validator/DropboxConfigurationValidator.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/validator/DropboxConfigurationValidator.java
new file mode 100755
index 0000000..a7c207a
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/validator/DropboxConfigurationValidator.java
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.validator;
+
+import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.util.DropboxException;
+import org.apache.camel.component.dropbox.util.DropboxOperation;
+
+
+import static org.apache.camel.component.dropbox.util.DropboxConstants.DROPBOX_FILE_SEPARATOR;
+
+public final class DropboxConfigurationValidator {
+
+ private DropboxConfigurationValidator() { }
+
+ /**
+ * Validate the parameters passed in the incoming url.
+ * @param configuration object containing the parameters.
+ * @throws DropboxException
+ */
+ public static void validate(DropboxConfiguration configuration) throws DropboxException {
+ validateCommonProperties(configuration);
+ DropboxOperation op = configuration.getOperation();
+ if (op == DropboxOperation.get) {
+ validateGetOp(configuration);
+ } else if (op == DropboxOperation.put) {
+ validatePutOp(configuration);
+ } else if (op == DropboxOperation.search) {
+ validateSearchOp(configuration);
+ } else if (op == DropboxOperation.del) {
+ validateDelOp(configuration);
+ } else if (op == DropboxOperation.move) {
+ validateMoveOp(configuration);
+ }
+ }
+
+ private static void validateCommonProperties(DropboxConfiguration configuration) throws DropboxException {
+ if (configuration.getAccessToken() == null || configuration.getAccessToken().equals("")) {
+ throw new DropboxException("option <accessToken> is not present or not valid!");
+ }
+ if (configuration.getClientIdentifier() == null || configuration.getClientIdentifier().equals("")) {
+ throw new DropboxException("option <clientIdentifier> is not present or not valid!");
+ }
+ }
+
+ private static void validateGetOp(DropboxConfiguration configuration) throws DropboxException {
+ validateRemotePath(configuration.getRemotePath());
+ }
+
+ private static void validatePutOp(DropboxConfiguration configuration) throws DropboxException {
+ validateLocalPath(configuration.getLocalPath());
+ //remote path is optional
+ if (configuration.getRemotePath() != null) {
+ validateRemotePathForPut(configuration.getRemotePath());
+ } else { //in case remote path is not set, local path is even the remote path so it must be validated as UNIX
+ validatePathInUnix(configuration.getLocalPath());
+ }
+ if (configuration.getUploadMode() == null) {
+ throw new DropboxException("option <uploadMode> is not present or not valid!");
+ }
+ }
+
+ private static void validateSearchOp(DropboxConfiguration configuration) throws DropboxException {
+ validateRemotePath(configuration.getRemotePath());
+ }
+
+ private static void validateDelOp(DropboxConfiguration configuration) throws DropboxException {
+ validateRemotePath(configuration.getRemotePath());
+ }
+
+ private static void validateMoveOp(DropboxConfiguration configuration) throws DropboxException {
+ validateRemotePath(configuration.getRemotePath());
+ validateRemotePath(configuration.getNewRemotePath());
+ }
+
+ private static void validateLocalPath(String localPath) throws DropboxException {
+ if (localPath == null || localPath.equals("")) {
+ throw new DropboxException("option <localPath> is not present or not valid!");
+ }
+ File file = new File(localPath);
+ if (!file.exists()) {
+ throw new DropboxException("option <localPath> is not an existing file or directory!");
+ }
+ }
+
+ private static void validateRemotePath(String remotePath) throws DropboxException {
+ if (remotePath == null || !remotePath.startsWith(DROPBOX_FILE_SEPARATOR)) {
+ throw new DropboxException("option <remotePath> is not valid!");
+ }
+ validatePathInUnix(remotePath);
+ }
+
+ private static void validateRemotePathForPut(String remotePath) throws DropboxException {
+ if (!remotePath.startsWith(DROPBOX_FILE_SEPARATOR)) {
+ throw new DropboxException("option <remotePath> is not valid!");
+ }
+ validatePathInUnix(remotePath);
+ }
+
+ private static void validatePathInUnix(String path) throws DropboxException {
+ Pattern pattern = Pattern.compile("/*?(\\S+)/*?", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(path);
+ if (!matcher.matches()) {
+ throw new DropboxException(path + " is not a valid path, must be in UNIX form!");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/META-INF/Dropbox_API_Terms_and_Conditions.txt
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/META-INF/Dropbox_API_Terms_and_Conditions.txt b/components/camel-dropbox/src/main/resources/META-INF/Dropbox_API_Terms_and_Conditions.txt
new file mode 100755
index 0000000..caf331e
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/META-INF/Dropbox_API_Terms_and_Conditions.txt
@@ -0,0 +1,2 @@
+please refer to:
+https://www.dropbox.com/developers/reference/tos
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/META-INF/LICENSE.txt b/components/camel-dropbox/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/META-INF/NOTICE.txt b/components/camel-dropbox/src/main/resources/META-INF/NOTICE.txt
new file mode 100755
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/META-INF/services/org/apache/camel/component/dropbox
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/META-INF/services/org/apache/camel/component/dropbox b/components/camel-dropbox/src/main/resources/META-INF/services/org/apache/camel/component/dropbox
new file mode 100755
index 0000000..1ed5712
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/META-INF/services/org/apache/camel/component/dropbox
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.dropbox.DropboxComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/dropbox.properties
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/dropbox.properties b/components/camel-dropbox/src/main/resources/dropbox.properties
new file mode 100755
index 0000000..e3fbe60
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/dropbox.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+accessToken=<access-token>
+clientIdentifier=<clientIdentifier>
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/features.xml b/components/camel-dropbox/src/main/resources/features.xml
new file mode 100644
index 0000000..8ca4145
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/features.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<features>
+ <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features</repository>
+
+ <feature name='camel-dropbox' version='${project.version}'>
+ <feature version="${project.version}">camel</feature>
+ <bundle>mvn:commons-io/commons-io/1.3.2</bundle>
+ <bundle>mvn:org.apache.camel/camel-dropbox/${project.version}</bundle>
+ </feature>
+
+</features>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/resources/log4j.properties b/components/camel-dropbox/src/main/resources/log4j.properties
new file mode 100755
index 0000000..4621723
--- /dev/null
+++ b/components/camel-dropbox/src/main/resources/log4j.properties
@@ -0,0 +1,16 @@
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..325066e
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/DropboxTestSupport.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+
+public class DropboxTestSupport extends CamelTestSupport {
+
+ protected final Properties properties;
+
+ protected DropboxTestSupport() throws Exception {
+ URL url = getClass().getResource("/test-options.properties");
+
+ InputStream inStream;
+ try {
+ inStream = url.openStream();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalAccessError("test-options.properties could not be found");
+ }
+
+ properties = new Properties();
+ try {
+ properties.load(inStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalAccessError("test-options.properties could not be found");
+ }
+ }
+
+ protected String getAuthParams() {
+ return "accessToken=" + properties.get("accessToken")
+ + "&clientIdentifier=" + properties.get("clientIdentifier");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java
new file mode 100755
index 0000000..71801b1
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerGetSingleTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.consumer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxConsumerGetSingleTest extends DropboxTestSupport {
+
+ public DropboxConsumerGetSingleTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILE.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("dropbox://get?" + getAuthParams() + "&remotePath=XXX")
+ .to("file:XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java
new file mode 100755
index 0000000..dce191c
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchQueryTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.consumer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxConsumerSearchQueryTest extends DropboxTestSupport {
+
+ public DropboxConsumerSearchQueryTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUNDED_FILES.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("dropbox://search?" + getAuthParams() + "&remotePath=/XXX&query=XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java
new file mode 100755
index 0000000..1eec3aa
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/consumer/DropboxConsumerSearchTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.consumer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxConsumerSearchTest extends DropboxTestSupport {
+
+ public DropboxConsumerSearchTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUNDED_FILES.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("dropbox://search?" + getAuthParams() + "&remotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java
new file mode 100755
index 0000000..5768fd4
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerDelTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerDelTest extends DropboxTestSupport {
+
+ public DropboxProducerDelTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.DELETED_PATH.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://del?" + getAuthParams() + "&remotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java
new file mode 100755
index 0000000..6652304
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetFolderTest.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerGetFolderTest extends DropboxTestSupport {
+
+ public DropboxProducerGetFolderTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILES.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+
+ System.out.println(header.toString());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://get?" + getAuthParams() + "&remotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java
new file mode 100755
index 0000000..d06c880
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerGetSingleTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerGetSingleTest extends DropboxTestSupport {
+
+ public DropboxProducerGetSingleTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILE.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://get?" + getAuthParams() + "&remotePath=/XXX")
+ .to("file:///XXX?fileName=XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java
new file mode 100755
index 0000000..f797330
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerMoveTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerMoveTest extends DropboxTestSupport {
+
+ public DropboxProducerMoveTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.MOVED_PATH.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://move?" + getAuthParams() + "&remotePath=/XXX&newRemotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java
new file mode 100755
index 0000000..1ff8204
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerPutSingleFileTest extends DropboxTestSupport {
+
+ public DropboxProducerPutSingleFileTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://put?" + getAuthParams() + "&uploadMode=add&localPath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java
new file mode 100755
index 0000000..a704ae3
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutSingleFileWithRemotePathTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerPutSingleFileWithRemotePathTest extends DropboxTestSupport {
+
+ public DropboxProducerPutSingleFileWithRemotePathTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://put?" + getAuthParams() + "&uploadMode=add&localPath=/XXX&remotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java
new file mode 100755
index 0000000..f99cb26
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerPutWithRemotePathTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerPutWithRemotePathTest extends DropboxTestSupport {
+
+ public DropboxProducerPutWithRemotePathTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILES.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://put?" + getAuthParams() + "&uploadMode=add&localPath=/XXX&remotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java
new file mode 100755
index 0000000..2550276
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchQueryTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerSearchQueryTest extends DropboxTestSupport {
+
+ public DropboxProducerSearchQueryTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUNDED_FILES.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://search?" + getAuthParams() + "&remotePath=/XXX&query=XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java
new file mode 100755
index 0000000..613b25c
--- /dev/null
+++ b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducerSearchTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dropbox.integration.DropboxTestSupport;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class DropboxProducerSearchTest extends DropboxTestSupport {
+
+ public DropboxProducerSearchTest() throws Exception { }
+
+ @Test
+ public void testCamelDropbox() throws Exception {
+ template.send("direct:start", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("test", "test");
+ }
+ });
+
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(DropboxResultHeader.FOUNDED_FILES.name());
+ Object body = exchange.getIn().getBody();
+ assertNotNull(header);
+ assertNotNull(body);
+
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("dropbox://search?" + getAuthParams() + "&remotePath=/XXX")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/test/resources/test-options.properties b/components/camel-dropbox/src/test/resources/test-options.properties
new file mode 100755
index 0000000..cf7d634
--- /dev/null
+++ b/components/camel-dropbox/src/test/resources/test-options.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+accessToken=<access-token>
+clientIdentifier=camel-dropbox
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 1218eee..9e5292f 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -78,6 +78,7 @@
<module>camel-disruptor</module>
<module>camel-dns</module>
<module>camel-dozer</module>
+ <module>camel-dropbox</module>
<module>camel-eclipse</module>
<module>camel-ejb</module>
<module>camel-elasticsearch</module>
[2/2] git commit: DropBox component initial commit. Great thanks to
Giovanni for the contribution.
Posted by he...@apache.org.
DropBox component initial commit. Great thanks to Giovanni for the contribution.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/037f3f09
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/037f3f09
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/037f3f09
Branch: refs/heads/master
Commit: 037f3f091f8de0f043e02a19f0131032821fe3c1
Parents: 82c7edc
Author: Henryk Konsek <he...@gmail.com>
Authored: Fri Apr 11 10:59:36 2014 +0200
Committer: Henryk Konsek <he...@gmail.com>
Committed: Fri Apr 11 10:59:36 2014 +0200
----------------------------------------------------------------------
components/camel-dropbox/pom.xml | 118 +++++++
.../component/dropbox/DropboxComponent.java | 73 +++++
.../component/dropbox/DropboxConfiguration.java | 140 +++++++++
.../component/dropbox/DropboxEndpoint.java | 105 +++++++
.../dropbox/core/DropboxAPIFacade.java | 314 +++++++++++++++++++
.../component/dropbox/dto/DropboxDelResult.java | 39 +++
.../dropbox/dto/DropboxFileDownloadResult.java | 59 ++++
.../dropbox/dto/DropboxFileUploadResult.java | 59 ++++
.../dropbox/dto/DropboxMoveResult.java | 40 +++
.../component/dropbox/dto/DropboxResult.java | 40 +++
.../dropbox/dto/DropboxSearchResult.java | 51 +++
.../consumer/DropboxScheduledPollConsumer.java | 72 +++++
.../DropboxScheduledPollGetConsumer.java | 56 ++++
.../DropboxScheduledPollSearchConsumer.java | 56 ++++
.../producer/DropboxDelProducer.java | 43 +++
.../producer/DropboxGetProducer.java | 43 +++
.../producer/DropboxMoveProducer.java | 42 +++
.../integration/producer/DropboxProducer.java | 59 ++++
.../producer/DropboxPutProducer.java | 43 +++
.../producer/DropboxSearchProducer.java | 41 +++
.../dropbox/util/DropboxConstants.java | 26 ++
.../dropbox/util/DropboxException.java | 23 ++
.../dropbox/util/DropboxOperation.java | 38 +++
.../dropbox/util/DropboxPropertyManager.java | 62 ++++
.../dropbox/util/DropboxResultCode.java | 22 ++
.../dropbox/util/DropboxResultHeader.java | 22 ++
.../dropbox/util/DropboxUploadMode.java | 35 +++
.../DropboxConfigurationValidator.java | 126 ++++++++
.../Dropbox_API_Terms_and_Conditions.txt | 2 +
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../services/org/apache/camel/component/dropbox | 18 ++
.../src/main/resources/dropbox.properties | 19 ++
.../src/main/resources/features.xml | 27 ++
.../src/main/resources/log4j.properties | 16 +
.../dropbox/integration/DropboxTestSupport.java | 55 ++++
.../consumer/DropboxConsumerGetSingleTest.java | 58 ++++
.../DropboxConsumerSearchQueryTest.java | 57 ++++
.../consumer/DropboxConsumerSearchTest.java | 57 ++++
.../producer/DropboxProducerDelTest.java | 66 ++++
.../producer/DropboxProducerGetFolderTest.java | 68 ++++
.../producer/DropboxProducerGetSingleTest.java | 67 ++++
.../producer/DropboxProducerMoveTest.java | 66 ++++
.../DropboxProducerPutSingleFileTest.java | 66 ++++
...ProducerPutSingleFileWithRemotePathTest.java | 66 ++++
.../DropboxProducerPutWithRemotePathTest.java | 67 ++++
.../DropboxProducerSearchQueryTest.java | 67 ++++
.../producer/DropboxProducerSearchTest.java | 67 ++++
.../src/test/resources/test-options.properties | 19 ++
components/pom.xml | 1 +
50 files changed, 2990 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/pom.xml b/components/camel-dropbox/pom.xml
new file mode 100755
index 0000000..7a75966
--- /dev/null
+++ b/components/camel-dropbox/pom.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.13-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-dropbox</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Dropbox</name>
+ <description>Camel Dropbox support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.dropbox.*</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=dropbox</camel.osgi.export.service>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>no-integration-test</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>
+ **/integration/**
+ </exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- dropbox -->
+ <dependency>
+ <groupId>com.dropbox.core</groupId>
+ <artifactId>dropbox-core-sdk</artifactId>
+ <version>[1.7,1.8)</version>
+ </dependency>
+
+ <!-- apache commons-io -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${mockito-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Allows the routes to be run via 'mvn camel:run' -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java
new file mode 100755
index 0000000..d445f76
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.dropbox.util.DropboxOperation;
+import org.apache.camel.component.dropbox.util.DropboxPropertyManager;
+import org.apache.camel.component.dropbox.util.DropboxUploadMode;
+import org.apache.camel.component.dropbox.validator.DropboxConfigurationValidator;
+import org.apache.camel.impl.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxComponent extends DefaultComponent {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxComponent.class);
+
+ /**
+ * Create a camel endpoint after passing validation on the incoming url.
+ * @param uri the full URI of the endpoint
+ * @param remaining the remaining part of the URI without the query
+ * parameters or component prefix
+ * @param parameters the optional parameters passed in
+ * @return the camel endpoint
+ * @throws Exception
+ */
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ DropboxConfiguration configuration = new DropboxConfiguration();
+
+ // set options from component
+ configuration.setAccessToken((String)parameters.get("accessToken"));
+ configuration.setLocalPath((String)parameters.get("localPath"));
+ configuration.setRemotePath((String)parameters.get("remotePath"));
+ configuration.setNewRemotePath((String)parameters.get("newRemotePath"));
+ configuration.setQuery((String)parameters.get("query"));
+ configuration.setOperation(DropboxOperation.valueOf(remaining));
+ configuration.setClientIdentifier(
+ parameters.get("clientIdentifier") == null
+ ? DropboxPropertyManager.getInstance().getProperty("clientIdentifier")
+ : (String) parameters.get("clientIdentifier"));
+ if (parameters.get("uploadMode") != null) {
+ configuration.setUploadMode(DropboxUploadMode.valueOf((String)parameters.get("uploadMode")));
+ }
+
+ //pass validation test
+ DropboxConfigurationValidator.validate(configuration);
+
+ // and then override from parameters
+ setProperties(configuration, parameters);
+
+ LOG.info("dropbox configuration set!");
+
+ Endpoint endpoint = new DropboxEndpoint(uri, this, configuration);
+ return endpoint;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxConfiguration.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..be6fe8b
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxConfiguration.java
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox;
+
+import java.util.Locale;
+
+import com.dropbox.core.DbxClient;
+import com.dropbox.core.DbxRequestConfig;
+import org.apache.camel.component.dropbox.util.DropboxException;
+import org.apache.camel.component.dropbox.util.DropboxOperation;
+import org.apache.camel.component.dropbox.util.DropboxUploadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DropboxConfiguration {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxConfiguration.class);
+
+ //dropbox auth options
+ private String accessToken;
+ //local path to put files
+ private String localPath;
+ //where to put files on dropbox
+ private String remotePath;
+ //new path on dropbox when moving files
+ private String newRemotePath;
+ //search query on dropbox
+ private String query;
+ //in case of uploading if force or add existing file
+ private DropboxUploadMode uploadMode;
+ //id of the app
+ private String clientIdentifier;
+ //specific dropbox operation for the component
+ private DropboxOperation operation;
+ //reference to dropboxclient
+ private DbxClient client;
+
+ public void setClient(DbxClient client) {
+ this.client = client;
+ }
+
+ public DbxClient getClient() {
+ return client;
+ }
+
+ /**
+ * Obtain a new instance of DbxClient and store it in configuration.
+ * @throws DropboxException
+ */
+ public void createClient() throws DropboxException {
+ DbxRequestConfig config =
+ new DbxRequestConfig(clientIdentifier, Locale.getDefault().toString());
+ DbxClient client = new DbxClient(config, accessToken);
+ if (client == null) {
+ throw new DropboxException("can't establish a Dropbox conenction!");
+ }
+ this.client = client;
+
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public String getLocalPath() {
+ return localPath;
+ }
+
+ public void setLocalPath(String localPath) {
+ this.localPath = localPath;
+ }
+
+ public String getRemotePath() {
+ return remotePath;
+ }
+
+ public void setRemotePath(String remotePath) {
+ this.remotePath = remotePath;
+ }
+
+ public String getNewRemotePath() {
+ return newRemotePath;
+ }
+
+ public void setNewRemotePath(String newRemotePath) {
+ this.newRemotePath = newRemotePath;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ public String getClientIdentifier() {
+ return clientIdentifier;
+ }
+
+ public void setClientIdentifier(String clientIdentifier) {
+ this.clientIdentifier = clientIdentifier;
+ }
+
+ public DropboxOperation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(DropboxOperation operation) {
+ this.operation = operation;
+ }
+
+ public DropboxUploadMode getUploadMode() {
+ return uploadMode;
+ }
+
+ public void setUploadMode(DropboxUploadMode uploadMode) {
+ this.uploadMode = uploadMode;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxEndpoint.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxEndpoint.java
new file mode 100755
index 0000000..5cbb0ed
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxEndpoint.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollConsumer;
+import org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollGetConsumer;
+import org.apache.camel.component.dropbox.integration.consumer.DropboxScheduledPollSearchConsumer;
+import org.apache.camel.component.dropbox.integration.producer.DropboxDelProducer;
+import org.apache.camel.component.dropbox.integration.producer.DropboxGetProducer;
+import org.apache.camel.component.dropbox.integration.producer.DropboxMoveProducer;
+import org.apache.camel.component.dropbox.integration.producer.DropboxPutProducer;
+import org.apache.camel.component.dropbox.integration.producer.DropboxSearchProducer;
+import org.apache.camel.component.dropbox.util.DropboxException;
+import org.apache.camel.component.dropbox.util.DropboxOperation;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.dropbox.util.DropboxConstants.POLL_CONSUMER_DELAY;
+
+public class DropboxEndpoint extends DefaultEndpoint {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxEndpoint.class);
+
+ private DropboxConfiguration configuration;
+
+ public DropboxEndpoint() {
+ }
+
+ public DropboxEndpoint(String uri, DropboxComponent component, DropboxConfiguration configuration) {
+ super(uri, component);
+ this.configuration = configuration;
+ }
+
+ public DropboxEndpoint(String endpointUri) {
+ super(endpointUri);
+ }
+
+ /**
+ * Create one of the camel producer available based on the configuration
+ * @return the camel producer
+ * @throws Exception
+ */
+ public Producer createProducer() throws Exception {
+ LOG.info("resolve producer dropbox endpoint {" + configuration.getOperation().toString() + "}");
+ LOG.info("resolve producer dropbox attached client: " + configuration.getClient());
+ if (configuration.getOperation() == DropboxOperation.put) {
+ return new DropboxPutProducer(this, configuration);
+ } else if (this.configuration.getOperation() == DropboxOperation.search) {
+ return new DropboxSearchProducer(this, configuration);
+ } else if (this.configuration.getOperation() == DropboxOperation.del) {
+ return new DropboxDelProducer(this, configuration);
+ } else if (this.configuration.getOperation() == DropboxOperation.get) {
+ return new DropboxGetProducer(this, configuration);
+ } else if (this.configuration.getOperation() == DropboxOperation.move) {
+ return new DropboxMoveProducer(this, configuration);
+ } else {
+ throw new DropboxException("operation specified is not valid for producer!");
+ }
+ }
+
+ /**
+ * Create one of the camel consumer available based on the configuration
+ * @param processor the given processor
+ * @return the camel consumer
+ * @throws Exception
+ */
+ public Consumer createConsumer(Processor processor) throws Exception {
+ LOG.debug("resolve consumer dropbox endpoint {" + configuration.getOperation().toString() + "}");
+ LOG.debug("resolve consumer dropbox attached client:" + configuration.getClient());
+ DropboxScheduledPollConsumer consumer = null;
+ if (this.configuration.getOperation() == DropboxOperation.search) {
+ consumer = new DropboxScheduledPollSearchConsumer(this, processor, configuration);
+ consumer.setDelay(POLL_CONSUMER_DELAY);
+ return consumer;
+ } else if (this.configuration.getOperation() == DropboxOperation.get) {
+ consumer = new DropboxScheduledPollGetConsumer(this, processor, configuration);
+ consumer.setDelay(POLL_CONSUMER_DELAY);
+ return consumer;
+ } else {
+ throw new DropboxException("operation specified is not valid for consumer!");
+ }
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..aba52f6
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/core/DropboxAPIFacade.java
@@ -0,0 +1,314 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.core;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.dropbox.core.DbxClient;
+import com.dropbox.core.DbxEntry;
+import com.dropbox.core.DbxException;
+import com.dropbox.core.DbxWriteMode;
+import org.apache.camel.component.dropbox.dto.DropboxDelResult;
+import org.apache.camel.component.dropbox.dto.DropboxFileDownloadResult;
+import org.apache.camel.component.dropbox.dto.DropboxFileUploadResult;
+import org.apache.camel.component.dropbox.dto.DropboxMoveResult;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+import org.apache.camel.component.dropbox.dto.DropboxSearchResult;
+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.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import static org.apache.camel.component.dropbox.util.DropboxConstants.DROPBOX_FILE_SEPARATOR;
+
+
+public final class DropboxAPIFacade {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxAPIFacade.class);
+
+ private static DropboxAPIFacade instance;
+ private static DbxClient client;
+
+ private DropboxAPIFacade() { }
+
+ /**
+ * Return a singleton instance of this class
+ * @param client the DbxClient performing dropbox low level operations
+ * @return the singleton instance of this class
+ */
+ public static DropboxAPIFacade getInstance(DbxClient client) {
+ if (instance == null) {
+ instance = new DropboxAPIFacade();
+ instance.client = client;
+ }
+ return instance;
+ }
+
+ /**
+ * Put or upload a new file or an entire directory to dropbox
+ * @param localPath the file path or the dir path on the local filesystem
+ * @param remotePath the remote path destination on dropbox
+ * @param mode how a file should be saved on dropbox;
+ * in case of "add" the new file will be renamed in 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 DropboxResult object reporting for each remote path the result of the operation.
+ * @throws DropboxException
+ */
+ public DropboxResult put(String localPath, String remotePath, DropboxUploadMode mode) throws DropboxException {
+ DropboxResult result = new DropboxFileUploadResult();
+ //a map representing for each path the result of the put operation
+ Map<String, DropboxResultCode> resultEntries = null;
+ //in case the remote path is not specified, the remotePath = localPath
+ String dropboxPath = remotePath == null ? localPath : remotePath;
+ DbxEntry entry = null;
+ try {
+ entry = instance.client.getMetadata(dropboxPath);
+ } catch (DbxException e) {
+ throw new DropboxException(dropboxPath + " does not exist or can't obtain metadata");
+ }
+ File fileLocalPath = new File(localPath);
+ //verify uploading of a single file
+ if (fileLocalPath.isFile()) {
+ //check if dropbox file exists
+ if (entry != null && !entry.isFile()) {
+ throw new DropboxException(dropboxPath + " exists on dropbox and is not a file!");
+ }
+ //in case the entry not exists on dropbox check if the filename should be appended
+ if (entry == null) {
+ if (dropboxPath.endsWith(DROPBOX_FILE_SEPARATOR)) {
+ dropboxPath = dropboxPath + fileLocalPath.getName();
+ }
+ }
+ resultEntries = new HashMap<String, DropboxResultCode>(1);
+ try {
+ DbxEntry.File uploadedFile = putSingleFile(fileLocalPath, dropboxPath, mode);
+ if (uploadedFile == null) {
+ resultEntries.put(dropboxPath, DropboxResultCode.KO);
+ } else {
+ resultEntries.put(dropboxPath, DropboxResultCode.OK);
+ }
+
+ } catch (Exception ex) {
+ resultEntries.put(dropboxPath, DropboxResultCode.KO);
+ } finally {
+ result.setResultEntries(resultEntries);
+ }
+ return result;
+ } else { //verify uploading of a list of files inside a dir
+ LOG.info("uploading a dir...");
+ //check if dropbox folder exists
+ if (entry != null && !entry.isFolder()) {
+ throw new DropboxException(dropboxPath + " exists on dropbox and is not a folder!");
+ }
+ if (!dropboxPath.endsWith(DROPBOX_FILE_SEPARATOR)) {
+ dropboxPath = dropboxPath + DROPBOX_FILE_SEPARATOR;
+ }
+ //revert to old path
+ String oldDropboxPath = dropboxPath;
+ //list all files in a dir
+ Collection<File> listFiles = FileUtils.listFiles(fileLocalPath, null, true);
+ if (listFiles == null || listFiles.isEmpty()) {
+ throw new DropboxException(localPath + " doesn't contain any files");
+ }
+ resultEntries = new HashMap<String, DropboxResultCode>(listFiles.size());
+ for (File file : listFiles) {
+ String absPath = file.getAbsolutePath();
+ int indexRemainingPath = localPath.length();
+ if (!localPath.endsWith("/")) {
+ indexRemainingPath += 1;
+ }
+ String remainingPath = absPath.substring(indexRemainingPath);
+ dropboxPath = dropboxPath + remainingPath;
+ try {
+ LOG.info("uploading:" + fileLocalPath + "," + dropboxPath);
+ DbxEntry.File uploadedFile = putSingleFile(file, dropboxPath, mode);
+ if (uploadedFile == null) {
+ resultEntries.put(dropboxPath, DropboxResultCode.KO);
+ } else {
+ resultEntries.put(dropboxPath, DropboxResultCode.OK);
+ }
+ } catch (Exception ex) {
+ resultEntries.put(dropboxPath, DropboxResultCode.KO);
+ }
+ dropboxPath = oldDropboxPath;
+ }
+ result.setResultEntries(resultEntries);
+ return result;
+ }
+ }
+
+ private DbxEntry.File putSingleFile(File inputFile, String dropboxPath, DropboxUploadMode mode) throws Exception {
+ FileInputStream inputStream = new FileInputStream(inputFile);
+ DbxEntry.File uploadedFile = null;
+ try {
+ DbxWriteMode uploadMode = null;
+ if (mode == DropboxUploadMode.force) {
+ uploadMode = DbxWriteMode.force();
+ } else {
+ uploadMode = DbxWriteMode.add();
+ }
+ uploadedFile =
+ instance.client.uploadFile(dropboxPath,
+ uploadMode, inputFile.length(), inputStream);
+ return uploadedFile;
+ } finally {
+ inputStream.close();
+ }
+ }
+
+ /**
+ * Search inside a remote path including its sub directories.
+ * 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 DropboxResult object containing all the files found.
+ * @throws DropboxException
+ */
+ public DropboxResult search(String remotePath, String query) throws DropboxException {
+ DropboxResult result = new DropboxSearchResult();
+ DbxEntry.WithChildren listing = null;
+ if (query == null) {
+ LOG.info("search no query");
+ try {
+ listing = instance.client.getMetadataWithChildren(remotePath);
+ } catch (DbxException e) {
+ throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
+ }
+ result.setResultEntries(listing.children);
+ } else {
+ LOG.info("search by query:" + query);
+ List<DbxEntry> entries = null;
+ try {
+ entries = instance.client.searchFileAndFolderNames(remotePath, query);
+ } catch (DbxException e) {
+ throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
+ }
+ result.setResultEntries(entries);
+ }
+ return result;
+ }
+
+ /**
+ * Delete every files and subdirectories inside the remote directory.
+ * In case the remotePath is a file, delete the file.
+ * @param remotePath the remote location to delete
+ * @return a DropboxResult object with the result of the delete operation.
+ * @throws DropboxException
+ */
+ public DropboxResult del(String remotePath) throws DropboxException {
+ DropboxResult result = null;
+ try {
+ instance.client.delete(remotePath);
+ } catch (DbxException e) {
+ throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
+ }
+ result = new DropboxDelResult();
+ result.setResultEntries(remotePath);
+ return result;
+ }
+
+ /**
+ * Rename a remote path with the new path location.
+ * @param remotePath the existing remote path to be renamed
+ * @param newRemotePath the new remote path substituting the old one
+ * @return a DropboxResult object with the result of the move operation.
+ * @throws DropboxException
+ */
+ public DropboxResult move(String remotePath, String newRemotePath) throws DropboxException {
+ DropboxResult result = null;
+ try {
+ instance.client.move(remotePath, newRemotePath);
+ } catch (DbxException e) {
+ throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
+ }
+ result = new DropboxMoveResult();
+ result.setResultEntries(remotePath + "-" + newRemotePath);
+ return result;
+ }
+
+ /**
+ * Get the content of every file inside the remote path.
+ * @param remotePath the remote path where to download from
+ * @return a DropboxResult object with the content (ByteArrayOutputStream) of every files inside the remote path.
+ * @throws DropboxException
+ */
+ public DropboxResult get(String remotePath) throws DropboxException {
+ DropboxResult result = new DropboxFileDownloadResult();
+ //a map representing for each path the result of the baos
+ Map<String, ByteArrayOutputStream> resultEntries = new HashMap<String, ByteArrayOutputStream>();
+ //iterate from the remotePath
+ downloadFilesInFolder(remotePath, resultEntries);
+ //put the map of baos as result
+ result.setResultEntries(resultEntries);
+ return result;
+ }
+
+ private void downloadFilesInFolder(String path, Map<String, ByteArrayOutputStream> resultEntries) throws DropboxException {
+ DbxEntry.WithChildren listing = null;
+ try {
+ listing = instance.client.getMetadataWithChildren(path);
+ } catch (DbxException e) {
+ throw new DropboxException(path + " does not exist or can't obtain metadata");
+ }
+ if (listing.children == null) {
+ LOG.info("downloading a single file...");
+ downloadSingleFile(path, resultEntries);
+ return;
+ }
+ for (DbxEntry entry : listing.children) {
+ if (entry.isFile()) {
+ try {
+ //get the baos of the file
+ downloadSingleFile(entry.path, resultEntries);
+ } catch (DropboxException e) {
+ LOG.warn("can't download from " + entry.path);
+ }
+ } else {
+ //iterate on folder
+ downloadFilesInFolder(entry.path, resultEntries);
+ }
+ }
+ }
+
+ private void downloadSingleFile(String path, Map<String, ByteArrayOutputStream> resultEntries) throws DropboxException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DbxEntry.File downloadedFile;
+ try {
+ downloadedFile = instance.client.getFile(path, null, baos);
+ } catch (DbxException e) {
+ throw new DropboxException(path + " does not exist or can't obtain metadata");
+ } catch (IOException e) {
+ throw new DropboxException(path + " can't obtain a stream");
+ }
+ if (downloadedFile != null) {
+ resultEntries.put(path, baos);
+ LOG.info("downloaded path:" + path + " - baos size:" + baos.size());
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxDelResult.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxDelResult.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxDelResult.java
new file mode 100755
index 0000000..50ed909
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxDelResult.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.dto;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxDelResult extends DropboxResult {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxDelResult.class);
+
+ /**
+ * Object payload contained in Exchange
+ * Exchange Body is populated with the remote path deleted on dropbox.
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ String remotePath = (String)resultEntries;
+ exchange.getIn().setHeader(DropboxResultHeader.DELETED_PATH.name(), remotePath);
+ exchange.getIn().setBody(remotePath);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileDownloadResult.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileDownloadResult.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileDownloadResult.java
new file mode 100755
index 0000000..394b05d
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileDownloadResult.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.dto;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+
+public class DropboxFileDownloadResult extends DropboxResult {
+
+ /**
+ * Object payload contained in Exchange
+ * In case of a single file Exchange Header is populated with the name of the remote path downloaded
+ * In case of a multiple files Exchange Header is populated with the name of the remote paths downloaded
+ * In case of a single file Exchange Body is populated with the ByteArrayOutputStream downloaded from dropbox.
+ * In case of multiple files Exchange Body is populated with a map containing as key the remote path
+ * and as value the linked ByteArrayOutputStream
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ //in case we have only one baos put it directly in body
+ Map<String, ByteArrayOutputStream> map = (Map<String, ByteArrayOutputStream>)resultEntries;
+ if (map.size() == 1) {
+ //set info in exchange
+ String pathExtracted = null;
+ ByteArrayOutputStream baosExtracted = null;
+ for (Map.Entry<String, ByteArrayOutputStream> entry : map.entrySet()) {
+ pathExtracted = entry.getKey();
+ baosExtracted = entry.getValue();
+ }
+ exchange.getIn().setHeader(DropboxResultHeader.DOWNLOADED_FILE.name(), pathExtracted);
+ exchange.getIn().setBody(baosExtracted);
+ } else {
+ StringBuffer pathsExtracted = new StringBuffer();
+ for (Map.Entry<String, ByteArrayOutputStream> entry : map.entrySet()) {
+ pathsExtracted.append(entry.getKey() + "\n");
+ }
+ exchange.getIn().setHeader(DropboxResultHeader.DOWNLOADED_FILES.name(), pathsExtracted.toString());
+ exchange.getIn().setBody(map);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileUploadResult.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileUploadResult.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileUploadResult.java
new file mode 100755
index 0000000..5774558
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxFileUploadResult.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.dto;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.util.DropboxResultCode;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+
+
+public class DropboxFileUploadResult extends DropboxResult {
+
+ /**
+ * Object payload contained in Exchange
+ * In case of a single file Exchange Header is populated with the name of the remote path uploaded
+ * In case of a multiple files Exchange Header is populated with the name of the remote paths uploaded
+ * In case of a single file Exchange Body is populated with the result code of the upload operation for the remote path.
+ * In case of multiple files Exchange Body is populated with a map containing as key the remote path uploaded
+ * and as value the result code of the upload operation
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ Map<String, DropboxResultCode> map = (Map<String, DropboxResultCode>)resultEntries;
+ if (map.size() == 1) {
+ //set info in exchange
+ String pathExtracted = null;
+ DropboxResultCode codeExtracted = null;
+ for (Map.Entry<String, DropboxResultCode> entry : map.entrySet()) {
+ pathExtracted = entry.getKey();
+ codeExtracted = entry.getValue();
+ }
+ exchange.getIn().setHeader(DropboxResultHeader.UPLOADED_FILE.name(), pathExtracted);
+ exchange.getIn().setBody(codeExtracted.name());
+ } else {
+ StringBuffer pathsExtracted = new StringBuffer();
+ for (Map.Entry<String, DropboxResultCode> entry : map.entrySet()) {
+ pathsExtracted.append(entry.getKey() + "\n");
+ }
+ exchange.getIn().setHeader(DropboxResultHeader.UPLOADED_FILES.name(), pathsExtracted.toString());
+ exchange.getIn().setBody(map);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxMoveResult.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxMoveResult.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxMoveResult.java
new file mode 100755
index 0000000..8337f62
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxMoveResult.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.dto;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DropboxMoveResult extends DropboxResult {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxMoveResult.class);
+
+ /**
+ * Object payload contained in Exchange
+ * Exchange Header and Body contains the mode path
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ String movedPath = (String)resultEntries;
+ exchange.getIn().setHeader(DropboxResultHeader.MOVED_PATH.name(), movedPath);
+ exchange.getIn().setBody(movedPath);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxResult.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxResult.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxResult.java
new file mode 100755
index 0000000..09bb40c
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxResult.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.dto;
+
+import org.apache.camel.Exchange;
+
+
+public abstract class DropboxResult {
+
+ protected Object resultEntries;
+
+ /**
+ * Populate the camel exchange with the results from dropbox method invocations.
+ * @param exchange
+ */
+ public abstract void populateExchange(Exchange exchange);
+
+ public Object getResultEntries() {
+ return resultEntries;
+ }
+
+ public void setResultEntries(Object resultEntries) {
+ this.resultEntries = resultEntries;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxSearchResult.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..97a5972
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/dto/DropboxSearchResult.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.dto;
+
+import java.util.List;
+
+import com.dropbox.core.DbxEntry;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.util.DropboxResultHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DropboxSearchResult extends DropboxResult {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxSearchResult.class);
+
+ /**
+ * Object payload contained in Exchange
+ * Exchange Header is populated with the remote paths found.
+ * Exchange Body is populated with the list of DbxEntry found.
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ StringBuffer fileExtracted = new StringBuffer();
+ List<DbxEntry> entries = null;
+ if (resultEntries != null) {
+ entries = (List<DbxEntry>) resultEntries;
+ for (DbxEntry entry : entries) {
+ fileExtracted.append(entry.name + "-" + entry.path + "\n");
+ }
+ }
+ exchange.getIn().setHeader(DropboxResultHeader.FOUNDED_FILES.name(), fileExtracted.toString());
+ exchange.getIn().setBody(entries);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollConsumer.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..7efc934
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollConsumer.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.consumer;
+
+import org.apache.camel.Processor;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class DropboxScheduledPollConsumer extends ScheduledPollConsumer {
+ protected static final transient Logger LOG = LoggerFactory.getLogger(DropboxScheduledPollConsumer.class);
+ protected DropboxEndpoint endpoint;
+ protected DropboxConfiguration configuration;
+
+ public DropboxScheduledPollConsumer(DropboxEndpoint endpoint, Processor processor, DropboxConfiguration configuration) {
+ super(endpoint, processor);
+ this.endpoint = endpoint;
+ this.configuration = configuration;
+ }
+
+ @Override
+ protected abstract int poll() throws Exception;
+
+ /**
+ * Lifecycle method invoked when the consumer has created.
+ * Internally create or reuse a connection to the low level dropbox client
+ * @throws Exception
+ */
+ @Override
+ protected void doStart() throws Exception {
+ if (configuration.getClient() == null) {
+ //create dropbox client
+ configuration.createClient();
+
+ LOG.info("consumer dropbox client created");
+ }
+
+ super.doStart();
+ }
+
+ /**
+ * Lifecycle method invoked when the consumer has destroyed.
+ * Erase the reference to the dropbox low level client
+ * @throws Exception
+ */
+ @Override
+ protected void doStop() throws Exception {
+ if (configuration.getClient() == null) {
+ configuration.setClient(null);
+
+ LOG.info("consumer dropbox client deleted");
+ }
+ super.doStop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollGetConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollGetConsumer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollGetConsumer.java
new file mode 100755
index 0000000..de42292
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollGetConsumer.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+
+public class DropboxScheduledPollGetConsumer extends DropboxScheduledPollConsumer {
+
+ public DropboxScheduledPollGetConsumer(DropboxEndpoint endpoint, Processor processor, DropboxConfiguration configuration) {
+ super(endpoint, processor, configuration);
+ }
+
+ /**
+ * Poll from a dropbox remote path and put the result in the message exchange
+ * @return number of messages polled
+ * @throws Exception
+ */
+ @Override
+ protected int poll() throws Exception {
+ Exchange exchange = endpoint.createExchange();
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .get(configuration.getRemotePath());
+ result.populateExchange(exchange);
+ LOG.info("consumer --> downloaded: " + result.toString());
+
+ try {
+ // send message to next processor in the route
+ getProcessor().process(exchange);
+ return 1; // number of messages polled
+ } finally {
+ // log exception if an exception occurred and was not handled
+ if (exchange.getException() != null) {
+ getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollSearchConsumer.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..a8c125f
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/consumer/DropboxScheduledPollSearchConsumer.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+
+public class DropboxScheduledPollSearchConsumer extends DropboxScheduledPollConsumer {
+
+ public DropboxScheduledPollSearchConsumer(DropboxEndpoint endpoint, Processor processor, DropboxConfiguration configuration) {
+ super(endpoint, processor, configuration);
+ }
+
+ /**
+ * Poll from a dropbox remote path and put the result in the message exchange
+ * @return number of messages polled
+ * @throws Exception
+ */
+ @Override
+ protected int poll() throws Exception {
+ Exchange exchange = endpoint.createExchange();
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .search(configuration.getRemotePath(), configuration.getQuery());
+ result.populateExchange(exchange);
+ LOG.info("consumer --> downloaded: " + result.toString());
+
+ try {
+ // send message to next processor in the route
+ getProcessor().process(exchange);
+ return 1; // number of messages polled
+ } finally {
+ // log exception if an exception occurred and was not handled
+ if (exchange.getException() != null) {
+ getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxDelProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxDelProducer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxDelProducer.java
new file mode 100755
index 0000000..f81ed34
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxDelProducer.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxDelProducer extends DropboxProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxDelProducer.class);
+
+ public DropboxDelProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .del(configuration.getRemotePath());
+ result.populateExchange(exchange);
+ log.info("Deleted: " + configuration.getRemotePath());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxGetProducer.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..9eaca52
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxGetProducer.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxGetProducer extends DropboxProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxGetProducer.class);
+
+ public DropboxGetProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .get(configuration.getRemotePath());
+ result.populateExchange(exchange);
+ LOG.info("producer --> downloaded: " + result.toString());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxMoveProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxMoveProducer.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxMoveProducer.java
new file mode 100755
index 0000000..7ab6142
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxMoveProducer.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxMoveProducer extends DropboxProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxMoveProducer.class);
+
+ public DropboxMoveProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .move(configuration.getRemotePath(), configuration.getNewRemotePath());
+ result.populateExchange(exchange);
+ log.info("Moved from " + configuration.getRemotePath() + " to " + configuration.getNewRemotePath());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducer.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..7faaa84
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxProducer.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.impl.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class DropboxProducer extends DefaultProducer {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxProducer.class);
+
+ protected DropboxEndpoint endpoint;
+ protected DropboxConfiguration configuration;
+
+ public DropboxProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.configuration = configuration;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ if (configuration.getClient() == null) {
+ //create dropbox client
+ configuration.createClient();
+
+ LOG.info("producer dropbox client created");
+ }
+
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (configuration.getClient() == null) {
+ configuration.setClient(null);
+
+ LOG.info("producer dropbox client deleted");
+ }
+ super.doStop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxPutProducer.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..1def466
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxPutProducer.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxPutProducer extends DropboxProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxPutProducer.class);
+
+ public DropboxPutProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .put(configuration.getLocalPath(), configuration.getRemotePath(), configuration.getUploadMode());
+ result.populateExchange(exchange);
+ LOG.info("Uploaded: " + result.toString());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxSearchProducer.java
----------------------------------------------------------------------
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
new file mode 100755
index 0000000..d15e91e
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/integration/producer/DropboxSearchProducer.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.dropbox.DropboxConfiguration;
+import org.apache.camel.component.dropbox.DropboxEndpoint;
+import org.apache.camel.component.dropbox.core.DropboxAPIFacade;
+import org.apache.camel.component.dropbox.dto.DropboxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DropboxSearchProducer extends DropboxProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(DropboxSearchProducer.class);
+
+ public DropboxSearchProducer(DropboxEndpoint endpoint, DropboxConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
+ .search(configuration.getRemotePath(), configuration.getQuery());
+ result.populateExchange(exchange);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxConstants.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxConstants.java
new file mode 100755
index 0000000..30cdfe4
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxConstants.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+public final class DropboxConstants {
+
+ public static final String DROPBOX_FILE_SEPARATOR = "/";
+ public static final long POLL_CONSUMER_DELAY = 60 * 60 * 1000L;
+
+ private DropboxConstants() { }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxException.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxException.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxException.java
new file mode 100755
index 0000000..387d239
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxException.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+public class DropboxException extends Exception {
+ public DropboxException(String message) {
+ super(message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxOperation.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxOperation.java
new file mode 100755
index 0000000..ab25b75
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxOperation.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+public enum DropboxOperation {
+ put("put"),
+ del("del"),
+ search("search"),
+ get("get"),
+ move("move");
+
+ private final String text;
+
+ private DropboxOperation(final String text) {
+ this.text = text;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxPropertyManager.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxPropertyManager.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxPropertyManager.java
new file mode 100755
index 0000000..f9778fe
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxPropertyManager.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+public final class DropboxPropertyManager {
+
+ private static Properties properties;
+ private static DropboxPropertyManager instance;
+
+ private DropboxPropertyManager() { }
+
+ public static synchronized DropboxPropertyManager getInstance() throws Exception {
+ if (instance == null) {
+ instance = new DropboxPropertyManager();
+ properties = loadProperties();
+ }
+ return instance;
+ }
+
+ public String getProperty(String key) {
+ return (String)properties.getProperty(key);
+ }
+
+
+ private static Properties loadProperties() throws Exception {
+ URL url = DropboxPropertyManager.class.getResource("/dropbox.properties");
+ InputStream inStream;
+ try {
+ inStream = url.openStream();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new DropboxException("dropbox.properties could not be found");
+ }
+ properties = new Properties();
+ try {
+ properties.load(inStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new DropboxException("dropbox.properties can't be read");
+ }
+ return properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/037f3f09/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultCode.java
----------------------------------------------------------------------
diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultCode.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultCode.java
new file mode 100755
index 0000000..d22acef
--- /dev/null
+++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/util/DropboxResultCode.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.dropbox.util;
+
+public enum DropboxResultCode {
+ OK, KO;
+}
+