agave-common/common-core/src/main/java/org/iplantc/service/common/persistence/TenancyHelper.java
/**
     * Adjusts the default API resource URLs to tenant-specific URLs given
     * in the tenants table in the db. This should be called when there
     * is no tenant associated with a session. ie. by worker processes.
     *
     * @param url      default url to resolve
     * @param tenantId the id of the tenant to resolve.
     * @return string tenant-specific url for the given resource
     */
Adjusts the default API resource URLs to tenant-specific URLs given
in the tenants table in the db. This should be called when there
is no tenant associated with a session. ie. by worker processes.

@param url      default url to resolve
@param tenantId the id of the tenant to resolve.
@return string tenant-specific url for the given resource
Adjusts the default API resource URLs to tenant - specific URLs given in the tenants table in the db . This should be called when there is no tenant associated with a session . ie . by worker processes . @param url default url to resolve @param tenantId the id of the tenant to resolve . @return string tenant - specific url for the given resource
public static String resolveURLToCurrentTenant(String url, String tenantId) {
        if (StringUtils.isEmpty(tenantId)) {
            tenantId = TenancyHelper.getCurrentTenantId();
        }
        Tenant tenant;
        try {
            tenant = _getTenant(tenantId);
            if (tenant == null) {
                return url;
            } else {
                String resolvedUrl = StringUtils.substringAfter(url, "://");
                boolean isRealtimeUrl = StringUtils.startsWith(resolvedUrl, "realtime.");
                resolvedUrl = StringUtils.substringAfter(resolvedUrl, "/");
                if (isRealtimeUrl) {
                    resolvedUrl = StringUtils.replace(tenant.getBaseUrl(), "://", "://realtime.");
                } else {
                    resolvedUrl = tenant.getBaseUrl() + resolvedUrl;
                }
                return resolvedUrl;
            }
        } catch (TenantException e) {
            log.error("Failed to resolve current tenant " + tenantId + " from db", e);
            return url;
        }
    }
public static String resolveURLToCurrentTenant ( String url , String tenantId ) { if ( StringUtils . isEmpty ( tenantId ) ) { tenantId = TenancyHelper . getCurrentTenantId ( ) ; } Tenant tenant ; try { tenant = _getTenant ( tenantId ) ; if ( tenant == null ) { return url ; } else { String resolvedUrl = StringUtils . substringAfter ( url , "://" ) ; boolean isRealtimeUrl = StringUtils . startsWith ( resolvedUrl , "realtime." ) ; resolvedUrl = StringUtils . substringAfter ( resolvedUrl , "/" ) ; if ( isRealtimeUrl ) { resolvedUrl = StringUtils . replace ( tenant . getBaseUrl ( ) , "://" , "://realtime." ) ; } else { resolvedUrl = tenant . getBaseUrl ( ) + resolvedUrl ; } return resolvedUrl ; } } catch ( TenantException e ) { log . error ( "Failed to resolve current tenant " + tenantId + " from db" , e ) ; return url ; } }
Adjusts the default API resource URLs to tenant-specific URLs given
 in the tenants table in the db.
Adjusts the default API resource URLs to tenant - specific URLs given in the tenants table in the db .
// returning the url if no tenant is found is probably a // tenancy violation if this is called in situations where // the tenant is not known.