Search in sources :

Example 31 with BoxAPIException

use of com.box.sdk.BoxAPIException in project camel by apache.

the class BoxTasksManager method getTaskAssignmentInfo.

/**
     * 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);
    }
}
Also used : BoxTaskAssignment(com.box.sdk.BoxTaskAssignment) BoxAPIException(com.box.sdk.BoxAPIException)

Example 32 with BoxAPIException

use of com.box.sdk.BoxAPIException in project camel by apache.

the class BoxCollaborationsManager method getFolderCollaborations.

/**
     * 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);
    }
}
Also used : BoxAPIException(com.box.sdk.BoxAPIException) BoxFolder(com.box.sdk.BoxFolder)

Example 33 with BoxAPIException

use of com.box.sdk.BoxAPIException in project camel by apache.

the class BoxCollaborationsManager method getCollaborationInfo.

/**
     * 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);
    }
}
Also used : BoxAPIException(com.box.sdk.BoxAPIException) BoxCollaboration(com.box.sdk.BoxCollaboration)

Example 34 with BoxAPIException

use of com.box.sdk.BoxAPIException in project camel by apache.

the class BoxUsersManagerIntegrationTest method testDeleteUserEmailAlias.

@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("CamelBox.userId", testUser.getID());
    // parameter type is String
    headers.put("CamelBox.emailAliasId", emailAlias.getID());
    requestBodyAndHeaders("direct://DELETEUSEREMAILALIAS", null, headers);
    assertNotNull("deleteUserEmailAlias email aliases", testUser.getEmailAliases());
    assertEquals("deleteUserEmailAlias email aliases", 0, testUser.getEmailAliases().size());
}
Also used : EmailAlias(com.box.sdk.EmailAlias) HashMap(java.util.HashMap) BoxAPIException(com.box.sdk.BoxAPIException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with BoxAPIException

use of com.box.sdk.BoxAPIException in project camel by apache.

the class BoxCollaborationsManager method updateCollaborationInfo.

/**
     * 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);
    }
}
Also used : BoxAPIException(com.box.sdk.BoxAPIException) BoxCollaboration(com.box.sdk.BoxCollaboration)

Aggregations

BoxAPIException (com.box.sdk.BoxAPIException)74 BoxFile (com.box.sdk.BoxFile)24 BoxFolder (com.box.sdk.BoxFolder)17 BoxUser (com.box.sdk.BoxUser)8 BoxTask (com.box.sdk.BoxTask)6 BoxCollaboration (com.box.sdk.BoxCollaboration)4 BoxComment (com.box.sdk.BoxComment)4 BoxGroup (com.box.sdk.BoxGroup)4 BoxFileVersion (com.box.sdk.BoxFileVersion)3 BoxGroupMembership (com.box.sdk.BoxGroupMembership)3 FailingHttpStatusCodeException (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException)3 IOException (java.io.IOException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Test (org.junit.Test)3 BoxItem (com.box.sdk.BoxItem)2 BoxTaskAssignment (com.box.sdk.BoxTaskAssignment)2 IAccessTokenCache (com.box.sdk.IAccessTokenCache)2