Example usage for org.springframework.util StringUtils hasLength

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

Introduction

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

Prototype

public static boolean hasLength(@Nullable String str) 

Source Link

Document

Check that the given String is neither null nor of length 0.

Usage

From source file:org.cloudfoundry.practical.demo.core.webdav.FolderWebdavStore.java

private Resource getStoredObjectResource(String uri) {
    if (!StringUtils.hasLength(uri) || uri.equals("/")) {
        return this.root;
    }/*  w  w w . j  ava 2s  . c o  m*/
    if (this.root.hasExisting(uri)) {
        return this.root.getExisting(uri);
    }
    return null;
}

From source file:org.openmrs.module.feedback.web.PredefinedSubjectFormController.java

@Override
protected Map referenceData(HttpServletRequest req) throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();
    Object o = Context.getService(FeedbackService.class);
    FeedbackService service = (FeedbackService) o;
    FeedbackService hService = (FeedbackService) Context.getService(FeedbackService.class);
    String predefinedsubjectid = req.getParameter("predefinedsubjectid");

    /* Predefined Subject is deleted incase the subject with predefinedID is not found */
    if (!StringUtils.hasLength(predefinedsubjectid)
            || (service.getPredefinedSubject(Integer.parseInt(predefinedsubjectid)) == null)) {
        PredefinedSubject s = new PredefinedSubject();

        map.put("predefinedsubjects", s);

        return map;
    }//from w  w w .j a va2s  . c o  m

    /* Otherwise give the data about the predefined subject */
    else {
        PredefinedSubject s = service.getPredefinedSubject(Integer.parseInt(predefinedsubjectid));

        map.put("predefinedsubjects", s);

        return map;
    }
}

From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java

public BeanDefinition parse(final Element element, final ParserContext parserContext) {

    AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
    if (!parserContext.getRegistry().containsBeanDefinition(ADVISOR_BEAN_NAME)) {

        final Boolean usePreprocessor = Boolean.valueOf(element.getAttribute(XSD_ATTR__USE_PREPROCESSOR));
        final String dtoSupportBeanName = element.getAttribute(XSD_ATTR__DTO_SUPPORT);

        final BeanDefinitionRegistry registry = parserContext.getRegistry();
        final Object elementSource = parserContext.extractSource(element);

        final RuntimeBeanReference dtoSupportDef;

        if (!registry.containsBeanDefinition(dtoSupportBeanName)) {

            final String dtoFactoryBeanName = element.getAttribute(XSD_ATTR__DTO_FACTORY);
            final RuntimeBeanReference dtoFactoryRef = new RuntimeBeanReference(dtoFactoryBeanName);

            final String dtoVcrBeanName = element.getAttribute(XSD_ATTR__DTO_ADAPTERS_REGISTRAR);
            final RuntimeBeanReference dtoVcrRef;
            if (StringUtils.hasLength(dtoVcrBeanName)) {
                dtoVcrRef = new RuntimeBeanReference(dtoVcrBeanName);
            } else {
                dtoVcrRef = null;/* www  .j  a  v a 2s.  c  o  m*/
            }

            final String dtoDslBeanName = element.getAttribute(XSD_ATTR__DTO_DSL_REGISTRAR);
            final RuntimeBeanReference dtoDslRef;
            if (StringUtils.hasLength(dtoDslBeanName)) {
                dtoDslRef = new RuntimeBeanReference(dtoDslBeanName);
            } else {
                dtoDslRef = null;
            }

            dtoSupportDef = this.setupDtoSupport(element, dtoSupportBeanName, registry, elementSource,
                    dtoFactoryRef, dtoVcrRef, dtoDslRef);

        } else {

            dtoSupportDef = new RuntimeBeanReference(dtoSupportBeanName);

        }

        if (usePreprocessor) {
            // bean pre processor version of configuration
            this.setupBootstapBeanPostprocessor(element, parserContext, elementSource);

            final RuntimeBeanReference defaultCfgAdvice = this.setupTransferableAdviceConfigResolver(
                    parserContext, elementSource, BootstrapAdviceConfigResolverImpl.class);

            final String[] matchRegEx = this.getPointcutRegex(element, XSD_ATTR__POINTCUT_MATCH_REGEX);
            final String[] noMatchRegEx = this.getPointcutRegex(element, XSD_ATTR__POINTCUT_NOMATCH_REGEX);

            final RuntimeBeanReference pointcut = this.setupPointcut(parserContext, elementSource,
                    defaultCfgAdvice, matchRegEx, noMatchRegEx);

            final RuntimeBeanReference defaultInterceptor = this.setupGeDAInterceptor(parserContext,
                    elementSource, dtoSupportDef, defaultCfgAdvice);

            this.setupPointcutAdvisor(element, parserContext, elementSource, pointcut, defaultInterceptor);

        } else {
            // runtime advice discovery
            final RuntimeBeanReference defaultCfgAdvice = this.setupTransferableAdviceConfigResolver(
                    parserContext, elementSource, RuntimeAdviceConfigResolverImpl.class);

            final String[] matchRegEx = this.getPointcutRegex(element, XSD_ATTR__POINTCUT_MATCH_REGEX);
            final String[] noMatchRegEx = this.getPointcutRegex(element, XSD_ATTR__POINTCUT_NOMATCH_REGEX);

            final RuntimeBeanReference pointcut = this.setupPointcut(parserContext, elementSource,
                    defaultCfgAdvice, matchRegEx, noMatchRegEx);

            final RuntimeBeanReference defaultInterceptor = this.setupGeDAInterceptor(parserContext,
                    elementSource, dtoSupportDef, defaultCfgAdvice);

            this.setupPointcutAdvisor(element, parserContext, elementSource, pointcut, defaultInterceptor);
        }
    }
    return null;
}

