Example usage for org.springframework.util StringUtils hasText

List of usage examples for org.springframework.util StringUtils hasText

Introduction

In this page you can find the example usage for org.springframework.util StringUtils hasText.

Prototype

public static boolean hasText(@Nullable String str) 

Source Link

Document

Check whether the given String contains actual text.

Usage

From source file:com.afousan.controller.RetwisController.java

@RequestMapping("/signUp")
public String signUp(String name, String pass, String pass2, Model model, HttpServletResponse response) {
    if (retwis.isUserValid(name)) {
        model.addAttribute("errorduplicateuser", Boolean.TRUE);
        return "signin";
    }/*from ww w  .  j ava  2  s.  c om*/

    if (!StringUtils.hasText(pass) || !StringUtils.hasText(pass2) || !pass.equals(pass2)) {
        model.addAttribute("errormatch", Boolean.TRUE);
        return "signin";
    }

    String auth = retwis.addUser(name, pass);
    addAuthCookie(auth, name, response);

    return "redirect:/!" + name;
}

From source file:com.consol.citrus.admin.controller.TestCaseController.java

@RequestMapping(method = { RequestMethod.POST })
@ResponseBody//from   w  w w  .j av  a2s .c om
public ModelAndView list(@RequestParam("dir") String dir) {
    ModelAndView view = new ModelAndView("TestFileTree");

    FileTreeModel model = testCaseService
            .getTestFileTree(FilenameUtils.separatorsToSystem(fileHelper.decodeDirectoryUrl(dir, "")));

    if (StringUtils.hasText(model.getCompactFolder())) {
        view.addObject("compactFolder", FilenameUtils.separatorsToUnix(model.getCompactFolder()));
        view.addObject("baseDir", FilenameUtils.separatorsToUnix(
                fileHelper.decodeDirectoryUrl(dir, "") + model.getCompactFolder() + File.separator));
    } else {
        view.addObject("baseDir", FilenameUtils.separatorsToUnix(fileHelper.decodeDirectoryUrl(dir, "")));
    }

    view.addObject("folders", model.getFolders());
    view.addObject("xmlFiles", model.getXmlFiles());
    view.addObject("javaFiles", model.getJavaFiles());

    return view;
}

From source file:org.pgptool.gui.config.impl.ConfigsBasePathResolverUserHomeImpl.java

private boolean tryAccept(String path) {
    log.debug("Testing path: " + path);
    if (!StringUtils.hasText(path)) {
        return false;
    }/*  w ww. ja v a 2  s . c  om*/

    if (path.endsWith(File.separator)) {
        path = path.substring(0, path.length() - 2);
    }

    if (!new File(path).exists()) {
        return false;
    }

    path += File.separator + configFolderName;

    try {
        File tsDir = new File(path);
        if (!tsDir.exists()) {
            if (!tsDir.mkdirs()) {
                throw new RuntimeException("Failed to create configs dir " + tsDir + ", path is not reliable");
            }
            File testFile = new File(path + File.separator + "test.test");
            TextFile.write(testFile.getAbsolutePath(), "test");
            if (!testFile.delete()) {
                throw new RuntimeException("Failed to delete test file " + testFile
                        + ", this might braka app logic, path is not reliable");
            }
        }
    } catch (Throwable t) {
        log.warn("Path is not acceptable, write test failed", t);
        return false;
    }

    chosenLocation = path;
    log.info("Path was chosen as a basepath for config files: " + path);
    return true;
}

From source file:com.ewcms.mongo.demo.web.PersonController.java

@RequestMapping(value = "/save.action", method = RequestMethod.POST)
public String save(@ModelAttribute("person") Person person,
        @RequestParam(required = false) List<String> selections, Model model) {
    Boolean close = Boolean.FALSE;
    if (StringUtils.hasText(person.getId())) {
        repository.save(person);//from w w w .ja  v  a  2 s . com
        selections.remove(0);
        if (selections == null || selections.isEmpty()) {
            close = Boolean.TRUE;
        } else {
            person = repository.findOne(selections.get(0));
            model.addAttribute("person", person);
            model.addAttribute("selections", selections);
        }
    } else {
        repository.save(person);
        selections = selections == null ? new ArrayList<String>() : selections;
        selections.add(0, person.getId());
        model.addAttribute("person", new Person());
        model.addAttribute("selections", selections);
    }
    model.addAttribute("close", close);

    return "person/edit";
}

From source file:org.openmrs.module.cohort.web.controller.AddCohortAttributesController.java

