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);
}
}
Aggregations