Example usage for org.springframework.util Assert hasLength

List of usage examples for org.springframework.util Assert hasLength

Introduction

In this page you can find the example usage for org.springframework.util Assert hasLength.

Prototype

public static void hasLength(@Nullable String text, Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given String is not empty; that is, it must not be null and not the empty String.

Usage

From source file:org.esco.portlets.news.dao.EscoUserDaoImpl.java

/**
 * @throws Exception/*from   ww  w.j a va  2 s  .c  o  m*/
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 */
public void afterPropertiesSet() throws Exception {
    Assert.notNull(this.ldapUserService,
            "The property ldapUserService in class " + this.getClass().getSimpleName() + " must not be null.");
    Assert.notNull(this.userDao,
            "The property userDao in class " + this.getClass().getSimpleName() + " must not be null.");
    Assert.hasLength(this.displayName, "The property displayName in class " + this.getClass().getSimpleName()
            + " must not be null or empty.");
    Assert.hasLength(this.mail,
            "The property mail in class " + this.getClass().getSimpleName() + " must not be null or empty.");
}

From source file:org.esco.portlets.news.utils.ListEditor.java

/**
 * @throws Exception//  w  w  w.  ja v  a2  s  .c  o m
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 */
public void afterPropertiesSet() throws Exception {
    Assert.hasLength(getProperty(), "The property property in class " + this.getClass().getSimpleName()
            + " must not be null and not empty.");

    this.setAsText(getProperty());
}

From source file:org.grails.gsp.GroovyPageResourceLoader.java

@Override
public Resource getResource(String location) {
    Assert.hasLength(location, "Argument [location] cannot be null or blank");

    Resource resource = super.getResource(location);

    if (LOG.isDebugEnabled()) {
        LOG.debug("Resolved GSP location [" + location + "] to resource [" + resource + "] (exists? ["
                + resource.exists() + "]) using base resource [" + localBaseResource + "]");
    }//from  w  ww. j  av  a 2s.c  o  m
    return resource;
}

From source file:org.grails.gsp.GroovyPagesTemplateEngine.java

/**
 * Creates a Template using the given text for the Template and the given name. The name
 * of the template is required//w  ww.  j  a v a 2 s .com
 *
 * @param txt The URI of the page to create the template for
 * @param pageName The name of the page being parsed
 *
 * @return The Template instance
 * @throws CompilationFailedException
 * @throws IOException Thrown if an IO exception occurs creating the Template
 */
public Template createTemplate(String txt, String pageName) throws IOException {
    Assert.hasLength(txt, "Argument [txt] cannot be null or blank");
    Assert.hasLength(pageName, "Argument [pageName] cannot be null or blank");

    return createTemplate(new ByteArrayResource(txt.getBytes("UTF-8"), pageName), pageName, pageName != null);
}

From source file:org.kuali.continuity.security.KualiAuthenticationProcessingFilterEntryPoint.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(super.getLoginFormUrl(), "loginFormUrl must be specified");
    Assert.notNull(portMapper, "portMapper must be specified");
    Assert.notNull(portResolver, "portResolver must be specified");
    Assert.hasLength(getDefaultLoginFormUrl(), "defaultLoginFormUrl must be specified");
    Assert.hasLength(getLogoutUrl(), "logoutUrl must be specified");
}

From source file:org.kuali.rice.krad.uif.service.impl.ViewDictionaryServiceImpl.java

/**
 * @see org.kuali.rice.krad.uif.service.ViewDictionaryService#getViewSessionPolicy(java.lang.String)
 *///  www . ja v a 2  s  . c  o  m
public ViewSessionPolicy getViewSessionPolicy(String viewId) {
    Assert.hasLength(viewId, "view id is required for retrieving the view session policy");

    ViewSessionPolicy viewSessionPolicy = null;

    View view = getDataDictionary().getImmutableViewById(viewId);
    if (view != null) {
        viewSessionPolicy = view.getSessionPolicy();
    }

    return viewSessionPolicy;
}

From source file:org.kuali.rice.krad.uif.service.impl.ViewDictionaryServiceImpl.java

/**
 * @see org.kuali.rice.krad.uif.service.ViewDictionaryService#isSessionStorageEnabled(java.lang.String)
 *///from  ww w .  j ava 2  s .  c  om
public boolean isSessionStorageEnabled(String viewId) {
    Assert.hasLength(viewId, "view id is required for retrieving session indicator");

    boolean sessionStorageEnabled = false;

    View view = getDataDictionary().getImmutableViewById(viewId);
    if (view != null) {
        sessionStorageEnabled = view.isPersistFormToSession();
    }

    return sessionStorageEnabled;
}

From source file:org.kuali.rice.krad.uif.util.ScriptUtils.java

/**
 * Builds the JavaScript string for binding the given script to the component with the given id
 * for the given event name (using jQuery)
 * /*from   w w  w . ja  v  a 2 s  . co m*/
 * @param id id of the element to handle the event for
 * @param eventName name of the event the script will handle
 * @param eventScript script to be executed when the event is thrown, if blank an empty string
 *        will be returned
 * @return JS event handler script
 */
public static String buildEventHandlerScript(String id, String eventName, String eventScript) {
    if (StringUtils.isBlank(eventScript)) {
        return "";
    }

    Assert.hasLength(id, "Id is required for building event handler script");
    Assert.hasLength(eventName, "Event name is required for building event handler script");

    StringBuffer sb = new StringBuffer();

    sb.append("jQuery('#" + id + "').on('");
    sb.append(eventName);
    sb.append("', function(e) {");
    sb.append(eventScript);
    sb.append("}); ");

    return sb.toString();
}

From source file:org.kuali.rice.krad.util.KRADUtils.java

/**
 * Helper method for building a URL that will invoke the given controller and render the given
 * KRAD view/*from  w  ww  . j  a va  2 s.c  o  m*/
 *
 * @param baseUrl base url (domain, port)
 * @param controllerMapping mapping for the controller that should be invoked
 * @param viewId id for the view that should be rendered
 * @return url for invoking the view
 */
public static String buildViewUrl(String baseUrl, String controllerMapping, String viewId) {
    Assert.hasLength(baseUrl, "base url is null or empty");
    Assert.hasLength(controllerMapping, "controller mapping is null or empty");
    Assert.hasLength(viewId, "view id is null or empty");

    StringBuffer url = new StringBuffer();

    url.append(baseUrl);

    if (!baseUrl.endsWith("/")) {
        url.append("/");
    }

    url.append(controllerMapping);

    url.append("?");
    url.append(UifParameters.VIEW_ID);
    url.append("=");
    url.append(viewId);

    return url.toString();
}

From source file:org.lexevs.dao.database.schemaversion.LexGridSchemaVersion.java

/**
 * Parses the string to version.// w w  w .j  av a 2 s .c  o  m
 * 
 * Assumes a String formatted as "'major-version'.'minor-version'".
 * 
 * @param version the version
 * 
 * @return the database version
 */
public static LexGridSchemaVersion parseStringToVersion(String version) {
    Assert.hasLength(version, "Version must not be blank.");

    String[] parsedVersion = StringUtils.split(version, ".");

    LexGridSchemaVersion dbVersion = new LexGridSchemaVersion();
    dbVersion.setMajorVersion(Integer.valueOf(parsedVersion[0]));
    dbVersion.setMinorVersion(Integer.valueOf(parsedVersion[1]));

    return dbVersion;
}