You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/03/06 08:36:21 UTC
[1/8] camel git commit: ASF license header added to pom files
Repository: camel
Updated Branches:
refs/heads/master b259c00cf -> d16d265cf
ASF license header added to pom files
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bc7a7416
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bc7a7416
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bc7a7416
Branch: refs/heads/master
Commit: bc7a741603ee62001c472ce79b00c9d36055a9a9
Parents: f6250e3
Author: William Collins <pu...@gmail.com>
Authored: Sat Mar 4 22:10:41 2017 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 6 08:48:05 2017 +0100
----------------------------------------------------------------------
components/camel-box2/camel-box2-api/pom.xml | 16 ++++++++++++++++
components/camel-box2/camel-box2-component/pom.xml | 16 ++++++++++++++++
components/camel-box2/pom.xml | 16 ++++++++++++++++
3 files changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/bc7a7416/components/camel-box2/camel-box2-api/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/pom.xml b/components/camel-box2/camel-box2-api/pom.xml
index a347278..8b23615 100644
--- a/components/camel-box2/camel-box2-api/pom.xml
+++ b/components/camel-box2/camel-box2-api/pom.xml
@@ -1,4 +1,20 @@
<?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>
http://git-wip-us.apache.org/repos/asf/camel/blob/bc7a7416/components/camel-box2/camel-box2-component/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/pom.xml b/components/camel-box2/camel-box2-component/pom.xml
index d5aebfb..dc7b012 100644
--- a/components/camel-box2/camel-box2-component/pom.xml
+++ b/components/camel-box2/camel-box2-component/pom.xml
@@ -1,4 +1,20 @@
<?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">
http://git-wip-us.apache.org/repos/asf/camel/blob/bc7a7416/components/camel-box2/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-box2/pom.xml b/components/camel-box2/pom.xml
index b25a287..1b6efac 100644
--- a/components/camel-box2/pom.xml
+++ b/components/camel-box2/pom.xml
@@ -1,4 +1,20 @@
<?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>
[8/8] camel git commit: CAMEL-9047: camel-box2
Posted by da...@apache.org.
CAMEL-9047: camel-box2
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d16d265c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d16d265c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d16d265c
Branch: refs/heads/master
Commit: d16d265cfc5112be33937c95e5753aa30f6482bb
Parents: bc7a741
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Mar 6 09:35:48 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 6 09:35:48 2017 +0100
----------------------------------------------------------------------
components/readme.adoc | 7 +-
docs/user-manual/en/SUMMARY.md | 2 +-
.../camel-box2-starter/pom.xml | 59 ++++
.../Box2ComponentAutoConfiguration.java | 110 +++++++
.../springboot/Box2ComponentConfiguration.java | 300 +++++++++++++++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
...dditional-spring-configuration-metadata.json | 10 +
.../main/resources/META-INF/spring.factories | 19 ++
.../src/main/resources/META-INF/spring.provides | 18 ++
.../camel-spring-boot-dependencies/pom.xml | 5 -
11 files changed, 734 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/components/readme.adoc
----------------------------------------------------------------------
diff --git a/components/readme.adoc b/components/readme.adoc
index fde808d..8270761 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -98,9 +98,6 @@ Number of Components: 220 in 175 JAR artifacts
| link:camel-box/src/main/docs/box-component.adoc[Box] (camel-box) +
`box:apiName/methodName` | 2.14 | For uploading downloading and managing files folders groups collaborations etc on box DOT com.
-| link:camel-box2/src/main/docs/box2-component.adoc[Box] (camel-box2) +
-`box2:apiName/methodName` | 2.19 | For uploading downloading and managing files folders groups collaborations etc on box DOT com.
-
| link:camel-braintree/src/main/docs/braintree-component.adoc[Braintree] (camel-braintree) +
`braintree:apiName/methodName` | 2.17 | The braintree component is used for integrating with the Braintree Payment System.
@@ -843,7 +840,7 @@ Miscellaneous Components
^^^^^^^^^^^^^^^^^^^^^^^^
// others: START
-Number of Miscellaneous Components: 36 in 36 JAR artifacts
+Number of Miscellaneous Components: 37 in 37 JAR artifacts
[width="100%",cols="4,1,5",options="header"]
|=======================================================================
@@ -853,6 +850,8 @@ Number of Miscellaneous Components: 36 in 36 JAR artifacts
| link:camel-blueprint/src/main/docs/blueprint.adoc[Blueprint] (camel-blueprint) | 2.4 | Using Camel with OSGi Blueprint
+| link:camel-box2-parent/src/main/docs/box2-parent.adoc[Box2 Parent] (camel-box2-parent) | | Parent project for Camel {Box2} Component
+
| link:camel-cdi/src/main/docs/cdi.adoc[CDI] (camel-cdi) | 2.10 | Using Camel with CDI
| link:camel-cxf-transport/src/main/docs/cxf-transport.adoc[CXF Transport] (camel-cxf-transport) | 2.8 | Camel Transport for Apache CXF
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 57a4822..b5bb5a3 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -152,7 +152,6 @@
* [Beanstalk](beanstalk-component.adoc)
* [Bonita](bonita-component.adoc)
* [Box](box-component.adoc)
- * [Box2](box2-component.adoc)
* [Braintree](braintree-component.adoc)
* [Camel Context](context-component.adoc)
* [Cassandra CQL](cql-component.adoc)
@@ -329,6 +328,7 @@
* Miscellaneous Components
* [BAM](bam.adoc)
* [Blueprint](blueprint.adoc)
+ * [Box2 Parent](box2-parent.adoc)
* [CDI](cdi.adoc)
* [CXF Transport](cxf-transport.adoc)
* [Eclipse](eclipse.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/pom.xml b/platforms/spring-boot/components-starter/camel-box2-starter/pom.xml
new file mode 100644
index 0000000..2d49fef
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/pom.xml
@@ -0,0 +1,59 @@
+<?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-starter</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>camel-box2-starter</artifactId>
+ <packaging>jar</packaging>
+ <name>Spring-Boot Starter :: Camel Box2 Component</name>
+ <description>Spring-Boot Starter for Camel Component for Box2</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-box2</artifactId>
+ <version>${project.version}</version>
+ <!--START OF GENERATED CODE-->
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ <!--END OF GENERATED CODE-->
+ </dependency>
+ <!--START OF GENERATED CODE-->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <!--END OF GENERATED CODE-->
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentAutoConfiguration.java
new file mode 100644
index 0000000..7818f49
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentAutoConfiguration.java
@@ -0,0 +1,110 @@
+/**
+ * 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.box2.springboot;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.box2.Box2Component;
+import org.apache.camel.util.IntrospectionSupport;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionMessage;
+import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Configuration
+@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@Conditional(Box2ComponentAutoConfiguration.Condition.class)
+@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@EnableConfigurationProperties(Box2ComponentConfiguration.class)
+public class Box2ComponentAutoConfiguration {
+
+ @Lazy
+ @Bean(name = "box2-component")
+ @ConditionalOnClass(CamelContext.class)
+ @ConditionalOnMissingBean(Box2Component.class)
+ public Box2Component configureBox2Component(CamelContext camelContext,
+ Box2ComponentConfiguration configuration) throws Exception {
+ Box2Component component = new Box2Component();
+ component.setCamelContext(camelContext);
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(configuration, parameters, null,
+ false);
+ for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+ Object value = entry.getValue();
+ Class<?> paramClass = value.getClass();
+ if (paramClass.getName().endsWith("NestedConfiguration")) {
+ Class nestedClass = null;
+ try {
+ nestedClass = (Class) paramClass.getDeclaredField(
+ "CAMEL_NESTED_CLASS").get(null);
+ HashMap<String, Object> nestedParameters = new HashMap<>();
+ IntrospectionSupport.getProperties(value, nestedParameters,
+ null, false);
+ Object nestedProperty = nestedClass.newInstance();
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), nestedProperty,
+ nestedParameters);
+ entry.setValue(nestedProperty);
+ } catch (NoSuchFieldException e) {
+ }
+ }
+ }
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ return component;
+ }
+
+ public static class Condition extends SpringBootCondition {
+ @Override
+ public ConditionOutcome getMatchOutcome(
+ ConditionContext conditionContext,
+ AnnotatedTypeMetadata annotatedTypeMetadata) {
+ boolean groupEnabled = isEnabled(conditionContext,
+ "camel.component.", true);
+ ConditionMessage.Builder message = ConditionMessage
+ .forCondition("camel.component.box2");
+ if (isEnabled(conditionContext, "camel.component.box2.",
+ groupEnabled)) {
+ return ConditionOutcome.match(message.because("enabled"));
+ }
+ return ConditionOutcome.noMatch(message.because("not enabled"));
+ }
+
+ private boolean isEnabled(
+ org.springframework.context.annotation.ConditionContext context,
+ java.lang.String prefix, boolean defaultValue) {
+ RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
+ context.getEnvironment(), prefix);
+ return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentConfiguration.java
new file mode 100644
index 0000000..d5d482e
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/java/org/apache/camel/component/box2/springboot/Box2ComponentConfiguration.java
@@ -0,0 +1,300 @@
+/**
+ * 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.box2.springboot;
+
+import java.util.Map;
+import com.box.sdk.IAccessTokenCache;
+import org.apache.camel.component.box2.internal.Box2ApiName;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
+
+/**
+ * Represents a Box2 endpoint.
+ *
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@ConfigurationProperties(prefix = "camel.component.box2")
+public class Box2ComponentConfiguration {
+
+ /**
+ * To use the shared configuration
+ */
+ private Box2ConfigurationNestedConfiguration configuration;
+ /**
+ * Whether the component should resolve property placeholders on itself when
+ * starting. Only properties which are of String type can use property
+ * placeholders.
+ */
+ private Boolean resolvePropertyPlaceholders = true;
+
+ public Box2ConfigurationNestedConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(
+ Box2ConfigurationNestedConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public Boolean getResolvePropertyPlaceholders() {
+ return resolvePropertyPlaceholders;
+ }
+
+ public void setResolvePropertyPlaceholders(
+ Boolean resolvePropertyPlaceholders) {
+ this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
+ }
+
+ public static class Box2ConfigurationNestedConfiguration {
+ public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.box2.Box2Configuration.class;
+ /**
+ * What kind of operation to perform
+ *
+ * @param apiNamethe
+ * API Name to set
+ */
+ private Box2ApiName apiName;
+ /**
+ * What sub operation to use for the selected operation
+ *
+ * @param methodNamethe
+ * methodName to set
+ */
+ private String methodName;
+ /**
+ * The enterprise ID to use for an App Enterprise.
+ *
+ * @param enterpriseIdthe
+ * enterpriseId to set
+ */
+ private String enterpriseId;
+ /**
+ * The user ID to use for an App User.
+ *
+ * @param userIdthe
+ * userId to set
+ */
+ private String userId;
+ /**
+ * The ID for public key for validating the JWT signature.
+ *
+ * @param publicKeyIdthe
+ * publicKeyId to set
+ */
+ private String publicKeyId;
+ /**
+ * The private key for generating the JWT signature.
+ *
+ * @param privateKeythe
+ * privateKey to set
+ */
+ private String privateKeyFile;
+ /**
+ * The password for the private key.
+ *
+ * @param privateKeyPasswordthe
+ * privateKeyPassword to set
+ */
+ private String privateKeyPassword;
+ /**
+ * The type of authentication for connection.
+ * <p>
+ * Types of Authentication:
+ * <ul>
+ * <li>STANDARD_AUTHENTICATION - OAuth 2.0 (3-legged)</li>
+ * <li>SERVER_AUTHENTICATION - OAuth 2.0 with JSON Web Tokens</li>
+ * </ul>
+ *
+ * @param authenticationTypethe
+ * authenticationType to set
+ */
+ private String authenticationType = "APP_USER_AUTHENTICATION";
+ /**
+ * Box application client ID
+ *
+ * @param clientIdthe
+ * clientId to set
+ */
+ private String clientId;
+ /**
+ * Box application client secret
+ *
+ * @param clientSecretthe
+ * clientSecret to set
+ */
+ private String clientSecret;
+ /**
+ * Box user name, MUST be provided
+ *
+ * @param userNamethe
+ * userName to set
+ */
+ private String userName;
+ /**
+ * Box user password, MUST be provided if authSecureStorage is not set,
+ * or returns null on first call
+ *
+ * @param userPasswordthe
+ * userPassword to set
+ */
+ private String userPassword;
+ /**
+ * Custom HTTP params for settings like proxy host
+ *
+ * @param httpParamsthe
+ * httpParams to set
+ */
+ private Map httpParams;
+ /**
+ * To configure security using SSLContextParameters.
+ *
+ * @param sslContextParametersthe
+ * sslContextParameters to set
+ */
+ @NestedConfigurationProperty
+ private SSLContextParameters sslContextParameters;
+ /**
+ * Custom Access Token Cache for storing and retrieving access tokens.
+ *
+ * @param accessTokenCache
+ * - the Custom Access Token Cache
+ */
+ private IAccessTokenCache accessTokenCache;
+
+ public Box2ApiName getApiName() {
+ return apiName;
+ }
+
+ public void setApiName(Box2ApiName apiName) {
+ this.apiName = apiName;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getEnterpriseId() {
+ return enterpriseId;
+ }
+
+ public void setEnterpriseId(String enterpriseId) {
+ this.enterpriseId = enterpriseId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getPublicKeyId() {
+ return publicKeyId;
+ }
+
+ public void setPublicKeyId(String publicKeyId) {
+ this.publicKeyId = publicKeyId;
+ }
+
+ public String getPrivateKeyFile() {
+ return privateKeyFile;
+ }
+
+ public void setPrivateKeyFile(String privateKeyFile) {
+ this.privateKeyFile = privateKeyFile;
+ }
+
+ public String getPrivateKeyPassword() {
+ return privateKeyPassword;
+ }
+
+ public void setPrivateKeyPassword(String privateKeyPassword) {
+ this.privateKeyPassword = privateKeyPassword;
+ }
+
+ public String getAuthenticationType() {
+ return authenticationType;
+ }
+
+ public void setAuthenticationType(String authenticationType) {
+ this.authenticationType = authenticationType;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getUserPassword() {
+ return userPassword;
+ }
+
+ public void setUserPassword(String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ public Map getHttpParams() {
+ return httpParams;
+ }
+
+ public void setHttpParams(Map httpParams) {
+ this.httpParams = httpParams;
+ }
+
+ public SSLContextParameters getSslContextParameters() {
+ return sslContextParameters;
+ }
+
+ public void setSslContextParameters(
+ SSLContextParameters sslContextParameters) {
+ this.sslContextParameters = sslContextParameters;
+ }
+
+ public IAccessTokenCache getAccessTokenCache() {
+ return accessTokenCache;
+ }
+
+ public void setAccessTokenCache(IAccessTokenCache accessTokenCache) {
+ this.accessTokenCache = accessTokenCache;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/LICENSE.txt b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/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/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/NOTICE.txt b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/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/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 0000000..64993c4
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,10 @@
+{
+ "properties": [
+ {
+ "defaultValue": true,
+ "name": "camel.component.box2.enabled",
+ "description": "Enable box2 component",
+ "type": "java.lang.Boolean"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..62224e6
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.camel.component.box2.springboot.Box2ComponentAutoConfiguration
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.provides
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.provides b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000..2e7effb
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-box2-starter/src/main/resources/META-INF/spring.provides
@@ -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.
+#
+
+provides: camel-box2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d16d265c/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index 75cd5de..42ac198 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -1009,11 +1009,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-groovy-dsl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-groovy-starter</artifactId>
<version>${project.version}</version>
</dependency>
[6/8] camel git commit: CAMEL-9047: Replace deprecated boxjavalibv2
with box-java-sdk
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
new file mode 100644
index 0000000..50698e2
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
@@ -0,0 +1,274 @@
+/**
+ * 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.box2.api;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxGroup;
+import com.box.sdk.BoxGroupMembership;
+import com.box.sdk.BoxUser;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Groups Manager
+ *
+ * <p>
+ * Provides operations to manage Box groups.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2GroupsManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2GroupsManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create groups manager to manage the users of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2GroupsManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Get all the groups in the enterprise.
+ *
+ * @return Collection containing all the enterprise's groups.
+ */
+ public Collection<BoxGroup> getAllGroups() {
+ try {
+ LOG.debug("Getting all groups");
+
+ Collection<BoxGroup> groups = new ArrayList<BoxGroup>();
+ for (BoxGroup.Info groupInfo : BoxGroup.getAllGroups(boxConnection)) {
+ groups.add(groupInfo.getResource());
+ }
+ return groups;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Create a new group with a specified name.
+ *
+ * @param name
+ * - the name of the new group.
+ * @return The newly created group.
+ */
+ public BoxGroup createGroup(String name) {
+ try {
+ LOG.debug("Creating group name=" + name);
+ if (name == null) {
+ throw new IllegalArgumentException("Parameter 'name' can not be null");
+ }
+
+ return BoxGroup.createGroup(boxConnection, name).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete group.
+ *
+ * @param groupId
+ * - the id of group to delete.
+ */
+ public void deleteGroup(String groupId) {
+ try {
+ LOG.debug("Deleting group(" + groupId + ")");
+ if (groupId == null) {
+ throw new IllegalArgumentException("Parameter 'groupId' can not be null");
+ }
+
+ BoxGroup group = new BoxGroup(boxConnection, groupId);
+ group.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get group information.
+ *
+ * @param groupId
+ * - the id of group.
+ * @return The group information.
+ */
+ public BoxGroup.Info getGroupInfo(String groupId) {
+ try {
+ LOG.debug("Getting info for group(id=" + groupId + ")");
+ if (groupId == null) {
+ throw new IllegalArgumentException("Parameter 'groupId' can not be null");
+ }
+
+ BoxGroup group = new BoxGroup(boxConnection, groupId);
+
+ return group.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get information about all of the group memberships for this group.
+ *
+ * @param groupId
+ * - the id of group.
+ * @return The group information.
+ */
+ public Collection<BoxGroupMembership.Info> getGroupMemberships(String groupId) {
+ try {
+ LOG.debug("Getting information about all memberships for group(id=" + groupId + ")");
+ if (groupId == null) {
+ throw new IllegalArgumentException("Parameter 'groupId' can not be null");
+ }
+
+ BoxGroup group = new BoxGroup(boxConnection, groupId);
+
+ return group.getMemberships();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Add a member to group with the specified role.
+ *
+ * @param groupId
+ * - the id of group.
+ * @param userId
+ * - the id of user to be added to group.
+ * @param role
+ * - the role of the user in this group. Can be <code>null</code>
+ * to assign the default role.
+ * @return The group information.
+ */
+ public BoxGroupMembership addGroupMembership(String groupId, String userId, BoxGroupMembership.Role role) {
+ try {
+ LOG.debug("Adding user(id=" + userId + ") as member to group(id=" + groupId
+ + (role == null ? ")" : ") with role=" + role.name()));
+ if (groupId == null) {
+ throw new IllegalArgumentException("Parameter 'groupId' can not be null");
+ }
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'userId' can not be null");
+ }
+
+ BoxGroup group = new BoxGroup(boxConnection, groupId);
+ BoxUser user = new BoxUser(boxConnection, userId);
+
+ return group.addMembership(user, role).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete group membership.
+ *
+ * @param groupMembershipId
+ * - the id of group membership to delete.
+ */
+ public void deleteGroupMembership(String groupMembershipId) {
+ try {
+ LOG.debug("Deleting groupMembership(id=" + groupMembershipId + ")");
+ if (groupMembershipId == null) {
+ throw new IllegalArgumentException("Parameter 'groupMemebershipId' can not be null");
+ }
+
+ BoxGroupMembership groupMembership = new BoxGroupMembership(boxConnection, groupMembershipId);
+
+ groupMembership.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get group membership information.
+ *
+ * @param groupMemebershipId
+ * - the id of group membership.
+ * @return The group information.
+ */
+ public BoxGroupMembership.Info getGroupMembershipInfo(String groupMemebershipId) {
+ try {
+ LOG.debug("Getting info for groupMemebership(id=" + groupMemebershipId + ")");
+ if (groupMemebershipId == null) {
+ throw new IllegalArgumentException("Parameter 'groupMemebershipId' can not be null");
+ }
+
+ BoxGroupMembership group = new BoxGroupMembership(boxConnection, groupMemebershipId);
+
+ return group.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Update group membership information.
+ *
+ * @param groupMembershipId
+ * - the id of group membership to update.
+ * @param info
+ * - the updated information.
+ * @return The group information.
+ */
+ public BoxGroupMembership updateGroupMembershipInfo(String groupMemebershipId, BoxGroupMembership.Info info) {
+ try {
+ LOG.debug("Updating info for groupMembership(id=" + groupMemebershipId + ")");
+ if (groupMemebershipId == null) {
+ throw new IllegalArgumentException("Parameter 'groupMemebershipId' can not be null");
+ }
+ if (info == null) {
+ throw new IllegalArgumentException("Parameter 'info' can not be null");
+ }
+
+ BoxGroupMembership groupMembership = new BoxGroupMembership(boxConnection, groupMemebershipId);
+
+ groupMembership.updateInfo(info);
+ return groupMembership;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
new file mode 100644
index 0000000..1ce47da
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
@@ -0,0 +1,93 @@
+/**
+ * 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.box2.api;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxItem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Search Manager
+ *
+ * <p>
+ * Provides operations to manage Box searches.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2SearchManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2SearchManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create search manager to manage the searches of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2SearchManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Search folder and all descendant folders using the given query.
+ *
+ * @param folderId
+ * - the id of folder searched.
+ * @param query
+ * - the search query.
+ *
+ * @return A collection of matching items.
+ */
+ public Collection<BoxItem> searchFolder(String folderId, String query) {
+ try {
+ LOG.debug("Searching folder(id=" + folderId + ") with query=" + query);
+
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (query == null) {
+ throw new IllegalArgumentException("Parameter 'query' can not be null");
+ }
+
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+
+ Collection<BoxItem> results = new ArrayList<BoxItem>();
+ for (BoxItem.Info info : folder.search(query)) {
+ results.add((BoxItem) info.getResource());
+ }
+
+ return results;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
new file mode 100644
index 0000000..ab64b1b
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
@@ -0,0 +1,324 @@
+/**
+ * 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.box2.api;
+
+import java.util.Date;
+import java.util.List;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxTask;
+import com.box.sdk.BoxTaskAssignment;
+import com.box.sdk.BoxUser;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Tasks Manager
+ *
+ * <p>
+ * Provides operations to manage Box tasks.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2TasksManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2TasksManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create tasks manager to manage the tasks of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2TasksManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Get a list of any tasks on file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @return The list of tasks on file.
+ */
+ public List<BoxTask.Info> getFileTasks(String fileId) {
+ try {
+ LOG.debug("Getting tasks of file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ return file.getTasks();
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Add task to file.
+ *
+ * @param fileId
+ * - the id of file to add task to.
+ * @param action
+ * - the action the task assignee will be prompted to do.
+ * @param dueAt
+ * - - the day at which this task is due.
+ * @param message
+ * - an optional message to include with the task.
+ * @return The new task.
+ */
+ public BoxTask addFileTask(String fileId, BoxTask.Action action, Date dueAt, String message) {
+ try {
+ LOG.debug("Adding task to file(id=" + fileId + ") to '" + message + "'");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (action == null) {
+ throw new IllegalArgumentException("Parameter 'action' can not be null");
+ }
+ if (dueAt == null) {
+ throw new IllegalArgumentException("Parameter 'dueAt' can not be null");
+ }
+
+ BoxFile fileToAddTaskOn = new BoxFile(boxConnection, fileId);
+ return (BoxTask) fileToAddTaskOn.addTask(action, message, dueAt).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete task.
+ *
+ * @param taskId
+ * - the id of task to delete.
+ */
+ public void deleteTask(String taskId) {
+ try {
+ LOG.debug("Deleting task(id=" + taskId + ")");
+ if (taskId == null) {
+ throw new IllegalArgumentException("Parameter 'taskId' can not be null");
+ }
+ BoxTask task = new BoxTask(boxConnection, taskId);
+ task.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get task information.
+ *
+ * @param taskId
+ * - the id of task.
+ * @return The task information.
+ */
+ public BoxTask.Info getTaskInfo(String taskId) {
+ try {
+ LOG.debug("Getting info for task(id=" + taskId + ")");
+ if (taskId == null) {
+ throw new IllegalArgumentException("Parameter 'taskId' can not be null");
+ }
+
+ BoxTask task = new BoxTask(boxConnection, taskId);
+
+ return task.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Update task information.
+ *
+ * @param taskId
+ * - the id of task.
+ * @param info
+ * - the updated information
+ * @return The updated task.
+ */
+ public BoxTask updateTaskInfo(String taskId, BoxTask.Info info) {
+ try {
+ LOG.debug("Updating info for task(id=" + taskId + ")");
+ if (taskId == null) {
+ throw new IllegalArgumentException("Parameter 'taskId' can not be null");
+ }
+ if (info == null) {
+ throw new IllegalArgumentException("Parameter 'info' can not be null");
+ }
+
+ BoxTask task = new BoxTask(boxConnection, taskId);
+ task.updateInfo(info);
+
+ return task;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get a list of any assignments for task.
+ *
+ * @param taskId
+ * - the id of task.
+ * @return The list of assignments for task.
+ */
+ public List<BoxTaskAssignment.Info> getTaskAssignments(String taskId) {
+ try {
+ LOG.debug("Getting assignments for task(id=" + taskId + ")");
+ if (taskId == null) {
+ throw new IllegalArgumentException("Parameter 'taskId' can not be null");
+ }
+
+ BoxTask file = new BoxTask(boxConnection, taskId);
+
+ return file.getAssignments();
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Add assignment for task.
+ *
+ * @param taskId
+ * - the id of task to add assignment for.
+ * @param assignTo
+ * - the user to assign to task.
+ * @return The assigned task.
+ */
+ @SuppressWarnings("unused") // compiler for some reason thinks 'if (assignTo
+ // == null)' clause is dead code.
+ public BoxTask addAssignmentToTask(String taskId, BoxUser assignTo) {
+ try {
+ LOG.debug("Assigning task(id=" + taskId + ") to user(id=" + assignTo.getID() + ")");
+ if (taskId == null) {
+ throw new IllegalArgumentException("Parameter 'commentId' can not be null");
+ }
+ if (assignTo == null) {
+ throw new IllegalArgumentException("Parameter 'assignTo' can not be null");
+ }
+
+ BoxTask task = new BoxTask(boxConnection, taskId);
+ task.addAssignment(assignTo);
+
+ return task;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get task assignment information.
+ *
+ * @param taskAssignmentId
+ * - the id of task assignment.
+ * @return The task assignment information.
+ */
+ public BoxTaskAssignment.Info getTaskAssignmentInfo(String taskAssignmentId) {
+ try {
+ LOG.debug("Getting info for task(id=" + taskAssignmentId + ")");
+ if (taskAssignmentId == null) {
+ throw new IllegalArgumentException("Parameter 'taskAssignmentId' can not be null");
+ }
+
+ BoxTaskAssignment taskAssignment = new BoxTaskAssignment(boxConnection, taskAssignmentId);
+
+ return taskAssignment.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ // TODO Add this method when BoxTaskAssignment API fixed:
+ // BoxTaskAssignment.update method currently
+ // takes BoxTask.Info instead of BoxTaskAssignment.Info
+ // /**
+ // * Update task assignment information.
+ // *
+ // * @param taskAssignmentId
+ // * - the id of task assignment.
+ // * @param info
+ // * - the updated information
+ // * @return The updated task assignment.
+ // */
+ // public BoxTaskAssignment updateTaskAssignmentInfo(String
+ // taskAssignmentId, BoxTaskAssignment.Info info) {
+ // try {
+ // LOG.debug("Updating info for task(id=" + taskAssignmentId + ")");
+ // if (taskAssignmentId == null) {
+ // throw new IllegalArgumentException("Parameter 'taskAssignmentId' can not
+ // be null");
+ // }
+ // if (info == null) {
+ // throw new IllegalArgumentException("Parameter 'info' can not be null");
+ // }
+ //
+ // BoxTaskAssignment taskAssignment = new BoxTaskAssignment(boxConnection,
+ // taskAssignmentId);
+ // taskAssignment.updateInfo(info);
+ //
+ // return taskAssignment;
+ // } catch (BoxAPIException e) {
+ // throw new RuntimeException(
+ // String.format("Box API returned the error code %d\n\n%s",
+ // e.getResponseCode(), e.getResponse()), e);
+ // }
+ // }
+
+ /**
+ * Delete task assignment.
+ *
+ * @param taskAssignmentId
+ * - the id of task assignment to delete.
+ */
+ public void deleteTaskAssignment(String taskAssignmentId) {
+ try {
+ LOG.debug("Deleting task(id=" + taskAssignmentId + ")");
+ if (taskAssignmentId == null) {
+ throw new IllegalArgumentException("Parameter 'taskAssignmentId' can not be null");
+ }
+ BoxTaskAssignment taskAssignment = new BoxTaskAssignment(boxConnection, taskAssignmentId);
+ taskAssignment.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
new file mode 100644
index 0000000..6c33e14
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
@@ -0,0 +1,333 @@
+/**
+ * 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.box2.api;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxUser;
+import com.box.sdk.CreateUserParams;
+import com.box.sdk.EmailAlias;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Users Manager
+ *
+ * <p>
+ * Provides operations to manage Box users.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2UsersManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2UsersManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create users manager to manage the users of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2UsersManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Get current user.
+ *
+ * @return The current user.
+ */
+ public BoxUser getCurrentUser() {
+ try {
+ LOG.debug("Getting current user");
+
+ return BoxUser.getCurrentUser(boxConnection);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get any managed users that match the filter term as well as any external
+ * users that match the filter term. For managed users it matches any users
+ * names or emails that start with the term. For external, it only does full
+ * match on email. This method is ideal to use in the case where you have a
+ * full email for a user and you don't know if they're managed or external.
+ *
+ * @param filterTerm
+ * - The filter term to lookup users by (login for external,
+ * login or name for managed); if <code>null</code> all managed
+ * users are returned.
+ * @param fields
+ * - the fields to retrieve. Leave this out for the standard
+ * fields.
+ * @return All the enterprise users or enterprise users that matches the
+ * filter.
+ */
+ public List<BoxUser.Info> getAllEnterpriseOrExternalUsers(String filterTerm, String... fields) {
+ try {
+ LOG.debug("Getting all enterprise users matching filterTerm=" + filterTerm);
+
+ List<BoxUser.Info> users = new ArrayList<BoxUser.Info>();
+ Iterable<BoxUser.Info> iterable;
+ if (filterTerm == null) {
+ iterable = BoxUser.getAllEnterpriseUsers(boxConnection);
+ } else {
+ iterable = BoxUser.getAllEnterpriseUsers(boxConnection, filterTerm, fields);
+ }
+ for (BoxUser.Info info : iterable) {
+ users.add(info);
+ }
+ return users;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Provision a new user in an enterprise with additional user information.
+ *
+ * @param login
+ * - the email address the user will use to login.
+ * @param name
+ * - the name of the user.
+ * @param params
+ * - additional user information.
+ * @return All the enterprise users or enterprise users that matches the
+ * filter.
+ */
+ public BoxUser createEnterpriseUser(String login, String name, CreateUserParams params) {
+ try {
+ LOG.debug("Creating enterprise user with login=" + login + " name=" + name);
+ if (login == null) {
+ throw new IllegalArgumentException("Parameter 'login' can not be null");
+ }
+ if (name == null) {
+ throw new IllegalArgumentException("Parameter 'name' can not be null");
+ }
+
+ if (params != null) {
+ return BoxUser.createEnterpriseUser(boxConnection, login, name, params).getResource();
+ } else {
+ return BoxUser.createEnterpriseUser(boxConnection, login, name).getResource();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Provision a new app user in an enterprise with additional user
+ * information using Box Developer Edition.
+ *
+ * @param name
+ * - the name of the user.
+ * @param params
+ * - additional user information.
+ * @return All the enterprise users or enterprise users that matches the
+ * filter.
+ */
+ public BoxUser createAppUser(String name, CreateUserParams params) {
+ try {
+ LOG.debug("Creating app user with name=" + name);
+ if (name == null) {
+ throw new IllegalArgumentException("Parameter 'name' can not be null");
+ }
+
+ if (params != null) {
+ return BoxUser.createAppUser(boxConnection, name, params).getResource();
+ } else {
+ return BoxUser.createAppUser(boxConnection, name).getResource();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get user information.
+ *
+ * @param userId
+ * - the id of user.
+ * @return The user information.
+ */
+ public BoxUser.Info getUserInfo(String userId) {
+ try {
+ LOG.debug("Getting info for user(id=" + userId + ")");
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'userId' can not be null");
+ }
+
+ BoxUser user = new BoxUser(boxConnection, userId);
+
+ return user.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Update user information.
+ *
+ * @param userId
+ * - the id of user to update.
+ * @param info
+ * - the updated information
+ * @return The updated user.
+ */
+ public BoxUser updateUserInfo(String userId, BoxUser.Info info) {
+ try {
+ LOG.debug("Updating info for user(id=" + userId + ")");
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'userId' can not be null");
+ }
+ if (info == null) {
+ throw new IllegalArgumentException("Parameter 'info' can not be null");
+ }
+
+ BoxUser user = new BoxUser(boxConnection, userId);
+ user.updateInfo(info);
+ return user;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete user from an enterprise account.
+ *
+ * @param userId
+ * - the id of user to delete.
+ * @param notifyUser
+ * - whether or not to send an email notification to the user
+ * that their account has been deleted.
+ * @param force
+ * - whether or not this user should be deleted even if they
+ * still own files.
+ */
+ public void deleteUser(String userId, boolean notifyUser, boolean force) {
+ try {
+ LOG.debug("Deleting user(id=" + userId + ") notifyUser=" + notifyUser + " force=" + force);
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxUser file = new BoxUser(boxConnection, userId);
+ file.delete(notifyUser, force);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Add a new email alias to user's account.
+ *
+ * @param userId
+ * - the id of user.
+ * @param email
+ * - the email address to add as an alias.
+ * @return The newly created email alias.
+ */
+ public EmailAlias addUserEmailAlias(String userId, String email) {
+ try {
+ LOG.debug("Adding email alias '" + email + "' to user(id=" + userId + ")");
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'userId' can not be null");
+ }
+ if (email == null) {
+ throw new IllegalArgumentException("Paramerer 'email' can not be null");
+ }
+
+ BoxUser user = new BoxUser(boxConnection, userId);
+
+ return user.addEmailAlias(email);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get a collection of all the email aliases for user.
+ *
+ * @param userId
+ * - the id of user.
+ * @return A collection of all the email aliases for user.
+ */
+ public Collection<EmailAlias> getUserEmailAlias(String userId) {
+ try {
+ LOG.debug("Get email aliases for user(id=" + userId + ")");
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'userId' can not be null");
+ }
+
+ BoxUser user = new BoxUser(boxConnection, userId);
+
+ return user.getEmailAliases();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete an email alias from user's account.
+ *
+ * @param userId
+ * - the id of user.
+ * @param emailAliasId
+ * - the id of the email alias to delete.
+ */
+ public void deleteUserEmailAlias(String userId, String emailAliasId) {
+ try {
+ LOG.debug("Deleting email_alias(" + emailAliasId + ") for user(id=" + userId + ")");
+ if (userId == null) {
+ throw new IllegalArgumentException("Parameter 'userId' can not be null");
+ }
+ if (emailAliasId == null) {
+ throw new IllegalArgumentException("Parameter 'emailAliasId' can not be null");
+ }
+
+ BoxUser user = new BoxUser(boxConnection, userId);
+
+ user.deleteEmailAlias(emailAliasId);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/pom.xml b/components/camel-box2/camel-box2-component/pom.xml
new file mode 100644
index 0000000..d5aebfb
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/pom.xml
@@ -0,0 +1,612 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>camel-box2-parent</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-box2</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel Box2 Component</name>
+ <description>Camel Component for Box2</description>
+
+ <properties>
+ <schemeName>box2</schemeName>
+ <componentName>Box2</componentName>
+ <componentPackage>org.apache.camel.component.box2</componentPackage>
+ <outPackage>org.apache.camel.component.box2.internal</outPackage>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-box2-api</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.box</groupId>
+ <artifactId>box-java-sdk</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.24</version>
+ </dependency>
+
+ <!-- Camel annotations in provided scope to avoid compile errors in IDEs -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>spi-annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Component API javadoc in provided scope to read API signatures -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-box2-api</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ <classifier>javadoc</classifier>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Component API javadoc in provided scope to read API signatures -->
+ <dependency>
+ <groupId>com.box</groupId>
+ <artifactId>box-java-sdk</artifactId>
+ <version>2.1.1</version>
+ <classifier>javadoc</classifier>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-api-component-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-test-component-classes</id>
+ <goals>
+ <goal>fromApis</goal>
+ </goals>
+ <configuration>
+ <apis>
+ <api>
+ <apiName>collaborations</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2CollaborationsManager</proxyClass>
+ <fromJavadoc />
+ <aliases>
+ <alias>
+ <methodPattern>addFolderCollaboration</methodPattern>
+ <methodAlias>add</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>addFolderCollaborationByEmail</methodPattern>
+ <methodAlias>addByEmail</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteCollaboration</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFolderCollaborations</methodPattern>
+ <methodAlias>collaborations</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getPendingCollaborations</methodPattern>
+ <methodAlias>pendingCollaborations</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getCollaborationInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateCollaborationInfo</methodPattern>
+ <methodAlias>updateInfo</methodAlias>
+ </alias>
+ </aliases>
+ </api>
+ <api>
+ <apiName>comments</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2CommentsManager</proxyClass>
+ <fromJavadoc />
+ <aliases>
+ <alias>
+ <methodPattern>addFileComment</methodPattern>
+ <methodAlias>add</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>changeCommentMessage</methodPattern>
+ <methodAlias>updateMessage</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteComment</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getCommentInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFileComments</methodPattern>
+ <methodAlias>comments</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>replyToComment</methodPattern>
+ <methodAlias>reply</methodAlias>
+ </alias>
+ </aliases>
+ </api>
+ <api>
+ <apiName>event-logs</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2EventLogsManager</proxyClass>
+ <fromJavadoc />
+ <aliases>
+ <alias>
+ <methodPattern>getEnterpriseEvents</methodPattern>
+ <methodAlias>events</methodAlias>
+ </alias>
+ </aliases>
+ <nullableOptions>
+ <nullableOption>position</nullableOption>
+ <nullableOption>types</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>files</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2FilesManager</proxyClass>
+ <fromJavadoc />
+ <aliases>
+ <alias>
+ <methodPattern>uploadFile</methodPattern>
+ <methodAlias>upload</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>downloadFile</methodPattern>
+ <methodAlias>download</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>copyFile</methodPattern>
+ <methodAlias>copy</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>moveFile</methodPattern>
+ <methodAlias>move</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>renameFile</methodPattern>
+ <methodAlias>rename</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>createFileSharedLink</methodPattern>
+ <methodAlias>link</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteFile</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>uploadNewFileVersion</methodPattern>
+ <methodAlias>uploadVersion</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>promoteFileVersion</methodPattern>
+ <methodAlias>promoteVersion</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFileVersions</methodPattern>
+ <methodAlias>versions</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>downloadPreviousFileVersions</methodPattern>
+ <methodAlias>downloadVersion</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteFileVersion</methodPattern>
+ <methodAlias>deleteVersion</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFileInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateFileInfo</methodPattern>
+ <methodAlias>updateInfo</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>createFileMetadata</methodPattern>
+ <methodAlias>createMetadata</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFileMetadata</methodPattern>
+ <methodAlias>metadata</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateFileMetadata</methodPattern>
+ <methodAlias>updateMetadata</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteFileMetadata</methodPattern>
+ <methodAlias>deleteMetadata</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getDownloadUrl</methodPattern>
+ <methodAlias>url</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getPreviewLink</methodPattern>
+ <methodAlias>preview</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFileThumbnail</methodPattern>
+ <methodAlias>thumbnail</methodAlias>
+ </alias>
+ </aliases>
+ <nullableOptions>
+ <nullableOption>fields</nullableOption>
+ <nullableOption>created</nullableOption>
+ <nullableOption>modified</nullableOption>
+ <nullableOption>size</nullableOption>
+ <nullableOption>fileSize</nullableOption>
+ <nullableOption>rangeStart</nullableOption>
+ <nullableOption>rangeEnd</nullableOption>
+ <nullableOption>listener</nullableOption>
+ <nullableOption>fileSize</nullableOption>
+ <nullableOption>newName</nullableOption>
+ <nullableOption>unshareDate</nullableOption>
+ <nullableOption>permissions</nullableOption>
+ <nullableOption>typeName</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>folders</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2FoldersManager</proxyClass>
+ <fromJavadoc>
+ </fromJavadoc>
+ <aliases>
+ <alias>
+ <methodPattern>getRootFolder</methodPattern>
+ <methodAlias>root</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>createFolder</methodPattern>
+ <methodAlias>create</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>copyFolder</methodPattern>
+ <methodAlias>copy</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>moveFolder</methodPattern>
+ <methodAlias>move</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>renameFolder</methodPattern>
+ <methodAlias>rename</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>createFolderSharedLink</methodPattern>
+ <methodAlias>link</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteFolder</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFolder</methodPattern>
+ <methodAlias>folder</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFolderInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFolderItems</methodPattern>
+ <methodAlias>items</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateFolderInfo</methodPattern>
+ <methodAlias>updateInfo</methodAlias>
+ </alias>
+ </aliases>
+ <nullableOptions>
+ <nullableOption>offset</nullableOption>
+ <nullableOption>limit</nullableOption>
+ <nullableOption>fields</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>groups</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2GroupsManager</proxyClass>
+ <fromJavadoc>
+ </fromJavadoc>
+ <aliases>
+ <alias>
+ <methodPattern>createGroup</methodPattern>
+ <methodAlias>create</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteGroup</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getAllGroups</methodPattern>
+ <methodAlias>groups</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getGroupInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>addGroupMembership</methodPattern>
+ <methodAlias>addMembership</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteGroupMembership</methodPattern>
+ <methodAlias>deleteMembership</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getGroupMemberships</methodPattern>
+ <methodAlias>memberships</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getGroupMembershipInfo</methodPattern>
+ <methodAlias>membershipInfo</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateGroupMembershipInfo</methodPattern>
+ <methodAlias>updateMembershipInfo</methodAlias>
+ </alias>
+ </aliases>
+ <nullableOptions>
+ <nullableOption>role</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>events</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2EventsManager</proxyClass>
+ <fromJavadoc>
+ <excludeMethods>stopListening</excludeMethods>
+ </fromJavadoc>
+ <excludeConfigNames>listener</excludeConfigNames>
+ <nullableOptions>
+ <nullableOption>startingPosition</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>search</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2SearchManager</proxyClass>
+ <fromJavadoc/>
+ <aliases>
+ <alias>
+ <methodPattern>searchFolder</methodPattern>
+ <methodAlias>search</methodAlias>
+ </alias>
+ </aliases>
+ </api>
+ <api>
+ <apiName>tasks</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2TasksManager</proxyClass>
+ <fromJavadoc>
+ </fromJavadoc>
+ <aliases>
+ <alias>
+ <methodPattern>addFileTask</methodPattern>
+ <methodAlias>add</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteTask</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getFileTasks</methodPattern>
+ <methodAlias>tasks</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getTaskInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateTaskInfo</methodPattern>
+ <methodAlias>updateInfo</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>addAssignmentToTask</methodPattern>
+ <methodAlias>addAssignment</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteTaskAssignment</methodPattern>
+ <methodAlias>deleteAssignment</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getTaskAssignments</methodPattern>
+ <methodAlias>assignments</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getTaskAssignmentInfo</methodPattern>
+ <methodAlias>assignmentInfo</methodAlias>
+ </alias>
+ </aliases>
+ <nullableOptions>
+ <nullableOption>message</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>users</apiName>
+ <proxyClass>org.apache.camel.component.box2.api.Box2UsersManager</proxyClass>
+ <fromJavadoc/>
+ <aliases>
+ <alias>
+ <methodPattern>getCurrentUser</methodPattern>
+ <methodAlias>currentUser</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getAllEnterpriseOrExternalUsers</methodPattern>
+ <methodAlias>users</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>createAppUser</methodPattern>
+ <methodAlias>create</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>createEnterpriseUser</methodPattern>
+ <methodAlias>create</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteUser</methodPattern>
+ <methodAlias>delete</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>addUserEmailAlias</methodPattern>
+ <methodAlias>addEmailAlias</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getUserEmailAlias</methodPattern>
+ <methodAlias>emailAlias</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>deleteUserEmailAlias</methodPattern>
+ <methodAlias>deleteEmailAlias</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>getUserInfo</methodPattern>
+ <methodAlias>info</methodAlias>
+ </alias>
+ <alias>
+ <methodPattern>updateUserInfo</methodPattern>
+ <methodAlias>updateInfo</methodAlias>
+ </alias>
+ </aliases>
+ <nullableOptions>
+ <nullableOption>filterTerm</nullableOption>
+ <nullableOption>fields</nullableOption>
+ <nullableOption>params</nullableOption>
+ </nullableOptions>
+ </api>
+ </apis>
+ <!-- Specify global values for all APIs here, these are overridden
+ at API level <substitutions/> <excludeConfigNames/> <excludeConfigTypes/>
+ <extraOptions> <fromJavadoc/> <aliases/> -->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- add generated source and test source to build -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-generated-sources</id>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/camel-component</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-generated-test-sources</id>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-test-sources/camel-component</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-api-component-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <scheme>${schemeName}</scheme>
+ <componentName>${componentName}</componentName>
+ <componentPackage>${componentPackage}</componentPackage>
+ <outPackage>${outPackage}</outPackage>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-api-component-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <scheme>${schemeName}</scheme>
+ <componentName>${componentName}</componentName>
+ <componentPackage>${componentPackage}</componentPackage>
+ <outPackage>${outPackage}</outPackage>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/docs/box2-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/docs/box2-component.adoc b/components/camel-box2/camel-box2-component/src/main/docs/box2-component.adoc
new file mode 100644
index 0000000..72e38f8
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/docs/box2-component.adoc
@@ -0,0 +1,744 @@
+## Box2 Component
+
+*Available as of Camel version *
+
+The Box2 component provides access to all of the Box.com APIs accessible
+using https://github.com/box/box-java-sdk/[box-java-sdk]. It
+allows producing messages to upload and download files, create, edit,
+and manage folders, etc. It also supports APIs that allow polling for
+updates to user accounts and even changes to enterprise accounts, etc.
+
+Box.com requires the use of OAuth2.0 for all client application
+authentication. In order to use camel-box with your account, you'll need
+to create a new application within Box.com at
+https://app.box.com/developers/services/edit/[https://app.box.com/developers/services/edit/].
+The Box application's client id and secret will allow access to Box APIs
+which require a current user. A user access token is generated and
+managed by the API for an end user.
+
+Maven users will need to add the following dependency to their pom.xml
+for this component:
+
+[source,java]
+-------------------------------------------
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-box2</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+-------------------------------------------
+
+### Connection Authentication Types
+
+The Box2 component supports three different types of authenticated connections.
+
+#### Standard Authentication
+
+*Standard Authentication* uses the *OAuth 2.0 three-legged authentication process* to authenticate its connections with Box.com. This type of authentication enables Box *managed users* and *external users* to access, edit, and save their Box content through the Box2 component.
+
+#### App Enterprise Authentication
+
+*App Enterprise Authentication* uses the *OAuth 2.0 with JSON Web Tokens (JWT)* to authenticate its connections as a *Service Account* for a *Box Application*. This type of authentication enables a service account to access, edit, and save the Box content of its *Box Application* through the Box2 component.
+
+#### App User Authentication
+
+*App User Authentication* uses the *OAuth 2.0 with JSON Web Tokens (JWT)* to authenticate its connections as an *App User* for a *Box Application*. This type of authentication enables app users to access, edit, and save their Box content in its *Box Application* through the Box2 component.
+
+### URI format
+
+[source,java]
+--------------------------------------------
+ box2://endpoint-prefix/endpoint?[options]
+--------------------------------------------
+
+Endpoint prefix can be one of:
+
+* collaborations
+* comments
+* event-logs
+* files
+* folders
+* groups
+* events
+* search
+* tasks
+* users
+
+### Box2Component
+
+The Box2 Component can be configured with the options below. These
+options can be provided using the component's bean
+property�*`configuration`*�of
+type�*`org.apache.camel.component.box2.Box2Configuration`*. These options
+can also be specified in the endpoint URI.�
+
+[width="100%",cols="10%,10%,80%",options="header",]
+|======================================================================= custom access token cachecom.box.sdk
+|Option |Type |Description
+
+|accessTokenCache |com.box.sdk.IAccessTokenCache |A custom access token cache. For production applications it is recommended to use a distributed cache like Memcached or Redis, and to implement this interface to store and retrieve access tokens appropriately for your environment; when not set an internal access token cache is used; ONLY used when using App Enterprise or User authentication.
+
+|clientId |String |Box application client ID
+
+|clientSecret |String |Box application client secret
+
+|encryptionAlgorithm |com.box.sdk.EncryptionAlgorithm |Algorithm used by OAuth 2.0 with JWT; MUST be provided when using App Enterprise and User authentication
+
+|enterpriseId |String |The enterprise ID to use for requesting access token; MUST be provided when using App Enterprise authentication
+
+|httpParams |java.util.Map |Custom HTTP params for settings like proxy host
+
+|maxCacheEntries |Integer |The maximum number of access tokens in cache; ONLY used when internal access token cache is used
+
+|privateKeyFile |String |Path to file containing private key used to generate signature in OAuth 2.0 with JWT; MUST be provided when using App Enterprise and User authentication
+
+|privateKeyPassword |String |Password for private key; only used for App Enterprise and User authentication; MUST be provided when using App Enterprise and User authentication
+
+|publicKeyId |String |The ID of public key used to generate signature in OAuth 2.0 with JWT; MUST be provided when using App Enterprise and User authentication
+
+|userId |String |The user ID to use for an App user Authentication; MUST be provided when using App User authentication
+
+|userName |String |Box user name for a Managed user; MUST be provided when using Standard Authentication
+
+|userPassword |String |Box user password, MUST be provided when using Standard Authentication and if authSecureStorage is not set, or
+returns null on first call
+|=======================================================================
+
+### Producer Endpoints:
+
+Producer endpoints can use endpoint prefixes followed by endpoint names
+and associated options described next. A shorthand alias can be used for
+some endpoints. The endpoint URI MUST contain a prefix.
+
+Endpoint options that are not mandatory are denoted by *[]*. When there
+are no mandatory options for an endpoint, one of the set of *[]* options
+MUST be provided. Producer endpoints can also use a special
+option�*`inBody`*�that in turn should contain the name of the endpoint
+option whose value will be contained in the Camel Exchange In message.
+
+Any of the endpoint options can be provided in either the endpoint URI,
+or dynamically in a message header. The message header name must be of
+the format�*`CamelBox2.<option>`*. Note that the�*`inBody`*�option
+overrides message header, i.e. the endpoint
+option�*`inBody=option`*�would override a�*`CamelBox2.option`*�header.
+
+If a value is not provided for the option *defaultRequest* either in the
+endpoint URI or in a message header, it will be assumed to be�`null`.
+Note that the�`null`�value will only be used if other options do not
+satisfy matching endpoints.
+
+In case of Box API errors the endpoint will throw a
+RuntimeCamelException with a
+*com.box.sdk.BoxAPIException*�derived exception
+cause.
+
+#### Endpoint Prefix�_collaborations_
+
+For more information on Box collaborations see
+https://docs.box.com/reference#collaboration-object[https://docs.box.com/reference#collaboration-object].�The
+following endpoints can be invoked with the prefix�*`collaborations`*�as
+follows:
+
+[source,java]
+-------------------------------------------
+ box2://collaborations/endpoint?[options]
+-------------------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|addFolderCollaboration |add |folderId, collaborator, role |com.box.sdk.BoxCollaboration
+
+|addFolderCollaborationByEmail |addByEmail |folderId, email, role |com.box.sdk.BoxCollaboration
+
+|deleteCollaboration |delete |collaborationId |
+
+|getFolderCollaborations |collaborations |folderId |java.util.Collection
+
+|getPendingCollaborations |pendingCollaborations | |java.util.Collection
+
+|getCollaborationInfo |info |collaborationId |com.box.sdk.BoxCollaboration.Info
+
+|updateCollaborationInfo |updateInfo |collaborationId, info |com.box.sdk.BoxCollaboration
+|=======================================================================
+
+[[Box-URIOptionsforcollaborations]]
+URI Options for�_collaborations_
+
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|collaborationId |String
+
+|collaborator |com.box.sdk.BoxCollaborator
+
+|role |com.box.sdk.BoxCollaboration.Role
+
+|folderId |String
+
+|email |String
+
+|info |com.box.sdk.BoxCollaboration.Info
+|=======================================================================
+
+#### Endpoint Prefix�_comments_
+
+For more information on Box comments see
+https://docs.box.com/reference#comment-object[https://docs.box.com/reference#comment-object].�The
+following endpoints can be invoked with the prefix�*`comments`*�as
+follows:
+
+[source,java]
+-------------------------------------------
+ box2://comments/endpoint?[options]
+-------------------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|addFileComment |add |fileId, message |com.box.sdk.BoxFile
+
+|changeCommentMessage |updateMessage |commentId, message |com.box.sdk.BoxComment
+
+|deleteComment |delete |commentId |
+
+|getCommentInfo |info |commentId |com.box.sdk.BoxComment.Info
+
+|getFileComments |comments |fileId |java.util.List
+
+|replyToComment |reply |commentId, message |com.box.sdk.BoxComment
+|=======================================================================
+
+[[Box-URIOptionsforcollaborations]]
+URI Options for�_collaborations_
+
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|commentId |String
+
+|fileId |String
+
+|message |String
+
+|=======================================================================
+
+#### Endpoint Prefix�_events-logs_
+
+For more information on Box event logs see
+https://docs.box.com/reference#events[https://docs.box.com/reference#events].
+The following endpoints can be invoked with the prefix�*`events`*�as follows:
+
+[source,java]
+---------------------------------
+ box2://event-logs/endpoint?[options]
+---------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|getEnterpriseEvents |events |position, after, before, [types] |java.util.List
+|=======================================================================
+
+[[Box-URIOptionsforevent-logs]]
+URI Options for�_event-logs_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|position |String
+
+|after |Date
+
+|before |Date
+
+|types |com.box.sdk.BoxEvent.Types[]
+|=======================================================================
+
+#### Endpoint Prefix�_files_
+
+For more information on Box files see
+https://docs.box.com/reference#file-object[https://docs.box.com/reference#file-object].
+The following endpoints can be invoked with the
+prefix�*`files`*�as follows.
+
+[source,java]
+----------------------------------------
+ box2://files/endpoint?[options]
+----------------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|uploadFile |upload |parentFolderId, content, fileName, [created], [modified], [size], [listener] |com.box.sdk.BoxFile
+
+|downloadFile |download |fileId, output, [rangeStart], [rangeEnd], [listener] |java.io.OutputStream
+
+|copyFile |copy |fileId, destinationFolderId, [newName] |com.box.sdk.BoxFile
+
+|moveFile |move |fileId, destinationFolderId, [newName] |com.box.sdk.BoxFile
+
+|renameFile |rename |fileId, newFileName |com.box.sdk.BoxFile
+
+|createFileSharedLink |link |fileId, access, [unshareDate], [permissions] |com.box.sdk.BoxSharedLink
+
+|deleteFile |delete |fileId |
+
+|uploadNewFileVersion |uploadVersion |fileId, fileContent, [modified], [fileSize], [listener] |com.box.boxsdk.BoxFile
+
+|promoteFileVersion |promoteVersion |fileId, version |com.box.sdk.BoxFileVersion
+
+|getFileVersions |versions |fileId |java.util.Collection
+
+|downloadPreviousFileVersions |downloadVersion |fileId, version, output, [listener] |java.io.OutputStream
+
+|deleteFileVersion |deleteVersion |fileId, version |
+
+|getFileInfo |info |fileId, fields |com.box.sdk.BoxFile.Info
+
+|updateFileInfo |updateInfo |fileId, info |com.box.sdk.BoxFile
+
+|createFileMetadata |createMetadata |fileId, metadata, [typeName] |com.box.sdk.Metadata
+
+|getFileMetadata |metadata |fileId, [typeName] |com.box.sdk.Metadata
+
+|updateFileMetadata |updateMetadata |fileId, metadata |com.box.sdk.Metadata
+
+|deleteFileMetadata |deleteMetadata |fileId |
+
+|getDownloadUrl |url |fileId |java.net.URL
+
+|getPreviewLink |preview |fileId |java.net.URL
+
+|getFileThumbnail |thumbnail |fileId, fileType, minWidth, minHeight, maxWidth, maxHeight |byte[]
+|=======================================================================
+
+[[Box-URIOptionsforfiles]]
+URI Options for _files_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|parentFolderId |String
+
+|content |java.io.InputStream
+
+|fileName |String
+
+|created |Date
+
+|modified |Date
+
+|size |Long
+
+|listener |com.box.sdk.ProgressListener
+
+|output |java.io.OutputStream
+
+|rangeStart |Long
+
+|rangeEnd |Long
+
+|outputStreams |java.io.OutputStream[]
+
+|destinationFolderId |String
+
+|newName |String
+
+|fields |String[]
+
+|info |com.box.sdk.BoxFile.Info
+
+|fileSize |Long
+
+|version |Integer
+
+|access |com.box.sdk.BoxSharedLink.Access
+
+|unshareDate |Date
+
+|permissions |com.box.sdk.BoxSharedLink.Permissions
+
+|fileType |com.box.sdk.BoxFile.ThumbnailFileType
+
+|minWidth |Integer
+
+|minHeight |Integer
+
+|maxWidth |Integer
+
+|maxHeight |Integer
+
+|metadata |com.box.sdk.Metadata
+
+|typeName |String
+|=======================================================================
+
+#### Endpoint Prefix _folders_
+
+For more information on Box folders see
+https://docs.box.com/reference#folder-object[https://docs.box.com/reference#folder-object].
+The following endpoints can be invoked with the prefix
+*`folders`*�as follows.
+
+[source,java]
+-------------------------------------------
+ box2://folders/endpoint?[options]
+-------------------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|getRootFolder |root | |com.box.sdk.BoxFolder
+
+|createFolder |create |parentFolderId, folderName |com.box.sdk.BoxFolder
+
+|copyFolder |copy |folderId, destinationfolderId, [newName] |com.box.sdk.BoxFolder
+
+|moveFolder |move |folderId, destinationFolderId, newName |com.box.sdk.BoxFolder
+
+|renameFolder |rename |folderId, newFolderName |com.box.sdk.BoxFolder
+
+|createFolderSharedLink |link |folderId, access, [unsharedDate], [permissions] |java.util.List
+
+|deleteFolder |delete |folderId |
+
+|getFolder |folder |path |com.box.sdk.BoxFolder
+
+|getFolderInfo |info |folderId, fields |com.box.sdk.BoxFolder.Info
+
+|getFolderItems |items |folderId, offset, limit, fields |com.box.sdk.BoxFolder
+
+|updateFolderInfo |updateInfo |folderId, info |com.box.sdk.BoxFolder
+|=======================================================================
+
+[[Box-URIOptionsforfolders]]
+URI Options for _folders_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|path |String[]
+
+|folderId |String
+
+|offset |Long
+
+|limit |Long
+
+|fields |String[]
+
+|parentFolderId |String
+
+|folderName |String
+
+|destinationFolderId |String
+
+|newName |String
+
+|newFolderName |String
+
+|info |String
+
+|access |com.box.sdk.BoxSharedLink.Access
+
+|unshareDate |Date
+
+|permissions |com.box.sdk.BoxSharedLink.Permissions
+|=======================================================================
+
+#### Endpoint Prefix�_groups_
+
+For more information on Box groups see
+https://docs.box.com/reference#group-object[https://docs.box.com/reference#group-object].
+The following endpoints can be invoked with the prefix�*`groups`*�as
+follows:
+
+[source,java]
+-----------------------------------
+ box2://groups/endpoint?[options]
+-----------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|createGroup |create |name |com.box.sdk.BoxGroup
+
+|addGroupMembership |createMembership |groupId, userId, role |com.box.sdk.BoxGroupMembership
+
+|deleteGroup |delete |groupId |
+
+|getAllGroups |groups | |java.util.Collection
+
+|getGroupInfo |info |groupId |com.box.sdk.BoxGroup.Info
+
+|addGroupMembership |addMembership |groupId, userId, role |com.box.sdk.BoxGroupMembership
+
+|deleteGroupMembership |deleteMembership |groupMembershipId |
+
+|getGroupMemberships |memberships |groupId |java.uti.Collection
+
+|getGroupMembershipInfo |membershipInfo |groupMemebershipId |com.box.sdk.BoxGroup.Info
+
+|updateGroupMembershipInfo |updateMembershipInfo |groupMemebershipId, info |com.box.sdk.BoxGroupMembership
+|=======================================================================
+
+[[Box-URIOptionsforgroups]]
+URI Options for�_groups_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|name |String
+
+|groupId |String
+
+|userId |String
+
+|role |com.box.sdk.BoxGroupMembership.Role
+
+|groupMembershipId |String
+
+|info |com.box.sdk.BoxGroupMembership.Info
+
+|=======================================================================
+
+#### Endpoint Prefix�_search_
+
+For more information on Box search API see
+https://docs.box.com/reference#searching-for-content[https://docs.box.com/reference#searching-for-content].�The
+following endpoints can be invoked with the prefix�*`search`*�as
+follows:
+
+[source,java]
+-----------------------------------
+ box2://search/endpoint?[options]
+-----------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|searchFolder |search |folderId, query |java.util.Collection
+|=======================================================================
+
+[[Box-URIOptionsforsearch]]
+URI Options for�_search_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|folderId |String
+
+|query |String
+|=======================================================================
+
+#### Endpoint Prefix�_tasks_
+
+For information on Box tasks see
+https://docs.box.com/reference#task-object-1[https://docs.box.com/reference#task-object-1].
+The following endpoints can be invoked with the prefix�*`tasks`*�as
+follows:
+
+[source,java]
+----------------------------------
+ box2://tasks/endpoint?[options]
+----------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|addFileTask |add |fileId, action, dueAt, [message] |com.box.sdk.BoxUser
+
+|deleteTask |delete |taskId |
+
+|getFileTasks |tasks |fileId |java.util.List
+
+|getTaskInfo |info |taskId |com.box.sdk.BoxTask.Info
+
+|updateTaskInfo |updateInfo |taskId, info |com.box.sdk.BoxTask
+
+|addAssignmentToTask |addAssignment |taskId, assignTo |com.box.sdk.BoxTask
+
+|deleteTaskAssignment |deleteAssignment |taskAssignmentId |
+
+|getTaskAssignments |assignments | taskId |java.util.List
+
+|getTaskAssignmentInfo |assignmentInfo |taskAssignmentId |com.box.sdk.BoxTaskAssignment.Info
+|=======================================================================
+
+[[Box-URIOptionsfortasks]]
+URI Options for�_tasks_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|fileId |String
+
+|action |com.box.sdk.BoxTask.Action
+
+|dueAt |Date
+
+|message |String
+
+|taskId |String
+
+|info |com.box.sdk.BoxTask.Info
+
+|assignTo |com.box.sdk.BoxUser
+
+|taskAssignmentId |String
+|=======================================================================
+
+#### Endpoint Prefix�_users_
+
+For information on Box users see
+https://docs.box.com/reference#user-object[https://docs.box.com/reference#user-object].
+The following endpoints can be invoked with the prefix�*`users`*�as
+follows:
+
+[source,java]
+----------------------------------
+ box2://users/endpoint?[options]
+----------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|getCurrentUser |currentUser | |com.box.sdk.BoxUser
+
+|getAllEnterpriseOrExternalUsers |users |filterTerm, [fields] |com.box.sdk.BoxUser
+
+|createAppUser |create |name, [params] |com.box.sdk.BoxUser
+
+|createEnterpriseUser |create |login, name, [params] |com.box.sdk.BoxUser
+
+|deleteUser |delete |userId, notifyUser, force |
+
+|getUserEmailAlias |emailAlias |userId |com.box.sdk.BoxUser
+
+|deleteUserEmailAlias |deleteEmailAlias |userId, emailAliasId |java.util.List
+
+|getUserInfo |info | userId |com.box.sdk.BoxUser.Info
+
+|updateUserInfo |updateInfo |userId, info |com.box.sdk.BoxUser
+|=======================================================================
+
+[[Box-URIOptionsforusers]]
+URI Options for�_users_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|defaultRequest |com.box.restclientv2.requestsbase.BoxDefaultRequestObject
+
+|emailAliasRequest |com.box.boxjavalibv2.requests.requestobjects.BoxEmailAliasRequestObject
+
+|emailId |String
+
+|filterTerm |String
+
+|folderId |String
+
+|simpleUserRequest |com.box.boxjavalibv2.requests.requestobjects.BoxSimpleUserRequestObject
+
+|userDeleteRequest |com.box.boxjavalibv2.requests.requestobjects.BoxUserDeleteRequestObject
+
+|userId |String
+
+|userRequest |com.box.boxjavalibv2.requests.requestobjects.BoxUserRequestObject
+
+|userUpdateLoginRequest |com.box.boxjavalibv2.requests.requestobjects.BoxUserUpdateLoginRequestObject
+|=======================================================================
+
+### Consumer Endpoints:
+
+For more information on Box events see
+https://docs.box.com/reference#events[https://docs.box.com/reference#events].
+Consumer endpoints can only use the endpoint prefix *events* as
+shown in the example next.
+
+[source,java]
+----------------------------------------
+ box2://events/endpoint?[options]
+----------------------------------------
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Endpoint |Shorthand Alias |Options |Result Body Type
+
+|events | |[startingPosition] |com.box.sdk.BoxEvent
+|=======================================================================
+
+[[Box-URIOptionsforevents]]
+URI Options for�_events_
+
+[width="100%",cols="10%,90%",options="header",]
+|=======================================================================
+|Name |Type
+
+|startingPosition |Long
+|=======================================================================
+
+### Message header
+
+Any of the options�can be provided in a message header for producer
+endpoints with *CamelBox2.* prefix.
+
+### Message body
+
+All result message bodies utilize objects provided by the Box Java SDK.
+Producer endpoints can specify the option name for incoming message body
+in the *inBody* endpoint parameter.
+
+### Use cases
+
+The following route uploads new files to the user's root folder:
+
+[source,java]
+-----------------------------------------------------------
+ from("file:...")
+ .to("box2://files/upload/inBody=fileUploadRequest");
+-----------------------------------------------------------
+
+The following route polls user's account for updates:
+
+[source,java]
+-----------------------------------------------------------------------------
+ from("box2://events/listen?startingPosition=-1")
+ .to("bean:blah");
+-----------------------------------------------------------------------------
+
+The following route uses a producer with dynamic header options.�The
+*fileId*�property has the Box file id and the *output* property has
+the output stream of the file contents, so they are assigned to the
+*CamelBox2.fileId* header and *CamelBox2.output* header respectively
+as follows:
+
+[source,java]
+-------------------------------------------------------
+ from("direct:foo")
+ .setHeader("CamelBox2.fileId", header("fileId"))
+ .setHeader("CamelBox2.output", header("output"))
+ .to("box2://files/download")
+ .to("file://...");
+-------------------------------------------------------
[2/8] camel git commit: Removed @author tags from source code.
Posted by da...@apache.org.
Removed @author tags from source code.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f6250e3b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f6250e3b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f6250e3b
Branch: refs/heads/master
Commit: f6250e3b85af3b99c4b3d416f2805afa523e12c3
Parents: 45335d1
Author: William Collins <pu...@gmail.com>
Authored: Fri Mar 3 16:01:53 2017 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 6 08:48:05 2017 +0100
----------------------------------------------------------------------
.../apache/camel/component/box2/api/Box2CollaborationsManager.java | 2 +-
.../org/apache/camel/component/box2/api/Box2CommentsManager.java | 2 +-
.../org/apache/camel/component/box2/api/Box2EventLogsManager.java | 2 +-
.../org/apache/camel/component/box2/api/Box2EventsManager.java | 2 +-
.../java/org/apache/camel/component/box2/api/Box2FilesManager.java | 2 +-
.../org/apache/camel/component/box2/api/Box2FoldersManager.java | 2 +-
.../org/apache/camel/component/box2/api/Box2GroupsManager.java | 2 +-
.../org/apache/camel/component/box2/api/Box2SearchManager.java | 2 +-
.../java/org/apache/camel/component/box2/api/Box2TasksManager.java | 2 +-
.../java/org/apache/camel/component/box2/api/Box2UsersManager.java | 2 +-
.../main/java/org/apache/camel/component/box2/Box2Component.java | 2 +-
.../java/org/apache/camel/component/box2/Box2Configuration.java | 2 +-
.../main/java/org/apache/camel/component/box2/Box2Consumer.java | 2 +-
.../main/java/org/apache/camel/component/box2/Box2Endpoint.java | 2 +-
.../main/java/org/apache/camel/component/box2/Box2Producer.java | 2 +-
.../apache/camel/component/box2/internal/Box2ConnectionHelper.java | 2 +-
.../org/apache/camel/component/box2/internal/Box2Constants.java | 2 +-
.../apache/camel/component/box2/internal/Box2PropertiesHelper.java | 2 +-
18 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
index 5cbd7fb..6905036 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box collaborations.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2CollaborationsManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
index 946f292..b20c7bc 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box comments.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2CommentsManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
index a54c305..b7be4f7 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to read Box enterprise (admin) event logs.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2EventLogsManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java
index 7ef47f7..62b7f11 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box events.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2EventsManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
index 602a3c9..2435e34 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box files.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2FilesManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
index 4617fa2..5eba928 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box folders.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2FoldersManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
index 50698e2..0e2faa8 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2GroupsManager.java
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box groups.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2GroupsManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
index 1ce47da..4e6d37c 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2SearchManager.java
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box searches.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2SearchManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
index ab64b1b..a93b471 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2TasksManager.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box tasks.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2TasksManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
index 6c33e14..febfe70 100644
--- a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2UsersManager.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Provides operations to manage Box users.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2UsersManager {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
index 1b5fa50..2e8aade 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
@@ -29,7 +29,7 @@ import org.apache.camel.util.component.AbstractApiComponent;
/**
* Represents the component that manages {@link Box2Endpoint}.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
// @UriEndpoint(scheme = "box2", consumerClass = Box2Consumer.class,
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
index 0de24b8..222e5d4 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
@@ -32,7 +32,7 @@ import org.apache.camel.util.jsse.SSLContextParameters;
/**
* Component configuration for Box2 component.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
@UriParams
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
index 313ba2d..bad66c4 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
@@ -36,7 +36,7 @@ import org.apache.camel.util.component.ApiMethodHelper;
/**
* The Box2 consumer.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2Consumer extends AbstractApiConsumer<Box2ApiName, Box2Configuration> implements EventListener {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
index 0fe122f..88bd12c 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
@@ -47,7 +47,7 @@ import org.apache.camel.util.component.ApiMethodPropertiesHelper;
/**
* Represents a Box2 endpoint.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
@UriEndpoint(scheme = "box2", title = "Box2", syntax = "box2:apiName/methodName", consumerClass = Box2Consumer.class, consumerPrefix = "consumer", label = "api,file,cloud", lenientProperties = true)
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java
index 92ef415..c925ffa 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java
@@ -24,7 +24,7 @@ import org.apache.camel.util.component.AbstractApiProducer;
/**
* The Box2 producer.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public class Box2Producer extends AbstractApiProducer<Box2ApiName, Box2Configuration> {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
index c95efdc..529ac86 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
@@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Utility class for creating Box API Connections
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public final class Box2ConnectionHelper {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
index 595be90..2c5f9f5 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.box2.internal;
/**
* Constants for Box2 component.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public interface Box2Constants {
http://git-wip-us.apache.org/repos/asf/camel/blob/f6250e3b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
index f242c96..b34aff3 100644
--- a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
@@ -22,7 +22,7 @@ import org.apache.camel.util.component.ApiMethodPropertiesHelper;
/**
* Singleton {@link ApiMethodPropertiesHelper} for Box2 component.
*
- * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
*
*/
public final class Box2PropertiesHelper extends ApiMethodPropertiesHelper<Box2Configuration> {
[3/8] camel git commit: CAMEL-9047: Replace deprecated boxjavalibv2
with box-java-sdk
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2UsersManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2UsersManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2UsersManagerIntegrationTest.java
new file mode 100644
index 0000000..6b4b952
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2UsersManagerIntegrationTest.java
@@ -0,0 +1,323 @@
+/**
+ * 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.box2;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxUser;
+import com.box.sdk.CreateUserParams;
+import com.box.sdk.EmailAlias;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2UsersManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2UsersManager}
+ * APIs.
+ */
+public class Box2UsersManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2UsersManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2UsersManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_USER_EMAIL_ALIAS = "camel@example.com";
+ private static final String CAMEL_TEST_USER_JOB_TITLE = "Camel Tester";
+ private static final String CAMEL_TEST_CREATE_APP_USER_NAME = "Wilma";
+ private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME = "fred";
+ private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN = "fred@example.com";
+
+ private BoxUser testUser;
+
+ @Ignore
+ @Test
+ public void testAddUserEmailAlias() throws Exception {
+ com.box.sdk.EmailAlias result = null;
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.userId", testUser.getID());
+ // parameter type is String
+ headers.put("CamelBox2.email", CAMEL_TEST_USER_EMAIL_ALIAS);
+ result = requestBodyAndHeaders("direct://ADDUSEREMAILALIAS", null, headers);
+ assertNotNull("addUserEmailAlias result", result);
+ LOG.debug("addUserEmailAlias: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ testUser.deleteEmailAlias(result.getID());
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testCreateAppUser() throws Exception {
+ com.box.sdk.BoxUser result = null;
+
+ try {
+ CreateUserParams params = new CreateUserParams();
+ params.setSpaceAmount(1073741824); // 1 GB
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.name", CAMEL_TEST_CREATE_APP_USER_NAME);
+ // parameter type is com.box.sdk.CreateUserParams
+ headers.put("CamelBox2.params", params);
+
+ result = requestBodyAndHeaders("direct://CREATEAPPUSER", null, headers);
+
+ assertNotNull("createAppUser result", result);
+ LOG.debug("createAppUser: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete(false, true);
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testCreateEnterpriseUser() throws Exception {
+ com.box.sdk.BoxUser result = null;
+
+ try {
+ CreateUserParams params = new CreateUserParams();
+ params.setSpaceAmount(1073741824); // 1 GB
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.login", CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN);
+ // parameter type is String
+ headers.put("CamelBox2.name", CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME);
+ // parameter type is com.box.sdk.CreateUserParams
+ headers.put("CamelBox2.params", params);
+
+ result = requestBodyAndHeaders("direct://CREATEENTERPRISEUSER", null, headers);
+
+ assertNotNull("createEnterpriseUser result", result);
+ LOG.debug("createEnterpriseUser: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete(false, true);
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testDeleteUser() throws Exception {
+ BoxUser.Info info = BoxUser.createAppUser(getConnection(), CAMEL_TEST_CREATE_APP_USER_NAME);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.userId", info.getID());
+ headers.put("CamelBox2.notifyUser", Boolean.FALSE);
+ headers.put("CamelBox2.force", Boolean.FALSE);
+
+ requestBodyAndHeaders("direct://DELETEUSER", null, headers);
+
+ Iterable<BoxUser.Info> it = BoxUser.getAllEnterpriseUsers(getConnection(), CAMEL_TEST_CREATE_APP_USER_NAME);
+ int searchResults = sizeOfIterable(it);
+ boolean exists = searchResults > 0 ? true : false;
+ assertEquals("deleteUser exists", false, exists);
+ LOG.debug("deleteUser: exists? " + exists);
+ }
+
+ @Ignore
+ @Test
+ public void testDeleteUserEmailAlias() throws Exception {
+ EmailAlias emailAlias = null;
+ try {
+ emailAlias = testUser.addEmailAlias(CAMEL_TEST_USER_EMAIL_ALIAS);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.userId", testUser.getID());
+ // parameter type is String
+ headers.put("CamelBox2.emailAliasId", emailAlias.getID());
+
+ requestBodyAndHeaders("direct://DELETEUSEREMAILALIAS", null, headers);
+
+ assertNotNull("deleteUserEmailAlias email aliases", testUser.getEmailAliases());
+ assertEquals("deleteUserEmailAlias email aliases", 0, testUser.getEmailAliases().size());
+ }
+
+ @Test
+ public void testGetAllEnterpriseOrExternalUsers() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.filterTerm", null);
+ // parameter type is String[]
+ headers.put("CamelBox2.fields", null);
+
+ @SuppressWarnings("rawtypes")
+ final java.util.List result = requestBodyAndHeaders("direct://GETALLENTERPRISEOREXTERNALUSERS", null, headers);
+
+ assertNotNull("getAllEnterpriseOrExternalUsers result", result);
+ LOG.debug("getAllEnterpriseOrExternalUsers: " + result);
+ }
+
+ @Test
+ public void testGetCurrentUser() throws Exception {
+ final com.box.sdk.BoxUser result = requestBody("direct://GETCURRENTUSER", testUser.getID());
+
+ assertNotNull("getCurrentUser result", result);
+ LOG.debug("getCurrentUser: " + result);
+ }
+
+ @Test
+ public void testGetUserEmailAlias() throws Exception {
+ // using String message body for single parameter "userId"
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBody("direct://GETUSEREMAILALIAS", testUser.getID());
+
+ assertNotNull("getUserEmailAlias result", result);
+ LOG.debug("getUserEmailAlias: " + result);
+ }
+
+ @Test
+ public void testGetUserInfo() throws Exception {
+ // using String message body for single parameter "userId"
+ final com.box.sdk.BoxUser.Info result = requestBody("direct://GETUSERINFO", testUser.getID());
+
+ assertNotNull("getUserInfo result", result);
+ LOG.debug("getUserInfo: " + result);
+ }
+
+ @Test
+ public void testUpdateUserInfo() throws Exception {
+ BoxUser.Info info = testUser.getInfo();
+ info.setJobTitle(CAMEL_TEST_USER_JOB_TITLE);
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.userId", testUser.getID());
+ // parameter type is com.box.sdk.BoxUser.Info
+ headers.put("CamelBox2.info", info);
+ final com.box.sdk.BoxUser result = requestBodyAndHeaders("direct://UPDATEUSERINFO", null, headers);
+ assertNotNull("updateUserInfo result", result);
+ LOG.debug("updateUserInfo: " + result);
+ } finally {
+ info = testUser.getInfo();
+ info.setJobTitle("");
+ testUser.updateInfo(info);
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for addUserEmailAlias
+ from("direct://ADDUSEREMAILALIAS").to("box2://" + PATH_PREFIX + "/addUserEmailAlias");
+
+ // test route for createAppUser
+ from("direct://CREATEAPPUSER").to("box2://" + PATH_PREFIX + "/createAppUser");
+
+ // test route for createEnterpriseUser
+ from("direct://CREATEENTERPRISEUSER").to("box2://" + PATH_PREFIX + "/createEnterpriseUser");
+
+ // test route for deleteUser
+ from("direct://DELETEUSER").to("box2://" + PATH_PREFIX + "/deleteUser");
+
+ // test route for deleteUserEmailAlias
+ from("direct://DELETEUSEREMAILALIAS").to("box2://" + PATH_PREFIX + "/deleteUserEmailAlias");
+
+ // test route for getAllEnterpriseOrExternalUsers
+ from("direct://GETALLENTERPRISEOREXTERNALUSERS")
+ .to("box2://" + PATH_PREFIX + "/getAllEnterpriseOrExternalUsers");
+
+ // test route for getCurrentUser
+ from("direct://GETCURRENTUSER").to("box2://" + PATH_PREFIX + "/getCurrentUser");
+
+ // test route for getUserEmailAlias
+ from("direct://GETUSEREMAILALIAS").to("box2://" + PATH_PREFIX + "/getUserEmailAlias?inBody=userId");
+
+ // test route for getUserInfo
+ from("direct://GETUSERINFO").to("box2://" + PATH_PREFIX + "/getUserInfo?inBody=userId");
+
+ // test route for updateUserInfo
+ from("direct://UPDATEUSERINFO").to("box2://" + PATH_PREFIX + "/updateUserInfo");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestUser();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestUser();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/addUserEmailAlias");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestUser() {
+ testUser = getCurrentUser();
+ }
+
+ private void deleteTestUser() {
+ if (testUser != null) {
+ testUser = null;
+ }
+ }
+
+ private BoxUser getCurrentUser() {
+ return BoxUser.getCurrentUser(getConnection());
+ }
+
+ private int sizeOfIterable(Iterable<?> it) {
+ if (it instanceof Collection) {
+ return ((Collection<?>) it).size();
+ } else {
+ int i = 0;
+ for (@SuppressWarnings("unused")
+ Object obj : it) {
+ i++;
+ }
+ return i;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/resources/CamelTestFile.txt
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/resources/CamelTestFile.txt b/components/camel-box2/camel-box2-component/src/test/resources/CamelTestFile.txt
new file mode 100644
index 0000000..e420c95
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/resources/CamelTestFile.txt
@@ -0,0 +1 @@
+This is the CamelTestFile.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/resources/log4j.properties b/components/camel-box2/camel-box2-component/src/test/resources/log4j.properties
new file mode 100644
index 0000000..3b1bd38
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/resources/log4j.properties
@@ -0,0 +1,14 @@
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/resources/test-options.properties b/components/camel-box2/camel-box2-component/src/test/resources/test-options.properties
new file mode 100644
index 0000000..c5a5481
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/resources/test-options.properties
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+###############################################
+## Authentication properties for Box2 Component
+###############################################
+
+#############################################################################
+## Authentication properties for Box2 Component using STANDARD_AUTHENTICATION
+#############################################################################
+authenticationType=STANDARD_AUTHENTICATION
+## User name and password
+## Create a free developer account on http://developers.box.com/ and provide user name password
+userName=
+userPassword=
+## Application client id and secret
+## Create a test Box.com application and provide its clientId and clientSecret
+clientId=
+clientSecret=
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/tmp/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/tmp/test-options.properties b/components/camel-box2/camel-box2-component/tmp/test-options.properties
new file mode 100644
index 0000000..30a032c
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/tmp/test-options.properties
@@ -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.
+#
+
+###############################################
+## Authentication properties for Box2 Component
+###############################################
+
+#############################################################################
+## Authentication properties for Box2 Component using STANDARD_AUTHENTICATION
+#############################################################################
+authenticationType=STANDARD_AUTHENTICATION
+## User name and password
+## Create a free developer account on http://developers.box.com/ and provide user name password
+userName=punkhornsw@gmail.com
+userPassword=RedHat12!@
+## Application client id and secret
+## Create a test Box.com application and provide its clientId and clientSecret
+clientId=4vvr1njh5d0u3o8lpowbgnameqic9mz3
+clientSecret=rh0qN6EWyMek61fELV8N82XblkK2EJMr
+
+###################################################################################
+## Authentication properties for Box2 Component using APP_ENTERPRISE_AUTHENTICATION
+###################################################################################
+#authenticationType=APP_ENTERPRISE_AUTHENTICATION
+#enterpriseId=8962085
+#clientId=4vvr1njh5d0u3o8lpowbgnameqic9mz3
+#clientSecret=rh0qN6EWyMek61fELV8N82XblkK2EJMr
+#publicKeyId=b22nf9qt
+#privateKeyFile=/Volumes/Development/Dev/box-java-sdk/private_key.pem
+#privateKeyPassword=RedHat12!@
+#encryptionAlgorithm=RSA_SHA_256
+#maxCacheEntries=100
+### Application client id and secret
+### Create a test Box.com application and provide its clientId and clientSecret
+#clientId=4vvr1njh5d0u3o8lpowbgnameqic9mz3
+#clientSecret=rh0qN6EWyMek61fELV8N82XblkK2EJMr
+
+###################################################################################
+## Authentication properties for Box2 Component using APP_USER_AUTHENTICATION
+###################################################################################
+#authenticationType=APP_USER_AUTHENTICATION
+#userId=punkhornsw@gmail.com
+#clientId=4vvr1njh5d0u3o8lpowbgnameqic9mz3
+#clientSecret=rh0qN6EWyMek61fELV8N82XblkK2EJMr
+#publicKeyId=b22nf9qt
+#privateKeyFile=/Volumes/Development/Dev/box-java-sdk/private_key.pem
+#privateKeyPassword=RedHat12!@
+#encryptionAlgorithm=RSA_SHA_256
+#maxCacheEntries=100
+### Application client id and secret
+### Create a test Box.com application and provide its clientId and clientSecret
+#clientId=4vvr1njh5d0u3o8lpowbgnameqic9mz3
+#clientSecret=rh0qN6EWyMek61fELV8N82XblkK2EJMr
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-box2/pom.xml b/components/camel-box2/pom.xml
new file mode 100644
index 0000000..b25a287
--- /dev/null
+++ b/components/camel-box2/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <artifactId>components</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-box2-parent</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Camel Box2 Component Parent</name>
+ <description>Parent project for Camel {Box2} Component</description>
+
+ <modules>
+ <module>camel-box2-component</module>
+ <module>camel-box2-api</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/readme.adoc
----------------------------------------------------------------------
diff --git a/components/readme.adoc b/components/readme.adoc
index 0904eab..fde808d 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -98,6 +98,9 @@ Number of Components: 220 in 175 JAR artifacts
| link:camel-box/src/main/docs/box-component.adoc[Box] (camel-box) +
`box:apiName/methodName` | 2.14 | For uploading downloading and managing files folders groups collaborations etc on box DOT com.
+| link:camel-box2/src/main/docs/box2-component.adoc[Box] (camel-box2) +
+`box2:apiName/methodName` | 2.19 | For uploading downloading and managing files folders groups collaborations etc on box DOT com.
+
| link:camel-braintree/src/main/docs/braintree-component.adoc[Braintree] (camel-braintree) +
`braintree:apiName/methodName` | 2.17 | The braintree component is used for integrating with the Braintree Payment System.
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index d9212a8..57a4822 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -152,6 +152,7 @@
* [Beanstalk](beanstalk-component.adoc)
* [Bonita](bonita-component.adoc)
* [Box](box-component.adoc)
+ * [Box2](box2-component.adoc)
* [Braintree](braintree-component.adoc)
* [Camel Context](context-component.adoc)
* [Cassandra CQL](cql-component.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 3001de0..0874266 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -85,6 +85,7 @@
<boon-version>0.34</boon-version>
<bouncycastle-version>1.55</bouncycastle-version>
<boxjavalibv2.version>3.2.1</boxjavalibv2.version>
+ <box-java-sdk-version>2.1.1</box-java-sdk-version>
<braintree-gateway-version>2.63.0</braintree-gateway-version>
<brave-zipkin-version>4.0.6</brave-zipkin-version>
<build-helper-maven-plugin-version>1.10</build-helper-maven-plugin-version>
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/platforms/spring-boot/components-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml
index e0e5fca..b198c69 100644
--- a/platforms/spring-boot/components-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/pom.xml
@@ -94,6 +94,7 @@
<module>camel-bonita-starter</module>
<module>camel-boon-starter</module>
<module>camel-box-starter</module>
+ <module>camel-box2-starter</module>
<module>camel-braintree-starter</module>
<module>camel-cache-starter</module>
<module>camel-cassandraql-starter</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index 42ac198..75cd5de 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -1009,6 +1009,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-groovy-dsl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-groovy-starter</artifactId>
<version>${project.version}</version>
</dependency>
[7/8] camel git commit: CAMEL-9047: Replace deprecated boxjavalibv2
with box-java-sdk
Posted by da...@apache.org.
CAMEL-9047: Replace deprecated boxjavalibv2 with box-java-sdk
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/45335d1e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/45335d1e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/45335d1e
Branch: refs/heads/master
Commit: 45335d1ea29ecbf65e8bb983b623eccc86c58411
Parents: b259c00
Author: William Collins <pu...@gmail.com>
Authored: Fri Mar 3 12:30:29 2017 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 6 08:48:05 2017 +0100
----------------------------------------------------------------------
components/camel-box2/camel-box2-api/pom.xml | 79 ++
.../box2/api/Box2CollaborationsManager.java | 238 ++++++
.../component/box2/api/Box2CommentsManager.java | 205 +++++
.../box2/api/Box2EventLogsManager.java | 110 +++
.../component/box2/api/Box2EventsManager.java | 99 +++
.../component/box2/api/Box2FilesManager.java | 798 +++++++++++++++++++
.../component/box2/api/Box2FoldersManager.java | 407 ++++++++++
.../component/box2/api/Box2GroupsManager.java | 274 +++++++
.../component/box2/api/Box2SearchManager.java | 93 +++
.../component/box2/api/Box2TasksManager.java | 324 ++++++++
.../component/box2/api/Box2UsersManager.java | 333 ++++++++
.../camel-box2/camel-box2-component/pom.xml | 612 ++++++++++++++
.../src/main/docs/box2-component.adoc | 744 +++++++++++++++++
.../camel/component/box2/Box2Component.java | 115 +++
.../camel/component/box2/Box2Configuration.java | 475 +++++++++++
.../camel/component/box2/Box2Consumer.java | 111 +++
.../camel/component/box2/Box2Endpoint.java | 214 +++++
.../camel/component/box2/Box2Producer.java | 35 +
.../box2/internal/Box2ConnectionHelper.java | 286 +++++++
.../component/box2/internal/Box2Constants.java | 32 +
.../box2/internal/Box2PropertiesHelper.java | 42 +
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../services/org/apache/camel/component/box2 | 18 +
.../component/box2/AbstractBox2TestSupport.java | 82 ++
...ox2CollaborationsManagerIntegrationTest.java | 231 ++++++
.../Box2CommentsManagerIntegrationTest.java | 201 +++++
.../Box2EventLogsManagerIntegrationTest.java | 76 ++
.../box2/Box2EventsManagerIntegrationTest.java | 105 +++
.../box2/Box2FilesManagerIntegrationTest.java | 575 +++++++++++++
.../box2/Box2FoldersManagerIntegrationTest.java | 322 ++++++++
.../box2/Box2GroupsManagerIntegrationTest.java | 268 +++++++
.../box2/Box2SearchManagerIntegrationTest.java | 106 +++
.../box2/Box2TasksManagerIntegrationTest.java | 284 +++++++
.../box2/Box2UsersManagerIntegrationTest.java | 323 ++++++++
.../src/test/resources/CamelTestFile.txt | 1 +
.../src/test/resources/log4j.properties | 14 +
.../src/test/resources/test-options.properties | 33 +
.../tmp/test-options.properties | 67 ++
components/camel-box2/pom.xml | 32 +
components/readme.adoc | 3 +
docs/user-manual/en/SUMMARY.md | 1 +
parent/pom.xml | 1 +
.../spring-boot/components-starter/pom.xml | 1 +
.../camel-spring-boot-dependencies/pom.xml | 5 +
45 files changed, 8589 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/pom.xml b/components/camel-box2/camel-box2-api/pom.xml
new file mode 100644
index 0000000..a347278
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>camel-box2-parent</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-box2-api</artifactId>
+ <name>Camel Box2 Component API</name>
+ <description>API for Camel Box2 Component</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <!-- to generate API Javadoc -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-javadoc</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <attach>true</attach>
+ <source>1.7</source>
+ <quiet>true</quiet>
+ <detectOfflineLinks>false</detectOfflineLinks>
+ <javadocVersion>1.7</javadocVersion>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- Disable Java 8 doclint checks to avoid Javadoc plugin failures -->
+ <profiles>
+ <profile>
+ <id>doclint-java8-disable</id>
+ <activation>
+ <jdk>[1.8,</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalparam>-Xdoclint:none</additionalparam>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.box</groupId>
+ <artifactId>box-java-sdk</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
new file mode 100644
index 0000000..5cbd7fb
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CollaborationsManager.java
@@ -0,0 +1,238 @@
+/**
+ * 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.box2.api;
+
+import java.util.Collection;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxCollaboration;
+import com.box.sdk.BoxCollaborator;
+import com.box.sdk.BoxFolder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Collaborations Manager
+ *
+ * <p>
+ * Provides operations to manage Box collaborations.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2CollaborationsManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2CollaborationsManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create collaborations manager to manage the comments of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2CollaborationsManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Get information about all of the collaborations for folder.
+ *
+ * @param folderId
+ * - the id of folder to get collaborations information on.
+ *
+ * @return The collection of collaboration information for folder.
+ */
+ public Collection<BoxCollaboration.Info> getFolderCollaborations(String folderId) {
+ try {
+ LOG.debug("Getting collaborations for folder(id=" + folderId + ")");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ return folder.getCollaborations();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Add a collaboration to this folder.
+ *
+ * @param folderId
+ * - the id of folder to add collaboration to.
+ * @param collaborator
+ * - the collaborator to add.
+ * @param role
+ * - the role of the collaborator.
+ *
+ * @return The new collaboration.
+ */
+ @SuppressWarnings("unused") // compiler for some reason thinks 'if
+ // (collaborator == null)' clause is dead code.
+ public BoxCollaboration addFolderCollaboration(String folderId, BoxCollaborator collaborator,
+ BoxCollaboration.Role role) {
+ try {
+ LOG.debug("Creating collaborations for folder(id=" + folderId + ") with collaborator("
+ + collaborator.getID() + ")");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (collaborator == null) {
+ throw new IllegalArgumentException("Parameter 'collaborator' can not be null");
+ }
+ if (role == null) {
+ throw new IllegalArgumentException("Parameter 'role' can not be null");
+ }
+
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ return folder.collaborate(collaborator, role).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Add a collaboration to this folder. An email will be sent to the
+ * collaborator if they don't already have a Box account.
+ *
+ * @param folderId
+ * - the id of folder to add collaboration to.
+ * @param email
+ * - the email address of the collaborator to add.
+ * @param role
+ * - the role of the collaborator.
+ *
+ * @return The new collaboration.
+ */
+ public BoxCollaboration addFolderCollaborationByEmail(String folderId, String email, BoxCollaboration.Role role) {
+ try {
+ LOG.debug("Creating collaborations for folder(id=" + folderId + ") with collaborator(" + email + ")");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (email == null) {
+ throw new IllegalArgumentException("Parameter 'email' can not be null");
+ }
+ if (role == null) {
+ throw new IllegalArgumentException("Parameter 'role' can not be null");
+ }
+
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ return folder.collaborate(email, role).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get collaboration information.
+ *
+ * @param collaborationId
+ * - the id of collaboration.
+ * @return The collaboration information.
+ */
+ public BoxCollaboration.Info getCollaborationInfo(String collaborationId) {
+ try {
+ LOG.debug("Getting info for collaboration(id=" + collaborationId + ")");
+ if (collaborationId == null) {
+ throw new IllegalArgumentException("Parameter 'collaborationId' can not be null");
+ }
+
+ BoxCollaboration collaboration = new BoxCollaboration(boxConnection, collaborationId);
+
+ return collaboration.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Update collaboration information.
+ *
+ * @param collaborationId
+ * - the id of collaboration.
+ * @return The collaboration with updated information.
+ */
+ public BoxCollaboration updateCollaborationInfo(String collaborationId, BoxCollaboration.Info info) {
+ try {
+ LOG.debug("Updating info for collaboration(id=" + collaborationId + ")");
+ if (collaborationId == null) {
+ throw new IllegalArgumentException("Parameter 'collaborationId' can not be null");
+ }
+
+ BoxCollaboration collaboration = new BoxCollaboration(boxConnection, collaborationId);
+
+ collaboration.updateInfo(info);
+ return collaboration;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete collaboration.
+ *
+ * @param collaborationId
+ * - the id of comment to change.
+ * @param message
+ * - the new message for the comment.
+ * @return The comment with changed message.
+ */
+ public void deleteCollaboration(String collaborationId) {
+ try {
+ LOG.debug("Deleting collaboration(id=" + collaborationId + ")");
+ if (collaborationId == null) {
+ throw new IllegalArgumentException("Parameter 'collaborationId' can not be null");
+ }
+ BoxCollaboration collaboration = new BoxCollaboration(boxConnection, collaborationId);
+ collaboration.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get all pending collaboration invites for the current user.
+ *
+ * @return A collection of pending collaboration information.
+ */
+ public Collection<BoxCollaboration.Info> getPendingCollaborations() {
+ try {
+
+ return BoxCollaboration.getPendingCollaborations(boxConnection);
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
new file mode 100644
index 0000000..946f292
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2CommentsManager.java
@@ -0,0 +1,205 @@
+/**
+ * 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.box2.api;
+
+import java.util.List;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxComment;
+import com.box.sdk.BoxFile;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Comments Manager
+ *
+ * <p>
+ * Provides operations to manage Box comments.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2CommentsManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2CommentsManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create comments manager to manage the comments of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2CommentsManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Add comment to file.
+ *
+ * @param fileId
+ * - the id of file to rename.
+ * @param message
+ * - the comment's message.
+ * @return The commented file.
+ */
+ public BoxFile addFileComment(String fileId, String message) {
+ try {
+ LOG.debug("Adding comment to file(id=" + fileId + ") to '" + message + "'");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (message == null) {
+ throw new IllegalArgumentException("Parameter 'message' can not be null");
+ }
+
+ BoxFile fileToCommentOn = new BoxFile(boxConnection, fileId);
+ fileToCommentOn.addComment(message);
+ return fileToCommentOn;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get a list of any comments on this file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @return The list of comments on this file.
+ */
+ public List<BoxComment.Info> getFileComments(String fileId) {
+ try {
+ LOG.debug("Getting comments of file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ return file.getComments();
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get comment information.
+ *
+ * @param commentId
+ * - the id of comment.
+ * @return The comment information.
+ */
+ public BoxComment.Info getCommentInfo(String commentId) {
+ try {
+ LOG.debug("Getting info for comment(id=" + commentId + ")");
+ if (commentId == null) {
+ throw new IllegalArgumentException("Parameter 'commentId' can not be null");
+ }
+
+ BoxComment comment = new BoxComment(boxConnection, commentId);
+
+ return comment.getInfo();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Reply to a comment.
+ *
+ * @param commentId
+ * - the id of comment to reply to.
+ * @param message
+ * - the message for the reply.
+ * @return The newly created reply comment.
+ */
+ public BoxComment replyToComment(String commentId, String message) {
+ try {
+ LOG.debug("Replying to comment(id=" + commentId + ") with message=" + message);
+ if (commentId == null) {
+ throw new IllegalArgumentException("Parameter 'commentId' can not be null");
+ }
+ if (message == null) {
+ throw new IllegalArgumentException("Parameter 'message' can not be null");
+ }
+ BoxComment comment = new BoxComment(boxConnection, commentId);
+ return comment.reply(message).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Change comment message.
+ *
+ * @param commentId
+ * - the id of comment to change.
+ * @param message
+ * - the new message for the comment.
+ * @return The comment with changed message.
+ */
+ public BoxComment changeCommentMessage(String commentId, String message) {
+ try {
+ LOG.debug("Changing comment(id=" + commentId + ") message=" + message);
+ if (commentId == null) {
+ throw new IllegalArgumentException("Parameter 'commentId' can not be null");
+ }
+ if (message == null) {
+ throw new IllegalArgumentException("Parameter 'message' can not be null");
+ }
+ BoxComment comment = new BoxComment(boxConnection, commentId);
+ return comment.changeMessage(message).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete comment.
+ *
+ * @param commentId
+ * - the id of comment to delete.
+ */
+ public void deleteComment(String commentId) {
+ try {
+ LOG.debug("Deleting comment(id=" + commentId + ")");
+ if (commentId == null) {
+ throw new IllegalArgumentException("Parameter 'commentId' can not be null");
+ }
+ BoxComment comment = new BoxComment(boxConnection, commentId);
+ comment.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
new file mode 100644
index 0000000..a54c305
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventLogsManager.java
@@ -0,0 +1,110 @@
+/**
+ * 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.box2.api;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxEvent;
+import com.box.sdk.EventLog;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Event Logs Manager
+ *
+ * <p>
+ * Provides operations to read Box enterprise (admin) event logs.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2EventLogsManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2EventLogsManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create event logs manager to manage the event logs of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2EventLogsManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Create an event stream with optional starting initial position and add
+ * listener that will be notified when an event is received.
+ *
+ * @param position
+ * - the starting position of the event stream. May be
+ * <code>null</code> in which case all events within bounds
+ * returned.
+ * @param after
+ * - the lower bound on the timestamp of the events returned.
+ * @param after
+ * - the upper bound on the timestamp of the events returned.
+ * @param types
+ * - an optional list of event types to filter by.
+ *
+ * @return A list of all the events that met the given criteria.
+ */
+ public List<BoxEvent> getEnterpriseEvents(String position, Date after, Date before, BoxEvent.Type... types) {
+ try {
+ LOG.debug("Getting all enterprise events occuring between "
+ + (after == null ? after : SimpleDateFormat.getDateTimeInstance().format(after)) + " and "
+ + (before == null ? before : SimpleDateFormat.getDateTimeInstance().format(before))
+ + (position == null ? position : (" starting at " + position)));
+
+ if (after == null) {
+ throw new IllegalArgumentException("Parameter 'after' can not be null");
+ }
+ if (before == null) {
+ throw new IllegalArgumentException("Parameter 'before' can not be null");
+ }
+
+ if (types == null) {
+ types = new BoxEvent.Type[0];
+ }
+
+ EventLog eventLog = EventLog.getEnterpriseEvents(boxConnection, position, after, before, types);
+
+ List<BoxEvent> results = new ArrayList<BoxEvent>();
+ for (BoxEvent event : eventLog) {
+ results.add(event);
+ }
+
+ return results;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.java
new file mode 100644
index 0000000..7ef47f7
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2EventsManager.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.box2.api;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.EventListener;
+import com.box.sdk.EventStream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Events Manager
+ *
+ * <p>
+ * Provides operations to manage Box events.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2EventsManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2EventsManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ private EventStream eventStream;
+
+ /**
+ * Create events manager to manage the events of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2EventsManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Create an event stream with optional starting initial position and add
+ * listener that will be notified when an event is received.
+ *
+ * @param startingPosition
+ * - the starting position of the event stream.
+ * @param listener
+ * - the listener to add to event stream.
+ *
+ * @return The event stream.
+ */
+ public void listen(EventListener listener, Long startingPosition) {
+ try {
+ LOG.debug("Listening for events with listener=" + listener + " at startingPosition=" + startingPosition);
+
+ if (listener == null) {
+ LOG.debug("Parameter 'listener' is null: will not listen for events");
+ return;
+ }
+
+ if (startingPosition != null) {
+ eventStream = new EventStream(boxConnection, startingPosition);
+ } else {
+ eventStream = new EventStream(boxConnection);
+ }
+
+ eventStream.addListener(listener);
+
+ eventStream.start();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ public void stopListening() {
+ if (eventStream != null && eventStream.isStarted()) {
+ eventStream.stop();
+ }
+ eventStream = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
new file mode 100644
index 0000000..602a3c9
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FilesManager.java
@@ -0,0 +1,798 @@
+/**
+ * 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.box2.api;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxFileVersion;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxSharedLink;
+import com.box.sdk.FileUploadParams;
+import com.box.sdk.Metadata;
+import com.box.sdk.ProgressListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Files Manager
+ *
+ * <p>
+ * Provides operations to manage Box files.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2FilesManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2FilesManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create files manager to manage the files of Box connection's
+ * authenticated user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2FilesManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Get file information.
+ *
+ * @param fileId
+ * - the id of file.
+ * @param fields
+ * - the information fields to retrieve; if <code>null</code> all
+ * information fields are retrieved.
+ * @return The file information.
+ */
+ public BoxFile.Info getFileInfo(String fileId, String... fields) {
+ try {
+ LOG.debug("Getting info for file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ if (fields == null || fields.length == 0) {
+ return file.getInfo();
+ } else {
+ return file.getInfo(fields);
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Update file information.
+ *
+ * @param fileId
+ * - the id of file to update.
+ * @param info
+ * - the updated information
+ * @return The updated file.
+ */
+ public BoxFile updateFileInfo(String fileId, BoxFile.Info info) {
+ try {
+ LOG.debug("Updating info for file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (info == null) {
+ throw new IllegalArgumentException("Parameter 'info' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ file.updateInfo(info);
+ return file;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Upload a new file to parent folder.
+ *
+ * @param parentFolderId
+ * - the id of parent folder.
+ * @param content
+ * - a stream containing contents of the file to upload.
+ * @param fileName
+ * the name to give the uploaded file.
+ * @param created
+ * - the content created date that will be given to the uploaded
+ * file.
+ * @param modified
+ * - the content modified date that will be given to the uploaded
+ * file.
+ * @param size
+ * - the size of the file's content used for monitoring the
+ * upload's progress.
+ * @param listener
+ * - a listener for monitoring the upload's progress.
+ * @return The uploaded file.
+ */
+ public BoxFile uploadFile(String parentFolderId, InputStream content, String fileName, Date created, Date modified,
+ Long size, ProgressListener listener) {
+ try {
+ LOG.debug("Uploading file with name '" + fileName + "' to parent_folder(id=" + parentFolderId + ")");
+ if (parentFolderId == null) {
+ throw new IllegalArgumentException("Parameter 'parentFolderId' can not be null");
+ }
+ if (content == null) {
+ throw new IllegalArgumentException("Paramerer 'content' can not be null");
+ }
+ if (fileName == null) {
+ throw new IllegalArgumentException("Paramerer 'fileName' can not be null");
+ }
+ BoxFolder parentFolder = new BoxFolder(boxConnection, parentFolderId);
+
+ FileUploadParams uploadParams = new FileUploadParams();
+ uploadParams.setName(fileName);
+ uploadParams.setContent(content);
+ if (created != null) {
+ uploadParams.setCreated(created);
+ }
+ if (modified != null) {
+ uploadParams.setModified(modified);
+ }
+ if (size != null) {
+ uploadParams.setSize(size);
+ }
+ if (listener != null) {
+ uploadParams.setProgressListener(listener);
+ }
+
+ return parentFolder.uploadFile(uploadParams).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Upload a new version of file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @param fileContent
+ * - a stream containing contents of the file to upload.
+ * @param modified
+ * - the content modified date that will be given to the uploaded
+ * file.
+ * @param fileSize
+ * - the size of the file's content used for monitoring the
+ * upload's progress.
+ * @param listener
+ * - a listener for monitoring the upload's progress.
+ * @return The uploaded file.
+ */
+ public BoxFile uploadNewFileVersion(String fileId, InputStream fileContent, Date modified, Long fileSize,
+ ProgressListener listener) {
+ try {
+ LOG.debug("Uploading new version of file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (fileContent == null) {
+ throw new IllegalArgumentException("Paramerer 'fileContent' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ if (modified != null) {
+ if (fileSize != null && listener != null) {
+ file.uploadVersion(fileContent, modified, fileSize, listener);
+ } else {
+ file.uploadVersion(fileContent, modified);
+ }
+ } else {
+ file.uploadVersion(fileContent);
+ }
+
+ return file;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get any previous versions of file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @return The list of previous file versions.
+ */
+ public Collection<BoxFileVersion> getFileVersions(String fileId) {
+ try {
+ LOG.debug("Getting versions of file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ return file.getVersions();
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Download a file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @param output
+ * - the stream to which the file contents will be written.
+ * @param rangeStart
+ * - the byte offset in file at which to start the download; if
+ * <code>null</code> the entire contents of file will be
+ * downloaded.
+ * @param rangeEnd
+ * - the byte offset in file at which to stop the download; if
+ * <code>null</code> the entire contents of file will be
+ * downloaded.
+ * @param listener
+ * - a listener for monitoring the download's progress; if
+ * <code>null</code> the download's progress will not be
+ * monitored.
+ * @return The stream containing the contents of the downloaded file.
+ */
+ public OutputStream downloadFile(String fileId, OutputStream output, Long rangeStart, Long rangeEnd,
+ ProgressListener listener) {
+ try {
+ LOG.debug("Downloading file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (output == null) {
+ throw new IllegalArgumentException("Parameter 'output' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ if (listener != null) {
+ if (rangeStart != null && rangeEnd != null) {
+ file.downloadRange(output, rangeStart, rangeEnd, listener);
+ } else {
+ file.download(output, listener);
+ }
+ } else {
+ if (rangeStart != null && rangeEnd != null) {
+ file.downloadRange(output, rangeStart, rangeEnd);
+ } else {
+ file.download(output);
+ }
+ }
+ return output;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Download a previous version of file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @param version
+ * - the version of file to download; initial version of file has
+ * value of <code>0</code>, second version of file is
+ * <code>1</code> and so on.
+ * @param output
+ * - the stream to which the version contents will be written.
+ * @param listener
+ * - a listener for monitoring the download's progress; if
+ * <code>null</code> the download's progress will not be
+ * monitored.
+ * @return The stream containing the contents of the downloaded file
+ * version.
+ */
+ public OutputStream downloadPreviousFileVersion(String fileId, Integer version, OutputStream output,
+ ProgressListener listener) {
+ try {
+ LOG.debug("Downloading file(id=" + fileId + ", version=" + version + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (version == null) {
+ throw new IllegalArgumentException("Parameter 'version' can not be null");
+ }
+ if (output == null) {
+ throw new IllegalArgumentException("Parameter 'output' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ List<BoxFileVersion> fileVersions = (List<BoxFileVersion>) file.getVersions();
+ BoxFileVersion fileVersion = fileVersions.get(version);
+
+ if (listener != null) {
+ fileVersion.download(output, listener);
+ } else {
+ fileVersion.download(output);
+ }
+ return output;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Promote a previous version of file.
+ *
+ * @param fileId
+ * - the id of file.
+ * @param version
+ * - the version of file to promote; initial version of file has
+ * value of <code>0</code>, second version of file is
+ * <code>1</code> and so on.
+ * @return The promoted version of file.
+ */
+ public BoxFileVersion promoteFileVersion(String fileId, Integer version) {
+ try {
+ LOG.debug("Promoting file(id=" + fileId + ", version=" + version + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (version == null) {
+ throw new IllegalArgumentException("Parameter 'version' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ List<BoxFileVersion> fileVersions = (List<BoxFileVersion>) file.getVersions();
+ BoxFileVersion fileVersion = fileVersions.get(version);
+
+ fileVersion.promote();
+ return fileVersion;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Copy file to destination folder while optionally giving it a new name.
+ *
+ * @param fileId
+ * - the id of file to copy.
+ * @param destinationFolderId
+ * - the id of the destination folder.
+ * @param newName
+ * - the new name for copied file; if <code>newName</code> is
+ * <code>null</code>, the copied file has same name as the
+ * original.
+ * @return The copied file.
+ */
+ public BoxFile copyFile(String fileId, String destinationFolderId, String newName) {
+ try {
+ LOG.debug("Copying file(id=" + fileId + ") to destination_folder(id=" + destinationFolderId + ")"
+ + (newName == null ? "" : " with new name '" + newName + "'"));
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (destinationFolderId == null) {
+ throw new IllegalArgumentException("Parameter 'destinationFolderId' can not be null");
+ }
+ BoxFile fileToCopy = new BoxFile(boxConnection, fileId);
+ BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
+ if (newName == null) {
+ return fileToCopy.copy(destinationFolder).getResource();
+ } else {
+ return fileToCopy.copy(destinationFolder, newName).getResource();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Move file to destination folder while optionally giving it a new name.
+ *
+ * @param fileId
+ * - the id of file to move.
+ * @param destinationFolderId
+ * - the id of the destination folder.
+ * @param newName
+ * - the new name of moved file; if <code>newName</code> is
+ * <code>null</code>, the moved file has same name as the
+ * original.
+ * @return The moved file.
+ */
+ public BoxFile moveFile(String fileId, String destinationFolderId, String newName) {
+ try {
+ LOG.debug("Moving file(id=" + fileId + ") to destination_folder(id=" + destinationFolderId + ")"
+ + (newName == null ? "" : " with new name '" + newName + "'"));
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (destinationFolderId == null) {
+ throw new IllegalArgumentException("Parameter 'destinationFolderId' can not be null");
+ }
+ BoxFile fileToMove = new BoxFile(boxConnection, fileId);
+ BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
+ if (newName == null) {
+ return (BoxFile) fileToMove.move(destinationFolder).getResource();
+ } else {
+ return (BoxFile) fileToMove.move(destinationFolder, newName).getResource();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Rename file giving it the name <code>newName</code>
+ *
+ * @param fileId
+ * - the id of file to rename.
+ * @param newFileName
+ * - the new name of file.
+ * @return The renamed file.
+ */
+ public BoxFile renameFile(String fileId, String newFileName) {
+ try {
+ LOG.debug("Renaming file(id=" + fileId + ") to '" + newFileName + "'");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (newFileName == null) {
+ throw new IllegalArgumentException("Parameter 'newName' can not be null");
+ }
+ BoxFile fileToRename = new BoxFile(boxConnection, fileId);
+ fileToRename.rename(newFileName);
+ return fileToRename;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete the file.
+ *
+ * @param fileId
+ * - the id of file to delete.
+ */
+ public void deleteFile(String fileId) {
+ try {
+ LOG.debug("Deleting file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ file.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete a file version.
+ *
+ * @param fileId
+ * - the id of file with version to delete.
+ * @param version
+ * - the version of file to delete; initial version of file has
+ * value of <code>0</code>, second version of file is
+ * <code>1</code> and so on.
+ */
+ public void deleteFileVersion(String fileId, Integer version) {
+ try {
+ LOG.debug("Deleting file(id=" + fileId + ", version=" + version + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (version == null) {
+ throw new IllegalArgumentException("Parameter 'version' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ List<BoxFileVersion> versions = (List<BoxFileVersion>) file.getVersions();
+ BoxFileVersion fileVersion = versions.get(version);
+
+ fileVersion.delete();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Create a shared link to file.
+ *
+ * @param fileId
+ * - the id of the file to create shared link on.
+ * @param access
+ * - the access level of the shared link.
+ * @param unshareDate
+ * - the date and time at which time the created shared link will
+ * expire; if <code>unsharedDate</code> is <code>null</code> then
+ * a non-expiring link is created.
+ * @param permissions
+ * - the permissions of the created link; if
+ * <code>permissions</code> is <code>null</code> then the created
+ * shared link is create with default permissions.
+ * @return The created shared link.
+ */
+ public BoxSharedLink createFileSharedLink(String fileId, BoxSharedLink.Access access, Date unshareDate,
+ BoxSharedLink.Permissions permissions) {
+ try {
+ LOG.debug("Creating shared link for file(id=" + fileId + ") with access=" + access
+ + (unshareDate == null ? ""
+ : " unsharedDate=" + SimpleDateFormat.getDateTimeInstance().format(unshareDate)
+ + " permissions=" + permissions));
+
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (access == null) {
+ throw new IllegalArgumentException("Parameter 'access' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ return file.createSharedLink(access, unshareDate, permissions);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get an expiring URL for downloading a file directly from Box. This can be
+ * user, for example, for sending as a redirect to a browser to cause the
+ * browser to download the file directly from Box.
+ *
+ * @param fileId
+ * - the id of file.
+ * @return The temporary download URL
+ */
+ public URL getDownloadURL(String fileId) {
+ try {
+ LOG.debug("Getting download URL for file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ return file.getDownloadURL();
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get an expiring URL for creating an embedded preview session. The URL
+ * will expire after 60 seconds and the preview session will expire after 60
+ * minutes.
+ *
+ * @param fileId
+ * - the id of the file to get preview link on.
+ * @return The preview link.
+ */
+ public URL getFilePreviewLink(String fileId) {
+ try {
+ LOG.debug("Getting preview link for file(id=" + fileId + ")");
+
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ return file.getPreviewLink();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get an expiring URL for creating an embedded preview session. The URL
+ * will expire after 60 seconds and the preview session will expire after 60
+ * minutes.
+ *
+ * @param fileId
+ * - the id of the file to get preview link on.
+ * @param fileType
+ * - either PNG of JPG.
+ * @param minWidth
+ * - minimum width.
+ * @param minHeight
+ * - minimum height.
+ * @param maxWidth
+ * - maximum width.
+ * @param maxHeight
+ * - maximum height.
+ * @return The byte array of the thumbnail image.
+ */
+ public byte[] getFileThumbnail(String fileId, BoxFile.ThumbnailFileType fileType, Integer minWidth,
+ Integer minHeight, Integer maxWidth, Integer maxHeight) {
+ try {
+ LOG.debug("Getting thumbnail for file(id=" + fileId + ") fileType=" + fileType + " minWidth=" + minWidth
+ + " minHeight=" + minHeight + " maxWidth=" + maxWidth + " maxHeight=" + maxHeight);
+
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (fileType == null) {
+ throw new IllegalArgumentException("Parameter 'fileType' can not be null");
+ }
+ if (minWidth == null) {
+ throw new IllegalArgumentException("Parameter 'minWidth' can not be null");
+ }
+ if (minHeight == null) {
+ throw new IllegalArgumentException("Parameter 'minHeight' can not be null");
+ }
+ if (maxWidth == null) {
+ throw new IllegalArgumentException("Parameter 'maxWidth' can not be null");
+ }
+ if (maxHeight == null) {
+ throw new IllegalArgumentException("Parameter 'maxHeight' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ return file.getThumbnail(fileType, minWidth, minHeight, maxWidth, maxHeight);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Create metadata for file in either the global properties template or the
+ * specified template type.
+ *
+ * @param fileId
+ * - the id of the file to create metadata for.
+ * @param metadata
+ * - the new metadata values.
+ * @param typeName
+ * - the metadata template type name; if <code>null</code> the
+ * global properties template type is used.
+ * @return The metadata returned from the server.
+ */
+ public Metadata createFileMetadata(String fileId, Metadata metadata, String typeName) {
+ try {
+ LOG.debug("Creating metadata for file(id=" + fileId + ")");
+
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (metadata == null) {
+ throw new IllegalArgumentException("Parameter 'metadata' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ if (typeName != null) {
+ return file.createMetadata(typeName, metadata);
+ } else {
+ return file.createMetadata(metadata);
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Gets the file properties metadata.
+ *
+ * @param fileId
+ * - the id of the file to retrieve metadata for.
+ * @param typeName
+ * - the metadata template type name; if <code>null</code> the
+ * global properties template type is used.
+ * @return The metadata returned from the server.
+ */
+ public Metadata getFileMetadata(String fileId, String typeName) {
+ try {
+ LOG.debug("Get metadata for file(id=" + fileId + ")");
+
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+
+ BoxFile file = new BoxFile(boxConnection, fileId);
+
+ if (typeName != null) {
+ return file.getMetadata(typeName);
+ } else {
+ return file.getMetadata();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+
+ }
+
+ /**
+ * Update the file properties metadata.
+ *
+ * @param fileId
+ * - the id of file to delete.
+ * @param metadata
+ * - the new metadata values.
+ * @return The metadata returned from the server.
+ */
+ public Metadata updateFileMetadata(String fileId, Metadata metadata) {
+ try {
+ LOG.debug("Updating metadata for file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ if (metadata == null) {
+ throw new IllegalArgumentException("Parameter 'metadata' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ return file.updateMetadata(metadata);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete the file properties metadata.
+ *
+ * @param fileId
+ * - the id of file to delete.
+ */
+ public void deleteFileMetadata(String fileId) {
+ try {
+ LOG.debug("Deleting metadata for file(id=" + fileId + ")");
+ if (fileId == null) {
+ throw new IllegalArgumentException("Parameter 'fileId' can not be null");
+ }
+ BoxFile file = new BoxFile(boxConnection, fileId);
+ file.deleteMetadata();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
new file mode 100644
index 0000000..4617fa2
--- /dev/null
+++ b/components/camel-box2/camel-box2-api/src/main/java/org/apache/camel/component/box2/api/Box2FoldersManager.java
@@ -0,0 +1,407 @@
+/**
+ * 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.box2.api;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxItem;
+import com.box.sdk.BoxSharedLink;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2 Folders Manager
+ *
+ * <p>
+ * Provides operations to manage Box folders.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2FoldersManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2FoldersManager.class);
+
+ /**
+ * Box connection to authenticated user account.
+ */
+ private BoxAPIConnection boxConnection;
+
+ /**
+ * Create folder manager to manage folders of Box connection's authenticated
+ * user.
+ *
+ * @param boxConnection
+ * - Box connection to authenticated user account.
+ */
+ public Box2FoldersManager(BoxAPIConnection boxConnection) {
+ this.boxConnection = boxConnection;
+ }
+
+ /**
+ * Return the root folder of authenticated user.
+ *
+ * @return The root folder of authenticated user.
+ */
+ public BoxFolder getRootFolder() {
+ try {
+ LOG.debug("Getting root folder");
+ return BoxFolder.getRootFolder(boxConnection);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Return the Box folder referenced by <code>path</code>.
+ *
+ * @param path
+ * - Sequence of Box folder names from root folder to returned
+ * folder.
+ *
+ * @return The Box folder referenced by <code>path</code> or
+ * <code>null</code> if folder is not found.
+ */
+ public BoxFolder getFolder(String... path) {
+ try {
+ LOG.debug("Getting folder at path=" + Arrays.toString(path));
+
+ BoxFolder folder = BoxFolder.getRootFolder(boxConnection);
+ if (path == null || path.length == 0) {
+ // Return root folder if path is null or empty.
+ return folder;
+ }
+
+ searchPath: for (int folderIndex = 0; folderIndex < path.length; folderIndex++) {
+ for (BoxItem.Info itemInfo : folder) {
+ if (itemInfo instanceof BoxFolder.Info && itemInfo.getName().equals(path[folderIndex])) {
+ folder = (BoxFolder) itemInfo.getResource();
+ continue searchPath;
+ }
+ }
+ // Failed to find named folder in path: return null
+ return null;
+ }
+ return folder;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Returns a specific range of child items in folder and specifies which
+ * fields of each item to retrieve.
+ *
+ * @param folderId
+ * - the id of folder.
+ * @param offset
+ * - the index of first child item to retrieve; if
+ * <code>null</code> all child items are retrieved.
+ * @param limit
+ * - the maximum number of children to retrieve after the offset;
+ * if <code>null</code> all child items are retrieved.
+ * @param fields
+ * - the item fields to retrieve for each child item; if
+ * <code>null</code> all item fields are retrieved.
+ * @return The Items in folder
+ */
+ public Collection<BoxItem.Info> getFolderItems(String folderId, Long offset, Long limit, String... fields) {
+ try {
+ LOG.debug("Getting folder items in folder(id=" + folderId + ") at offset=" + offset + " and limit=" + limit
+ + " with fields=" + Arrays.toString(fields));
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ if (fields == null) {
+ fields = new String[0];
+ }
+ if (offset != null && limit != null) {
+ return folder.getChildrenRange(offset, limit, fields);
+ } else {
+ Collection<BoxItem.Info> folderItems = new ArrayList<BoxItem.Info>();
+ Iterable<BoxItem.Info> iterable;
+ if (fields.length > 0) {
+ iterable = folder.getChildren(fields);
+ } else {
+ iterable = folder.getChildren();
+ }
+ for (BoxItem.Info itemInfo : iterable) {
+ folderItems.add(itemInfo);
+ }
+
+ return folderItems;
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Create a folder in parent folder with given <code>folderName</code>.
+ *
+ * @param parentFolderId
+ * - the id of parent folder.
+ * @param folderName
+ * the name of created folder.
+ * @return The created folder.
+ */
+ public BoxFolder createFolder(String parentFolderId, String folderName) {
+ try {
+ LOG.debug("Creating folder with name '" + folderName + "' in parent_folder(id=" + parentFolderId + ")");
+ if (parentFolderId == null) {
+ throw new IllegalArgumentException("Parameter 'parentFolderId' can not be null");
+ }
+ if (folderName == null) {
+ throw new IllegalArgumentException("Paramerer 'folderName' can not be null");
+ }
+ BoxFolder parentFolder = new BoxFolder(boxConnection, parentFolderId);
+ return parentFolder.createFolder(folderName).getResource();
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Copy folder to destination folder while optionally giving it a new name.
+ *
+ * @param folderId
+ * - the id of folder to copy.
+ * @param destinationFolderId
+ * - the id of the destination folder.
+ * @param newName
+ * - the new name for copied folder; if <code>newName</code> is
+ * <code>null</code>, the copied folder has same name as the
+ * original.
+ * @return The copied folder.
+ */
+ public BoxFolder copyFolder(String folderId, String destinationFolderId, String newName) {
+ try {
+ LOG.debug("Copying folder(id=" + folderId + ") to destination_folder(id=" + destinationFolderId + ")"
+ + (newName == null ? "" : " with new name '" + newName + "'"));
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (destinationFolderId == null) {
+ throw new IllegalArgumentException("Parameter 'destinationFolderId' can not be null");
+ }
+ BoxFolder folderToCopy = new BoxFolder(boxConnection, folderId);
+ BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
+ if (newName == null) {
+ return folderToCopy.copy(destinationFolder).getResource();
+ } else {
+ return folderToCopy.copy(destinationFolder, newName).getResource();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Move folder to destination folder while optionally giving it a new name.
+ *
+ * @param folderId
+ * - the id of folder to move.
+ * @param destinationFolderId
+ * - the id of the destination folder.
+ * @param newName
+ * - the new name of moved folder; if <code>newName</code> is
+ * <code>null</code>, the moved folder has same name as the
+ * original.
+ * @return The moved folder.
+ */
+ public BoxFolder moveFolder(String folderId, String destinationFolderId, String newName) {
+ try {
+ LOG.debug("Moving folder(id=" + folderId + ") to destination_folder(id=" + destinationFolderId + ")"
+ + (newName == null ? "" : " with new name '" + newName + "'"));
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (destinationFolderId == null) {
+ throw new IllegalArgumentException("Parameter 'destinationFolderId' can not be null");
+ }
+ BoxFolder folderToMove = new BoxFolder(boxConnection, folderId);
+ BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
+ if (newName == null) {
+ return (BoxFolder) folderToMove.move(destinationFolder).getResource();
+ } else {
+ return (BoxFolder) folderToMove.move(destinationFolder, newName).getResource();
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Rename folder giving it the name <code>newName</code>
+ *
+ * @param folderId
+ * - the id of folder to rename.
+ * @param newFolderName
+ * - the new name of folder.
+ * @return The renamed folder.
+ */
+ public BoxFolder renameFolder(String folderId, String newFolderName) {
+ try {
+ LOG.debug("Renaming folder(id=" + folderId + ") to '" + newFolderName + "'");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (newFolderName == null) {
+ throw new IllegalArgumentException("Parameter 'newFolderName' can not be null");
+ }
+ BoxFolder folderToRename = new BoxFolder(boxConnection, folderId);
+ folderToRename.rename(newFolderName);
+ return folderToRename;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Delete folder.
+ *
+ * @param folderId
+ * - the id of folder to delete.
+ */
+ public void deleteFolder(String folderId) {
+ try {
+ LOG.debug("Deleting folder(id=" + folderId + ")");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ folder.delete(true);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Get folder information.
+ *
+ * @param folderId
+ * - the id of folder.
+ * @param fields
+ * - the information fields to retrieve; if <code>null</code> all
+ * information fields are retrieved.
+ * @return The folder information.
+ */
+ public BoxFolder.Info getFolderInfo(String folderId, String... fields) {
+ try {
+ LOG.debug("Getting info for folder(id=" + folderId + ")");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+
+ if (fields == null || fields.length == 0) {
+ return folder.getInfo();
+ } else {
+ return folder.getInfo(fields);
+ }
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Update folder information.
+ *
+ * @param folderId
+ * - the id of folder to update.
+ * @param info
+ * - the updated information
+ * @return The updated folder.
+ */
+ public BoxFolder updateFolderInfo(String folderId, BoxFolder.Info info) {
+ try {
+ LOG.debug("Updating info for folder(id=" + folderId + ")");
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (info == null) {
+ throw new IllegalArgumentException("Parameter 'info' can not be null");
+ }
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ folder.updateInfo(info);
+ return folder;
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+ /**
+ * Create a shared link to folder.
+ *
+ * @param folderId
+ * - the id of folder to create shared link on.
+ * @param access
+ * - the access level of the shared link.
+ * @param unshareDate
+ * - the date and time at which time the created shared link will
+ * expire; if <code>unsharedDate</code> is <code>null</code> then
+ * a non-expiring link is created.
+ * @param permissions
+ * - the permissions of the created link; if
+ * <code>permissions</code> is <code>null</code> then the created
+ * shared link is create with default permissions.
+ * @return The created shared link.
+ */
+ public BoxSharedLink createFolderSharedLink(String folderId, BoxSharedLink.Access access, Date unshareDate,
+ BoxSharedLink.Permissions permissions) {
+ try {
+ LOG.debug("Creating shared link for folder(id=" + folderId + ") with access=" + access
+ + (unshareDate == null ? ""
+ : " unsharedDate=" + SimpleDateFormat.getDateTimeInstance().format(unshareDate)
+ + " permissions=" + permissions));
+
+ if (folderId == null) {
+ throw new IllegalArgumentException("Parameter 'folderId' can not be null");
+ }
+ if (access == null) {
+ throw new IllegalArgumentException("Parameter 'access' can not be null");
+ }
+
+ BoxFolder folder = new BoxFolder(boxConnection, folderId);
+ return folder.createSharedLink(access, unshareDate, permissions);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ }
+ }
+
+}
[4/8] camel git commit: CAMEL-9047: Replace deprecated boxjavalibv2
with box-java-sdk
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CommentsManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CommentsManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CommentsManagerIntegrationTest.java
new file mode 100644
index 0000000..39cbf1e
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CommentsManagerIntegrationTest.java
@@ -0,0 +1,201 @@
+/**
+ * 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.box2;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxComment;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxFolder;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2CommentsManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for
+ * {@link org.apache.camel.component.box2.api.Box2CommentsManager} APIs.
+ */
+public class Box2CommentsManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2CommentsManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2CommentsManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_FILE = "/CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_NAME = "CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_COMMENT = "CamelTestFile comment.";
+ private static final String CAMEL_TEST_FILE_CHANGED_COMMENT = "CamelTestFile changed comment.";
+ private static final String CAMEL_TEST_FILE_REPLY_COMMENT = "CamelTestFile changed comment.";
+
+ private BoxFile testFile;
+
+ @Test
+ public void testAddFileComment() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is String
+ headers.put("CamelBox2.message", CAMEL_TEST_FILE_COMMENT);
+
+ final com.box.sdk.BoxFile result = requestBodyAndHeaders("direct://ADDFILECOMMENT", null, headers);
+
+ assertNotNull("addFileComment result", result);
+ assertNotNull("addFileComment comments", result.getComments());
+ assertTrue("changeCommentMessage comments size", result.getComments().size() > 0);
+ assertEquals("changeCommentMessage comment message", CAMEL_TEST_FILE_COMMENT,
+ result.getComments().get(0).getMessage());
+ LOG.debug("addFileComment: " + result);
+ }
+
+ @Test
+ public void testChangeCommentMessage() throws Exception {
+
+ BoxComment.Info commentInfo = testFile.addComment(CAMEL_TEST_FILE_COMMENT);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.commentId", commentInfo.getID());
+ // parameter type is String
+ headers.put("CamelBox2.message", CAMEL_TEST_FILE_CHANGED_COMMENT);
+
+ final com.box.sdk.BoxComment result = requestBodyAndHeaders("direct://CHANGECOMMENTMESSAGE", null, headers);
+
+ assertNotNull("changeCommentMessage result", result);
+ assertNotNull("changeCommentMessage message", result.getInfo().getMessage());
+ assertEquals("changeCommentMessage message", CAMEL_TEST_FILE_CHANGED_COMMENT, result.getInfo().getMessage());
+ LOG.debug("changeCommentMessage: " + result);
+ }
+
+ @Test
+ public void testDeleteComment() throws Exception {
+ BoxComment.Info commentInfo = testFile.addComment(CAMEL_TEST_FILE_COMMENT);
+
+ // using String message body for single parameter "commentId"
+ requestBody("direct://DELETECOMMENT", commentInfo.getID());
+
+ List<BoxComment.Info> comments = testFile.getComments();
+ assertNotNull("deleteComment comments", comments);
+ assertEquals("deleteComment comments empty", 0, comments.size());
+ }
+
+ @Test
+ public void testGetCommentInfo() throws Exception {
+
+ BoxComment.Info commentInfo = testFile.addComment(CAMEL_TEST_FILE_COMMENT);
+
+ // using String message body for single parameter "commentId"
+ final com.box.sdk.BoxComment.Info result = requestBody("direct://GETCOMMENTINFO", commentInfo.getID());
+
+ assertNotNull("getCommentInfo result", result);
+ assertEquals("getCommentInfo message", CAMEL_TEST_FILE_COMMENT, result.getMessage());
+ LOG.debug("getCommentInfo: " + result);
+ }
+
+ @Test
+ public void testGetFileComments() throws Exception {
+ testFile.addComment(CAMEL_TEST_FILE_COMMENT);
+
+ // using String message body for single parameter "fileId"
+ @SuppressWarnings("rawtypes")
+ final java.util.List result = requestBody("direct://GETFILECOMMENTS", testFile.getID());
+
+ assertNotNull("getFileComments result", result);
+ assertEquals("getFileComments size", 1, result.size());
+ LOG.debug("getFileComments: " + result);
+ }
+
+ @Test
+ public void testReplyToComment() throws Exception {
+
+ BoxComment.Info commentInfo = testFile.addComment(CAMEL_TEST_FILE_COMMENT);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.commentId", commentInfo.getID());
+ // parameter type is String
+ headers.put("CamelBox2.message", CAMEL_TEST_FILE_REPLY_COMMENT);
+
+ final com.box.sdk.BoxComment result = requestBodyAndHeaders("direct://REPLYTOCOMMENT", null, headers);
+
+ assertNotNull("replyToComment result", result);
+ assertEquals("replyToComment result", CAMEL_TEST_FILE_REPLY_COMMENT, result.getInfo().getMessage());
+ LOG.debug("replyToComment: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for addFileComment
+ from("direct://ADDFILECOMMENT").to("box2://" + PATH_PREFIX + "/addFileComment");
+
+ // test route for changeCommentMessage
+ from("direct://CHANGECOMMENTMESSAGE").to("box2://" + PATH_PREFIX + "/changeCommentMessage");
+
+ // test route for deleteComment
+ from("direct://DELETECOMMENT").to("box2://" + PATH_PREFIX + "/deleteComment?inBody=commentId");
+
+ // test route for getCommentInfo
+ from("direct://GETCOMMENTINFO").to("box2://" + PATH_PREFIX + "/getCommentInfo?inBody=commentId");
+
+ // test route for getFileComments
+ from("direct://GETFILECOMMENTS").to("box2://" + PATH_PREFIX + "/getFileComments?inBody=fileId");
+
+ // test route for replyToComment
+ from("direct://REPLYTOCOMMENT").to("box2://" + PATH_PREFIX + "/replyToComment");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestFile();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestFile();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/addFileComment");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestFile() throws FileNotFoundException {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ InputStream stream = getClass().getResourceAsStream(CAMEL_TEST_FILE);
+ testFile = rootFolder.uploadFile(stream, CAMEL_TEST_FILE_NAME).getResource();
+ }
+
+ private void deleteTestFile() {
+ testFile.delete();
+ testFile = null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventLogsManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventLogsManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventLogsManagerIntegrationTest.java
new file mode 100644
index 0000000..deb502e
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventLogsManagerIntegrationTest.java
@@ -0,0 +1,76 @@
+/**
+ * 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.box2;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2EventLogsManagerApiMethod;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for
+ * {@link org.apache.camel.component.box2.api.Box2EventLogsManager} APIs.
+ */
+public class Box2EventLogsManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2EventLogsManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2EventLogsManagerApiMethod.class).getName();
+ private static final long ONE_MINUTE_OF_MILLISECONDS = 1000 * 60;
+
+ @Ignore // Requires enterprise admin account to test
+ @Test
+ public void testGetEnterpriseEvents() throws Exception {
+ Date before = new Date();
+ Date after = new Date();
+ after.setTime(before.getTime() - ONE_MINUTE_OF_MILLISECONDS);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.position", null);
+ // parameter type is java.util.Date
+ headers.put("CamelBox2.after", after);
+ // parameter type is java.util.Date
+ headers.put("CamelBox2.before", before);
+ // parameter type is com.box.sdk.BoxEvent.Type[]
+ headers.put("CamelBox2.types", null);
+
+ @SuppressWarnings("rawtypes")
+ final java.util.List result = requestBodyAndHeaders("direct://GETENTERPRISEEVENTS", null, headers);
+
+ assertNotNull("getEnterpriseEvents result", result);
+ LOG.debug("getEnterpriseEvents: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for getEnterpriseEvents
+ from("direct://GETENTERPRISEEVENTS").to("box2://" + PATH_PREFIX + "/getEnterpriseEvents");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventsManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventsManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventsManagerIntegrationTest.java
new file mode 100644
index 0000000..3af1b68
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2EventsManagerIntegrationTest.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.box2;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxFolder;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2EventsManagerApiMethod;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2EventsManager}
+ * APIs. TODO Move the file to src/test/java, populate parameter values, and
+ * remove @Ignore annotations. The class source won't be generated again if the
+ * generator MOJO finds it under src/test/java.
+ */
+public class Box2EventsManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2EventsManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2EventsManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_FILE = "/CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_NAME = "CamelTestFile.txt";
+
+ private BoxFile testFile;
+
+ @Test
+ public void testListen() throws Exception {
+ try {
+ // generate a file create event
+ createTestFile();
+ } finally {
+ // generate a file delete event
+ deleteTestFile();
+ }
+
+ MockEndpoint mockEndpoint = getMockEndpoint("mock:box2Events");
+ mockEndpoint.expectedMinimumMessageCount(2);
+ mockEndpoint.setResultWaitTime(TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS));
+ mockEndpoint.assertIsSatisfied();
+
+ final List<Exchange> exchanges = mockEndpoint.getExchanges();
+ assertNotNull("poll result", exchanges);
+ assertFalse("poll result", exchanges.isEmpty());
+ LOG.debug("poll result: " + exchanges);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+
+ // test route for events
+ from("box2://" + PATH_PREFIX + "/listen?startingPosition=0").to("mock:box2Events");
+
+ }
+ };
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context()
+ .getEndpoint("box2://" + PATH_PREFIX + "/listen?startingPosition=0");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestFile() throws FileNotFoundException {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ InputStream stream = getClass().getResourceAsStream(CAMEL_TEST_FILE);
+ testFile = rootFolder.uploadFile(stream, CAMEL_TEST_FILE_NAME).getResource();
+ }
+
+ private void deleteTestFile() {
+ try {
+ testFile.delete();
+ } catch (Throwable t) {
+ }
+ testFile = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FilesManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FilesManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FilesManagerIntegrationTest.java
new file mode 100644
index 0000000..ecf6677
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FilesManagerIntegrationTest.java
@@ -0,0 +1,575 @@
+/**
+ * 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.box2;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxFile.ThumbnailFileType;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxItem;
+import com.box.sdk.BoxSharedLink;
+import com.box.sdk.Metadata;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2FilesManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2FilesManager}
+ * APIs.
+ */
+public class Box2FilesManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2FilesManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2FilesManagerApiMethod.class).getName();
+
+ private static final String CAMEL_TEST_FILE = "/CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_NAME = "CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_DESCRIPTION = "CamelTestFile.txt description";
+ private static final String CAMEL_TEST_COPY_FILE_NAME = "CamelTestFile_Copy.txt";
+ private static final String CAMEL_TEST_MOVE_FILE_NAME = "CamelTestFile_Move.txt";
+ private static final String CAMEL_TEST_RENAME_FILE_NAME = "CamelTestFile_Rename.txt";
+ private static final String CAMEL_TEST_UPLOAD_FILE_NAME = "CamelTestFile_Upload.txt";
+
+ private BoxFile testFile;
+
+ @Test
+ public void testCopyFile() throws Exception {
+ com.box.sdk.BoxFile result = null;
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is String
+ headers.put("CamelBox2.destinationFolderId", "0");
+ // parameter type is String
+ headers.put("CamelBox2.newName", CAMEL_TEST_COPY_FILE_NAME);
+
+ result = requestBodyAndHeaders("direct://COPYFILE", null, headers);
+
+ assertNotNull("copyFile result", result);
+ assertEquals("copyFile name", CAMEL_TEST_COPY_FILE_NAME, result.getInfo().getName());
+ LOG.debug("copyFile: " + result);
+ } finally {
+ if (result != null) {
+ result.delete();
+ }
+ }
+ }
+
+ @Test
+ public void testCreateFileMetadata() throws Exception {
+ Metadata metadata = new Metadata();
+ metadata.add("/foo", "bar");
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is com.box.sdk.Metadata
+ headers.put("CamelBox2.metadata", metadata);
+ // parameter type is String
+ headers.put("CamelBox2.typeName", null);
+
+ final com.box.sdk.Metadata result = requestBodyAndHeaders("direct://CREATEFILEMETADATA", null, headers);
+
+ assertNotNull("createFileMetadata result", result);
+ assertEquals("createFileMetadata result", "bar", result.get("/foo"));
+ LOG.debug("createFileMetadata: " + result);
+ }
+
+ @Test
+ public void testCreateFileSharedLink() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is com.box.sdk.BoxSharedLink.Access
+ headers.put("CamelBox2.access", BoxSharedLink.Access.DEFAULT);
+ // parameter type is java.util.Date
+ headers.put("CamelBox2.unshareDate", null);
+ // parameter type is com.box.sdk.BoxSharedLink.Permissions
+ headers.put("CamelBox2.permissions", null);
+
+ final com.box.sdk.BoxSharedLink result = requestBodyAndHeaders("direct://CREATEFILESHAREDLINK", null, headers);
+
+ assertNotNull("createFileSharedLink result", result);
+ LOG.debug("createFileSharedLink: " + result);
+ }
+
+ @Test
+ public void testDeleteFile() throws Exception {
+ // using String message body for single parameter "fileId"
+ requestBody("direct://DELETEFILE", testFile.getID());
+
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ Iterable<BoxItem.Info> it = rootFolder.search("^" + CAMEL_TEST_FILE + "$");
+ int searchResults = sizeOfIterable(it);
+ boolean exists = searchResults > 0 ? true : false;
+ assertEquals("deleteFile exists", false, exists);
+ LOG.debug("deleteFile: exists? " + exists);
+
+ }
+
+ @Test
+ public void testDeleteFileMetadata() throws Exception {
+ testFile.createMetadata(new Metadata());
+
+ // using String message body for single parameter "fileId"
+ requestBody("direct://DELETEFILEMETADATA", testFile.getID());
+
+ try {
+ testFile.getMetadata();
+ } catch (BoxAPIException e) {
+ if (e.getResponseCode() == 404) {
+ // Box API should return a
+ return;
+ }
+ }
+ fail("deleteFileMetadata metadata");
+
+ }
+
+ @Ignore // Requires premium user account to test.
+ @Test
+ public void testDeleteFileVersion() throws Exception {
+ testFile.uploadVersion(getClass().getResourceAsStream(CAMEL_TEST_FILE));
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is Integer
+ headers.put("CamelBox2.version", 0);
+
+ requestBodyAndHeaders("direct://DELETEFILEVERSION", null, headers);
+ boolean onlyOneVersion = testFile.getVersions().size() == 1;
+ assertTrue("deleteFileVersion version deleted", onlyOneVersion);
+ }
+
+ @Test
+ public void testDownloadFile() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is java.io.OutputStream
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ headers.put("CamelBox2.output", output);
+ // parameter type is Long
+ headers.put("CamelBox2.rangeStart", null);
+ // parameter type is Long
+ headers.put("CamelBox2.rangeEnd", null);
+ // parameter type is com.box.sdk.ProgressListener
+ headers.put("CamelBox2.listener", null);
+
+ final java.io.OutputStream result = requestBodyAndHeaders("direct://DOWNLOADFILE", null, headers);
+
+ assertNotNull("downloadFile result", result);
+ LOG.debug("downloadFile: " + result);
+ }
+
+ @Ignore // Requires premium user account to test
+ @Test
+ public void testDownloadPreviousFileVersion() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is Integer
+ headers.put("CamelBox2.version", 0);
+ // parameter type is java.io.OutputStream
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ headers.put("CamelBox2.output", output);
+ // parameter type is com.box.sdk.ProgressListener
+ headers.put("CamelBox2.listener", null);
+
+ final java.io.OutputStream result = requestBodyAndHeaders("direct://DOWNLOADPREVIOUSFILEVERSION", null,
+ headers);
+
+ assertNotNull("downloadPreviousFileVersion result", result);
+ LOG.debug("downloadPreviousFileVersion: " + result);
+ }
+
+ @Test
+ public void testGetDownloadURL() throws Exception {
+ // using String message body for single parameter "fileId"
+ final java.net.URL result = requestBody("direct://GETDOWNLOADURL", testFile.getID());
+
+ assertNotNull("getDownloadURL result", result);
+ LOG.debug("getDownloadURL: " + result);
+ }
+
+ @Test
+ public void testGetFileInfo() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is String[]
+ headers.put("CamelBox2.fields", null);
+
+ final com.box.sdk.BoxFile.Info result = requestBodyAndHeaders("direct://GETFILEINFO", null, headers);
+
+ assertNotNull("getFileInfo result", result);
+ LOG.debug("getFileInfo: " + result);
+ }
+
+ @Test
+ public void testGetFileMetadata() throws Exception {
+ testFile.createMetadata(new Metadata());
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is String
+ headers.put("CamelBox2.typeName", null);
+
+ final com.box.sdk.Metadata result = requestBodyAndHeaders("direct://GETFILEMETADATA", null, headers);
+
+ assertNotNull("getFileMetadata result", result);
+ LOG.debug("getFileMetadata: " + result);
+ }
+
+ @Test
+ public void testGetFilePreviewLink() throws Exception {
+ // using String message body for single parameter "fileId"
+ final java.net.URL result = requestBody("direct://GETFILEPREVIEWLINK", testFile.getID());
+
+ assertNotNull("getFilePreviewLink result", result);
+ LOG.debug("getFilePreviewLink: " + result);
+ }
+
+ @Test
+ public void testGetFileThumbnail() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is com.box.sdk.BoxFile.ThumbnailFileType
+ headers.put("CamelBox2.fileType", ThumbnailFileType.JPG);
+ // parameter type is Integer
+ headers.put("CamelBox2.minWidth", 32);
+ // parameter type is Integer
+ headers.put("CamelBox2.minHeight", 32);
+ // parameter type is Integer
+ headers.put("CamelBox2.maxWidth", 32);
+ // parameter type is Integer
+ headers.put("CamelBox2.maxHeight", 32);
+
+ final byte[] result = requestBodyAndHeaders("direct://GETFILETHUMBNAIL", null, headers);
+
+ assertNotNull("getFileThumbnail result", result);
+ LOG.debug("getFileThumbnail: " + result);
+ }
+
+ @Test
+ public void testGetFileVersions() throws Exception {
+ // using String message body for single parameter "fileId"
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBody("direct://GETFILEVERSIONS", testFile.getID());
+
+ assertNotNull("getFileVersions result", result);
+ LOG.debug("getFileVersions: " + result);
+ }
+
+ @Test
+ public void testMoveFile() throws Exception {
+ com.box.sdk.BoxFile result = null;
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is String
+ headers.put("CamelBox2.destinationFolderId", "0");
+ // parameter type is String
+ headers.put("CamelBox2.newName", CAMEL_TEST_MOVE_FILE_NAME);
+
+ result = requestBodyAndHeaders("direct://MOVEFILE", null, headers);
+
+ assertNotNull("moveFile result", result);
+ assertEquals("moveFile name", CAMEL_TEST_MOVE_FILE_NAME, result.getInfo().getName());
+ LOG.debug("moveFile: " + result);
+ } finally {
+ if (result != null) {
+ result.delete();
+ }
+ }
+ }
+
+ @Ignore // Requires premium user account to test
+ @Test
+ public void testPromoteFileVersion() throws Exception {
+ testFile.uploadVersion(getClass().getResourceAsStream(CAMEL_TEST_FILE));
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is Integer
+ headers.put("CamelBox2.version", 1);
+
+ final com.box.sdk.BoxFileVersion result = requestBodyAndHeaders("direct://PROMOTEFILEVERSION", null, headers);
+
+ assertNotNull("promoteFileVersion result", result);
+ LOG.debug("promoteFileVersion: " + result);
+ }
+
+ @Test
+ public void testRenameFile() throws Exception {
+
+ com.box.sdk.BoxFile result = null;
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is String
+ headers.put("CamelBox2.newFileName", CAMEL_TEST_RENAME_FILE_NAME);
+
+ result = requestBodyAndHeaders("direct://RENAMEFILE", null, headers);
+
+ assertNotNull("renameFile result", result);
+ assertEquals("renameFile name", CAMEL_TEST_RENAME_FILE_NAME, result.getInfo().getName());
+ LOG.debug("renameFile: " + result);
+ } finally {
+ if (result != null) {
+ result.delete();
+ }
+ }
+ }
+
+ @Test
+ public void testUpdateFileInfo() throws Exception {
+ BoxFile.Info info = testFile.getInfo();
+ info.setDescription(CAMEL_TEST_FILE_DESCRIPTION);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is com.box.sdk.BoxFile.Info
+ headers.put("CamelBox2.info", info);
+
+ final com.box.sdk.BoxFile result = requestBodyAndHeaders("direct://UPDATEFILEINFO", null, headers);
+
+ assertNotNull("updateFileInfo result", result);
+ assertEquals("updateFileInfo info", CAMEL_TEST_FILE_DESCRIPTION, result.getInfo().getDescription());
+ LOG.debug("updateFileInfo: " + result);
+ }
+
+ @Test
+ public void testUpdateFileMetadata() throws Exception {
+ Metadata metadata = new Metadata();
+ // metadata.add("/foo", "bar");
+ metadata = testFile.createMetadata(metadata);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is com.box.sdk.Metadata
+ headers.put("CamelBox2.metadata", metadata);
+
+ final com.box.sdk.Metadata result = requestBodyAndHeaders("direct://UPDATEFILEMETADATA", null, headers);
+
+ assertNotNull("updateFileMetadata result", result);
+ LOG.debug("updateFileMetadata: " + result);
+ }
+
+ @Ignore
+ @Test
+ public void testUploadFile() throws Exception {
+ com.box.sdk.BoxFile result = null;
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put("CamelBox2.parentFolderId", "0");
+ headers.put("CamelBox2.content", getClass().getResourceAsStream(CAMEL_TEST_FILE));
+ headers.put("CamelBox2.fileName", CAMEL_TEST_UPLOAD_FILE_NAME);
+ headers.put("CamelBox2.created", null);
+ headers.put("CamelBox2.modified", null);
+ headers.put("CamelBox2.size", null);
+ headers.put("CamelBox2.listener", null);
+
+ result = requestBodyAndHeaders("direct://UPLOADFILE", null, headers);
+
+ assertNotNull("uploadFile result", result);
+ LOG.debug("uploadFile: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testUploadNewFileVersion() throws Exception {
+ com.box.sdk.BoxFile result = null;
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is java.io.InputStream
+ headers.put("CamelBox2.fileContent", getClass().getResourceAsStream(CAMEL_TEST_FILE));
+ // parameter type is java.util.Date
+ headers.put("CamelBox2.modified", null);
+ // parameter type is Long
+ headers.put("CamelBox2.fileSize", null);
+ // parameter type is com.box.sdk.ProgressListener
+ headers.put("CamelBox2.listener", null);
+
+ result = requestBodyAndHeaders("direct://UPLOADNEWFILEVERSION", null, headers);
+
+ assertNotNull("uploadNewFileVersion result", result);
+ LOG.debug("uploadNewFileVersion: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for copyFile
+ from("direct://COPYFILE").to("box2://" + PATH_PREFIX + "/copyFile");
+
+ // test route for createFileMetadata
+ from("direct://CREATEFILEMETADATA").to("box2://" + PATH_PREFIX + "/createFileMetadata");
+
+ // test route for createFileSharedLink
+ from("direct://CREATEFILESHAREDLINK").to("box2://" + PATH_PREFIX + "/createFileSharedLink");
+
+ // test route for deleteFile
+ from("direct://DELETEFILE").to("box2://" + PATH_PREFIX + "/deleteFile?inBody=fileId");
+
+ // test route for deleteFileMetadata
+ from("direct://DELETEFILEMETADATA").to("box2://" + PATH_PREFIX + "/deleteFileMetadata?inBody=fileId");
+
+ // test route for deleteFileVersion
+ from("direct://DELETEFILEVERSION").to("box2://" + PATH_PREFIX + "/deleteFileVersion");
+
+ // test route for downloadFile
+ from("direct://DOWNLOADFILE").to("box2://" + PATH_PREFIX + "/downloadFile");
+
+ // test route for downloadPreviousFileVersion
+ from("direct://DOWNLOADPREVIOUSFILEVERSION")
+ .to("box2://" + PATH_PREFIX + "/downloadPreviousFileVersion");
+
+ // test route for getDownloadURL
+ from("direct://GETDOWNLOADURL").to("box2://" + PATH_PREFIX + "/getDownloadURL?inBody=fileId");
+
+ // test route for getFileInfo
+ from("direct://GETFILEINFO").to("box2://" + PATH_PREFIX + "/getFileInfo");
+
+ // test route for getFileMetadata
+ from("direct://GETFILEMETADATA").to("box2://" + PATH_PREFIX + "/getFileMetadata");
+
+ // test route for getFilePreviewLink
+ from("direct://GETFILEPREVIEWLINK").to("box2://" + PATH_PREFIX + "/getFilePreviewLink?inBody=fileId");
+
+ // test route for getFileThumbnail
+ from("direct://GETFILETHUMBNAIL").to("box2://" + PATH_PREFIX + "/getFileThumbnail");
+
+ // test route for getFileVersions
+ from("direct://GETFILEVERSIONS").to("box2://" + PATH_PREFIX + "/getFileVersions?inBody=fileId");
+
+ // test route for moveFile
+ from("direct://MOVEFILE").to("box2://" + PATH_PREFIX + "/moveFile");
+
+ // test route for promoteFileVersion
+ from("direct://PROMOTEFILEVERSION").to("box2://" + PATH_PREFIX + "/promoteFileVersion");
+
+ // test route for renameFile
+ from("direct://RENAMEFILE").to("box2://" + PATH_PREFIX + "/renameFile");
+
+ // test route for updateFileInfo
+ from("direct://UPDATEFILEINFO").to("box2://" + PATH_PREFIX + "/updateFileInfo");
+
+ // test route for updateFileMetadata
+ from("direct://UPDATEFILEMETADATA").to("box2://" + PATH_PREFIX + "/updateFileMetadata");
+
+ // test route for uploadFile
+ from("direct://UPLOADFILE").to("box2://" + PATH_PREFIX + "/uploadFile");
+
+ // test route for uploadNewFileVersion
+ from("direct://UPLOADNEWFILEVERSION").to("box2://" + PATH_PREFIX + "/uploadNewFileVersion");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestFile();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestFile();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/copyFile");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestFile() throws FileNotFoundException {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ InputStream stream = getClass().getResourceAsStream(CAMEL_TEST_FILE);
+ testFile = rootFolder.uploadFile(stream, CAMEL_TEST_FILE_NAME).getResource();
+ }
+
+ private void deleteTestFile() {
+ try {
+ testFile.delete();
+ } catch (Throwable t) {
+ }
+ testFile = null;
+ }
+
+ private int sizeOfIterable(Iterable<?> it) {
+ if (it instanceof Collection) {
+ return ((Collection<?>) it).size();
+ } else {
+ int i = 0;
+ for (@SuppressWarnings("unused")
+ Object obj : it) {
+ i++;
+ }
+ return i;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FoldersManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FoldersManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FoldersManagerIntegrationTest.java
new file mode 100644
index 0000000..92a5765
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2FoldersManagerIntegrationTest.java
@@ -0,0 +1,322 @@
+/**
+ * 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.box2;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxItem;
+import com.box.sdk.BoxSharedLink;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2FoldersManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2FoldersManager}
+ * APIs.
+ */
+public class Box2FoldersManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2FoldersManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2FoldersManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_FOLDER = "CamelTestFolder";
+ private static final String CAMEL_TEST_FOLDER_DESCRIPTION = "This is a description of CamelTestFolder";
+ private static final String CAMEL_TEST_COPY_FOLDER = Box2FoldersManagerIntegrationTest.CAMEL_TEST_FOLDER + "_Copy";
+ private static final String CAMEL_TEST_MOVE_FOLDER = Box2FoldersManagerIntegrationTest.CAMEL_TEST_FOLDER + "_Move";
+ private static final String CAMEL_TEST_RENAME_FOLDER = Box2FoldersManagerIntegrationTest.CAMEL_TEST_FOLDER
+ + "_Rename";
+ private static final String CAMEL_TEST_ROOT_FOLDER_ID = "0";
+ private static final String CAMEL_TEST_DESTINATION_FOLDER_ID = "0";
+
+ private BoxFolder testFolder;
+
+ @Test
+ public void testCreateFolder() throws Exception {
+
+ // delete folder created in test setup.
+ deleteTestFolder();
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.parentFolderId", "0");
+ // parameter type is String
+ headers.put("CamelBox2.folderName", CAMEL_TEST_FOLDER);
+
+ testFolder = requestBodyAndHeaders("direct://CREATEFOLDER", null, headers);
+
+ assertNotNull("createFolder result", testFolder);
+ assertEquals("createFolder folder name", CAMEL_TEST_FOLDER, testFolder.getInfo().getName());
+ LOG.debug("createFolder: " + testFolder);
+ }
+
+ @Test
+ public void testDeleteFolder() throws Exception {
+ // using String message body for single parameter "folderId"
+ requestBody("direct://DELETEFOLDER", testFolder.getID());
+
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ Iterable<BoxItem.Info> it = rootFolder.search("^" + CAMEL_TEST_FOLDER + "$");
+ int searchResults = sizeOfIterable(it);
+ boolean exists = searchResults > 0 ? true : false;
+ assertEquals("deleteFolder exists", false, exists);
+ LOG.debug("deleteFolder: exists? " + exists);
+ }
+
+ @Test
+ public void testCopyFolder() throws Exception {
+ com.box.sdk.BoxFolder result = null;
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is String
+ headers.put("CamelBox2.destinationFolderId", CAMEL_TEST_DESTINATION_FOLDER_ID);
+ // parameter type is String
+ headers.put("CamelBox2.newName", CAMEL_TEST_COPY_FOLDER);
+ result = requestBodyAndHeaders("direct://COPYFOLDER", null, headers);
+ assertNotNull("copyFolder result", result);
+ assertEquals("copyFolder folder name", CAMEL_TEST_COPY_FOLDER, result.getInfo().getName());
+ LOG.debug("copyFolder: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete(true);
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testCreateSharedLink() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is com.box.sdk.BoxSharedLink.Access
+ headers.put("CamelBox2.access", BoxSharedLink.Access.COLLABORATORS);
+ // parameter type is java.util.Date
+ headers.put("CamelBox2.unshareDate", null);
+ // parameter type is com.box.sdk.BoxSharedLink.Permissions
+ headers.put("CamelBox2.permissions", new BoxSharedLink.Permissions());
+
+ final com.box.sdk.BoxSharedLink result = requestBodyAndHeaders("direct://CREATEFOLDERSHAREDLINK", null,
+ headers);
+
+ assertNotNull("createFolderSharedLink result", result);
+ LOG.debug("createFolderSharedLink: " + result);
+ }
+
+ @Test
+ public void testGetFolder() throws Exception {
+ // using String[] message body for single parameter "path"
+ final com.box.sdk.BoxFolder result = requestBody("direct://GETFOLDER", new String[] {CAMEL_TEST_FOLDER});
+
+ assertNotNull("getFolder result", result);
+ assertEquals("getFolder folder id", testFolder.getID(), result.getID());
+ LOG.debug("getFolder: " + result);
+ }
+
+ @Test
+ public void testGetFolderInfo() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is String[]
+ headers.put("CamelBox2.fields", new String[] {"name"});
+
+ final com.box.sdk.BoxFolder.Info result = requestBodyAndHeaders("direct://GETFOLDERINFO", null, headers);
+
+ assertNotNull("getFolderInfo result", result);
+ assertNotNull("getFolderInfo result.getName()", result.getName());
+ assertEquals("getFolderInfo info name", CAMEL_TEST_FOLDER, result.getName());
+ LOG.debug("getFolderInfo: " + result);
+ }
+
+ @Test
+ public void testGetFolderItems() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", CAMEL_TEST_ROOT_FOLDER_ID);
+ // parameter type is Long
+ headers.put("CamelBox2.offset", null);
+ // parameter type is Long
+ headers.put("CamelBox2.limit", null);
+ // parameter type is String[]
+ headers.put("CamelBox2.fields", null);
+
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBodyAndHeaders("direct://GETFOLDERITEMS", null, headers);
+
+ assertNotNull("getFolderItems result", result);
+ LOG.debug("getFolderItems: " + result);
+ }
+
+ @Test
+ public void testGetRootFolder() throws Exception {
+ final com.box.sdk.BoxFolder result = requestBody("direct://GETROOTFOLDER", null);
+
+ assertNotNull("getRootFolder result", result);
+ LOG.debug("getRootFolder: " + result);
+ }
+
+ @Test
+ public void testMoveFolder() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is String
+ headers.put("CamelBox2.destinationFolderId", CAMEL_TEST_DESTINATION_FOLDER_ID);
+ // parameter type is String
+ headers.put("CamelBox2.newName", CAMEL_TEST_MOVE_FOLDER);
+
+ final com.box.sdk.BoxFolder result = requestBodyAndHeaders("direct://MOVEFOLDER", null, headers);
+
+ assertNotNull("moveFolder result", result);
+ assertEquals("moveFolder folder name", CAMEL_TEST_MOVE_FOLDER, result.getInfo().getName());
+ LOG.debug("moveFolder: " + result);
+ }
+
+ @Test
+ public void testRenameFolder() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is String
+ headers.put("CamelBox2.newFolderName", CAMEL_TEST_RENAME_FOLDER);
+
+ final com.box.sdk.BoxFolder result = requestBodyAndHeaders("direct://RENAMEFOLDER", null, headers);
+
+ assertNotNull("renameFolder result", result);
+ assertEquals("moveFolder folder name", CAMEL_TEST_RENAME_FOLDER, result.getInfo().getName());
+ LOG.debug("renameFolder: " + result);
+ }
+
+ @Test
+ public void testUpdateInfo() throws Exception {
+ final BoxFolder.Info testFolderInfo = testFolder.getInfo();
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is com.box.sdk.BoxFolder.Info
+ testFolderInfo.setDescription(CAMEL_TEST_FOLDER_DESCRIPTION);
+ headers.put("CamelBox2.info", testFolderInfo);
+
+ final com.box.sdk.BoxFolder result = requestBodyAndHeaders("direct://UPDATEFOLDERINFO", null, headers);
+
+ assertNotNull("updateInfo result", result);
+ assertEquals("update folder info description", CAMEL_TEST_FOLDER_DESCRIPTION,
+ result.getInfo().getDescription());
+ LOG.debug("updateInfo: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for copyFolder
+ from("direct://COPYFOLDER").to("box2://" + PATH_PREFIX + "/copyFolder");
+
+ // test route for createFolder
+ from("direct://CREATEFOLDER").to("box2://" + PATH_PREFIX + "/createFolder");
+
+ // test route for createFolderSharedLink
+ from("direct://CREATEFOLDERSHAREDLINK").to("box2://" + PATH_PREFIX + "/createFolderSharedLink");
+
+ // test route for deleteFolder
+ from("direct://DELETEFOLDER").to("box2://" + PATH_PREFIX + "/deleteFolder?inBody=folderId");
+
+ // test route for getFolder
+ from("direct://GETFOLDER").to("box2://" + PATH_PREFIX + "/getFolder?inBody=path");
+
+ // test route for getFolderInfo
+ from("direct://GETFOLDERINFO").to("box2://" + PATH_PREFIX + "/getFolderInfo");
+
+ // test route for getFolderItems
+ from("direct://GETFOLDERITEMS").to("box2://" + PATH_PREFIX + "/getFolderItems");
+
+ // test route for getRootFolder
+ from("direct://GETROOTFOLDER").to("box2://" + PATH_PREFIX + "/getRootFolder");
+
+ // test route for moveFolder
+ from("direct://MOVEFOLDER").to("box2://" + PATH_PREFIX + "/moveFolder");
+
+ // test route for renameFolder
+ from("direct://RENAMEFOLDER").to("box2://" + PATH_PREFIX + "/renameFolder");
+
+ // test route for updateFolderInfo
+ from("direct://UPDATEFOLDERINFO").to("box2://" + PATH_PREFIX + "/updateFolderInfo");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestFolder();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestFolder();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/copyFolder");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestFolder() {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ testFolder = rootFolder.createFolder(CAMEL_TEST_FOLDER).getResource();
+ }
+
+ private void deleteTestFolder() {
+ if (testFolder != null) {
+ try {
+ testFolder.delete(true);
+ } catch (Throwable t) {
+ }
+ testFolder = null;
+ }
+ }
+
+ private int sizeOfIterable(Iterable<?> it) {
+ if (it instanceof Collection) {
+ return ((Collection<?>) it).size();
+ } else {
+ int i = 0;
+ for (@SuppressWarnings("unused")
+ Object obj : it) {
+ i++;
+ }
+ return i;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2GroupsManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2GroupsManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2GroupsManagerIntegrationTest.java
new file mode 100644
index 0000000..6d987ee
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2GroupsManagerIntegrationTest.java
@@ -0,0 +1,268 @@
+/**
+ * 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.box2;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxGroup;
+import com.box.sdk.BoxGroupMembership;
+import com.box.sdk.BoxUser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2GroupsManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2GroupsManager}
+ * APIs.
+ */
+public class Box2GroupsManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2GroupsManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2GroupsManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_GROUP_NAME = "CamelTestGroup";
+ private static final String CAMEL_TEST_CREATE_GROUP_NAME = "CamelTestCreateGroup";
+
+ private BoxGroup testGroup;
+ private BoxUser testUser;
+
+ @Test
+ public void testAddGroupMembership() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.groupId", testGroup.getID());
+ // parameter type is String
+ headers.put("CamelBox2.userId", testUser.getID());
+ // parameter type is com.box.sdk.BoxGroupMembership.Role
+ headers.put("CamelBox2.role", null);
+
+ final com.box.sdk.BoxGroupMembership result = requestBodyAndHeaders("direct://ADDGROUPMEMBERSHIP", null,
+ headers);
+
+ assertNotNull("addGroupMembership result", result);
+ LOG.debug("addGroupMembership: " + result);
+ }
+
+ @Test
+ public void testCreateGroup() throws Exception {
+ com.box.sdk.BoxGroup result = null;
+
+ try {
+ // using String message body for single parameter "name"
+ result = requestBody("direct://CREATEGROUP", CAMEL_TEST_CREATE_GROUP_NAME);
+ assertNotNull("createGroup result", result);
+ assertEquals(CAMEL_TEST_CREATE_GROUP_NAME, result.getInfo().getName());
+ LOG.debug("createGroup: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testDeleteGroup() throws Exception {
+ // using String message body for single parameter "groupId"
+ requestBody("direct://DELETEGROUP", testGroup.getID());
+
+ testGroup = null;
+
+ Iterable<BoxGroup.Info> it = BoxGroup.getAllGroups(getConnection());
+ int searchResults = sizeOfIterable(it);
+ boolean exists = searchResults > 0 ? true : false;
+ assertEquals("deleteGroup exists", false, exists);
+ LOG.debug("deleteGroup: exists? " + exists);
+ }
+
+ @Test
+ public void testDeleteGroupMembership() throws Exception {
+ BoxGroupMembership.Info info = testGroup.addMembership(testUser, BoxGroupMembership.Role.MEMBER);
+
+ // using String message body for single parameter "groupMembershipId"
+ requestBody("direct://DELETEGROUPMEMBERSHIP", info.getID());
+
+ Collection<BoxGroupMembership.Info> memberships = testGroup.getMemberships();
+ assertNotNull("deleteGroupMemberships memberships", memberships);
+ assertEquals("deleteGroupMemberships memberships exists", 0, memberships.size());
+ }
+
+ @Test
+ public void testGetAllGroups() throws Exception {
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBody("direct://GETALLGROUPS", null);
+
+ assertNotNull("getAllGroups result", result);
+ LOG.debug("getAllGroups: " + result);
+ }
+
+ @Test
+ public void testGetGroupInfo() throws Exception {
+ // using String message body for single parameter "groupId"
+ final com.box.sdk.BoxGroup.Info result = requestBody("direct://GETGROUPINFO", testGroup.getID());
+
+ assertNotNull("getGroupInfo result", result);
+ LOG.debug("getGroupInfo: " + result);
+ }
+
+ @Test
+ public void testGetGroupMembershipInfo() throws Exception {
+ BoxGroupMembership.Info info = testGroup.addMembership(testUser, BoxGroupMembership.Role.MEMBER);
+
+ // using String message body for single parameter "groupMemebershipId"
+ final com.box.sdk.BoxGroupMembership.Info result = requestBody("direct://GETGROUPMEMBERSHIPINFO", info.getID());
+
+ assertNotNull("getGroupMembershipInfo result", result);
+ LOG.debug("getGroupMembershipInfo: " + result);
+ }
+
+ @Test
+ public void testGetGroupMemberships() throws Exception {
+ // using String message body for single parameter "groupId"
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBody("direct://GETGROUPMEMBERSHIPS", testGroup.getID());
+
+ assertNotNull("getGroupMemberships result", result);
+ LOG.debug("getGroupMemberships: " + result);
+ }
+
+ @Test
+ public void testUpdateGroupMembershipInfo() throws Exception {
+ BoxGroupMembership.Info info = testGroup.addMembership(testUser, BoxGroupMembership.Role.MEMBER);
+ info.setRole(BoxGroupMembership.Role.ADMIN);
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.groupMemebershipId", info.getID());
+ // parameter type is com.box.sdk.BoxGroupMembership.Info
+ headers.put("CamelBox2.info", info);
+
+ final com.box.sdk.BoxGroupMembership result = requestBodyAndHeaders("direct://UPDATEGROUPMEMBERSHIPINFO", null,
+ headers);
+
+ assertNotNull("updateGroupMembershipInfo result", result);
+ LOG.debug("updateGroupMembershipInfo: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for addGroupMembership
+ from("direct://ADDGROUPMEMBERSHIP").to("box2://" + PATH_PREFIX + "/addGroupMembership");
+
+ // test route for createGroup
+ from("direct://CREATEGROUP").to("box2://" + PATH_PREFIX + "/createGroup?inBody=name");
+
+ // test route for deleteGroup
+ from("direct://DELETEGROUP").to("box2://" + PATH_PREFIX + "/deleteGroup?inBody=groupId");
+
+ // test route for deleteGroupMembership
+ from("direct://DELETEGROUPMEMBERSHIP")
+ .to("box2://" + PATH_PREFIX + "/deleteGroupMembership?inBody=groupMembershipId");
+
+ // test route for getAllGroups
+ from("direct://GETALLGROUPS").to("box2://" + PATH_PREFIX + "/getAllGroups");
+
+ // test route for getGroupInfo
+ from("direct://GETGROUPINFO").to("box2://" + PATH_PREFIX + "/getGroupInfo?inBody=groupId");
+
+ // test route for getGroupMembershipInfo
+ from("direct://GETGROUPMEMBERSHIPINFO")
+ .to("box2://" + PATH_PREFIX + "/getGroupMembershipInfo?inBody=groupMemebershipId");
+
+ // test route for getGroupMemberships
+ from("direct://GETGROUPMEMBERSHIPS")
+ .to("box2://" + PATH_PREFIX + "/getGroupMemberships?inBody=groupId");
+
+ // test route for updateGroupMembershipInfo
+ from("direct://UPDATEGROUPMEMBERSHIPINFO").to("box2://" + PATH_PREFIX + "/updateGroupMembershipInfo");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestGroup();
+ createTestUser();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestGroup();
+ deleteTestUser();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/addGroupMembership");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestGroup() {
+ testGroup = BoxGroup.createGroup(getConnection(), CAMEL_TEST_GROUP_NAME).getResource();
+ }
+
+ private void deleteTestGroup() {
+ if (testGroup != null) {
+ try {
+ testGroup.delete();
+ } catch (Throwable t) {
+ }
+ testGroup = null;
+ }
+ }
+
+ private void createTestUser() {
+ testUser = getCurrentUser();
+ }
+
+ private void deleteTestUser() {
+ if (testUser != null) {
+ testUser = null;
+ }
+ }
+
+ private BoxUser getCurrentUser() {
+ return BoxUser.getCurrentUser(getConnection());
+ }
+
+ private int sizeOfIterable(Iterable<?> it) {
+ if (it instanceof Collection) {
+ return ((Collection<?>) it).size();
+ } else {
+ int i = 0;
+ for (@SuppressWarnings("unused")
+ Object obj : it) {
+ i++;
+ }
+ return i;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2SearchManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2SearchManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2SearchManagerIntegrationTest.java
new file mode 100644
index 0000000..66be97d
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2SearchManagerIntegrationTest.java
@@ -0,0 +1,106 @@
+/**
+ * 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.box2;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxFolder;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2SearchManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2SearchManager}
+ * APIs.
+ */
+public class Box2SearchManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2SearchManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2SearchManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_FILE = "/CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_NAME = "CamelTestFile.txt";
+
+ private BoxFile testFile;
+
+ @Test
+ public void testSearchFolder() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", "0");
+ // parameter type is String
+ headers.put("CamelBox2.query", CAMEL_TEST_FILE_NAME);
+
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBodyAndHeaders("direct://SEARCHFOLDER", null, headers);
+
+ assertNotNull("searchFolder result", result);
+ assertEquals("searchFolder file found", 1, result.size());
+ LOG.debug("searchFolder: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for searchFolder
+ from("direct://SEARCHFOLDER").to("box2://" + PATH_PREFIX + "/searchFolder");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestFile();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestFile();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/searchFolder");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestFile() throws FileNotFoundException {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ InputStream stream = getClass().getResourceAsStream(CAMEL_TEST_FILE);
+ testFile = rootFolder.uploadFile(stream, CAMEL_TEST_FILE_NAME).getResource();
+ }
+
+ private void deleteTestFile() {
+ try {
+ testFile.delete();
+ } catch (Throwable t) {
+ }
+ testFile = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2TasksManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2TasksManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2TasksManagerIntegrationTest.java
new file mode 100644
index 0000000..b0aacfe
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2TasksManagerIntegrationTest.java
@@ -0,0 +1,284 @@
+/**
+ * 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.box2;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxFile;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxTask;
+import com.box.sdk.BoxTask.Action;
+import com.box.sdk.BoxTaskAssignment;
+import com.box.sdk.BoxUser;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2TasksManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for {@link org.apache.camel.component.box2.api.Box2TasksManager}
+ * APIs.
+ */
+public class Box2TasksManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2TasksManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2TasksManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_FILE = "/CamelTestFile.txt";
+ private static final String CAMEL_TEST_FILE_NAME = "CamelTestFile.txt";
+ private static final String CAMEL_TEST_MESSAGE = "Camel Test Message";
+ private static final long TEN_MINUTES_IN_MILLIS = 600000;
+
+ private BoxFile testFile;
+ private BoxTask testTask;
+
+ @Test
+ public void testAddAssignmentToTask() throws Exception {
+ com.box.sdk.BoxTask result = null;
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.taskId", testTask.getID());
+ // parameter type is com.box.sdk.BoxUser
+ headers.put("CamelBox2.assignTo", getCurrentUser());
+
+ result = requestBodyAndHeaders("direct://ADDASSIGNMENTTOTASK", null, headers);
+
+ assertNotNull("addAssignmentToTask result", result);
+ LOG.debug("addAssignmentToTask: " + result);
+ }
+
+ @Test
+ public void testAddFileTask() throws Exception {
+ com.box.sdk.BoxTask result = null;
+
+ try {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.fileId", testFile.getID());
+ // parameter type is com.box.sdk.BoxTask.Action
+ headers.put("CamelBox2.action", BoxTask.Action.REVIEW);
+ // parameter type is java.util.Date
+ Date now = new Date();
+ Date dueAt = new Date(now.getTime() + TEN_MINUTES_IN_MILLIS);
+ headers.put("CamelBox2.dueAt", dueAt);
+ // parameter type is String
+ headers.put("CamelBox2.message", CAMEL_TEST_MESSAGE);
+
+ result = requestBodyAndHeaders("direct://ADDFILETASK", null, headers);
+
+ assertNotNull("addFileTask result", result);
+ LOG.debug("addFileTask: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ result.delete();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testDeleteTask() throws Exception {
+ // using String message body for single parameter "taskId"
+ requestBody("direct://DELETETASK", testTask.getID());
+
+ List<BoxTask.Info> tasks = testFile.getTasks();
+ boolean exists = tasks.size() != 0;
+ assertEquals("deleteTask task still exists.", false, exists);
+ }
+
+ @Ignore // Receiving "not found" exception from Box API
+ @Test
+ public void testDeleteTaskAssignment() throws Exception {
+ BoxTaskAssignment.Info info = testTask.addAssignment(getCurrentUser());
+
+ // using String message body for single parameter "taskAssignmentId"
+ requestBody("direct://DELETETASKASSIGNMENT", info.getID());
+
+ List<BoxTaskAssignment.Info> assignments = testTask.getAssignments();
+ boolean exists = assignments.size() != 0;
+ assertEquals("deleteTaskAssignment assignment still exists.", false, exists);
+ }
+
+ @Test
+ public void testGetFileTasks() throws Exception {
+ // using String message body for single parameter "fileId"
+ @SuppressWarnings("rawtypes")
+ final java.util.List result = requestBody("direct://GETFILETASKS", testFile.getID());
+
+ assertNotNull("getFileTasks result", result);
+ LOG.debug("getFileTasks: " + result);
+ }
+
+ @Ignore
+ @Test
+ public void testGetTaskAssignmentInfo() throws Exception {
+ BoxTaskAssignment.Info info = testTask.addAssignment(getCurrentUser());
+ com.box.sdk.BoxTaskAssignment.Info result = null;
+
+ try {
+ // using String message body for single parameter "taskAssignmentId"
+ result = requestBody("direct://GETTASKASSIGNMENTINFO", info.getID());
+
+ assertNotNull("getTaskAssignmentInfo result", result);
+ LOG.debug("getTaskAssignmentInfo: " + result);
+ } finally {
+ if (result != null) {
+ try {
+ ((BoxTaskAssignment) result.getResource()).delete();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testGetTaskAssignments() throws Exception {
+ // using String message body for single parameter "taskId"
+ @SuppressWarnings("rawtypes")
+ final java.util.List result = requestBody("direct://GETTASKASSIGNMENTS", testTask.getID());
+
+ assertNotNull("getTaskAssignments result", result);
+ LOG.debug("getTaskAssignments: " + result);
+ }
+
+ @Test
+ public void testGetTaskInfo() throws Exception {
+ // using String message body for single parameter "taskId"
+ final com.box.sdk.BoxTask.Info result = requestBody("direct://GETTASKINFO", testTask.getID());
+
+ assertNotNull("getTaskInfo result", result);
+ LOG.debug("getTaskInfo: " + result);
+ }
+
+ @Ignore // No way to change BoxTask.Info parameters
+ @Test
+ public void testUpdateTaskInfo() throws Exception {
+ BoxTask.Info info = testTask.getInfo();
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.taskId", testTask.getID());
+ // parameter type is com.box.sdk.BoxTask.Info
+ headers.put("CamelBox2.info", info);
+
+ final com.box.sdk.BoxTask result = requestBodyAndHeaders("direct://UPDATETASKINFO", null, headers);
+
+ assertNotNull("updateTaskInfo result", result);
+ LOG.debug("updateTaskInfo: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for addAssignmentToTask
+ from("direct://ADDASSIGNMENTTOTASK").to("box2://" + PATH_PREFIX + "/addAssignmentToTask");
+
+ // test route for addFileTask
+ from("direct://ADDFILETASK").to("box2://" + PATH_PREFIX + "/addFileTask");
+
+ // test route for deleteTask
+ from("direct://DELETETASK").to("box2://" + PATH_PREFIX + "/deleteTask?inBody=taskId");
+
+ // test route for deleteTaskAssignment
+ from("direct://DELETETASKASSIGNMENT")
+ .to("box2://" + PATH_PREFIX + "/deleteTaskAssignment?inBody=taskAssignmentId");
+
+ // test route for getFileTasks
+ from("direct://GETFILETASKS").to("box2://" + PATH_PREFIX + "/getFileTasks?inBody=fileId");
+
+ // test route for getTaskAssignmentInfo
+ from("direct://GETTASKASSIGNMENTINFO")
+ .to("box2://" + PATH_PREFIX + "/getTaskAssignmentInfo?inBody=taskAssignmentId");
+
+ // test route for getTaskAssignments
+ from("direct://GETTASKASSIGNMENTS").to("box2://" + PATH_PREFIX + "/getTaskAssignments?inBody=taskId");
+
+ // test route for getTaskInfo
+ from("direct://GETTASKINFO").to("box2://" + PATH_PREFIX + "/getTaskInfo?inBody=taskId");
+
+ // test route for updateTaskInfo
+ from("direct://UPDATETASKINFO").to("box2://" + PATH_PREFIX + "/updateTaskInfo");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestFile();
+ createTestTask();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestTask();
+ deleteTestFile();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context().getEndpoint("box2://" + PATH_PREFIX + "/addAssignmentToTask");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestTask() {
+ Date now = new Date();
+ Date dueAt = new Date(now.getTime() + TEN_MINUTES_IN_MILLIS);
+ testTask = (BoxTask) testFile.addTask(Action.REVIEW, CAMEL_TEST_MESSAGE, dueAt).getResource();
+ }
+
+ private void deleteTestTask() {
+ try {
+ testTask.delete();
+ } catch (Throwable t) {
+ }
+ testTask = null;
+ }
+
+ private void createTestFile() throws FileNotFoundException {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ InputStream stream = getClass().getResourceAsStream(CAMEL_TEST_FILE);
+ testFile = rootFolder.uploadFile(stream, CAMEL_TEST_FILE_NAME).getResource();
+ }
+
+ private void deleteTestFile() {
+ try {
+ testFile.delete();
+ } catch (Throwable t) {
+ }
+ testFile = null;
+ }
+
+ private BoxUser getCurrentUser() {
+ return BoxUser.getCurrentUser(getConnection());
+ }
+}
[5/8] camel git commit: CAMEL-9047: Replace deprecated boxjavalibv2
with box-java-sdk
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
new file mode 100644
index 0000000..1b5fa50
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Component.java
@@ -0,0 +1,115 @@
+/**
+ * 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.box2;
+
+import com.box.sdk.BoxAPIConnection;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2ApiName;
+import org.apache.camel.component.box2.internal.Box2ConnectionHelper;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.component.AbstractApiComponent;
+
+/**
+ * Represents the component that manages {@link Box2Endpoint}.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+// @UriEndpoint(scheme = "box2", consumerClass = Box2Consumer.class,
+// consumerPrefix = "consumer", syntax = "", title = "Box2 Component")
+public class Box2Component extends AbstractApiComponent<Box2ApiName, Box2Configuration, Box2ApiCollection> {
+
+ @Metadata(label = "advanced")
+ BoxAPIConnection boxConnection;
+
+ public Box2Component() {
+ super(Box2Endpoint.class, Box2ApiName.class, Box2ApiCollection.getCollection());
+ }
+
+ public Box2Component(CamelContext context) {
+ super(context, Box2Endpoint.class, Box2ApiName.class, Box2ApiCollection.getCollection());
+ }
+
+ @Override
+ protected Box2ApiName getApiName(String apiNameStr) throws IllegalArgumentException {
+ return Box2ApiName.fromValue(apiNameStr);
+ }
+
+ /**
+ * To use the shared configuration
+ */
+ @Override
+ public void setConfiguration(Box2Configuration configuration) {
+ super.setConfiguration(configuration);
+ }
+
+ /**
+ * To use the shared configuration
+ */
+ @Override
+ public Box2Configuration getConfiguration() {
+ return super.getConfiguration();
+ }
+
+ /**
+ * To use a shared connection
+ *
+ * @return the shared connection
+ */
+ public BoxAPIConnection getBoxConnection() {
+ return boxConnection;
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String methodName, Box2ApiName apiName,
+ Box2Configuration endpointConfiguration) {
+ endpointConfiguration.setApiName(apiName);
+ endpointConfiguration.setMethodName(methodName);
+ return new Box2Endpoint(uri, this, apiName, methodName, endpointConfiguration);
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ if (boxConnection == null) {
+ if (configuration != null) {
+ boxConnection = Box2ConnectionHelper.createConnection(configuration);
+ } else {
+ throw new IllegalArgumentException("Unable to connect, Box2 component configuration is missing");
+ }
+ }
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (boxConnection != null) {
+ boxConnection = null;
+ }
+ }
+
+ @Override
+ public void doShutdown() throws Exception {
+ if (boxConnection != null) {
+ boxConnection = null;
+ }
+ super.doShutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
new file mode 100644
index 0000000..0de24b8
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Configuration.java
@@ -0,0 +1,475 @@
+/**
+ * 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.box2;
+
+import java.util.Map;
+
+import com.box.sdk.EncryptionAlgorithm;
+import com.box.sdk.IAccessTokenCache;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.box2.internal.Box2ApiName;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+/**
+ * Component configuration for Box2 component.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+@UriParams
+public class Box2Configuration {
+
+ /**
+ * Authentication Types for Connection
+ */
+ public static final String APP_ENTERPRISE_AUTHENTICATION = "APP_ENTERPRISE_AUTHENTICATION";
+ public static final String APP_USER_AUTHENTICATION = "APP_USER_AUTHENTICATION";
+ public static final String STANDARD_AUTHENTICATION = "STANDARD_AUTHENTICATION";
+
+ /**
+ * Encryption Algorithm Types for Server Authentication.
+ */
+ public static final String RSA_SHA_512 = "RSA_SHA_512";
+ public static final String RSA_SHA_384 = "RSA_SHA_384";
+ public static final String RSA_SHA_256 = "RSA_SHA_256";
+
+ @UriPath
+ @Metadata(required = "true")
+ private Box2ApiName apiName;
+
+ @UriPath
+ @Metadata(required = "true")
+ private String methodName;
+
+ @UriParam
+ private String enterpriseId;
+
+ @UriParam
+ private String userId;
+
+ @UriParam
+ private String clientId;
+
+ @UriParam(label = "security", secret = true)
+ private String publicKeyId;
+
+ @UriParam(label = "security", secret = true)
+ private String privateKeyFile;
+
+ @UriParam(label = "security", secret = true)
+ private String privateKeyPassword;
+
+ @UriParam(label = "security", secret = true)
+ private String clientSecret;
+ @UriParam(label = "security", secret = true)
+ private String userName;
+ @UriParam(label = "security", secret = true)
+ private String userPassword;
+
+ @UriParam(label = "advanced,security")
+ private IAccessTokenCache accessTokenCache;
+
+ @UriParam(label = "advanced,security", defaultValue = "100")
+ private int maxCacheEntries;
+
+ @UriParam(label = "advanced,security", defaultValue = RSA_SHA_256)
+ private EncryptionAlgorithm encryptionAlgorithm;
+
+ @UriParam(label = "authentication", defaultValue = APP_USER_AUTHENTICATION)
+ private String authenticationType;
+
+ @UriParam(label = "advanced")
+ private Map<String, Object> httpParams;
+ @UriParam(label = "security")
+ private SSLContextParameters sslContextParameters;
+
+ /**
+ * What kind of operation to perform
+ *
+ * @return the API Name
+ */
+ public Box2ApiName getApiName() {
+ return apiName;
+ }
+
+ /**
+ * What kind of operation to perform
+ *
+ * @param apiName
+ * the API Name to set
+ */
+ public void setApiName(Box2ApiName apiName) {
+ this.apiName = apiName;
+ }
+
+ /**
+ * What sub operation to use for the selected operation
+ *
+ * @return the methodName
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ /**
+ * What sub operation to use for the selected operation
+ *
+ * @param methodName
+ * the methodName to set
+ */
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ /**
+ * The enterprise ID to use for an App Enterprise.
+ *
+ * @return the enterpriseId
+ */
+ public String getEnterpriseId() {
+ return enterpriseId;
+ }
+
+ /**
+ * The enterprise ID to use for an App Enterprise.
+ *
+ * @param enterpriseId
+ * the enterpriseId to set
+ */
+ public void setEnterpriseId(String enterpriseId) {
+ this.enterpriseId = enterpriseId;
+ }
+
+ /**
+ * The user ID to use for an App User.
+ *
+ * @return the userId
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * The user ID to use for an App User.
+ *
+ * @param userId
+ * the userId to set
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ /**
+ * The ID for public key for validating the JWT signature.
+ *
+ * @return the publicKeyId
+ */
+ public String getPublicKeyId() {
+ return publicKeyId;
+ }
+
+ /**
+ * The ID for public key for validating the JWT signature.
+ *
+ * @param publicKeyId
+ * the publicKeyId to set
+ */
+ public void setPublicKeyId(String publicKeyId) {
+ this.publicKeyId = publicKeyId;
+ }
+
+ /**
+ * The private key for generating the JWT signature.
+ *
+ * @return the privateKey
+ */
+ public String getPrivateKeyFile() {
+ return privateKeyFile;
+ }
+
+ /**
+ * The private key for generating the JWT signature.
+ *
+ * @param privateKey
+ * the privateKey to set
+ */
+ public void setPrivateKeyFile(String privateKey) {
+ this.privateKeyFile = privateKey;
+ }
+
+ /**
+ * The password for the private key.
+ *
+ * @return the privateKeyPassword
+ */
+ public String getPrivateKeyPassword() {
+ return privateKeyPassword;
+ }
+
+ /**
+ * The password for the private key.
+ *
+ * @param privateKeyPassword
+ * the privateKeyPassword to set
+ */
+ public void setPrivateKeyPassword(String privateKeyPassword) {
+ this.privateKeyPassword = privateKeyPassword;
+ }
+
+ /**
+ * The maximum number of access tokens in cache.
+ *
+ * @return the maxCacheEntries
+ */
+ public int getMaxCacheEntries() {
+ return maxCacheEntries;
+ }
+
+ /**
+ * The maximum number of access tokens in cache.
+ *
+ * @param maxCacheEntries
+ * the maxCacheEntries to set
+ */
+ public void setMaxCacheEntries(String maxCacheEntries) {
+ try {
+ this.maxCacheEntries = Integer.decode(maxCacheEntries);
+ } catch (NumberFormatException e) {
+ throw new RuntimeCamelException(String.format("Invalid 'maxCacheEntries' value: %s", maxCacheEntries), e);
+ }
+ }
+
+ /**
+ * The type of encryption algorithm for JWT.
+ *
+ * @return the encryptionAlgorithm
+ */
+ public EncryptionAlgorithm getEncryptionAlgorithm() {
+ return encryptionAlgorithm;
+ }
+
+ /**
+ * The type of encryption algorithm for JWT.
+ *
+ * <p>
+ * Supported Algorithms:
+ * <ul>
+ * <li>RSA_SHA_256</li>
+ * <li>RSA_SHA_384</li>
+ * <li>RSA_SHA_512</li>
+ * </ul>
+ *
+ * @param encryptionAlgorithm
+ * the encryptionAlgorithm to set
+ */
+ public void setEncryptionAlgorithm(String encryptionAlgorithm) {
+ switch (encryptionAlgorithm) {
+ case RSA_SHA_256:
+ this.encryptionAlgorithm = EncryptionAlgorithm.RSA_SHA_256;
+ return;
+ case RSA_SHA_384:
+ this.encryptionAlgorithm = EncryptionAlgorithm.RSA_SHA_384;
+ return;
+ case RSA_SHA_512:
+ this.encryptionAlgorithm = EncryptionAlgorithm.RSA_SHA_512;
+ return;
+ default:
+ throw new RuntimeCamelException(String.format("Invalid Encryption Algorithm: %s", encryptionAlgorithm));
+ }
+ }
+
+ /**
+ * The type of authentication for connection.
+ *
+ * <p>
+ * Types of Authentication:
+ * <ul>
+ * <li>STANDARD_AUTHENTICATION - OAuth 2.0 (3-legged)</li>
+ * <li>SERVER_AUTHENTICATION - OAuth 2.0 with JSON Web Tokens</li>
+ * </ul>
+ *
+ * @return the authenticationType
+ */
+ public String getAuthenticationType() {
+ return authenticationType;
+ }
+
+ /**
+ * The type of authentication for connection.
+ *
+ * <p>
+ * Types of Authentication:
+ * <ul>
+ * <li>STANDARD_AUTHENTICATION - OAuth 2.0 (3-legged)</li>
+ * <li>SERVER_AUTHENTICATION - OAuth 2.0 with JSON Web Tokens</li>
+ * </ul>
+ *
+ * @param authenticationType
+ * the authenticationType to set
+ */
+ public void setAuthenticationType(String authenticationType) {
+ switch (authenticationType) {
+ case STANDARD_AUTHENTICATION:
+ case APP_USER_AUTHENTICATION:
+ case APP_ENTERPRISE_AUTHENTICATION:
+ this.authenticationType = authenticationType;
+ return;
+ default:
+ throw new RuntimeCamelException(String.format("Invalid Authentication Type: %s", authenticationType));
+ }
+ }
+
+ /**
+ * Box application client ID
+ *
+ * @return the clientId
+ */
+ public String getClientId() {
+ return clientId;
+ }
+
+ /**
+ * Box application client ID
+ *
+ * @param clientId
+ * the clientId to set
+ */
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ /**
+ * Box application client secret
+ *
+ * @return the clientSecret
+ */
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ /**
+ * Box application client secret
+ *
+ * @param clientSecret
+ * the clientSecret to set
+ */
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ /**
+ * Box user name, MUST be provided
+ *
+ * @return the userName
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+ /**
+ * Box user name, MUST be provided
+ *
+ * @param userName
+ * the userName to set
+ */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ /**
+ * Box user password, MUST be provided if authSecureStorage is not set, or
+ * returns null on first call
+ *
+ * @return the userPassword
+ */
+ public String getUserPassword() {
+ return userPassword;
+ }
+
+ /**
+ * Box user password, MUST be provided if authSecureStorage is not set, or
+ * returns null on first call
+ *
+ * @param userPassword
+ * the userPassword to set
+ */
+ public void setUserPassword(String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ /**
+ * Custom HTTP params for settings like proxy host
+ *
+ * @return the httpParams
+ */
+ public Map<String, Object> getHttpParams() {
+ return httpParams;
+ }
+
+ /**
+ * Custom HTTP params for settings like proxy host
+ *
+ * @param httpParams
+ * the httpParams to set
+ */
+ public void setHttpParams(Map<String, Object> httpParams) {
+ this.httpParams = httpParams;
+ }
+
+ /**
+ * To configure security using SSLContextParameters.
+ *
+ * @return the sslContextParameters
+ */
+ public SSLContextParameters getSslContextParameters() {
+ return sslContextParameters;
+ }
+
+ /**
+ * To configure security using SSLContextParameters.
+ *
+ * @param sslContextParameters
+ * the sslContextParameters to set
+ */
+ public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+ this.sslContextParameters = sslContextParameters;
+ }
+
+ /**
+ * Custom Access Token Cache for storing and retrieving access tokens.
+ *
+ * @return Custom Access Token Cache
+ */
+ public IAccessTokenCache getAccessTokenCache() {
+ return accessTokenCache;
+ }
+
+ /**
+ * Custom Access Token Cache for storing and retrieving access tokens.
+ *
+ * @param accessTokenCache
+ * - the Custom Access Token Cache
+ */
+ public void setAccessTokenCache(IAccessTokenCache accessTokenCache) {
+ this.accessTokenCache = accessTokenCache;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
new file mode 100644
index 0000000..313ba2d
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Consumer.java
@@ -0,0 +1,111 @@
+/**
+ * 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.box2;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxEvent;
+import com.box.sdk.EventListener;
+
+import org.apache.camel.Processor;
+import org.apache.camel.component.box2.api.Box2EventsManager;
+import org.apache.camel.component.box2.internal.Box2ApiName;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.component.AbstractApiConsumer;
+import org.apache.camel.util.component.ApiConsumerHelper;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodHelper;
+
+/**
+ * The Box2 consumer.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2Consumer extends AbstractApiConsumer<Box2ApiName, Box2Configuration> implements EventListener {
+
+ private static final String LISTENER_PROPERTY = "listener";
+
+ private BoxAPIConnection boxConnection;
+
+ private Box2EventsManager apiProxy;
+
+ private final ApiMethod apiMethod;
+
+ private final Map<String, Object> properties;
+
+ public Box2Consumer(Box2Endpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+
+ apiMethod = ApiConsumerHelper.findMethod(endpoint, this);
+
+ // Add listener property to register this consumer as listener for
+ // events.
+ properties = new HashMap<String, Object>();
+ properties.putAll(endpoint.getEndpointProperties());
+ properties.put(LISTENER_PROPERTY, this);
+
+ boxConnection = endpoint.getBoxConnection();
+
+ apiProxy = new Box2EventsManager(boxConnection);
+ }
+
+ @Override
+ public void interceptPropertyNames(Set<String> propertyNames) {
+ propertyNames.add(LISTENER_PROPERTY);
+ }
+
+ @Override
+ public void onEvent(BoxEvent event) {
+ try {
+ // Convert Events to exchange and process
+ log.debug("Processed {} event for {}", ApiConsumerHelper.getResultsProcessed(this, event, false),
+ boxConnection);
+ } catch (Exception e) {
+ log.info("Received exception consuming event: ", e);
+ }
+ }
+
+ @Override
+ public void onNextPosition(long position) {
+ }
+
+ @Override
+ public boolean onException(Throwable e) {
+ getExceptionHandler().handleException(ObjectHelper.wrapRuntimeCamelException(e));
+ return true;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ // invoke the API method to start listening
+ ApiMethodHelper.invokeMethod(apiProxy, apiMethod, properties);
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ apiProxy.stopListening();
+
+ super.doStop();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
new file mode 100644
index 0000000..0fe122f
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Endpoint.java
@@ -0,0 +1,214 @@
+/**
+ * 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.box2;
+
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.box2.api.Box2CollaborationsManager;
+import org.apache.camel.component.box2.api.Box2CommentsManager;
+import org.apache.camel.component.box2.api.Box2EventLogsManager;
+import org.apache.camel.component.box2.api.Box2EventsManager;
+import org.apache.camel.component.box2.api.Box2FilesManager;
+import org.apache.camel.component.box2.api.Box2FoldersManager;
+import org.apache.camel.component.box2.api.Box2GroupsManager;
+import org.apache.camel.component.box2.api.Box2SearchManager;
+import org.apache.camel.component.box2.api.Box2TasksManager;
+import org.apache.camel.component.box2.api.Box2UsersManager;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2ApiName;
+import org.apache.camel.component.box2.internal.Box2ConnectionHelper;
+import org.apache.camel.component.box2.internal.Box2Constants;
+import org.apache.camel.component.box2.internal.Box2PropertiesHelper;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.component.AbstractApiEndpoint;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodPropertiesHelper;
+
+/**
+ * Represents a Box2 endpoint.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+@UriEndpoint(scheme = "box2", title = "Box2", syntax = "box2:apiName/methodName", consumerClass = Box2Consumer.class, consumerPrefix = "consumer", label = "api,file,cloud", lenientProperties = true)
+public class Box2Endpoint extends AbstractApiEndpoint<Box2ApiName, Box2Configuration> {
+
+ @UriParam(name = "configuration", description = "Box 2 Configuration")
+ private Box2Configuration configuration;
+
+ // cached connection
+ private BoxAPIConnection boxConnection;
+
+ private Object apiProxy;
+
+ private boolean boxConnectionShared;
+
+ public Box2Endpoint(String uri, Box2Component component, Box2ApiName apiName, String methodName,
+ Box2Configuration endpointConfiguration) {
+ super(uri, component, apiName, methodName, Box2ApiCollection.getCollection().getHelper(apiName),
+ endpointConfiguration);
+ this.configuration = endpointConfiguration;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.camel.impl.DefaultEndpoint#getComponent()
+ */
+ @Override
+ public Box2Component getComponent() {
+ return (Box2Component) super.getComponent();
+ }
+
+ /**
+ * The BoxAPIConnection of endpoint.
+ *
+ * @return the BoxAPIConnection of endpoint.
+ */
+ public BoxAPIConnection getBoxConnection() {
+ return boxConnection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.camel.Endpoint#createProducer()
+ */
+ public Producer createProducer() throws Exception {
+ return new Box2Producer(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.camel.Endpoint#createConsumer(org.apache.camel.Processor)
+ */
+ public Consumer createConsumer(Processor processor) throws Exception {
+ // make sure inBody is not set for consumers
+ if (inBody != null) {
+ throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
+ }
+ final Box2Consumer consumer = new Box2Consumer(this, processor);
+ // also set consumer.* properties
+ configureConsumer(consumer);
+ return consumer;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.camel.util.component.AbstractApiEndpoint#getPropertiesHelper()
+ */
+ @Override
+ protected ApiMethodPropertiesHelper<Box2Configuration> getPropertiesHelper() {
+ return Box2PropertiesHelper.getHelper();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.camel.util.component.AbstractApiEndpoint#getThreadProfileName(
+ * )
+ */
+ protected String getThreadProfileName() {
+ return Box2Constants.THREAD_PROFILE_NAME;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.camel.util.component.AbstractApiEndpoint#
+ * afterConfigureProperties()
+ */
+ @Override
+ protected void afterConfigureProperties() {
+ // create connection eagerly, a good way to validate configuration
+ createBoxConnection();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.camel.util.component.AbstractApiEndpoint#getApiProxy(org.
+ * apache.camel.util.component.ApiMethod, java.util.Map)
+ */
+ @Override
+ public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
+ if (apiProxy == null) {
+ // create API proxy lazily
+ createApiProxy(args);
+ }
+ return apiProxy;
+ }
+
+ private void createBoxConnection() {
+ final Box2Component component = getComponent();
+ this.boxConnectionShared = configuration.equals(getComponent().getConfiguration());
+ if (boxConnectionShared) {
+ // get shared singleton connection from Component
+ this.boxConnection = component.getBoxConnection();
+ } else {
+ this.boxConnection = Box2ConnectionHelper.createConnection(configuration);
+ }
+ }
+
+ private void createApiProxy(Map<String, Object> args) {
+ switch (apiName) {
+ case COLLABORATIONS:
+ apiProxy = new Box2CollaborationsManager(getBoxConnection());
+ break;
+ case COMMENTS:
+ apiProxy = new Box2CommentsManager(getBoxConnection());
+ break;
+ case EVENT_LOGS:
+ apiProxy = new Box2EventLogsManager(getBoxConnection());
+ break;
+ case EVENTS:
+ apiProxy = new Box2EventsManager(getBoxConnection());
+ break;
+ case FILES:
+ apiProxy = new Box2FilesManager(getBoxConnection());
+ break;
+ case FOLDERS:
+ apiProxy = new Box2FoldersManager(getBoxConnection());
+ break;
+ case GROUPS:
+ apiProxy = new Box2GroupsManager(getBoxConnection());
+ break;
+ case SEARCH:
+ apiProxy = new Box2SearchManager(getBoxConnection());
+ break;
+ case TASKS:
+ apiProxy = new Box2TasksManager(getBoxConnection());
+ break;
+ case USERS:
+ apiProxy = new Box2UsersManager(getBoxConnection());
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid API name " + apiName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.java
new file mode 100644
index 0000000..92ef415
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/Box2Producer.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.box2;
+
+import org.apache.camel.component.box2.internal.Box2ApiName;
+import org.apache.camel.component.box2.internal.Box2PropertiesHelper;
+
+import org.apache.camel.util.component.AbstractApiProducer;
+
+/**
+ * The Box2 producer.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public class Box2Producer extends AbstractApiProducer<Box2ApiName, Box2Configuration> {
+
+ public Box2Producer(Box2Endpoint endpoint) {
+ super(endpoint, Box2PropertiesHelper.getHelper());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
new file mode 100644
index 0000000..c95efdc
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2ConnectionHelper.java
@@ -0,0 +1,286 @@
+/**
+ * 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.box2.internal;
+
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.GeneralSecurityException;
+import java.security.SecureRandom;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.net.ssl.SSLContext;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxDeveloperEditionAPIConnection;
+import com.box.sdk.IAccessTokenCache;
+import com.box.sdk.InMemoryLRUAccessTokenCache;
+import com.box.sdk.JWTEncryptionPreferences;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.ProxyConfig;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebClientOptions;
+import com.gargoylesoftware.htmlunit.WebRequest;
+import com.gargoylesoftware.htmlunit.WebResponse;
+import com.gargoylesoftware.htmlunit.html.HtmlButton;
+import com.gargoylesoftware.htmlunit.html.HtmlDivision;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+import com.gargoylesoftware.htmlunit.util.WebConnectionWrapper;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.box2.Box2Configuration;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Box2ConnectionHelper
+ *
+ * <p>
+ * Utility class for creating Box API Connections
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public final class Box2ConnectionHelper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2ConnectionHelper.class);
+
+ private static final Pattern QUERY_PARAM_PATTERN = Pattern.compile("&?([^=]+)=([^&]+)");
+
+ private Box2ConnectionHelper() {
+ // hide utility class constructor
+ }
+
+ public static BoxAPIConnection createConnection(final Box2Configuration configuration) {
+ if (configuration.getAuthenticationType() == null) {
+ throw new RuntimeCamelException(
+ "Box API connection failed: Authentication type not specified in configuration");
+ }
+ switch (configuration.getAuthenticationType()) {
+ case Box2Configuration.APP_ENTERPRISE_AUTHENTICATION:
+ return createAppEnterpriseAuthenticatedConnection(configuration);
+ case Box2Configuration.APP_USER_AUTHENTICATION:
+ return createAppUserAuthenticatedConnection(configuration);
+ case Box2Configuration.STANDARD_AUTHENTICATION:
+ return createStandardAuthenticatedConnection(configuration);
+ default:
+ throw new RuntimeCamelException(String.format("Box API connection failed: Invalid authentication type '%s'",
+ configuration.getAuthenticationType()));
+ }
+ }
+
+ public static BoxAPIConnection createStandardAuthenticatedConnection(Box2Configuration configuration) {
+
+ // Create web client for first leg of OAuth2
+ //
+ final WebClient webClient = new WebClient();
+ final WebClientOptions options = webClient.getOptions();
+ options.setRedirectEnabled(true);
+ options.setJavaScriptEnabled(false);
+ options.setThrowExceptionOnFailingStatusCode(true);
+ options.setThrowExceptionOnScriptError(true);
+ options.setPrintContentOnFailingStatusCode(LOG.isDebugEnabled());
+ try {
+ // use default SSP to create supported non-SSL protocols list
+ final SSLContext sslContext = new SSLContextParameters().createSSLContext(null);
+ options.setSSLClientProtocols(sslContext.createSSLEngine().getEnabledProtocols());
+ } catch (GeneralSecurityException e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ } catch (IOException e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ } finally {
+ if (webClient != null) {
+ webClient.close();
+ }
+ }
+
+ // disable default gzip compression, as htmlunit does not negotiate
+ // pages sent with no compression
+ new WebConnectionWrapper(webClient) {
+ @Override
+ public WebResponse getResponse(WebRequest request) throws IOException {
+ request.setAdditionalHeader(HttpHeaders.ACCEPT_ENCODING, "identity");
+ return super.getResponse(request);
+ }
+ };
+
+ // add HTTP proxy if set
+ final Map<String, Object> httpParams = configuration.getHttpParams();
+ if (httpParams != null && httpParams.get("http.route.default-proxy") != null) {
+ final HttpHost proxyHost = (HttpHost) httpParams.get("http.route.default-proxy");
+ final Boolean socksProxy = (Boolean) httpParams.get("http.route.socks-proxy");
+ final ProxyConfig proxyConfig = new ProxyConfig(proxyHost.getHostName(), proxyHost.getPort(),
+ socksProxy != null ? socksProxy : false);
+ options.setProxyConfig(proxyConfig);
+ }
+
+ // authorize application on user's behalf
+ try {
+
+ // generate anti-forgery token to prevent/detect CSRF attack
+ final String csrfToken = String.valueOf(new SecureRandom().nextLong());
+
+ final HtmlPage authPage = webClient.getPage(authorizationUrl(configuration.getClientId(), csrfToken));
+
+ // look for <div role="error_message">
+ final HtmlDivision div = authPage
+ .getFirstByXPath("//div[contains(concat(' ', @class, ' '), ' error_message ')]");
+ if (div != null) {
+ final String errorMessage = div.getTextContent().replaceAll("\\s+", " ")
+ .replaceAll(" Show Error Details", ":").trim();
+ throw new IllegalArgumentException("Error authorizing application: " + errorMessage);
+ }
+
+ // submit login credentials
+ final HtmlForm loginForm = authPage.getFormByName("login_form");
+ final HtmlTextInput login = loginForm.getInputByName("login");
+ login.setText(configuration.getUserName());
+ final HtmlPasswordInput password = loginForm.getInputByName("password");
+ password.setText(configuration.getUserPassword());
+ final HtmlSubmitInput submitInput = loginForm.getInputByName("login_submit");
+
+ // submit consent
+ final HtmlPage consentPage = submitInput.click();
+ final HtmlForm consentForm = consentPage.getFormByName("consent_form");
+ final HtmlButton consentAccept = consentForm.getButtonByName("consent_accept");
+
+ // disable redirect to avoid loading redirect URL
+ webClient.getOptions().setRedirectEnabled(false);
+
+ // validate CSRF and get authorization code
+ String redirectQuery;
+ try {
+ final Page redirectPage = consentAccept.click();
+ redirectQuery = redirectPage.getUrl().getQuery();
+ } catch (FailingHttpStatusCodeException e) {
+ // escalate non redirect errors
+ if (e.getStatusCode() != HttpStatus.SC_MOVED_TEMPORARILY) {
+ throw e;
+ }
+ final String location = e.getResponse().getResponseHeaderValue("Location");
+ redirectQuery = new URL(location).getQuery();
+ }
+ final Map<String, String> params = new HashMap<String, String>();
+ final Matcher matcher = QUERY_PARAM_PATTERN.matcher(redirectQuery);
+ while (matcher.find()) {
+ params.put(matcher.group(1), matcher.group(2));
+ }
+ final String state = params.get("state");
+ if (!csrfToken.equals(state)) {
+ throw new SecurityException("Invalid CSRF code!");
+ } else {
+
+ // get authorization code
+ final String authorizationCode = params.get("code");
+
+ return new BoxAPIConnection(configuration.getClientId(), configuration.getClientSecret(),
+ authorizationCode);
+ }
+
+ } catch (BoxAPIException e) {
+ throw new RuntimeCamelException(
+ String.format("Box API connection failed: API returned the error code %d\n\n%s",
+ e.getResponseCode(), e.getResponse()),
+ e);
+ } catch (Exception e) {
+ throw new RuntimeCamelException(String.format("Box API connection failed: %s", e.getMessage()), e);
+ }
+ }
+
+ public static BoxAPIConnection createAppUserAuthenticatedConnection(Box2Configuration configuration) {
+ // Create Encryption Preferences
+ JWTEncryptionPreferences encryptionPref = new JWTEncryptionPreferences();
+ encryptionPref.setPublicKeyID(configuration.getPublicKeyId());
+
+ try {
+ encryptionPref.setPrivateKey(new String(Files.readAllBytes(Paths.get(configuration.getPrivateKeyFile()))));
+ } catch (Exception e) {
+ throw new RuntimeCamelException("Box API connection failed: could not read privateKeyFile", e);
+ }
+
+ encryptionPref.setPrivateKeyPassword(configuration.getPrivateKeyPassword());
+ encryptionPref.setEncryptionAlgorithm(configuration.getEncryptionAlgorithm());
+
+ IAccessTokenCache accessTokenCache = configuration.getAccessTokenCache();
+ if (accessTokenCache == null) {
+ accessTokenCache = new InMemoryLRUAccessTokenCache(configuration.getMaxCacheEntries());
+ }
+
+ try {
+ return BoxDeveloperEditionAPIConnection.getAppUserConnection(configuration.getUserId(),
+ configuration.getClientId(), configuration.getClientSecret(), encryptionPref, accessTokenCache);
+ } catch (BoxAPIException e) {
+ throw new RuntimeCamelException(
+ String.format("Box API connection failed: API returned the error code %d\n\n%s",
+ e.getResponseCode(), e.getResponse()),
+ e);
+ }
+
+ }
+
+ public static BoxAPIConnection createAppEnterpriseAuthenticatedConnection(Box2Configuration configuration) {
+ // Create Encryption Preferences
+ JWTEncryptionPreferences encryptionPref = new JWTEncryptionPreferences();
+ encryptionPref.setPublicKeyID(configuration.getPublicKeyId());
+
+ try {
+ encryptionPref.setPrivateKey(new String(Files.readAllBytes(Paths.get(configuration.getPrivateKeyFile()))));
+ } catch (Exception e) {
+ throw new RuntimeCamelException("Box API connection failed: could not read privateKeyFile", e);
+ }
+
+ encryptionPref.setPrivateKeyPassword(configuration.getPrivateKeyPassword());
+ encryptionPref.setEncryptionAlgorithm(configuration.getEncryptionAlgorithm());
+
+ IAccessTokenCache accessTokenCache = configuration.getAccessTokenCache();
+ if (accessTokenCache == null) {
+ accessTokenCache = new InMemoryLRUAccessTokenCache(configuration.getMaxCacheEntries());
+ }
+
+ try {
+ return BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(configuration.getEnterpriseId(),
+ configuration.getClientId(), configuration.getClientSecret(), encryptionPref, accessTokenCache);
+ } catch (BoxAPIException e) {
+ throw new RuntimeCamelException(
+ String.format("Box API connection failed: API returned the error code %d\n\n%s",
+ e.getResponseCode(), e.getResponse()),
+ e);
+ }
+
+ }
+
+ public static String authorizationUrl(String clientId, String stateToken) {
+ return "https://account.box.com/api/oauth2/authorize?response_type=code&redirect_url=https%3A%2F%2Flocalhost%2F&client_id="
+ + clientId + "&state=" + stateToken;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
new file mode 100644
index 0000000..595be90
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2Constants.java
@@ -0,0 +1,32 @@
+/**
+ * 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.box2.internal;
+
+/**
+ * Constants for Box2 component.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public interface Box2Constants {
+
+ // suffix for parameters when passed as exchange header properties
+ String PROPERTY_PREFIX = "CamelBox2.";
+
+ // thread profile name for this component
+ String THREAD_PROFILE_NAME = "CamelBox2";
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
new file mode 100644
index 0000000..f242c96
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/java/org/apache/camel/component/box2/internal/Box2PropertiesHelper.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.box2.internal;
+
+import org.apache.camel.component.box2.Box2Configuration;
+import org.apache.camel.util.component.ApiMethodPropertiesHelper;
+
+/**
+ * Singleton {@link ApiMethodPropertiesHelper} for Box2 component.
+ *
+ * @author <a href="mailto:punkhornsw@gmail.com">William Collins</a>
+ *
+ */
+public final class Box2PropertiesHelper extends ApiMethodPropertiesHelper<Box2Configuration> {
+
+ private static Box2PropertiesHelper helper;
+
+ private Box2PropertiesHelper() {
+ super(Box2Configuration.class, Box2Constants.PROPERTY_PREFIX);
+ }
+
+ public static synchronized Box2PropertiesHelper getHelper() {
+ if (helper == null) {
+ helper = new Box2PropertiesHelper();
+ }
+ return helper;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/resources/META-INF/LICENSE.txt b/components/camel-box2/camel-box2-component/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/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/45335d1e/components/camel-box2/camel-box2-component/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/resources/META-INF/NOTICE.txt b/components/camel-box2/camel-box2-component/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/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/45335d1e/components/camel-box2/camel-box2-component/src/main/resources/META-INF/services/org/apache/camel/component/box2
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/main/resources/META-INF/services/org/apache/camel/component/box2 b/components/camel-box2/camel-box2-component/src/main/resources/META-INF/services/org/apache/camel/component/box2
new file mode 100644
index 0000000..9442073
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/main/resources/META-INF/services/org/apache/camel/component/box2
@@ -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.box2.Box2Component
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/AbstractBox2TestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/AbstractBox2TestSupport.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/AbstractBox2TestSupport.java
new file mode 100644
index 0000000..c29399d
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/AbstractBox2TestSupport.java
@@ -0,0 +1,82 @@
+/**
+ * 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.box2;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IntrospectionSupport;
+
+/**
+ * Abstract base class for Box2 Integration tests generated by Camel API component maven plugin.
+ */
+public class AbstractBox2TestSupport extends CamelTestSupport {
+
+ private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties";
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+
+ final CamelContext context = super.createCamelContext();
+
+ // read Box2 component configuration from TEST_OPTIONS_PROPERTIES
+ final Properties properties = new Properties();
+ try {
+ properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+ } catch (Exception e) {
+ throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()),
+ e);
+ }
+
+ Map<String, Object> options = new HashMap<String, Object>();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ options.put(entry.getKey().toString(), entry.getValue());
+ }
+
+ final Box2Configuration configuration = new Box2Configuration();
+ IntrospectionSupport.setProperties(configuration, options);
+
+ // add Box2Component to Camel context
+ final Box2Component component = new Box2Component(context);
+ component.setConfiguration(configuration);
+ context.addComponent("box2", component);
+
+ return context;
+ }
+
+ @Override
+ public boolean isCreateCamelContextPerClass() {
+ // only create the context once for this class
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers)
+ throws CamelExecutionException {
+ return (T) template().requestBodyAndHeaders(endpointUri, body, headers);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T requestBody(String endpoint, Object body) throws CamelExecutionException {
+ return (T) template().requestBody(endpoint, body);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/45335d1e/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CollaborationsManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CollaborationsManagerIntegrationTest.java b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CollaborationsManagerIntegrationTest.java
new file mode 100644
index 0000000..6470c20
--- /dev/null
+++ b/components/camel-box2/camel-box2-component/src/test/java/org/apache/camel/component/box2/Box2CollaborationsManagerIntegrationTest.java
@@ -0,0 +1,231 @@
+/**
+ * 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.box2;
+
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.box.sdk.BoxAPIConnection;
+import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxCollaboration;
+import com.box.sdk.BoxFolder;
+import com.box.sdk.BoxUser;
+import com.box.sdk.CreateUserParams;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.box2.internal.Box2ApiCollection;
+import org.apache.camel.component.box2.internal.Box2CollaborationsManagerApiMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for
+ * {@link org.apache.camel.component.box2.api.Box2CollaborationsManager} APIs.
+ */
+public class Box2CollaborationsManagerIntegrationTest extends AbstractBox2TestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Box2CollaborationsManagerIntegrationTest.class);
+ private static final String PATH_PREFIX = Box2ApiCollection.getCollection()
+ .getApiName(Box2CollaborationsManagerApiMethod.class).getName();
+ private static final String CAMEL_TEST_FOLDER = "CamelTestFolder";
+ private static final String CAMEL_TEST_COLLABORATOR_EMAIL = "cameltest@example.com";
+ private static final String CAMEL_TEST_COLLABORATOR_NAME = "cameltest";
+
+ private BoxFolder testFolder;
+ private BoxCollaboration testCollaboration;
+
+ @Test
+ public void testAddFolderCollaborationByEmail() throws Exception {
+ // delete collaborator created by setupTest
+ deleteTestCollaborator();
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is String
+ headers.put("CamelBox2.email", CAMEL_TEST_COLLABORATOR_EMAIL);
+ // parameter type is com.box.sdk.BoxCollaboration.Role
+ headers.put("CamelBox2.role", BoxCollaboration.Role.EDITOR);
+
+ final com.box.sdk.BoxCollaboration result = requestBodyAndHeaders("direct://ADDFOLDERCOLLABORATIONBYEMAIL",
+ testFolder.getID(), headers);
+
+ assertNotNull("addFolderCollaboration result", result);
+ LOG.debug("addFolderCollaboration: " + result);
+ }
+
+ @Test
+ public void testAddFolderCollaboration() throws Exception {
+ // delete collaborator created by setupTest
+ deleteTestCollaborator();
+ BoxUser user = null;
+ try {
+ // create test collaborator
+ CreateUserParams params = new CreateUserParams();
+ params.setSpaceAmount(1073741824); // 1 GB
+ user = BoxUser.createAppUser(getConnection(), CAMEL_TEST_COLLABORATOR_NAME, params).getResource();
+
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.folderId", testFolder.getID());
+ // parameter type is String
+ headers.put("CamelBox2.collaborator", user);
+ // parameter type is com.box.sdk.BoxCollaboration.Role
+ headers.put("CamelBox2.role", BoxCollaboration.Role.EDITOR);
+
+ final com.box.sdk.BoxCollaboration result = requestBodyAndHeaders("direct://ADDFOLDERCOLLABORATION",
+ testFolder.getID(), headers);
+ assertNotNull("addFolderCollaboration result", result);
+ LOG.debug("addFolderCollaboration: " + result);
+ } catch (BoxAPIException e) {
+ throw new RuntimeException(
+ String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
+ } finally {
+ if (user != null) {
+ user.delete(false, true);
+ }
+ }
+ }
+
+ @Test
+ public void testGetCollaborationInfo() throws Exception {
+ // using String message body for single parameter "collaborationId"
+ final com.box.sdk.BoxCollaboration.Info result = requestBody("direct://GETCOLLABORATIONINFO",
+ testCollaboration.getID());
+
+ assertNotNull("getCollaborationInfo result", result);
+ LOG.debug("getCollaborationInfo: " + result);
+ }
+
+ @Test
+ public void testGetFolderCollaborations() throws Exception {
+ // using String message body for single parameter "folderId"
+ @SuppressWarnings("rawtypes")
+ final java.util.Collection result = requestBody("direct://GETFOLDERCOLLABORATIONS", testFolder.getID());
+
+ assertNotNull("getFolderCollaborations result", result);
+ LOG.debug("getFolderCollaborations: " + result);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void testGetPendingCollaborations() throws Exception {
+ final java.util.Collection result = requestBody("direct://GETPENDINGCOLLABORATIONS", null);
+
+ assertNotNull("getPendingCollaborations result", result);
+ LOG.debug("getPendingCollaborations: " + result);
+ }
+
+ @Test
+ public void testUpdateCollaborationInfo() throws Exception {
+ final Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelBox2.collaborationId", testCollaboration.getID());
+ // parameter type is com.box.sdk.BoxCollaboration.Info
+
+ BoxCollaboration.Info info = testCollaboration.getInfo();
+ info.setRole(BoxCollaboration.Role.PREVIEWER);
+ headers.put("CamelBox2.info", info);
+
+ final com.box.sdk.BoxCollaboration result = requestBodyAndHeaders("direct://UPDATECOLLABORATIONINFO", null,
+ headers);
+
+ assertNotNull("updateCollaborationInfo result", result);
+ assertNotNull("updateCollaborationInfo info", result.getInfo());
+ assertEquals("updateCollaborationInfo info", BoxCollaboration.Role.PREVIEWER, result.getInfo().getRole());
+ LOG.debug("updateCollaborationInfo: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+
+ // test route for addFolderCollaboration
+ from("direct://ADDFOLDERCOLLABORATIONBYEMAIL")
+ .to("box2://" + PATH_PREFIX + "/addFolderCollaborationByEmail");
+
+ // test route for addFolderCollaboration
+ from("direct://ADDFOLDERCOLLABORATION").to("box2://" + PATH_PREFIX + "/addFolderCollaboration");
+
+ // test route for deleteCollaboration
+ from("direct://DELETECOLLABORATION")
+ .to("box2://" + PATH_PREFIX + "/deleteCollaboration?inBody=collaborationId");
+
+ // test route for getCollaborationInfo
+ from("direct://GETCOLLABORATIONINFO")
+ .to("box2://" + PATH_PREFIX + "/getCollaborationInfo?inBody=collaborationId");
+
+ // test route for getFolderCollaborations
+ from("direct://GETFOLDERCOLLABORATIONS")
+ .to("box2://" + PATH_PREFIX + "/getFolderCollaborations?inBody=folderId");
+
+ // test route for getPendingCollaborations
+ from("direct://GETPENDINGCOLLABORATIONS").to("box2://" + PATH_PREFIX + "/getPendingCollaborations");
+
+ // test route for updateCollaborationInfo
+ from("direct://UPDATECOLLABORATIONINFO").to("box2://" + PATH_PREFIX + "/updateCollaborationInfo");
+
+ }
+ };
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ createTestFolder();
+ createTestCollaborator();
+ }
+
+ @After
+ public void teardownTest() {
+ deleteTestCollaborator();
+ deleteTestFolder();
+ }
+
+ public BoxAPIConnection getConnection() {
+ Box2Endpoint endpoint = (Box2Endpoint) context()
+ .getEndpoint("box2://" + PATH_PREFIX + "/addFolderCollaboration");
+ return endpoint.getBoxConnection();
+ }
+
+ private void createTestFolder() throws FileNotFoundException {
+ BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
+ testFolder = rootFolder.createFolder(CAMEL_TEST_FOLDER).getResource();
+ }
+
+ private void deleteTestFolder() {
+ testFolder.delete(true);
+ testFolder = null;
+ }
+
+ private void createTestCollaborator() {
+ testCollaboration = testFolder.collaborate(CAMEL_TEST_COLLABORATOR_EMAIL, BoxCollaboration.Role.EDITOR)
+ .getResource();
+ }
+
+ private void deleteTestCollaborator() {
+ if (testCollaboration != null) {
+ testCollaboration.delete();
+ testCollaboration = null;
+ }
+ }
+
+}