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:org.jasig.cas.web.flow.InitialFlowSetupAction.java

protected Event doExecute(final RequestContext context) throws Exception {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    if (!this.pathPopulated) {
        final String contextPath = context.getExternalContext().getContextPath();
        final String cookiePath = StringUtils.hasText(contextPath) ? contextPath + "/" : "/";
        logger.info("Setting path for cookies to: " + cookiePath);
        this.warnCookieGenerator.setCookiePath(cookiePath);
        this.ticketGrantingTicketCookieGenerator.setCookiePath(cookiePath);
        this.pathPopulated = true;
    }/*from  w w  w.  j  ava 2  s. c o m*/
    String tgt = this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request);
    if (tgt != null && tgt.indexOf("TGT-") != -1) {
        context.getFlowScope().put("ticketGrantingTicketId", tgt);
    } else {
        context.getFlowScope().put("ticketGrantingTicketId", null);
    }

    context.getFlowScope().put("warnCookieValue",
            Boolean.valueOf(this.warnCookieGenerator.retrieveCookieValue(request)));

    final Service service = WebUtils.getService(this.argumentExtractors, context);

    if (service != null && logger.isDebugEnabled()) {
        logger.debug("Placing service in FlowScope: " + service.getId());
    }

    context.getFlowScope().put("service", service);

    return result("success");
}

From source file:com.joyveb.dbpimpl.cass.prepare.config.xml.CassandraClusterParser.java

@Override
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
        throws BeanDefinitionStoreException {

    String id = super.resolveId(element, definition, parserContext);
    return StringUtils.hasText(id) ? id : ConfigConstants.CASSANDRA_CLUSTER;
}

From source file:es.ucm.fdi.dalgs.rest.security.RestAuthenticationSuccessHandler.java

@Override
public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response,
        final Authentication authentication) throws ServletException, IOException {
    final SavedRequest savedRequest = requestCache.getRequest(request, response);

    if (savedRequest == null) {
        clearAuthenticationAttributes(request);
        return;// www  .  j  ava2  s.c om
    }
    final String targetUrlParameter = getTargetUrlParameter();
    if (isAlwaysUseDefaultTargetUrl()
            || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
        requestCache.removeRequest(request, response);
        clearAuthenticationAttributes(request);
        return;
    }

    clearAuthenticationAttributes(request);

    // Use the DefaultSavedRequest URL
    // final String targetUrl = savedRequest.getRedirectUrl();
    // logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
    // getRedirectStrategy().sendRedirect(request, response, targetUrl);
}

From source file:com.ryantenney.metrics.spring.config.RegisterMetricBeanDefinitionParser.java

@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    final CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(),
            parserContext.extractSource(element));
    parserContext.pushContainingComponent(compDefinition);

    final String metricRegistryBeanName = element.getAttribute("metric-registry");
    if (!StringUtils.hasText(metricRegistryBeanName)) {
        throw new RuntimeException(); // TODO
    }//w ww. jav  a  2s . co  m
    final RuntimeBeanReference metricRegistryBeanRef = new RuntimeBeanReference(metricRegistryBeanName);

    final List<Element> metricElements = DomUtils.getChildElementsByTagName(element,
            new String[] { "bean", "ref" });
    for (Element metricElement : metricElements) {
        // Get the name attribute and remove it (to prevent Spring from looking for a BeanDefinitionDecorator)
        final String name = metricElement.getAttributeNS(METRICS_NAMESPACE, "name");
        if (name != null) {
            metricElement.removeAttributeNS(METRICS_NAMESPACE, "name");
        }

        final Object metric = parserContext.getDelegate().parsePropertySubElement(metricElement, null);

        final RootBeanDefinition metricRegistererDef = new RootBeanDefinition(MetricRegisterer.class);
        metricRegistererDef.setSource(parserContext.extractSource(metricElement));
        metricRegistererDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

        final ConstructorArgumentValues args = metricRegistererDef.getConstructorArgumentValues();
        args.addIndexedArgumentValue(0, metricRegistryBeanRef);
        args.addIndexedArgumentValue(1, name);
        args.addIndexedArgumentValue(2, metric);

        final String beanName = parserContext.getReaderContext().registerWithGeneratedName(metricRegistererDef);
        parserContext.registerComponent(new BeanComponentDefinition(metricRegistererDef, beanName));
    }

    parserContext.popAndRegisterContainingComponent();

    return null;
}

From source file:org.focusns.common.web.performance.MonitorFilter.java

