agave-common/common-core/src/main/java/org/iplantc/service/common/dao/TenantDao.java
/**
	 * Looks up a tenant by the {@link Tenant#getBaseUrl()} hostname.
	 * @param baseUrl the tenant url to look up
	 * @return the matching tenant or null if no match
	 * @throws TenantException if unable to query
	 */
Looks up a tenant by the  Tenant#getBaseUrl() hostname.
@param baseUrl the tenant url to look up
@return the matching tenant or null if no match
@throws TenantException if unable to query
Looks up a tenant by the Tenant#getBaseUrl () hostname . @param baseUrl the tenant url to look up @return the matching tenant or null if no match @throws TenantException if unable to query
public Tenant findByBaseUrl(String baseUrl)
	throws TenantException
	{
		baseUrl = StringUtils.trimToNull(baseUrl);
		if (baseUrl == null) return null;
		try
		{
			Session session = getSession();
			session.clear();
			Tenant tenant = (Tenant) session.createQuery("from Tenant t where t.baseUrl like :httpUrl or t.baseUrl like :sslUrl")
					.setString("httpUrl",  "http://" + baseUrl + "%")
					.setString("sslUrl",  "https://" + baseUrl + "%")
					.setMaxResults(1)
					.uniqueResult();
			session.flush();
			return tenant;
		}
		catch (HibernateException ex)
		{
			throw new TenantException(ex);
		}
		finally {
			try { HibernateUtil.commitTransaction();} catch (Exception ignored) {}
		}
	}
public Tenant findByBaseUrl ( String baseUrl ) throws TenantException { baseUrl = StringUtils . trimToNull ( baseUrl ) ; if ( baseUrl == null ) return null ; try { Session session = getSession ( ) ; session . clear ( ) ; Tenant tenant = ( Tenant ) session . createQuery ( "from Tenant t where t.baseUrl like :httpUrl or t.baseUrl like :sslUrl" ) . setString ( "httpUrl" , "http://" + baseUrl + "%" ) . setString ( "sslUrl" , "https://" + baseUrl + "%" ) . setMaxResults ( 1 ) . uniqueResult ( ) ; session . flush ( ) ; return tenant ; } catch ( HibernateException ex ) { throw new TenantException ( ex ) ; } finally { try { HibernateUtil . commitTransaction ( ) ; } catch ( Exception ignored ) { } } }
Looks up a tenant by the {@link Tenant#getBaseUrl()} hostname.
Looks up a tenant by the { @link Tenant#getBaseUrl () } hostname .
// clean up the hostname in clase it has spaces before or affer // empty or null hostname has no match. return null