Example usage for org.apache.commons.lang3 StringUtils trimToNull

List of usage examples for org.apache.commons.lang3 StringUtils trimToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils trimToNull.

Prototype

public static String trimToNull(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .

Usage

From source file:at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils.java

public static void initHibernate(Configuration config, Properties hibernateProperties) {

    String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY));
    if (scm != null) {
        automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1
                || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1;
    }/*  w w w  .j av  a  2  s  .  c  om*/
    Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\".");
    if (automaticSessionHandling) {
        Logger.info("Hibernate is automatically handling session context management.");
    } else {
        Logger.info(
                "Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling.");
    }
    try {
        //Create the SessionFactory
        Logger.debug("Creating initial MOASession session factory...");

        config.configure("hibernate_moasession.cfg.xml");
        //serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();

        serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();

        sessionFactory = config.buildSessionFactory(serviceRegistry);
        Logger.debug("Initial MOASession session factory successfully created.");

    } catch (Throwable ex) {
        Logger.error("Initial MOASession session factory creation failed: " + ex.getMessage());
        throw new ExceptionInInitializerError(ex);
    }
}

From source file:com.thoughtworks.go.config.ResourceConfig.java

public String getName() {
    return StringUtils.trimToNull(name);
}

From source file:ch.aonyx.broker.ib.api.execution.CommissionReport.java

public String getCurrencyCode() {
    return StringUtils.trimToNull(currencyCode);
}

From source file:com.hubrick.vertx.s3.model.Grantee.java

public Grantee(String id, String displayName) {
    checkNotNull(StringUtils.trimToNull(id), "id must not be null");
    checkNotNull(StringUtils.trimToNull(displayName), "displayName must not be null");

    this.id = id;
    this.displayName = displayName;
}

From source file:at.gv.egovernment.moa.id.commons.db.StatisticLogDBUtils.java

public static void initHibernate(Configuration config, Properties hibernateProperties) {

    String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY));
    if (scm != null) {
        automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1
                || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1;
    }//  w  ww  .  j a va  2  s .c  om
    Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\".");
    if (automaticSessionHandling) {
        Logger.info("Hibernate is automatically handling session context management.");
    } else {
        Logger.info(
                "Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling.");
    }
    try {
        //Create the SessionFactory
        Logger.debug("Creating initial StatisicLogger session factory...");

        config.configure("hibernate_statistic.cfg.xml");
        //serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();

        serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();

        sessionFactory = config.buildSessionFactory(serviceRegistry);
        Logger.debug("Initial StatisicLogger session factory successfully created.");

    } catch (Throwable ex) {
        Logger.error("Initial StatisicLogger session factory creation failed: " + ex.getMessage());
        throw new ExceptionInInitializerError(ex);
    }
}

From source file:com.hubrick.vertx.s3.model.request.CompleteMultipartUploadRequest.java

public CompleteMultipartUploadRequest(String uploadId, List<Part> parts) {
    checkNotNull(StringUtils.trimToNull(uploadId), "uploadId must not be null");
    checkNotNull(parts, "parts must not be null");

    this.uploadId = uploadId;
    this.parts = parts;
}

From source file:com.threewks.thundr.user.controller.AuthenticatedInterceptor.java

@SuppressWarnings("unchecked")
@Override/* www  .j  a va  2 s .  co m*/
public View before(Authenticated annotation, Request req, Response resp) {
    Session session = getSession(req, resp);
    if (session != null && session.isAuthenticated()) {
        return null;
    }
    String redirect = StringUtils.trimToNull(annotation.redirect());
    if (redirect != null) {
        return redirectToRouteOrPath(redirect);
    }
    throw new HttpStatusException(StatusCode.Unauthorized, "User not identified");
}

From source file:com.webbfontaine.valuewebb.action.irms.PermissionValidator.java

public boolean checkMandatoryFields() {
    return StringUtils.trimToNull(permission.getCriterionCode()) != null
            && StringUtils.trimToNull(permission.getUserName()) != null;
}

From source file:com.thoughtworks.go.config.ResourceConfig.java

public void setName(String name) {
    this.name = StringUtils.trimToNull(name);
}

From source file:com.olegchir.flussonic_userlinks.wicket.SecurityResolver.SecurityResolver.java

@Override
public Component resolve(final MarkupContainer container, final MarkupStream markupStream,
        final ComponentTag tag) {
    // It must be <wicket:...>
    if (tag instanceof WicketTag) {
        final WicketTag wicketTag = (WicketTag) tag;

        // It must be <wicket:security...>
        if (TAGNAME_SECURITY.equalsIgnoreCase(tag.getName())) {
            boolean authorized = true;
            String rolesInOneString = StringUtils.trimToNull(wicketTag.getAttribute("onlyroles"));
            if (null != rolesInOneString) {
                Roles roles = AuthChecker.extractRoles();
                authorized = roles.hasAnyRole(new Roles(rolesInOneString));
            }//from www.ja v  a 2  s.  c  o m

            String id = wicketTag.getId() + container.getPage().getAutoIndex();

            Component result = new TransparentWebMarkupContainer(id);
            if (!authorized) {
                result.setVisible(false);
            }

            return result;
        }
    }

    // We were not able to handle the componentId
    return null;
}