Example usage for org.apache.commons.lang BooleanUtils toBoolean

List of usage examples for org.apache.commons.lang BooleanUtils toBoolean

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils toBoolean.

Prototype

public static boolean toBoolean(String str) 

Source Link

Document

Converts a String to a boolean (optimised for performance).

'true', 'on' or 'yes' (case insensitive) will return true.

Usage

From source file:com.baasbox.controllers.Document.java

private static String prepareResponseToJson(ODocument doc) {
    response().setContentType("application/json");
    Formats format;/*from   w  w w. ja v  a2 s  .  c  o m*/
    try {
        DbHelper.filterOUserPasswords(true);
        if (BooleanUtils.toBoolean(Http.Context.current().request().getQueryString("withAcl"))) {
            format = JSONFormats.Formats.DOCUMENT_WITH_ACL;
            return JSONFormats.prepareResponseToJson(doc, format, true);
        } else {
            format = JSONFormats.Formats.DOCUMENT;
            return JSONFormats.prepareResponseToJson(doc, format, false);
        }
    } finally {
        DbHelper.filterOUserPasswords(false);
    }
}

From source file:edu.mayo.cts2.framework.core.config.Cts2DeploymentConfig.java

/**
 * Gets the boolean property.//  www.  jav a 2 s .  c  o m
 *
 * @param propertyName the property name
 * @return the boolean property
 */
public boolean getBooleanProperty(String propertyName, boolean defaultValue) {
    String value = this.cts2ConfigProperties.getProperty(propertyName);
    if (StringUtils.isBlank(value)) {
        return defaultValue;
    } else {
        return BooleanUtils.toBoolean(value);
    }
}

From source file:com.hpe.application.automation.bamboo.tasks.AlmLabManagementTask.java

@NotNull
@java.lang.Override/*from w  ww .j a va 2 s. c  o  m*/
public TaskResult execute(@NotNull final TaskContext taskContext) throws TaskException {
    final BuildLogger buildLogger = taskContext.getBuildLogger();

    final ConfigurationMap map = taskContext.getConfigurationMap();

    final String almServerPath = map.get(AlmLabManagementTaskConfigurator.ALM_SERVER_PARAM);

    RunManager runManager = new RunManager();

    CdaDetails cdaDetails = null;
    boolean useCda = BooleanUtils.toBoolean(map.get(AlmLabManagementTaskConfigurator.USE_SDA_PARAM));
    if (useCda) {
        cdaDetails = new CdaDetails(map.get(AlmLabManagementTaskConfigurator.DEPLOYMENT_ACTION_PARAM),
                map.get(AlmLabManagementTaskConfigurator.DEPLOYED_ENVIRONMENT_NAME),
                map.get(AlmLabManagementTaskConfigurator.DEPROVISIONING_ACTION_PARAM));
    }

    Args args = new Args(almServerPath, map.get(AlmLabManagementTaskConfigurator.DOMAIN_PARAM),
            map.get(AlmLabManagementTaskConfigurator.PROJECT_NAME_PARAM),
            map.get(AlmLabManagementTaskConfigurator.USER_NAME_PARAM),
            map.get(AlmLabManagementTaskConfigurator.PASSWORD_PARAM),
            map.get(AlmLabManagementTaskConfigurator.RUN_TYPE_PARAM),
            map.get(AlmLabManagementTaskConfigurator.TEST_ID_PARAM),
            map.get(AlmLabManagementTaskConfigurator.DURATION_PARAM),
            map.get(AlmLabManagementTaskConfigurator.DESCRIPTION_PARAM), null,
            map.get(AlmLabManagementTaskConfigurator.ENVIRONMENT_ID_PARAM), cdaDetails);

    RestClient restClient = new RestClient(args.getUrl(), args.getDomain(), args.getProject(),
            args.getUsername());

    try {
        Logger logger = new Logger() {

            public void log(String message) {
                buildLogger.addBuildLogEntry(message);
            }
        };

        Testsuites result = runManager.execute(restClient, args, logger);

        ResultSerializer.saveResults(result, taskContext.getWorkingDirectory().getPath(), logger);

    } catch (InterruptedException e) {
        e.printStackTrace();
        return TaskResultBuilder.create(taskContext).failed().build();
    } catch (SSEException e) {
        return TaskResultBuilder.create(taskContext).failed().build();
    }

    TestResultHelper.CollateResults(testCollationService, taskContext);
    AddALMArtifacts(taskContext, null, LINK_SEARCH_FILTER, i18nBean);

    return TaskResultBuilder.create(taskContext).checkTestFailures().build();
}

From source file:com.hortonworks.streamline.streams.metrics.storm.graphite.GraphiteWithStormQuerier.java

