Search in sources :

Example 1 with ObjectUserSecretKeys

use of com.emc.ecs.management.entity.ObjectUserSecretKeys in project ecs-dashboard by carone1.

the class ManagementClient method getHostsInVDC.

/**
 * Retrieve S3 uid and secret keys
 * @param uid - user id
 * @param namespace - namespace
 * @return ObjectUserSecretKeysResponse
 */
public ObjectUserSecretKeys getHostsInVDC(String uid, String namespace) {
    String authToken = getAuthToken();
    WebResource mgmtResource = this.mgmtClient.resource(uri);
    String restPath = REST_GET_KEYS_FOR_USERS + uid + "/" + namespace;
    // get keys for user
    WebResource getUserSecretKeysResource = mgmtResource.path(restPath);
    ObjectUserSecretKeys userSecretKeys = null;
    try {
        userSecretKeys = getUserSecretKeysResource.header(X_SDS_AUTH_TOKEN, authToken).get(ObjectUserSecretKeys.class);
    } catch (UniformInterfaceException ex) {
        // The workaround is just to generate an empty reponse
        if (ex.getResponse().getStatusInfo().getStatusCode() == Response.Status.NOT_FOUND.getStatusCode()) {
            userSecretKeys = new ObjectUserSecretKeys();
        }
    }
    return userSecretKeys;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) WebResource(com.sun.jersey.api.client.WebResource) ObjectUserSecretKeys(com.emc.ecs.management.entity.ObjectUserSecretKeys)

Example 2 with ObjectUserSecretKeys

use of com.emc.ecs.management.entity.ObjectUserSecretKeys in project ecs-dashboard by carone1.

the class BillingBO method getObjectUserSecretKeys.

// ================================
// Public methods
// ================================
/**
 * Retrieve Object uid and secret keys
 * @return ObjectUserDetails
 */
public List<ObjectUserDetails> getObjectUserSecretKeys() {
    List<ObjectUserDetails> userDetails = new ArrayList<ObjectUserDetails>();
    // Collect all uids in order to collect secret keys after
    List<ObjectUser> objectUserList = new ArrayList<ObjectUser>();
    // first batch
    ObjectUsersRequest objectUsersRequest = new ObjectUsersRequest();
    ObjectUsers objectUsersResult = client.getObjectUsersUid(objectUsersRequest);
    if (objectUsersResult != null) {
        if (objectUsersResult.getBlobUser() != null) {
            objectUserList.addAll(objectUsersResult.getBlobUser());
        }
        objectUsersRequest.setMarker(objectUsersResult.getNextMarker());
        // Subsequent batches
        while (objectUsersResult.getNextMarker() != null) {
            objectUsersResult = client.getObjectUsersUid(objectUsersRequest);
            if (objectUsersResult != null) {
                objectUserList.addAll(objectUsersResult.getBlobUser());
                objectUsersRequest.setMarker(objectUsersResult.getNextMarker());
            } else {
                break;
            }
        }
    }
    // Collect secret keys
    for (ObjectUser objectUser : objectUserList) {
        ObjectUserSecretKeys objectUserSecretKeys = client.getObjectUserSecretKeys(objectUser.getUserId().toString(), objectUser.getNamespace().toString());
        if (objectUserSecretKeys != null) {
            userDetails.add(new ObjectUserDetails(objectUser, objectUserSecretKeys));
        }
    }
    return userDetails;
}
Also used : ObjectUsers(com.emc.ecs.management.entity.ObjectUsers) ObjectUserDetails(com.emc.ecs.management.entity.ObjectUserDetails) ObjectUser(com.emc.ecs.management.entity.ObjectUser) ObjectUsersRequest(com.emc.ecs.management.entity.ObjectUsersRequest) ArrayList(java.util.ArrayList) ObjectUserSecretKeys(com.emc.ecs.management.entity.ObjectUserSecretKeys)

Example 3 with ObjectUserSecretKeys

use of com.emc.ecs.management.entity.ObjectUserSecretKeys in project ecs-dashboard by carone1.

the class ManagementClient method getObjectUserSecretKeys.

/**
 * Retrieve S3 uid and secret keys
 * @param uid - user id
 * @param namespace - namespace
 * @return ObjectUserSecretKeysResponse
 */
public ObjectUserSecretKeys getObjectUserSecretKeys(String uid, String namespace) {
    String authToken = getAuthToken();
    WebResource mgmtResource = this.mgmtClient.resource(uri);
    String restPath = REST_GET_KEYS_FOR_USERS + uid + "/" + namespace;
    // get keys for user
    WebResource getUserSecretKeysResource = mgmtResource.path(restPath);
    ObjectUserSecretKeys userSecretKeys = null;
    try {
        userSecretKeys = getUserSecretKeysResource.header(X_SDS_AUTH_TOKEN, authToken).get(ObjectUserSecretKeys.class);
    } catch (UniformInterfaceException ex) {
        // The workaround is just to generate an empty reponse
        if (ex.getResponse().getStatusInfo().getStatusCode() == Response.Status.NOT_FOUND.getStatusCode()) {
            userSecretKeys = new ObjectUserSecretKeys();
        }
    }
    return userSecretKeys;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) WebResource(com.sun.jersey.api.client.WebResource) ObjectUserSecretKeys(com.emc.ecs.management.entity.ObjectUserSecretKeys)

Aggregations

ObjectUserSecretKeys (com.emc.ecs.management.entity.ObjectUserSecretKeys)3 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 WebResource (com.sun.jersey.api.client.WebResource)2 ObjectUser (com.emc.ecs.management.entity.ObjectUser)1 ObjectUserDetails (com.emc.ecs.management.entity.ObjectUserDetails)1 ObjectUsers (com.emc.ecs.management.entity.ObjectUsers)1 ObjectUsersRequest (com.emc.ecs.management.entity.ObjectUsersRequest)1 ArrayList (java.util.ArrayList)1