camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-11781: Support for BoxUser.moveFolderToUser in camel-box.
Date Mon, 18 Sep 2017 13:36:03 GMT
Repository: camel
Updated Branches:
  refs/heads/master 28ae19d86 -> 19828ff57


CAMEL-11781: Support for BoxUser.moveFolderToUser in camel-box.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/19828ff5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/19828ff5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/19828ff5

Branch: refs/heads/master
Commit: 19828ff5734bbafd63c6f99d828fac67fabe141a
Parents: 28ae19d
Author: Fredrik Jönsson <fjo@kth.se>
Authored: Mon Sep 18 14:10:13 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Sep 18 15:34:49 2017 +0200

----------------------------------------------------------------------
 .../component/box/api/BoxUsersManager.java      | 27 ++++++++++++++++++++
 .../src/main/docs/box-component.adoc            |  2 ++
 .../box/BoxUsersManagerIntegrationTest.java     | 20 +++++++++++++++
 3 files changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/19828ff5/components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxUsersManager.java
----------------------------------------------------------------------
diff --git a/components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxUsersManager.java
b/components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxUsersManager.java
index dda4821..b496828 100644
--- a/components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxUsersManager.java
+++ b/components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxUsersManager.java
@@ -22,6 +22,7 @@ import java.util.List;
 
 import com.box.sdk.BoxAPIConnection;
 import com.box.sdk.BoxAPIException;
+import com.box.sdk.BoxFolder;
 import com.box.sdk.BoxUser;
 import com.box.sdk.CreateUserParams;
 import com.box.sdk.EmailAlias;
@@ -330,4 +331,30 @@ public class BoxUsersManager {
         }
     }
 
+    /**
+     * Move root folder for specified user to current user.
+     *
+     * @param userId
+     *            - the id of user.
+     * @param sourceUserId
+     *            - the user id of the user whose files will be the source for this operation.
+     */
+    public BoxFolder.Info moveFolderToUser(String userId, String sourceUserId) {
+        try {
+            LOG.debug("Moving root folder for user(id=" + sourceUserId + ") to user(id="
+ userId + ")");
+            if (userId == null) {
+                throw new IllegalArgumentException("Parameter 'userId' can not be null");
+            }
+            if (sourceUserId == null) {
+                throw new IllegalArgumentException("Parameter 'sourceUserId' can not be null");
+            }
+
+            BoxUser user = new BoxUser(boxConnection, userId);
+
+            return user.moveFolderToUser(sourceUserId);
+        } 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/19828ff5/components/camel-box/camel-box-component/src/main/docs/box-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-box/camel-box-component/src/main/docs/box-component.adoc b/components/camel-box/camel-box-component/src/main/docs/box-component.adoc
index ce3a621..e2a52dc 100644
--- a/components/camel-box/camel-box-component/src/main/docs/box-component.adoc
+++ b/components/camel-box/camel-box-component/src/main/docs/box-component.adoc
@@ -652,6 +652,8 @@ follows:
 |getUserInfo |info  | userId |com.box.sdk.BoxUser.Info
 
 |updateUserInfo |updateInfo |userId, info |com.box.sdk.BoxUser
+
+|moveFolderToUser |- |userId, sourceUserId |com.box.sdk.BoxFolder.Info
 |=======================================================================
 
 URI Options for _users_

http://git-wip-us.apache.org/repos/asf/camel/blob/19828ff5/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java
b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java
index ad59b21..6e50cc3 100644
--- a/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java
+++ b/components/camel-box/camel-box-component/src/test/java/org/apache/camel/component/box/BoxUsersManagerIntegrationTest.java
@@ -51,6 +51,8 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport
{
     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 static final String CAMEL_TEST_CREATE_ENTERPRISE_USER2_NAME = "gregory";
+    private static final String CAMEL_TEST_CREATE_ENTERPRISE_USER2_LOGIN = "gregory@example.com";
 
     private BoxUser testUser;
 
@@ -240,6 +242,22 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport
{
         }
     }
 
+    @Test
+    public void testmMoveFolderToUser() throws Exception {
+        BoxUser.Info user1 = BoxUser.createEnterpriseUser(getConnection(),
+                CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN, CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME);
+        BoxUser.Info user2 = BoxUser.createEnterpriseUser(getConnection(),
+                CAMEL_TEST_CREATE_ENTERPRISE_USER2_LOGIN, CAMEL_TEST_CREATE_ENTERPRISE_USER2_NAME);
+
+        final Map<String, Object> headers = new HashMap<String, Object>();
+        // parameter type is String
+        headers.put("CamelBox.userId", user1.getID());
+        headers.put("CamelBox.sourceUserId", user2.getID());
+
+        final com.box.sdk.BoxFolder.Info result = requestBodyAndHeaders("direct://MOVEFOLDERTOUSER",
null, headers);
+        assertNotNull("moveFolderToUser result", result);
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -275,6 +293,8 @@ public class BoxUsersManagerIntegrationTest extends AbstractBoxTestSupport
{
                 // test route for updateUserInfo
                 from("direct://UPDATEUSERINFO").to("box://" + PATH_PREFIX + "/updateUserInfo");
 
+                // test route for moveFolderToUser
+                from("direct://MOVEFOLDERTOUSER").to("box://" + PATH_PREFIX + "/moveFolderToUser");
             }
         };
     }


Mime
View raw message