Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

In this page you can find the example usage for java.lang Boolean valueOf.

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:com.janrain.backplane2.server.config.Backplane2Config.java

/**
* @return the debugMode
*/
public boolean isDebugMode() {
    return Boolean.valueOf(cachedGet(BpServerConfig.Field.DEBUG_MODE));
}

From source file:com.cisco.dvbu.ps.common.util.wsapi.WsApiHelperObjects.java

public static CompositeServer getServerLogger(String serverId, String pathToServersXML, String prefix,
        Log logger) throws CompositeException {

    // Extract the serverId variable if it exists
    serverId = CommonUtils.extractVariable(prefix, serverId, propertyFile, true);

    // Get the server information
    CompositeServer serverInfo = getServerImpl(serverId, pathToServersXML);

    // Validate the configuration property file exists
    if (!PropertyManager.getInstance().doesPropertyFileExist(propertyFile)) {
        throw new ApplicationException(
                "The property file does not exist for CONFIG_PROPERTY_FILE=" + propertyFile);
    }/*from   www  .j av a 2  s . c om*/

    String validOptions = "true,false";
    // Get the property from the property file
    boolean debug1 = false;
    // Get debug2 (level two) from the property file to determine if server info should be printed out or not.
    String debug = CommonUtils.getFileOrSystemPropertyValue(propertyFile, "DEBUG2");
    boolean debug2 = false;
    if (debug != null && validOptions.contains(debug)) {
        debug2 = Boolean.valueOf(debug);
    }
    boolean debug3 = false;
    /* Example servers.xml
        <id>localhost9400</id>
       <hostname>localhost</hostname>
       <port>9400</port>
       <usage>DEV6.2</usage>
       <user>admin</user>
       <encryptedpassword>Encrypted:7F6324FFD300BE8F</encryptedpassword>
       <domain>composite</domain>
       <cishome>C:\CompositeSoftware\CIS6.2.0</cishome>
       <clustername>cluster2</clustername>
       <site>US East</site>
       <useHttps>false</useHttps>
      <allowVariables>false</allowVariables>
     */
    CommonUtils.writeOutput("Server Info:", prefix, "-debug2", logger, debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-id=               " + serverInfo.getId(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-hostname=         " + serverInfo.getHostname(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-port=             " + String.valueOf(serverInfo.getPort()), prefix,
            "-debug2", logger, debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-usage=            " + serverInfo.getUsage(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-user=             " + serverInfo.getUser(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-encryptedpassword=********", prefix, "-debug2", logger, debug1, debug2,
            debug3);
    CommonUtils.writeOutput("  Server-domain=           " + serverInfo.getDomain(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-cishome=          " + serverInfo.getCishome(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-clustername=      " + serverInfo.getClustername(), prefix, "-debug2",
            logger, debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-site=             " + serverInfo.getSite(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-useHttps=         " + serverInfo.isUseHttps(), prefix, "-debug2", logger,
            debug1, debug2, debug3);
    CommonUtils.writeOutput("  Server-allowVariables=   " + serverInfo.isAllowVariables(), prefix, "-debug2",
            logger, debug1, debug2, debug3);
    CommonUtils.writeOutput("", prefix, "-debug2", logger, debug1, debug2, debug3);

    return serverInfo;
}

From source file:com.wickettasks.business.entities.tasklist.repository.TestTaskListRepository.java

@Test
public void testSaveTaskList() {
    TaskList taskList = new TaskList();
    taskList.setName("testTaskList");
    taskList.setUser(this.user);
    this.taskListRepository.save(taskList);
    assertEquals(Boolean.TRUE, Boolean.valueOf(taskList.getId() != null));
}

From source file:com.brightcove.com.uploader.helper.MannheimWaiter.java

@Override
public boolean done() {
    String jobStatus = null;//www.  j a va 2s  .com

    try {
        log.info(jobIdString);
        HttpResponse jobStatusResponse = facade.jobStatus(jobIdString);
        jobStatus = facade.getEntityContentString(jobStatusResponse);
        log.info(jobStatus);
    } catch (Exception e) {
        fail("Caught Exception waiting for job " + jobIdString + " to complete: " + e.getMessage());
    }

    assertNotNull("jobstatus returned null for Job ID " + jobIdString, jobStatus);

    // TODO: Sean says to add logging here to just keep TeamCity from timing out. 
    if (System.currentTimeMillis() - startTime > TC_HANG_DETECTION_THRESHOLD_MS) {
        log.info("I'm not quite dead yet; just still waiting.");
        startTime = System.currentTimeMillis();
    }

    return Boolean.valueOf(jobStatus);
}

From source file:fr.itldev.koya.webscript.user.NotificationStatus.java

@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {

    //passer obligatoirement la cible de notifs
    Map<String, String> urlParams = KoyaWebscript.getUrlParamsMap(req);
    String strEnable = (String) urlParams.get(KoyaWebscript.WSCONST_ENABLE);
    String username = (String) urlParams.get(KoyaWebscript.WSCONST_USERNAME);
    String response;/*from   w ww .j a  v  a 2  s.  c  om*/

    /**
     * TODO process secureditem parameter
     */
    SecuredItem node = null;
    try {
        User u = userService.getUserByUsername(username);
        if (strEnable != null) {
            if (Boolean.valueOf(strEnable)) {
                koyaNotificationService.addNotification(u, node);
            } else {
                koyaNotificationService.removeNotification(u, node);
            }
        }
        response = KoyaWebscript.getObjectAsJson(koyaNotificationService.isUserNotified(u, node));
    } catch (KoyaServiceException ex) {
        throw new WebScriptException("KoyaError : " + ex.getErrorCode().toString());
    }
    res.setContentType("application/json");
    res.getWriter().write(response);
}

From source file:org.openmrs.module.htmlformentry19ext.ProviderAndRoleElement.java

/**
  * @param parameters/*from  w w w  .  j  a va2 s  . co m*/
 * @throws BadFormDesignException 
  */
public ProviderAndRoleElement(FormEntryContext context, Map<String, String> parameters)
        throws BadFormDesignException {
    if (parameters.containsKey("required")) {
        required = Boolean.valueOf(parameters.get("required"));
    }
    if (parameters.containsKey("count")) {
        count = Integer.valueOf(parameters.get("count"));
    }

    // if there is an encounterRole specified, use that; otherwise create a roleWidget
    if (parameters.containsKey("encounterRole")) {
        EncounterService es = Context.getEncounterService();
        String param = parameters.get("encounterRole");
        try {
            encounterRole = es.getEncounterRole(Integer.valueOf(param));
        } catch (Exception ex) {
            encounterRole = es.getEncounterRoleByUuid(param);
        }
        if (encounterRole == null)
            throw new BadFormDesignException("Cannot find EncounterRole \"" + param + "\"");

    } else {
        roleWidget = new EncounterRoleWidget();
        roleErrorWidget = new ErrorWidget();
        context.registerWidget(roleWidget);
        context.registerErrorWidget(roleWidget, roleErrorWidget);
    }

    boolean initialProviderSet = false;

    // handle the case where no encounterRole attribute is specified
    if (encounterRole == null) {
        if (count > 1) {
            throw new BadFormDesignException(
                    "HTML Form Entry does not (yet) support multiple providers per encounter without specifying encounter roles");
        }

        ProviderWidget providerWidget = new ProviderWidget();
        ErrorWidget providerErrorWidget = new ErrorWidget();
        context.registerWidget(providerWidget);
        context.registerErrorWidget(providerWidget, providerErrorWidget);
        providerWidgets.add(providerWidget);
        providerErrorWidgets.add(providerErrorWidget);

        if (context.getExistingEncounter() != null) {
            Map<EncounterRole, Set<Provider>> byRoles = context.getExistingEncounter().getProvidersByRoles();
            if (byRoles.size() > 0) {
                // currently we only support a single provider in this mode
                if (byRoles.size() > 1 || byRoles.values().iterator().next().size() > 1) {
                    throw new BadFormDesignException(
                            "HTML Form Entry does not (yet) support multiple providers per encounter without specifying encounter roles");
                }

                Entry<EncounterRole, Set<Provider>> roleAndProvider = byRoles.entrySet().iterator().next();
                Provider p = roleAndProvider.getValue().iterator().next();
                providerWidget.setInitialValue(p);
                initialProviderSet = true;
                roleWidget.setInitialValue(roleAndProvider.getKey());
            }
        }
    }
    // handle the case where an encounter role is specified
    else {

        // get any existing providers for the specified role
        List<Provider> byRole = null;
        if (context.getExistingEncounter() != null) {
            byRole = new ArrayList<Provider>(context.getExistingEncounter().getProvidersByRole(encounterRole));
        }

        // register the provider widgets, setting any existing provider values
        for (int currentIteration = 0; currentIteration < count; currentIteration++) {

            ProviderWidget providerWidget = new ProviderWidget();
            ErrorWidget providerErrorWidget = new ErrorWidget();
            context.registerWidget(providerWidget);
            context.registerErrorWidget(providerWidget, providerErrorWidget);
            providerWidgets.add(providerWidget);
            providerErrorWidgets.add(providerErrorWidget);

            if (byRole != null && byRole.size() > currentIteration) {
                providerWidget.setInitialValue(byRole.get(currentIteration));
                initialProviderSet = true;
            }
        }
    }

    // set the default provider if no existing provider and a default is specified
    if (!initialProviderSet && providerWidgets.iterator().next() != null
            && StringUtils.hasText(parameters.get("default"))) {
        String temp = parameters.get("default");
        Provider provider = null;
        if ("currentUser".equals(temp)) {
            Person me = Context.getAuthenticatedUser().getPerson();
            Collection<Provider> candidates = Context.getProviderService().getProvidersByPerson(me);
            if (candidates.size() > 0)
                provider = candidates.iterator().next();
        } else {
            try {
                provider = Context.getProviderService().getProvider(Integer.valueOf(temp));
            } catch (Exception ex) {
                provider = Context.getProviderService().getProviderByUuid(temp);
            }
        }
        if (provider != null) {
            providerWidgets.iterator().next().setInitialValue(provider);
        }
    }
}

From source file:com.safedocs.license.controller.SafeDocsLicenseController.java

@RequestMapping(value = "/find", method = RequestMethod.POST)
public ModelAndView find(@RequestParam Map<String, String> params) throws Exception {
    String uuid = params.get("uuid");
    boolean isFirstTimeOpen = Boolean.valueOf(params.get("firsttimeopen"));
    printInfo(params, "/find");

    SafeDocsLicenseModel model = new SafeDocsLicenseModel(uuid);
    if (isFirstTimeOpen) {
        model.setStatus(0);// w w w . j  a v a2  s.co  m
    } else {
        model.setHardwareid(params.get("hardwareid"));
        model.setStatus(1);

    }

    return new ModelAndView(safedocsMarshallingView, (Map<String, ?>) licenseService.findLicenseData(model));

}

From source file:com.aurel.track.util.StringArrayParameterUtils.java

public static Boolean parseBooleanValue(Map<String, String[]> configParameters, String fieldName,
        Boolean defaultValue) {/*from  w  w  w .j a v a  2 s . c  o m*/
    Boolean result = defaultValue;
    String[] strArr = null;
    if (configParameters != null) {
        try {
            strArr = (String[]) configParameters.get(fieldName);
        } catch (Exception e) {
            LOGGER.info("parseIntValue: converting the " + fieldName + " parameter to String[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    if (strArr != null && strArr.length > 0) {
        String str = strArr[0];
        if (str != null && !"".equals(str)) {
            try {
                result = Boolean.valueOf(str);
            } catch (Exception e) {
                LOGGER.info("Converting the value " + str + " for field " + fieldName + " to int failed with "
                        + e.getMessage());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
    return result;
}

From source file:com.epam.cme.storefront.controllers.pages.AbstractSearchPageController.java

protected void populateModel(final Model model, final SearchPageData<?> searchPageData,
        final ShowMode showMode) {
    model.addAttribute("searchPageData", searchPageData);
    model.addAttribute("isShowAllAllowed",
            Boolean.valueOf(showMode == ShowMode.Page && isShowAllAllowed(searchPageData)));
    model.addAttribute("isShowAllRequested", Boolean.valueOf(showMode == ShowMode.All));
    model.addAttribute("maxPageLimit", Integer.valueOf(getMaxSearchPageSize()));
}

From source file:org.openmrs.web.attribute.handler.BooleanFieldGenDatatypeHandler.java

/**
 * @see org.openmrs.web.attribute.handler.FieldGenDatatypeHandler#getValue(org.openmrs.customdatatype.CustomDatatype, javax.servlet.http.HttpServletRequest, java.lang.String)
 *//* www .  j a  v  a2 s.c  o  m*/
@Override
public Boolean getValue(org.openmrs.customdatatype.datatype.BooleanDatatype datatype,
        HttpServletRequest request, String formFieldName) throws InvalidCustomValueException {
    String result = request.getParameter(formFieldName);
    if (StringUtils.isBlank(result)) {
        return null;
    }
    try {
        return Boolean.valueOf(result);
    } catch (Exception ex) {
        throw new InvalidCustomValueException("Invalid boolean: " + result);
    }
}