Search in sources :

Example 1 with ObjectNamespaceList

use of com.emc.storageos.model.object.ObjectNamespaceList in project coprhd-controller by CoprHD.

the class ObjectNamespaceService method getObjectNamespaces.

/**
 * Get IDs of all object storage namespaces
 *
 * @brief List namespace names and IDs
 * @return object namespace list
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN, Role.SECURITY_ADMIN })
public ObjectNamespaceList getObjectNamespaces() {
    _log.info("Getting namespaces from all object storage systesm");
    ObjectNamespaceList objNamespaceList = new ObjectNamespaceList();
    List<URI> ids = _dbClient.queryByType(ObjectNamespace.class, true);
    for (URI id : ids) {
        ObjectNamespace objNamespace = _dbClient.queryObject(ObjectNamespace.class, id);
        if (objNamespace != null) {
            objNamespaceList.getNamespaces().add(toNamedRelatedResource(objNamespace, objNamespace.getNativeGuid()));
        }
    }
    return objNamespaceList;
}
Also used : ObjectNamespaceList(com.emc.storageos.model.object.ObjectNamespaceList) URI(java.net.URI) ObjectNamespace(com.emc.storageos.db.client.model.ObjectNamespace) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ObjectNamespaceList

use of com.emc.storageos.model.object.ObjectNamespaceList in project coprhd-controller by CoprHD.

the class TenantUtils method getUnmappedNamespace.

public static List<StringOption> getUnmappedNamespace() {
    ObjectNamespaceList objNamespaceList = getViprClient().objectNamespace().getObjectNamespaces();
    List<StringOption> namespaceOptions = Lists.newArrayList();
    List<NamedRelatedResourceRep> ObjNamedList = objNamespaceList.getNamespaces();
    for (NamedRelatedResourceRep namedRes : ObjNamedList) {
        URI uri = namedRes.getId();
        ObjectNamespaceRestRep objNs = getViprClient().objectNamespace().getObjectNamespace(uri);
        if (objNs != null && objNs.getMapped() == false) {
            // only unmapped namespaces to be added to list
            namespaceOptions.add(new StringOption(objNs.getNativeId(), objNs.getNsName()));
        }
    }
    return namespaceOptions;
}
Also used : ObjectNamespaceList(com.emc.storageos.model.object.ObjectNamespaceList) ObjectNamespaceRestRep(com.emc.storageos.model.object.ObjectNamespaceRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 3 with ObjectNamespaceList

use of com.emc.storageos.model.object.ObjectNamespaceList in project coprhd-controller by CoprHD.

the class StorageSystemService method getAllObjectNamespaces.

/**
 * Gets all object namespaces for the registered storage system with the passed id
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief List object storage namespaces
 * @return A reference to a ObjectNamespaceList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/object-namespaces")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ObjectNamespaceList getAllObjectNamespaces(@PathParam("id") URI id) {
    // Make sure storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    if (!StorageSystem.Type.ecs.toString().equals(system.getSystemType())) {
        throw APIException.badRequests.invalidParameterURIInvalid("id", id);
    }
    ObjectNamespaceList objNamespaceList = new ObjectNamespaceList();
    URIQueryResultList objNamespaceURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceObjectNamespaceConstraint(id), objNamespaceURIs);
    Iterator<URI> ecsNsIter = objNamespaceURIs.iterator();
    while (ecsNsIter.hasNext()) {
        URI nsURI = ecsNsIter.next();
        ObjectNamespace namespace = _dbClient.queryObject(ObjectNamespace.class, nsURI);
        if (namespace != null && !namespace.getInactive()) {
            objNamespaceList.getNamespaces().add(toNamedRelatedResource(namespace, namespace.getNativeGuid()));
        }
    }
    return objNamespaceList;
}
Also used : ObjectNamespaceList(com.emc.storageos.model.object.ObjectNamespaceList) URI(java.net.URI) ObjectNamespace(com.emc.storageos.db.client.model.ObjectNamespace) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

ObjectNamespaceList (com.emc.storageos.model.object.ObjectNamespaceList)3 URI (java.net.URI)3 ObjectNamespace (com.emc.storageos.db.client.model.ObjectNamespace)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 ObjectNamespaceRestRep (com.emc.storageos.model.object.ObjectNamespaceRestRep)1 Path (javax.ws.rs.Path)1