use of com.box.sdk.BoxUser in project camel by apache.
the class BoxUsersManager method getUserEmailAlias.
/**
* 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);
}
}
use of com.box.sdk.BoxUser in project camel by apache.
the class BoxUsersManager method deleteUserEmailAlias.
/**
* 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);
}
}
use of com.box.sdk.BoxUser in project camel by apache.
the class BoxCollaborationsManagerIntegrationTest method testAddFolderCollaboration.
@Test
public void testAddFolderCollaboration() throws Exception {
// delete collaborator created by setupTest
deleteTestCollaborator();
BoxUser user = null;
try {
// create test collaborator
CreateUserParams params = new CreateUserParams();
// 1 GB
params.setSpaceAmount(1073741824);
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("CamelBox.folderId", testFolder.getID());
// parameter type is String
headers.put("CamelBox.collaborator", user);
// parameter type is com.box.sdk.BoxCollaboration.Role
headers.put("CamelBox.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);
}
}
}
Aggregations