From source file:com.threepillar.labs.socialauthsample.controller.SuccessController.java

private ModelAndView importContacts(final AuthProvider provider) throws Exception {
    List<Contact> contactsList = new ArrayList<Contact>();
    contactsList = provider.getContactList();
    if (contactsList != null && contactsList.size() > 0) {
        for (Contact p : contactsList) {
            if (!StringUtils.hasLength(p.getFirstName()) && !StringUtils.hasLength(p.getLastName())) {
                p.setFirstName(p.getDisplayName());
            }//from   w w w  .  j av  a  2  s  .  c  o  m
        }
    }
    ModelAndView view = new ModelAndView("showImportContacts", "contacts", contactsList);
    return view;
}

From source file:com.github.zhanhb.ckfinder.connector.handlers.command.BaseCommand.java

/**
 * check request for security issue./*from   w  w  w.j  a v a  2  s.  co  m*/
 *
 * @param reqParam request param
 * @throws ConnectorException if validation error occurs.
 */
@SuppressWarnings("FinalMethod")
final void checkRequestPathValid(String reqParam) throws ConnectorException {
    if (StringUtils.hasLength(reqParam)
            && Pattern.compile(Constants.INVALID_PATH_REGEX).matcher(reqParam).find()) {
        throw new ConnectorException(ErrorCode.INVALID_NAME);
    }
}

From source file:org.openmrs.module.feedback.web.SeverityFormController.java

@Override
protected Map referenceData(HttpServletRequest req) throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();
    Object o = Context.getService(FeedbackService.class);
    FeedbackService service = (FeedbackService) o;
    FeedbackService hService = (FeedbackService) Context.getService(FeedbackService.class);
    String SeverityId = req.getParameter("feedbackSeverityId");

    /* To display the message that the severity has been deleted */
    if (!StringUtils.hasLength(SeverityId) || (service.getSeverity(Integer.parseInt(SeverityId)) == null)) {
        Severity s = new Severity();

        map.put("severity", s);

        return map;
    } else {//  w  ww . j a  v a 2s .  co m

        /* Return the severity with the specific feedbackID */
        Severity s = service.getSeverity(Integer.parseInt(SeverityId));

        map.put("severity", s);

        return map;
    }
}

From source file:edu.uchicago.duo.service.DuoPhoneObjImpl.java

@Override
public String createObjByParam(String phoneNumber, String device, String deviceOS, String tabletName,
        String landLineExtension) {
    String phoneID = null;/*  w w  w  . j  av  a2 s .c o m*/

    request = genHttpRequest("POST", duoPhoneApi, "admin");
    if (device.equals("mobile")) {
        request.addParam("number", phoneNumber);
        request.addParam("type", device);
        request.addParam("platform", deviceOS);
    }

    if (device.equals("tablet")) {
        request.addParam("type", "mobile");
        request.addParam("platform", deviceOS);
        request.addParam("name", tabletName);
    }

    if (device.equals("landline")) {
        request.addParam("number", phoneNumber);
        request.addParam("type", "landline");
        if (StringUtils.hasLength(landLineExtension)) {
            request.addParam("extension", landLineExtension);
            request.addParam("postdelay", "6");
        }
    }

    request = signHttpRequest("admin");

    try {
        jResult = (JSONObject) request.executeRequest();
        phoneID = jResult.getString("phone_id");
        logger.debug("2FA Debug - " + "Successfully Created Phone, Type:" + device + "/Number:" + phoneNumber);
    } catch (Exception ex) {
        logger.error("2FA Error - " + "Unable to Create Duo Phone Object!!!!, Number:" + phoneNumber);
        logger.error("2FA Error - " + "The Error is(PhoneObjImp): " + ex.toString());
    }

    return phoneID;

}

From source file:com.excilys.ebi.bank.util.Asserts.java

public static void doesNotContain(String textToSearch, String substring, String messagePattern, Object arg1,
        Object arg2) {//  ww w. j  a v a 2  s. com
    if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring)
            && textToSearch.indexOf(substring) != -1) {
        throw new IllegalArgumentException(MessageFormatter.format(messagePattern, arg1, arg2).getMessage());
    }
}

From source file:lodsve.core.condition.BeanTypeRegistry.java

private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
        String name) throws Exception, ClassNotFoundException, LinkageError {
    if (StringUtils.hasLength(definition.getFactoryBeanName())
            && StringUtils.hasLength(definition.getFactoryMethodName())) {
        return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
    }//from w  ww  .java  2s. c  o m
    if (StringUtils.hasLength(definition.getBeanClassName())) {
        return getDirectFactoryBeanGeneric(beanFactory, definition, name);
    }
    return null;
}

From source file:org.elasticsoftware.elasterix.server.messages.AbstractSipMessage.java

/**
 * Parses a traditional sip user element belonging to given header, e.g. <br>
 * "Hans de Borst"<sip:124@sip.outerteams.com:5060>;tag=ce337d00<br>
 * If no header is passed, SipHeader.TO will be used
 *
 * @param header//from w ww  . j a  v a 2 s .c  om
 * @return
 */
@JsonIgnore
public SipUser getSipUser(SipHeader header) {
    if (header == null) {
        header = SipHeader.TO;
    }
    String user = getHeader(header);
    if (!StringUtils.hasLength(user)) {
        return null;
    }
    return new SipUser(user);
}