/**
 * {@inheritDoc}/*  w  w w.  ja v  a  2s  .co m*/
 */
@Override
public void init(Map<String, String> conf) throws ConfigException {
    if (conf != null) {
        try {
            renderApiUrl = new URI(conf.get(RENDER_API_URL));
            metricNamePrefix = conf.get(METRIC_NAME_PREFIX);
            useFQDN = BooleanUtils.toBoolean(conf.get(USE_FQDN));
        } catch (URISyntaxException e) {
            throw new ConfigException(e);
        }
    }
    client = ClientBuilder.newClient(new ClientConfig());
}

From source file:com.switchfly.inputvalidation.RequestParameter.java

public boolean toBoolean() {
    String value = toString();
    return BooleanUtils.toBoolean(value);
}

From source file:com.cognifide.cq.cqsm.core.servlets.ScriptConfigServlet.java

@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    final ResourceResolver resolver = request.getResourceResolver();
    final String searchPath = request.getParameter("scriptPath");
    final Script script = scriptFinder.find(searchPath, resolver);
    if (script == null) {
        ServletUtils.writeMessage(response, "error", "Script not found: " + searchPath);
        return;// w  w  w. java 2s . c o  m
    }
    final ModifiableScript modifiableScript = new ModifiableScriptWrapper(resolver, script);
    try {
        final String executionMode = request.getParameter("executionMode");
        if (executionMode != null) {
            modifiableScript.setExecutionMode(ExecutionMode.valueOf(executionMode.toUpperCase()));
        }

        final String executionEnabled = request.getParameter("executionEnabled");
        if (executionEnabled != null) {
            modifiableScript.setExecutionEnabled(BooleanUtils.toBoolean(executionEnabled));
        }

        ServletUtils.writeMessage(response, "success", "Script configuration updated");
    } catch (PersistenceException e) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        ServletUtils.writeMessage(response, "error", "Cannot update script configuration: " + e.getMessage());
    }
}

From source file:com.zimbra.cs.gal.GalSyncToken.java

private void parseLdapTimestamp() {
    if (!StringUtils.isEmpty(mLdapTimestamp)) {
        int pos = mLdapTimestamp.indexOf('_');
        if (pos != -1) {
            String[] parsedToken = mLdapTimestamp.split("_");
            if (parsedToken.length >= 4) {
                intLdapCreateDateTs = parsedToken[0];
                intLdapMatchCount = Integer.parseInt(parsedToken[1]);
                intLdapHasMore = BooleanUtils.toBoolean(Integer.parseInt(parsedToken[2]));
                intMaxModificationDateLdapTs = parsedToken[3];
            }/*  w w w .j a  va 2s .c  o m*/

            if (parsedToken.length == 8) {
                extLdapCreateDateTs = parsedToken[4];
                extLdapMatchCount = Integer.parseInt(parsedToken[5]);
                extLdapHasMore = BooleanUtils.toBoolean(Integer.parseInt(parsedToken[6]));
                extMaxModificationDateLdapTs = parsedToken[7];
            }
        } //else its internal gal sync only.no ldap sync.
    }
}

From source file:com.bstek.dorado.core.ConfigureStore.java

/**
 * boolean???//from   w  w w. j  a  v a 2  s  . c o  m
 * 
 * @param key
 *            ???
 */
public boolean getBoolean(String key) {
    Object value = get(key);
    return (value instanceof Boolean) ? ((Boolean) value).booleanValue()
            : BooleanUtils.toBoolean((value == null) ? null : value.toString());
}

From source file:mitm.application.djigzo.james.mailets.Attach.java

@Override
final public void initMailet() {
    getLogger().info("Initializing mailet: " + getMailetName());

    String param = getInitParameter(Parameter.RETAIN_MESSAGE_ID.name);

    if (param != null) {
        retainMessageID = BooleanUtils.toBoolean(param);
    }/*from   w  w w . j  a v  a2 s.c  o m*/

    filename = getInitParameter(Parameter.FILE_NAME.name, filename);

    StrBuilder sb = new StrBuilder();

    sb.append("Retain Message-ID: ");
    sb.append(retainMessageID);
    sb.append("; Filename: ");
    sb.append(filename);

    getLogger().info(sb.toString());
}

From source file:com.redhat.rhn.domain.monitoring.Probe.java

/**
 * Setter for notifyCritical//from  www . j  a  v a  2 s. c o  m
 * @param notifyCriticalIn to set
*/
public void setNotifyCritical(Boolean notifyCriticalIn) {
    setNotifyCritical(BooleanUtils.toBoolean(notifyCriticalIn) ? '1' : null);
}