You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/11/19 09:11:49 UTC
[1/3] camel git commit: CAMEL-8055 Added the atmos component
implementation
Repository: camel
Updated Branches:
refs/heads/camel-atmos [created] 7e9cb79b5
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/resources/META-INF/LICENSE.txt b/components/camel-atmos/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-atmos/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/7d292021/components/camel-atmos/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/resources/META-INF/NOTICE.txt b/components/camel-atmos/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-atmos/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/7d292021/components/camel-atmos/src/main/resources/META-INF/services/org/apache/camel/component/atmos
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/resources/META-INF/services/org/apache/camel/component/atmos b/components/camel-atmos/src/main/resources/META-INF/services/org/apache/camel/component/atmos
new file mode 100644
index 0000000..8a22a6a
--- /dev/null
+++ b/components/camel-atmos/src/main/resources/META-INF/services/org/apache/camel/component/atmos
@@ -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.atmos.AtmosComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/resources/atmos.properties
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/resources/atmos.properties b/components/camel-atmos/src/main/resources/atmos.properties
new file mode 100644
index 0000000..c51ff51
--- /dev/null
+++ b/components/camel-atmos/src/main/resources/atmos.properties
@@ -0,0 +1,21 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+fullTokenId=<Subtentant_ID/UID>
+secretKey=<UID_shared_secret>
+uri=<http(s)://atmos_host>
+sslValidation=<true|false>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
new file mode 100644
index 0000000..85dbb0f
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/AtmosConsumerTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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.atmos;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.consumer.AtmosScheduledPollGetConsumer;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.camel.component.atmos.util.AtmosOperation.get;
+
+public class AtmosConsumerTest extends CamelTestSupport {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("atmos://" + get + "?remotePath=/path").to("mock:test");
+ }
+ };
+ }
+
+ @Test
+ public void shouldCreateGetConsumer() throws Exception {
+ // Given
+ Endpoint atmosEndpoint = context.getEndpoint("atmos://" + get + "?remotePath=/path");
+
+ // When
+ Consumer consumer = atmosEndpoint.createConsumer(null);
+
+ // Then
+ Assert.assertTrue(consumer instanceof AtmosScheduledPollGetConsumer);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/AtmosTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/AtmosTestSupport.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/AtmosTestSupport.java
new file mode 100644
index 0000000..8a9a193
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/AtmosTestSupport.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.atmos.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 AtmosTestSupport extends CamelTestSupport {
+
+ protected final Properties properties;
+
+ protected AtmosTestSupport() 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/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/consumer/AtmosConsumerGetSingleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/consumer/AtmosConsumerGetSingleTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/consumer/AtmosConsumerGetSingleTest.java
new file mode 100644
index 0000000..3ce9239
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/consumer/AtmosConsumerGetSingleTest.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.atmos.integration.consumer;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosConsumerGetSingleTest extends AtmosTestSupport {
+
+ public AtmosConsumerGetSingleTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() throws Exception {
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied(100L, TimeUnit.SECONDS);
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(AtmosResultHeader.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("atmos://get?remotePath=/dummy.txt&localPath=/home")
+ .to("file:///dummy.txt")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerDelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerDelTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerDelTest.java
new file mode 100644
index 0000000..63ef590
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerDelTest.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.atmos.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.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerDelTest extends AtmosTestSupport {
+
+ public AtmosProducerDelTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(AtmosResultHeader.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("atmos://del?remotePath=/dummy.txt")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetFolderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetFolderTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetFolderTest.java
new file mode 100644
index 0000000..a8bbff7
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetFolderTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.atmos.integration.producer;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerGetFolderTest extends AtmosTestSupport {
+
+ public AtmosProducerGetFolderTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(100L, TimeUnit.SECONDS);
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(AtmosResultHeader.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("atmos://get?remotePath=/dummy/&localPath=/home/")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetSingleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetSingleTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetSingleTest.java
new file mode 100644
index 0000000..4d84c36
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerGetSingleTest.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.atmos.integration.producer;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerGetSingleTest extends AtmosTestSupport {
+
+ public AtmosProducerGetSingleTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(100L, TimeUnit.SECONDS);
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(AtmosResultHeader.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("atmos://get?remotePath=/dummy/dummy.txt")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerMoveTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerMoveTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerMoveTest.java
new file mode 100644
index 0000000..22234bf
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerMoveTest.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.atmos.integration.producer;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerMoveTest extends AtmosTestSupport {
+
+ public AtmosProducerMoveTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(100L, TimeUnit.SECONDS);
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(AtmosResultHeader.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("atmos://move?remotePath=/dummy/&newRemotePath=/dummy2/")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutFolderWithRemotePathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutFolderWithRemotePathTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutFolderWithRemotePathTest.java
new file mode 100644
index 0000000..e4c28f2
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutFolderWithRemotePathTest.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.atmos.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.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerPutFolderWithRemotePathTest extends AtmosTestSupport {
+
+ public AtmosProducerPutFolderWithRemotePathTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(AtmosResultHeader.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("atmos://put?localPath=/home&remotePath=/dummy/")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileTest.java
new file mode 100644
index 0000000..6bca8ea
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileTest.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.atmos.integration.producer;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerPutSingleFileTest extends AtmosTestSupport {
+
+ public AtmosProducerPutSingleFileTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(100L, TimeUnit.SECONDS);
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(AtmosResultHeader.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("atmos://put?localPath=/home/dummy.txt")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileWithRemotePathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileWithRemotePathTest.java b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileWithRemotePathTest.java
new file mode 100644
index 0000000..f473838
--- /dev/null
+++ b/components/camel-atmos/src/test/java/org/apache/camel/component/atmos/integration/producer/AtmosProducerPutSingleFileWithRemotePathTest.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.atmos.integration.producer;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.atmos.integration.AtmosTestSupport;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+
+public class AtmosProducerPutSingleFileWithRemotePathTest extends AtmosTestSupport {
+
+ public AtmosProducerPutSingleFileWithRemotePathTest() throws Exception { }
+
+ @Test
+ public void testCamelAtmos() 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(100L, TimeUnit.SECONDS);
+
+ List<Exchange> exchanges = mock.getReceivedExchanges();
+ Exchange exchange = exchanges.get(0);
+ Object header = exchange.getIn().getHeader(AtmosResultHeader.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("atmos://put?localPath=/home/dummy.txt&remotePath=/dummy/")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/resources/log4j.properties b/components/camel-atmos/src/test/resources/log4j.properties
new file mode 100644
index 0000000..1f2a1f3
--- /dev/null
+++ b/components/camel-atmos/src/test/resources/log4j.properties
@@ -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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.springframework=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-atmos-test.log
+log4j.appender.out.append=true
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/resources/test-options.properties b/components/camel-atmos/src/test/resources/test-options.properties
new file mode 100644
index 0000000..52e50d9
--- /dev/null
+++ b/components/camel-atmos/src/test/resources/test-options.properties
@@ -0,0 +1,21 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+fullTokenId=<Subtentant_ID/UID>
+secretKey=<UID_shared_secret>
+uri=<http(s)://atmos_host>
+sslValidation=<true|false>
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 5a98fa3..575ee1d 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -59,6 +59,7 @@
<module>camel-ahc-ws</module>
<module>camel-amqp</module>
<module>camel-apns</module>
+ <module>camel-atmos</module>
<module>camel-atmosphere-websocket</module>
<module>camel-atom</module>
<module>camel-avro</module>
[2/3] camel git commit: CAMEL-8055 Added the atmos component
implementation
Posted by ni...@apache.org.
CAMEL-8055 Added the atmos component implementation
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7d292021
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7d292021
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7d292021
Branch: refs/heads/camel-atmos
Commit: 7d2920217b9bcc91bc2eaaab21cd37a52502f876
Parents: e6f9f02
Author: Alessio Cervellin <al...@3bitcom.com>
Authored: Tue Nov 18 19:36:22 2014 +0100
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 19 15:44:50 2014 +0800
----------------------------------------------------------------------
components/camel-atmos/pom.xml | 116 ++++++++
.../camel/component/atmos/AtmosComponent.java | 75 ++++++
.../component/atmos/AtmosConfiguration.java | 160 +++++++++++
.../camel/component/atmos/AtmosEndpoint.java | 99 +++++++
.../component/atmos/core/AtmosAPIFacade.java | 269 +++++++++++++++++++
.../component/atmos/dto/AtmosDelResult.java | 35 +++
.../atmos/dto/AtmosFileDownloadResult.java | 59 ++++
.../atmos/dto/AtmosFileUploadResult.java | 59 ++++
.../component/atmos/dto/AtmosMoveResult.java | 36 +++
.../camel/component/atmos/dto/AtmosResult.java | 40 +++
.../consumer/AtmosScheduledPollConsumer.java | 72 +++++
.../consumer/AtmosScheduledPollGetConsumer.java | 56 ++++
.../integration/producer/AtmosDelProducer.java | 40 +++
.../integration/producer/AtmosGetProducer.java | 43 +++
.../integration/producer/AtmosMoveProducer.java | 39 +++
.../integration/producer/AtmosProducer.java | 59 ++++
.../integration/producer/AtmosPutProducer.java | 43 +++
.../component/atmos/util/AtmosConstants.java | 26 ++
.../component/atmos/util/AtmosException.java | 30 +++
.../component/atmos/util/AtmosOperation.java | 38 +++
.../atmos/util/AtmosPropertyManager.java | 62 +++++
.../component/atmos/util/AtmosResultCode.java | 22 ++
.../component/atmos/util/AtmosResultHeader.java | 22 ++
.../validator/AtmosConfigurationValidator.java | 128 +++++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../services/org/apache/camel/component/atmos | 18 ++
.../src/main/resources/atmos.properties | 21 ++
.../component/atmos/AtmosConsumerTest.java | 53 ++++
.../atmos/integration/AtmosTestSupport.java | 55 ++++
.../consumer/AtmosConsumerGetSingleTest.java | 59 ++++
.../producer/AtmosProducerDelTest.java | 66 +++++
.../producer/AtmosProducerGetFolderTest.java | 69 +++++
.../producer/AtmosProducerGetSingleTest.java | 67 +++++
.../producer/AtmosProducerMoveTest.java | 67 +++++
...tmosProducerPutFolderWithRemotePathTest.java | 67 +++++
.../AtmosProducerPutSingleFileTest.java | 67 +++++
...ProducerPutSingleFileWithRemotePathTest.java | 67 +++++
.../src/test/resources/log4j.properties | 35 +++
.../src/test/resources/test-options.properties | 21 ++
components/pom.xml | 1 +
41 files changed, 2575 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-atmos/pom.xml b/components/camel-atmos/pom.xml
new file mode 100644
index 0000000..c18de89
--- /dev/null
+++ b/components/camel-atmos/pom.xml
@@ -0,0 +1,116 @@
+<?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.15-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-atmos</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Atmos</name>
+ <description>Camel Atmos support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.atmos.*</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=atmos</camel.osgi.export.service>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- atmos -->
+ <dependency>
+ <groupId>com.emc.vipr</groupId>
+ <artifactId>atmos-client</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+
+ <!-- apache commons-io -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons-io-version}</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-core</artifactId>
+ <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>
+
+ <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>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
new file mode 100644
index 0000000..576c955
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
@@ -0,0 +1,75 @@
+/**
+ * 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.atmos;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.atmos.util.AtmosOperation;
+import org.apache.camel.component.atmos.util.AtmosPropertyManager;
+import org.apache.camel.component.atmos.validator.AtmosConfigurationValidator;
+import org.apache.camel.impl.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AtmosComponent extends DefaultComponent {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosComponent.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 {
+ AtmosConfiguration configuration = new AtmosConfiguration();
+
+ // set options from component
+ configuration.setUri((String) parameters.get("uri") == null
+ ? AtmosPropertyManager.getInstance().getProperty("uri")
+ : (String) parameters.get("uri"));
+ configuration.setSecretKey((String) parameters.get("secretKey") == null
+ ? AtmosPropertyManager.getInstance().getProperty("secretKey")
+ : (String) parameters.get("secretKey"));
+ 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(AtmosOperation.valueOf(remaining));
+ configuration.setFullTokenId(parameters.get("fullTokenId") == null
+ ? AtmosPropertyManager.getInstance().getProperty("fullTokenId")
+ : (String) parameters.get("fullTokenId"));
+ configuration.setEnableSslValidation(Boolean.parseBoolean((String) AtmosPropertyManager.getInstance().getProperty("sslValidation")));
+
+ //pass validation test
+ AtmosConfigurationValidator.validate(configuration);
+
+ // and then override from parameters
+ setProperties(configuration, parameters);
+
+ LOG.info("atmos configuration set!");
+
+ Endpoint endpoint = new AtmosEndpoint(uri, this, configuration);
+ return endpoint;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
new file mode 100644
index 0000000..43a7386
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
@@ -0,0 +1,160 @@
+/**
+ * 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.atmos;
+
+import com.emc.atmos.api.AtmosApi;
+import com.emc.atmos.api.AtmosConfig;
+import com.emc.atmos.api.jersey.AtmosApiClient;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.component.atmos.util.AtmosException;
+import org.apache.camel.component.atmos.util.AtmosOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AtmosConfiguration {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosConfiguration.class);
+
+ //atmos shared secret
+ private String secretKey;
+ //local path to put files
+ private String localPath;
+ //where to put files on atmos
+ private String remotePath;
+ //new path on atmos when moving files
+ private String newRemotePath;
+ //search query on atmos
+ private String query;
+ //atmos client fullTokenId
+ private String fullTokenId;
+ //atmos server uri
+ private String uri;
+ //atmos ssl validation
+ private boolean enableSslValidation;
+ //specific atmos operation for the component
+ private AtmosOperation operation;
+ //reference to atmo client
+ private AtmosApi client;
+
+ public void setClient(AtmosApi client) {
+ this.client = client;
+ }
+
+ public AtmosApi getClient() {
+ return client;
+ }
+
+ /**
+ * Obtain a new instance of AtmosApi client and store it in configuration.
+ *
+ * @throws AtmosException
+ */
+ public void createClient() throws AtmosException {
+ AtmosConfig config = null;
+ try {
+ config = new AtmosConfig(fullTokenId, secretKey, new URI(uri));
+ } catch (URISyntaxException use) {
+ throw new AtmosException("wrong syntax for Atmos URI!", use);
+ }
+ if (config == null) {
+ throw new AtmosException("can't configure the Atmos client!");
+ }
+ if (!enableSslValidation) {
+ config.setDisableSslValidation(true);
+ }
+ AtmosApi atmosclient = new AtmosApiClient(config);
+ if (atmosclient == null) {
+ throw new AtmosException("can't establish an Atmos connection!");
+ }
+ this.client = atmosclient;
+ }
+
+ public String getSecretKey() {
+ return secretKey;
+ }
+
+ public void setSecretKey(String secretKey) {
+ this.secretKey = secretKey;
+ }
+
+ 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 getFullTokenId() {
+ return fullTokenId;
+ }
+
+ public void setFullTokenId(String fullTokenId) {
+ this.fullTokenId = fullTokenId;
+ }
+
+ public AtmosOperation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(AtmosOperation operation) {
+ this.operation = operation;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public boolean isEnableSslValidation() {
+ return enableSslValidation;
+ }
+
+ public void setEnableSslValidation(boolean enableSslValidation) {
+ this.enableSslValidation = enableSslValidation;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
new file mode 100644
index 0000000..f272ab4
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
@@ -0,0 +1,99 @@
+/**
+ * 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.atmos;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.atmos.integration.consumer.AtmosScheduledPollConsumer;
+import org.apache.camel.component.atmos.integration.consumer.AtmosScheduledPollGetConsumer;
+import org.apache.camel.component.atmos.integration.producer.AtmosDelProducer;
+import org.apache.camel.component.atmos.integration.producer.AtmosGetProducer;
+import org.apache.camel.component.atmos.integration.producer.AtmosMoveProducer;
+import org.apache.camel.component.atmos.integration.producer.AtmosPutProducer;
+import org.apache.camel.component.atmos.util.AtmosException;
+import org.apache.camel.component.atmos.util.AtmosOperation;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.atmos.util.AtmosConstants.POLL_CONSUMER_DELAY;
+
+public class AtmosEndpoint extends DefaultEndpoint {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosEndpoint.class);
+
+ private AtmosConfiguration configuration;
+
+ public AtmosEndpoint() {
+ }
+
+ public AtmosEndpoint(String uri, AtmosComponent component, AtmosConfiguration configuration) {
+ super(uri, component);
+ this.configuration = configuration;
+ }
+
+ public AtmosEndpoint(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 atmos endpoint {" + configuration.getOperation().toString() + "}");
+ LOG.info("resolve producer atmos attached client: " + configuration.getClient());
+ if (configuration.getOperation() == AtmosOperation.put) {
+ return new AtmosPutProducer(this, configuration);
+ } else if (this.configuration.getOperation() == AtmosOperation.del) {
+ return new AtmosDelProducer(this, configuration);
+ } else if (this.configuration.getOperation() == AtmosOperation.get) {
+ return new AtmosGetProducer(this, configuration);
+ } else if (this.configuration.getOperation() == AtmosOperation.move) {
+ return new AtmosMoveProducer(this, configuration);
+ } else {
+ throw new AtmosException("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 atmos endpoint {" + configuration.getOperation().toString() + "}");
+ LOG.debug("resolve consumer atmos attached client:" + configuration.getClient());
+ AtmosScheduledPollConsumer consumer = null;
+ if (this.configuration.getOperation() == AtmosOperation.get) {
+ consumer = new AtmosScheduledPollGetConsumer(this, processor, configuration);
+ consumer.setDelay(POLL_CONSUMER_DELAY);
+ return consumer;
+ } else {
+ throw new AtmosException("operation specified is not valid for consumer!");
+ }
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
new file mode 100644
index 0000000..852193e
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
@@ -0,0 +1,269 @@
+/**
+ * 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.atmos.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.Map;
+
+import com.emc.atmos.api.AtmosApi;
+import com.emc.atmos.api.ObjectId;
+import com.emc.atmos.api.ObjectPath;
+import com.emc.atmos.api.bean.DirectoryEntry;
+import com.emc.atmos.api.request.CreateObjectRequest;
+import com.emc.atmos.api.request.ListDirectoryRequest;
+import org.apache.camel.component.atmos.dto.AtmosDelResult;
+import org.apache.camel.component.atmos.dto.AtmosFileDownloadResult;
+import org.apache.camel.component.atmos.dto.AtmosFileUploadResult;
+import org.apache.camel.component.atmos.dto.AtmosMoveResult;
+import org.apache.camel.component.atmos.dto.AtmosResult;
+import org.apache.camel.component.atmos.util.AtmosException;
+import org.apache.camel.component.atmos.util.AtmosResultCode;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.atmos.util.AtmosConstants.ATMOS_FILE_SEPARATOR;
+
+public final class AtmosAPIFacade {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosAPIFacade.class);
+
+ private static AtmosAPIFacade instance;
+ private static AtmosApi client;
+
+ private AtmosAPIFacade() {
+ }
+
+ /**
+ * Return a singleton instance of this class
+ *
+ * @param client the AtmosClient performing atmos low level operations
+ * @return the singleton instance of this class
+ */
+ public static AtmosAPIFacade getInstance(AtmosApi client) {
+ if (instance == null) {
+ instance = new AtmosAPIFacade();
+ AtmosAPIFacade.client = client;
+ }
+ return instance;
+ }
+
+ /**
+ * Put or upload a new file or an entire directory to atmos
+ *
+ * @param localPath the file path or the dir path on the local filesystem
+ * @param remotePath the remote path destination on atmos
+ * the file already existing with the same name
+ * will be overridden.
+ * @return a AtmosResult object reporting for each remote path the result of
+ * the operation.
+ * @throws AtmosException
+ */
+ public AtmosResult put(String localPath, String remotePath) throws AtmosException {
+ AtmosResult result = new AtmosFileUploadResult();
+ //a map representing for each path the result of the put operation
+ Map<String, AtmosResultCode> resultEntries = null;
+ //in case the remote path is not specified, the remotePath = localPath
+ String atmosPath = remotePath == null ? localPath : remotePath;
+ if (!atmosPath.endsWith(ATMOS_FILE_SEPARATOR)) {
+ atmosPath += ATMOS_FILE_SEPARATOR;
+ }
+ ObjectPath atmosEntry = new ObjectPath(atmosPath);
+
+ if (!atmosPath.equals(ATMOS_FILE_SEPARATOR)) {
+ if (AtmosAPIFacade.client.getSystemMetadata(atmosEntry) == null) {
+ throw new AtmosException(atmosPath + " does not exist or can't obtain metadata");
+ }
+ }
+
+ File fileLocalPath = new File(localPath);
+ //verify uploading of a single file
+ if (fileLocalPath.isFile()) {
+ //check if atmos file exists
+ if (atmosEntry != null && !atmosEntry.isDirectory()) {
+ throw new AtmosException(atmosPath + " exists on atmos and is not a folder!");
+ }
+ atmosPath = atmosPath + fileLocalPath.getName();
+ resultEntries = new HashMap<String, AtmosResultCode>(1);
+ try {
+ ObjectId uploadedFile = putSingleFile(fileLocalPath, atmosPath);
+ if (uploadedFile == null) {
+ resultEntries.put(atmosPath, AtmosResultCode.KO);
+ } else {
+ resultEntries.put(atmosPath, AtmosResultCode.OK);
+ }
+
+ } catch (Exception ex) {
+ resultEntries.put(atmosPath, AtmosResultCode.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 atmos folder exists
+ if (atmosEntry != null && !atmosEntry.isDirectory()) {
+ throw new AtmosException(atmosPath + " exists on atmos and is not a folder!");
+ }
+ //revert to old path
+ String oldAtmosPath = atmosPath;
+ //list all files in a dir
+ Collection<File> listFiles = FileUtils.listFiles(fileLocalPath, null, true);
+ if (listFiles == null || listFiles.isEmpty()) {
+ throw new AtmosException(localPath + " doesn't contain any files");
+ }
+ resultEntries = new HashMap<String, AtmosResultCode>(listFiles.size());
+ for (File file : listFiles) {
+ String absPath = file.getAbsolutePath();
+ int indexRemainingPath = localPath.length();
+ if (!localPath.endsWith("/")) {
+ indexRemainingPath += 1;
+ }
+ String remainingPath = absPath.substring(indexRemainingPath);
+ atmosPath = atmosPath + remainingPath;
+ try {
+ LOG.info("uploading:" + fileLocalPath + "," + atmosPath);
+ ObjectId uploadedFile = putSingleFile(file, atmosPath);
+ if (uploadedFile == null) {
+ resultEntries.put(atmosPath, AtmosResultCode.KO);
+ } else {
+ resultEntries.put(atmosPath, AtmosResultCode.OK);
+ }
+ } catch (Exception ex) {
+ resultEntries.put(atmosPath, AtmosResultCode.KO);
+ }
+ atmosPath = oldAtmosPath;
+ }
+ result.setResultEntries(resultEntries);
+ return result;
+ }
+ }
+
+ private ObjectId putSingleFile(File inputFile, String atmosPath) throws Exception {
+ FileInputStream inputStream = new FileInputStream(inputFile);
+ ObjectId uploadedFile = null;
+ try {
+ ObjectPath op = new ObjectPath(atmosPath);
+ CreateObjectRequest request = new CreateObjectRequest();
+ request.identifier(op).content(inputStream).contentLength(inputFile.length());
+ uploadedFile = AtmosAPIFacade.client.createObject(request).getObjectId();
+ return uploadedFile;
+ } finally {
+ inputStream.close();
+ }
+ }
+
+ /**
+ * 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 AtmosResult object with the result of the delete operation.
+ * @throws AtmosException
+ */
+ public AtmosResult del(String remotePath) throws AtmosException {
+ AtmosResult result = null;
+ ObjectPath op = new ObjectPath(remotePath);
+ AtmosAPIFacade.client.delete(op);
+ result = new AtmosDelResult();
+ 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 AtmosResult object with the result of the move operation.
+ * @throws AtmosException
+ */
+ public AtmosResult move(String remotePath, String newRemotePath) throws AtmosException {
+ AtmosResult result = null;
+ AtmosAPIFacade.client.move(new ObjectPath(remotePath), new ObjectPath(newRemotePath), true);
+ result = new AtmosMoveResult();
+ 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 AtmosResult object with the content (ByteArrayOutputStream) of
+ * every files inside the remote path.
+ * @throws AtmosException
+ */
+ public AtmosResult get(String remotePath) throws AtmosException {
+ AtmosResult result = new AtmosFileDownloadResult();
+ //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 atmosPath, Map<String, ByteArrayOutputStream> resultEntries) throws AtmosException {
+ ObjectPath atmosEntry = new ObjectPath(atmosPath);
+ if (AtmosAPIFacade.client.getSystemMetadata(atmosEntry) == null) {
+ throw new AtmosException(atmosPath + " does not exist or can't obtain metadata");
+ }
+ if (!atmosEntry.isDirectory()) {
+ LOG.info("downloading a single file...");
+ downloadSingleFile(atmosPath, resultEntries);
+ return;
+ }
+ ListDirectoryRequest listRequest = new ListDirectoryRequest().path(atmosEntry);
+ AtmosAPIFacade.client.listDirectory(listRequest);
+ for (DirectoryEntry entry : AtmosAPIFacade.client.listDirectory(listRequest).getEntries()) {
+ if (!entry.isDirectory()) {
+ try {
+ //get the baos of the file
+ downloadSingleFile(atmosEntry.getPath().concat(entry.getFilename()), resultEntries);
+ } catch (AtmosException e) {
+ LOG.warn("can't download from " + entry.getFilename());
+ }
+ } else {
+ //iterate on folder
+ downloadFilesInFolder(atmosEntry.getPath().concat(entry.getFilename()), resultEntries);
+ }
+ }
+ }
+
+ private void downloadSingleFile(String path, Map<String, ByteArrayOutputStream> resultEntries) throws AtmosException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] content = null;
+ try {
+ content = AtmosAPIFacade.client.readObject(new ObjectPath(path), byte[].class);
+ baos.write(content);
+ } catch (IOException e) {
+ throw new AtmosException(path + " can't obtain a stream", e);
+ }
+ if (content != null) {
+ resultEntries.put(path, baos);
+ LOG.info("downloaded path:" + path + " - baos size:" + baos.size());
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosDelResult.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosDelResult.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosDelResult.java
new file mode 100644
index 0000000..bd9927e
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosDelResult.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.atmos.dto;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+
+public class AtmosDelResult extends AtmosResult {
+
+ /**
+ * Object payload contained in Exchange
+ * Exchange Body is populated with the remote path deleted on atmos.
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ String remotePath = (String)resultEntries;
+ exchange.getIn().setHeader(AtmosResultHeader.DELETED_PATH.name(), remotePath);
+ exchange.getIn().setBody(remotePath);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileDownloadResult.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileDownloadResult.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileDownloadResult.java
new file mode 100644
index 0000000..1b18264
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileDownloadResult.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.atmos.dto;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+
+public class AtmosFileDownloadResult extends AtmosResult {
+
+ /**
+ * 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 atmos.
+ * 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(AtmosResultHeader.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(AtmosResultHeader.DOWNLOADED_FILES.name(), pathsExtracted.toString());
+ exchange.getIn().setBody(map);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileUploadResult.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileUploadResult.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileUploadResult.java
new file mode 100644
index 0000000..c7b4dcf
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosFileUploadResult.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.atmos.dto;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.util.AtmosResultCode;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+
+
+public class AtmosFileUploadResult extends AtmosResult {
+
+ /**
+ * 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, AtmosResultCode> map = (Map<String, AtmosResultCode>)resultEntries;
+ if (map.size() == 1) {
+ //set info in exchange
+ String pathExtracted = null;
+ AtmosResultCode codeExtracted = null;
+ for (Map.Entry<String, AtmosResultCode> entry : map.entrySet()) {
+ pathExtracted = entry.getKey();
+ codeExtracted = entry.getValue();
+ }
+ exchange.getIn().setHeader(AtmosResultHeader.UPLOADED_FILE.name(), pathExtracted);
+ exchange.getIn().setBody(codeExtracted.name());
+ } else {
+ StringBuffer pathsExtracted = new StringBuffer();
+ for (Map.Entry<String, AtmosResultCode> entry : map.entrySet()) {
+ pathsExtracted.append(entry.getKey() + "\n");
+ }
+ exchange.getIn().setHeader(AtmosResultHeader.UPLOADED_FILES.name(), pathsExtracted.toString());
+ exchange.getIn().setBody(map);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosMoveResult.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosMoveResult.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosMoveResult.java
new file mode 100644
index 0000000..e745da5
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosMoveResult.java
@@ -0,0 +1,36 @@
+/**
+ * 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.atmos.dto;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.util.AtmosResultHeader;
+
+
+public class AtmosMoveResult extends AtmosResult {
+
+ /**
+ * Object payload contained in Exchange
+ * Exchange Header and Body contains the moved path
+ * @param exchange
+ */
+ @Override
+ public void populateExchange(Exchange exchange) {
+ String movedPath = (String)resultEntries;
+ exchange.getIn().setHeader(AtmosResultHeader.MOVED_PATH.name(), movedPath);
+ exchange.getIn().setBody(movedPath);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosResult.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosResult.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosResult.java
new file mode 100644
index 0000000..74e22d3
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/dto/AtmosResult.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.atmos.dto;
+
+import org.apache.camel.Exchange;
+
+
+public abstract class AtmosResult {
+
+ protected Object resultEntries;
+
+ /**
+ * Populate the camel exchange with the results from atmos 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/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollConsumer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollConsumer.java
new file mode 100644
index 0000000..24863b0
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollConsumer.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.atmos.integration.consumer;
+
+import org.apache.camel.Processor;
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class AtmosScheduledPollConsumer extends ScheduledPollConsumer {
+ protected static final transient Logger LOG = LoggerFactory.getLogger(AtmosScheduledPollConsumer.class);
+ protected AtmosEndpoint endpoint;
+ protected AtmosConfiguration configuration;
+
+ public AtmosScheduledPollConsumer(AtmosEndpoint endpoint, Processor processor, AtmosConfiguration 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 atmos client
+ * @throws Exception
+ */
+ @Override
+ protected void doStart() throws Exception {
+ if (configuration.getClient() == null) {
+ //create atmos client
+ configuration.createClient();
+
+ LOG.info("consumer atmos client created");
+ }
+
+ super.doStart();
+ }
+
+ /**
+ * Lifecycle method invoked when the consumer has destroyed.
+ * Erase the reference to the atmos low level client
+ * @throws Exception
+ */
+ @Override
+ protected void doStop() throws Exception {
+ if (configuration.getClient() == null) {
+ configuration.setClient(null);
+
+ LOG.info("consumer atmos client deleted");
+ }
+ super.doStop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollGetConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollGetConsumer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollGetConsumer.java
new file mode 100644
index 0000000..a97f15e
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/consumer/AtmosScheduledPollGetConsumer.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.atmos.integration.consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.component.atmos.core.AtmosAPIFacade;
+import org.apache.camel.component.atmos.dto.AtmosResult;
+
+public class AtmosScheduledPollGetConsumer extends AtmosScheduledPollConsumer {
+
+ public AtmosScheduledPollGetConsumer(AtmosEndpoint endpoint, Processor processor, AtmosConfiguration configuration) {
+ super(endpoint, processor, configuration);
+ }
+
+ /**
+ * Poll from an atmos 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();
+ AtmosResult result = AtmosAPIFacade.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/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosDelProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosDelProducer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosDelProducer.java
new file mode 100644
index 0000000..bf8c9b7
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosDelProducer.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.atmos.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.component.atmos.core.AtmosAPIFacade;
+import org.apache.camel.component.atmos.dto.AtmosResult;
+
+public class AtmosDelProducer extends AtmosProducer {
+
+ public AtmosDelProducer(AtmosEndpoint endpoint, AtmosConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ AtmosResult result = AtmosAPIFacade.getInstance(configuration.getClient())
+ .del(configuration.getRemotePath());
+ result.populateExchange(exchange);
+ log.info("Deleted: " + configuration.getRemotePath());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosGetProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosGetProducer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosGetProducer.java
new file mode 100644
index 0000000..256ad97
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosGetProducer.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.atmos.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.component.atmos.core.AtmosAPIFacade;
+import org.apache.camel.component.atmos.dto.AtmosResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AtmosGetProducer extends AtmosProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosGetProducer.class);
+
+ public AtmosGetProducer(AtmosEndpoint endpoint, AtmosConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ AtmosResult result = AtmosAPIFacade.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/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosMoveProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosMoveProducer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosMoveProducer.java
new file mode 100644
index 0000000..a33536a
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosMoveProducer.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.atmos.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.component.atmos.core.AtmosAPIFacade;
+import org.apache.camel.component.atmos.dto.AtmosResult;
+
+public class AtmosMoveProducer extends AtmosProducer {
+
+ public AtmosMoveProducer(AtmosEndpoint endpoint, AtmosConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ AtmosResult result = AtmosAPIFacade.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/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosProducer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosProducer.java
new file mode 100644
index 0000000..afea01c
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosProducer.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.atmos.integration.producer;
+
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.impl.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AtmosProducer extends DefaultProducer {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosProducer.class);
+
+ protected AtmosEndpoint endpoint;
+ protected AtmosConfiguration configuration;
+
+ public AtmosProducer(AtmosEndpoint endpoint, AtmosConfiguration configuration) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.configuration = configuration;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ if (configuration.getClient() == null) {
+ //create atmos client
+ configuration.createClient();
+
+ LOG.info("producer atmos client created");
+ }
+
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (configuration.getClient() == null) {
+ configuration.setClient(null);
+
+ LOG.info("producer atmos client deleted");
+ }
+ super.doStop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosPutProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosPutProducer.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosPutProducer.java
new file mode 100644
index 0000000..c6cfa1f
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/integration/producer/AtmosPutProducer.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.atmos.integration.producer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.AtmosEndpoint;
+import org.apache.camel.component.atmos.core.AtmosAPIFacade;
+import org.apache.camel.component.atmos.dto.AtmosResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AtmosPutProducer extends AtmosProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(AtmosPutProducer.class);
+
+ public AtmosPutProducer(AtmosEndpoint endpoint, AtmosConfiguration configuration) {
+ super(endpoint, configuration);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ AtmosResult result = AtmosAPIFacade.getInstance(configuration.getClient())
+ .put(configuration.getLocalPath(), configuration.getRemotePath());
+ result.populateExchange(exchange);
+ LOG.info("Uploaded: " + result.toString());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosConstants.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosConstants.java
new file mode 100644
index 0000000..3049e67
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosConstants.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.atmos.util;
+
+public final class AtmosConstants {
+
+ public static final String ATMOS_FILE_SEPARATOR = "/";
+ public static final long POLL_CONSUMER_DELAY = 60 * 60 * 1000L;
+
+ private AtmosConstants() { }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosException.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosException.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosException.java
new file mode 100644
index 0000000..1740887
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.atmos.util;
+
+public class AtmosException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public AtmosException(String message) {
+ super(message);
+ }
+
+ public AtmosException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosOperation.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosOperation.java
new file mode 100644
index 0000000..2764c18
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosOperation.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.atmos.util;
+
+public enum AtmosOperation {
+ put("put"),
+ del("del"),
+ search("search"),
+ get("get"),
+ move("move");
+
+ private final String text;
+
+ private AtmosOperation(final String text) {
+ this.text = text;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
new file mode 100644
index 0000000..cc8ceec
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.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.atmos.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+public final class AtmosPropertyManager {
+
+ private static Properties properties;
+ private static AtmosPropertyManager instance;
+
+ private AtmosPropertyManager() { }
+
+ public static synchronized AtmosPropertyManager getInstance() throws Exception {
+ if (instance == null) {
+ instance = new AtmosPropertyManager();
+ properties = loadProperties();
+ }
+ return instance;
+ }
+
+ public String getProperty(String key) {
+ return properties.getProperty(key);
+ }
+
+
+ private static Properties loadProperties() throws Exception {
+ URL url = AtmosPropertyManager.class.getResource("/atmos.properties");
+ InputStream inStream;
+ try {
+ inStream = url.openStream();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new AtmosException("atmos.properties could not be found");
+ }
+ properties = new Properties();
+ try {
+ properties.load(inStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new AtmosException("atmos.properties can't be read");
+ }
+ return properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultCode.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultCode.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultCode.java
new file mode 100644
index 0000000..db860ce
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultCode.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.atmos.util;
+
+public enum AtmosResultCode {
+ OK, KO;
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultHeader.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultHeader.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultHeader.java
new file mode 100644
index 0000000..c119401
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosResultHeader.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.atmos.util;
+
+public enum AtmosResultHeader {
+ DOWNLOADED_FILE, DOWNLOADED_FILES, UPLOADED_FILE, UPLOADED_FILES, FOUND_FILES , DELETED_PATH, MOVED_PATH;
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/7d292021/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
new file mode 100644
index 0000000..ccb2fcf
--- /dev/null
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
@@ -0,0 +1,128 @@
+/**
+ * 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.atmos.validator;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.component.atmos.AtmosConfiguration;
+import org.apache.camel.component.atmos.util.AtmosException;
+import org.apache.camel.component.atmos.util.AtmosOperation;
+import static org.apache.camel.component.atmos.util.AtmosConstants.ATMOS_FILE_SEPARATOR;
+
+public final class AtmosConfigurationValidator {
+
+ private AtmosConfigurationValidator() {
+ }
+
+ /**
+ * Validate the parameters passed in the incoming url.
+ *
+ * @param configuration object containing the parameters.
+ * @throws AtmosException
+ */
+ public static void validate(AtmosConfiguration configuration) throws AtmosException {
+ validateCommonProperties(configuration);
+ AtmosOperation op = configuration.getOperation();
+ if (op == AtmosOperation.get) {
+ validateGetOp(configuration);
+ } else if (op == AtmosOperation.put) {
+ validatePutOp(configuration);
+ } else if (op == AtmosOperation.del) {
+ validateDelOp(configuration);
+ } else if (op == AtmosOperation.move) {
+ validateMoveOp(configuration);
+ }
+ }
+
+ private static void validateCommonProperties(AtmosConfiguration configuration) throws AtmosException {
+ if (configuration.getFullTokenId() == null || configuration.getFullTokenId().equals("")) {
+ throw new AtmosException("option <fullTokenId> is not present or not valid!");
+ }
+ if (configuration.getSecretKey() == null || configuration.getSecretKey().equals("")) {
+ throw new AtmosException("option <secretKey> is not present or not valid!");
+ }
+ if (configuration.getUri() == null || configuration.getUri().equals("")) {
+ throw new AtmosException("option <uri> is not present!");
+ } else {
+ try {
+ URI uri = new URI(configuration.getUri());
+ } catch (URISyntaxException use) {
+ throw new AtmosException("option <uri> is not valid!", use);
+ }
+ }
+ }
+
+ private static void validateGetOp(AtmosConfiguration configuration) throws AtmosException {
+ validateRemotePath(configuration.getRemotePath());
+ }
+
+ private static void validatePutOp(AtmosConfiguration configuration) throws AtmosException {
+ 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());
+ }
+ }
+
+ private static void validateDelOp(AtmosConfiguration configuration) throws AtmosException {
+ validateRemotePath(configuration.getRemotePath());
+ }
+
+ private static void validateMoveOp(AtmosConfiguration configuration) throws AtmosException {
+ validateRemotePath(configuration.getRemotePath());
+ validateRemotePath(configuration.getNewRemotePath());
+ }
+
+ private static void validateLocalPath(String localPath) throws AtmosException {
+ if (localPath == null || localPath.equals("")) {
+ throw new AtmosException("option <localPath> is not present or not valid!");
+ }
+ File file = new File(localPath);
+ if (!file.exists()) {
+ throw new AtmosException("option <localPath> is not an existing file or directory!");
+ }
+ }
+
+ private static void validateRemotePath(String remotePath) throws AtmosException {
+ if (remotePath == null || !remotePath.startsWith(ATMOS_FILE_SEPARATOR)) {
+ throw new AtmosException("option <remotePath> is not valid!");
+ }
+ validatePathInUnix(remotePath);
+ }
+
+ private static void validateRemotePathForPut(String remotePath) throws AtmosException {
+ if (!remotePath.startsWith(ATMOS_FILE_SEPARATOR)) {
+ throw new AtmosException("option <remotePath> is not valid!");
+ }
+ validatePathInUnix(remotePath);
+ }
+
+ private static void validatePathInUnix(String path) throws AtmosException {
+ Pattern pattern = Pattern.compile("/*?(\\S+)/*?", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(path);
+ if (!matcher.matches()) {
+ throw new AtmosException(path + " is not a valid path, must be in UNIX form!");
+ }
+ }
+
+}
[3/3] camel git commit: CAMEL-8055 Fixed some CS errors and Unit test
error
Posted by ni...@apache.org.
CAMEL-8055 Fixed some CS errors and Unit test error
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7e9cb79b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7e9cb79b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7e9cb79b
Branch: refs/heads/camel-atmos
Commit: 7e9cb79b5a96f2e40f9a4f6dc6a1e6c7dd022c6b
Parents: 7d29202
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Nov 19 16:11:20 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 19 16:11:20 2014 +0800
----------------------------------------------------------------------
.../camel/component/atmos/AtmosComponent.java | 20 ++++++------
.../component/atmos/AtmosConfiguration.java | 33 +++++++++-----------
.../camel/component/atmos/AtmosEndpoint.java | 20 ++++++------
.../component/atmos/core/AtmosAPIFacade.java | 20 ++++++------
.../atmos/util/AtmosPropertyManager.java | 2 --
.../validator/AtmosConfigurationValidator.java | 20 ++++++------
.../src/main/resources/atmos.properties | 21 -------------
.../src/test/resources/atmos.properties | 22 +++++++++++++
.../src/test/resources/test-options.properties | 21 -------------
9 files changed, 77 insertions(+), 102 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
index 576c955..0008ce6 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosComponent.java
@@ -1,18 +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
+ * 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
+ * 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.
+ * 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.atmos;
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
index 43a7386..71b41ac 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosConfiguration.java
@@ -1,26 +1,27 @@
/**
* 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
+ * 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
+ * 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.
+ * 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.atmos;
+import java.net.URI;
+import java.net.URISyntaxException;
+
import com.emc.atmos.api.AtmosApi;
import com.emc.atmos.api.AtmosConfig;
import com.emc.atmos.api.jersey.AtmosApiClient;
-import java.net.URI;
-import java.net.URISyntaxException;
import org.apache.camel.component.atmos.util.AtmosException;
import org.apache.camel.component.atmos.util.AtmosOperation;
@@ -72,16 +73,12 @@ public class AtmosConfiguration {
} catch (URISyntaxException use) {
throw new AtmosException("wrong syntax for Atmos URI!", use);
}
- if (config == null) {
- throw new AtmosException("can't configure the Atmos client!");
- }
+
if (!enableSslValidation) {
config.setDisableSslValidation(true);
}
AtmosApi atmosclient = new AtmosApiClient(config);
- if (atmosclient == null) {
- throw new AtmosException("can't establish an Atmos connection!");
- }
+
this.client = atmosclient;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
index f272ab4..29841db 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/AtmosEndpoint.java
@@ -1,18 +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
+ * 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
+ * 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.
+ * 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.atmos;
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
index 852193e..2fe0234 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/core/AtmosAPIFacade.java
@@ -1,18 +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
+ * 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
+ * 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.
+ * 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.atmos.core;
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
index cc8ceec..0b76edb 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/util/AtmosPropertyManager.java
@@ -47,14 +47,12 @@ public final class AtmosPropertyManager {
try {
inStream = url.openStream();
} catch (IOException e) {
- e.printStackTrace();
throw new AtmosException("atmos.properties could not be found");
}
properties = new Properties();
try {
properties.load(inStream);
} catch (IOException e) {
- e.printStackTrace();
throw new AtmosException("atmos.properties can't be read");
}
return properties;
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
index ccb2fcf..ec16fad 100644
--- a/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
+++ b/components/camel-atmos/src/main/java/org/apache/camel/component/atmos/validator/AtmosConfigurationValidator.java
@@ -1,18 +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
+ * 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
+ * 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.
+ * 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.atmos.validator;
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/main/resources/atmos.properties
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/main/resources/atmos.properties b/components/camel-atmos/src/main/resources/atmos.properties
deleted file mode 100644
index c51ff51..0000000
--- a/components/camel-atmos/src/main/resources/atmos.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
-fullTokenId=<Subtentant_ID/UID>
-secretKey=<UID_shared_secret>
-uri=<http(s)://atmos_host>
-sslValidation=<true|false>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/test/resources/atmos.properties
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/resources/atmos.properties b/components/camel-atmos/src/test/resources/atmos.properties
new file mode 100644
index 0000000..4932d00
--- /dev/null
+++ b/components/camel-atmos/src/test/resources/atmos.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+fullTokenId=<Subtentant_ID/UID>
+secretKey=<UID_shared_secret>
+# The uri need to valide value
+uri=http://atmos_host
+sslValidation=<true|false>
http://git-wip-us.apache.org/repos/asf/camel/blob/7e9cb79b/components/camel-atmos/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-atmos/src/test/resources/test-options.properties b/components/camel-atmos/src/test/resources/test-options.properties
deleted file mode 100644
index 52e50d9..0000000
--- a/components/camel-atmos/src/test/resources/test-options.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
-fullTokenId=<Subtentant_ID/UID>
-secretKey=<UID_shared_secret>
-uri=<http(s)://atmos_host>
-sslValidation=<true|false>