Search in sources :

Example 1 with TenantResource

use of com.emc.storageos.db.client.model.TenantResource in project coprhd-controller by CoprHD.

the class BasePermissionsHelper method getTenantResourceTenantId.

/**
 * Get tenant id from a project id retrieved from uri
 *
 * @param childId
 * @return
 */
public URI getTenantResourceTenantId(String childId) {
    if (childId == null) {
        return null;
    }
    try {
        URI id = URI.create(childId);
        TenantResource ret = null;
        if (URIUtil.isType(id, Host.class)) {
            ret = getObjectById(id, Host.class);
        } else if (URIUtil.isType(id, VcenterDataCenter.class)) {
            ret = getObjectById(id, VcenterDataCenter.class);
        } else if (URIUtil.isType(id, Cluster.class)) {
            ret = getObjectById(id, Cluster.class);
        } else if (URIUtil.isType(id, Initiator.class)) {
            Initiator ini = getObjectById(id, Initiator.class);
            if (ini.getHost() != null) {
                ret = getObjectById(ini.getHost(), Host.class);
            }
        } else if (URIUtil.isType(id, IpInterface.class)) {
            IpInterface hostIf = getObjectById(id, IpInterface.class);
            if (hostIf.getHost() != null) {
                ret = getObjectById(hostIf.getHost(), Host.class);
            }
        } else {
            throw APIException.badRequests.theURIIsNotOfType(id, TenantResource.class.getName());
        }
        if (ret == null) {
            throw FatalDatabaseException.fatals.unableToFindEntity(id);
        }
        return ret.getTenant();
    } catch (DatabaseException ex) {
        throw SecurityException.fatals.failedGettingTenant(ex);
    }
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) TenantResource(com.emc.storageos.db.client.model.TenantResource) Initiator(com.emc.storageos.db.client.model.Initiator) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FatalDatabaseException(com.emc.storageos.db.exceptions.FatalDatabaseException)

Aggregations

Cluster (com.emc.storageos.db.client.model.Cluster)1 Host (com.emc.storageos.db.client.model.Host)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 IpInterface (com.emc.storageos.db.client.model.IpInterface)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 TenantResource (com.emc.storageos.db.client.model.TenantResource)1 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 FatalDatabaseException (com.emc.storageos.db.exceptions.FatalDatabaseException)1 URI (java.net.URI)1