private String getRequestDescription(HttpServletRequest request) {
    StringBuilder sb = new StringBuilder(request.getRequestURI());
    if (StringUtils.hasText(request.getQueryString())) {
        sb.append("?").append(request.getQueryString());
    }//from  w w w  . j ava  2  s  . c o  m
    sb.append(" [").append(request.getMethod()).append("]");
    return sb.toString();
}

From source file:com.streamreduce.datasource.DatastoreFactoryBean.java

@Override
protected AdvancedDatastore createInstance() throws Exception {
    AdvancedDatastore datastore;/*  w ww. j  av  a 2  s  . c  om*/

    if (StringUtils.hasText(user)) {
        // If there is a username supplied, we need to authenticate.  Morphia does not
        // allow us to use a MongoDB admin user so we need to do some setup work prior
        // to involving Morphia.  To do this, we will first try to authenticate as a
        // database user and if that fails, we will try to authenticate as an admin
        // user.  If both fail, we let the MongoException bubble up as it is unhandleable.
        logger.debug("Create the morphia datastore with credentials");

        // Try to login as a database user first and fall back to admin user if login fails
        if (mongo.getDB(dbName).authenticate(user, password.toCharArray())) {
            logger.debug("Successfully authenticated to MongoDB database (" + dbName + ") as " + user);
        } else {
            if (mongo.getDB("admin").authenticate(user, password.toCharArray())) {
                logger.debug(
                        "Successfully authenticated to MongoDB database (" + dbName + ") as admin " + user);
            } else {
                throw new MongoException("Unable to authenticate to MongoDB using " + user + "@" + dbName
                        + " or " + user + "@admin.");
            }
        }
    } else {
        logger.debug("Create the morphia datastore WITHOUT credentials");
    }

    datastore = (AdvancedDatastore) morphia.createDatastore(mongo, dbName);

    datastore.ensureCaps();
    datastore.ensureIndexes();

    return datastore;
}

From source file:com.uimirror.location.latlong.stepdef.LocationByLongLatStepDef.java

@Given("^press submit$")
public void press_submit() throws Throwable {
    String url = "http://localhost:8080/uim/location/lookup/lat=" + latitude + "&lon=" + longitude;
    if (StringUtils.hasText(expanded))
        url += "&expanded" + expanded;
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
    this.entity = entity;
}

From source file:com.artivisi.iso8583.persistence.service.MapperServiceImpl.java

@Override
public Mapper findMapperByName(String name) {
    if (!StringUtils.hasText(name)) {
        return null;
    }//  ww  w  . jav a 2  s .c o m
    Mapper m = mapperDao.findByName(name);
    if (m != null) {
        m.getDataElement().size();
    }
    return m;
}

From source file:com.seajas.search.contender.jms.endpoint.ReplicationEndpoint.java

/**
 * Process the incoming message and delegate it according to its payload.
 * /* w w w. j  a  v a  2  s  .c o  m*/
 * @param message
 */
@ServiceActivator(inputChannel = "replicationChannel")
public void process(final Message<?> message) {
    final String action = message.getHeaders().get(MessageConstants.HEADER_CHANNEL_REPLICATIONACTION,
            String.class);

    if (StringUtils.hasText(action)) {
        if (action.equals(MessageConstants.REPLICATION_ACTION_DELETE_MODIFIER))
            modifierCache.delete((Integer) message.getPayload());
        else if (action.equals(MessageConstants.REPLICATION_ACTION_UPDATE_MODIFIER))
            modifierCache.update((Modifier) message.getPayload());
        else if (action.equals(MessageConstants.REPLICATION_ACTION_DELETE_TAXONOMY))
            taxonomyCache.delete((Integer) message.getPayload());
        else if (action.equals(MessageConstants.REPLICATION_ACTION_UPDATE_TAXONOMY))
            taxonomyCache.update((TaxonomyNode) message.getPayload());
        else
            logger.error("Unknown replication action '" + action + "' received. Discarding.");
    } else
        logger.error("Unknown replication action (no action header) received. Discarding.");
}

From source file:com.mtgi.analytics.servlet.ServletRequestBehaviorTrackingAdapter.java

public ServletRequestBehaviorTrackingAdapter(String eventType, BehaviorTrackingManager manager,
        String[] parameters, String[] nameParameters, Pattern[] uriPatterns) {
    this.eventType = StringUtils.hasText(eventType) ? eventType : DEFAULT_EVENT_TYPE;
    this.manager = manager;
    this.parameters = parameters;
    this.nameParameters = nameParameters;
    this.uriPatterns = uriPatterns;
}