@RequestMapping(value = "/module/cohort/addCohortAttributes", method = RequestMethod.GET)
public void manage(@RequestParam(required = false, value = "ca") Integer id, WebRequest request, ModelMap model,
        @ModelAttribute("cohortatt") CohortAttribute cohortattribute) {
    int a = 0;/*  w ww. j  a v  a2  s.  co m*/
    CohortM cohort = null;
    CohortAttributeType coat = null;
    CohortService s = Context.getService(CohortService.class);
    List<CohortAttributeType> att = s.findCohortAttributes();
    model.addAttribute("attypes", att);
    String atype = request.getParameter("cohortAttributeTypeId");
    if (StringUtils.hasText(atype)) {
        a = Integer.parseInt(atype);
    }
    List<CohortAttributeType> cat = s.findCohortAttType(a);
    if (cat.size() > 0) {
        coat = cat.get(0);
    }
    /*if(cohortattribute!=null)
    {
    //cohortattribute=new CohortAttribute();
    //}*/
    List<CohortM> c = s.findCohort(id);
    if (c.size() > 0) {
        cohort = c.get(0);
    }
    model.addAttribute("cohortmodule", cohort);
    cohortattribute.setCohort(cohort);
    cohortattribute.setCohortAttributeType(coat);
    model.addAttribute("cohortatt", cohortattribute);
    //}

    /*model.addAttribute("cohort",c.get(0));*/
    model.addAttribute("selectedvalue", request.getParameter("selectedvalue"));

}

From source file:org.springbyexample.jdbc.datasource.HsqldbInitializingDriverManagerDataSource.java

/**
 * Implementation of <code>InitializingBean</code>
 *//* w w w  . j a va 2s. c o m*/
@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws Exception {
    if (getDriver() == null && !StringUtils.hasText(driverClassName)) {
        setDriverClass((Class<? extends Driver>) ClassUtils.forName(DRIVER_CLASS_NAME,
                ClassUtils.getDefaultClassLoader()));
    }

    if (!StringUtils.hasText(getUrl())) {
        setUrl(URL);
    }

    if (!StringUtils.hasText(getUsername())) {
        setUsername(USERNAME);
    }

    if (!StringUtils.hasText(getPassword())) {
        setPassword(PASSWORD);
    }

    super.afterPropertiesSet();
}

From source file:com.uimirror.image.form.UimImageFormParam.java

public Color getBg() {
    try {// ww w. j  a  va  2 s  . co m
        Color cl = StringUtils.hasText(bg) ? Color.decode(bg) : Color.BLUE;
        return cl;
    } catch (Exception e) {
        return Color.BLUE;
    }
}

From source file:org.openmrs.module.cohort.web.controller.AddCohortMemberAttributesController.java

@RequestMapping(value = "/module/cohort/addCohortMemberAttribute", method = RequestMethod.GET)
public void manage(@RequestParam(required = false, value = "cma") Integer id, WebRequest request,
        ModelMap model, @ModelAttribute("cohortatt") CohortMemberAttribute cohortattribute) {
    int a = 0;//from   ww  w .j  a  v  a  2 s  . c  o  m
    CohortMember cohort = null;
    CohortMemberAttributeType coat = null;
    CohortService s = Context.getService(CohortService.class);
    List<CohortMemberAttributeType> ls = s.findCohortMemberAttributeType();
    model.addAttribute("attypes", ls);
    String atype = request.getParameter("cohortMemberAttributeTypeId");
    if (StringUtils.hasText(atype)) {
        a = Integer.parseInt(atype);
    }
    List<CohortMemberAttributeType> cat = s.findCohortMemAttType(a);
    if (cat.size() > 0) {
        coat = cat.get(0);
    }
    List<CohortMember> c = s.getCohortMember(id);
    if (c.size() > 0) {
        cohort = c.get(0);
    }
    cohortattribute.setCohortMember(cohort);
    model.addAttribute("cohortmember", cohort);
    cohortattribute.setCohortMemberAttributeType(coat);
    model.addAttribute("cohortatt", cohortattribute);
    model.addAttribute("selectedvalue", request.getParameter("selectedvalue"));
}

From source file:ch.sdi.core.impl.data.filter.FilterCommentedLine.java

/**
 * @see ch.sdi.core.impl.data.filter.CollectFilter#init(org.springframework.core.env.Environment, java.lang.String)
 *//* w w w.  j av  a 2 s .  c  o  m*/
@Override
public RawDataFilter<String> init(Environment aEnv, String aParameters) throws SdiException {
    if (!StringUtils.hasText(aParameters)) {
        throw new SdiException("Character(s) expected for this filter", SdiException.EXIT_CODE_CONFIG_ERROR);

    }

    myCommentChars = aParameters;

    return this;
}

From source file:org.opencredo.esper.config.xml.EsperTemplateParser.java

private void initializeUnmatchedListener(Element element, BeanDefinitionBuilder builder) {
    String unmatchedListenerRef = (String) element
            .getAttribute(EsperNamespaceUtils.UNMATCHED_LISTENER_ATTRIBUTE);

    if (StringUtils.hasText(unmatchedListenerRef)) {
        builder.addPropertyReference("unmatchedListener", unmatchedListenerRef);
    }//from   w ww .  j  av  a 2 s.  com
}