List of usage examples for org.apache.commons.lang BooleanUtils toBoolean
public static boolean toBoolean(String str)
Converts a String to a boolean (optimised for performance).
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:com.cognifide.cq.cqsm.core.servlets.ScriptUploadServlet.java
private boolean shouldRedirect(SlingHttpServletRequest request) { return BooleanUtils.toBoolean(request.getParameter("redirect")); }
From source file:eionet.cr.dao.SearchDAOTest.java
/** * Returns true if the configuration says that the underlying triple-store has real-time full-text indexing activated. * * @return True/false./*from ww w .j a v a 2 s. c o m*/ */ private boolean isRealTimeFullTextIndexingActivated() { String value = GeneralConfig.getProperty(GeneralConfig.VIRTUOSO_REAL_TIME_FT_INDEXING); return BooleanUtils.toBoolean(value); }
From source file:de.hybris.platform.secureportaladdon.controllers.AbstractB2BRegistrationController.java
/** * Spring MVC Model attribute that holds the list of countries used to populate the "Country" dropdown. *//*from w w w . j a v a 2s . c o m*/ @ModelAttribute("enableCaptcha") public boolean getEnableCaptcha() { return BooleanUtils.toBoolean(baseStoreService.getCurrentBaseStore().getCaptchaCheckEnabled()); }
From source file:de.pawlidi.openaletheia.utils.PropertiesUtils.java
/** * Return boolean value for given key. The boolean returned represents the * value true if the property value is not null and is equal, to the string * <code>'true'</code>, <code>'on'</code> or <code>'yes'</code> (case * insensitive) will return <code>true</code>. <code>'false'</code>, * <code>'off'</code> or <code>'no'</code> (case insensitive) will return * <code>false</code>. Otherwise, <code>null</code> is returned. * </p>// w w w . j a va 2 s . c o m * * @param properties * @param key * @return */ public static Boolean getBooleanProperty(Properties properties, final String key) { if (PropertiesUtils.isEmpty(properties) || StringUtils.isBlank(key)) { return null; } final String property = properties.getProperty(key); if (property == null) { return null; } return BooleanUtils.toBoolean(property); }
From source file:com.cognifide.cq.cqsm.core.servlets.ScriptUploadServlet.java
private boolean isOverwrite(SlingHttpServletRequest request) { return BooleanUtils.toBoolean(request.getParameter("overwrite")); }
From source file:com.hpe.application.automation.bamboo.tasks.RunFromFileSystemTask.java
@java.lang.Override protected Properties getTaskProperties(final TaskContext taskContext) throws Exception { final ConfigurationMap map = taskContext.getConfigurationMap(); final BuildLogger buildLogger = taskContext.getBuildLogger(); LauncherParamsBuilder builder = new LauncherParamsBuilder(); builder.setRunType(RunType.FileSystem); String timeout = map.get(RunFromFileSystemTaskConfigurator.TIMEOUT); builder.setPerScenarioTimeOut(timeout); boolean useMC = BooleanUtils.toBoolean(map.get(RunFromFileSystemTaskConfigurator.USE_MC_SETTINGS)); if (useMC) {/*from w w w . j a v a 2 s . c o m*/ String mcServerUrl = map.get(RunFromFileSystemTaskConfigurator.MCSERVERURL); String mcUserName = map.get(RunFromFileSystemTaskConfigurator.MCUSERNAME); String mcPassword = map.get(RunFromFileSystemTaskConfigurator.MCPASSWORD); String proxyAddress = null; String proxyUserName = null; String proxyPassword = null; boolean useSSL = BooleanUtils.toBoolean(map.get(RunFromFileSystemTaskConfigurator.USE_SSL)); builder.setMobileUseSSL(useSSL ? 1 : 0); if (useSSL) { buildLogger.addBuildLogEntry("********** Use SSL ********** "); } boolean useProxy = BooleanUtils.toBoolean(map.get(RunFromFileSystemTaskConfigurator.USE_PROXY)); builder.setMobileUseProxy(useProxy ? 1 : 0); if (useProxy) { buildLogger.addBuildLogEntry("********** Use Proxy ********** "); builder.setMobileProxyType(2); proxyAddress = map.get(RunFromFileSystemTaskConfigurator.PROXY_ADDRESS); //proxy info if (proxyAddress != null) { builder.setMobileProxySetting_Address(proxyAddress); } Boolean specifyAuthentication = BooleanUtils .toBoolean(RunFromFileSystemTaskConfigurator.SPECIFY_AUTHENTICATION); builder.setMobileProxySetting_Authentication(specifyAuthentication ? 1 : 0); if (specifyAuthentication) { proxyUserName = map.get(RunFromFileSystemTaskConfigurator.PROXY_USERNAME); proxyPassword = map.get(RunFromFileSystemTaskConfigurator.PROXY_PASSWORD); if (proxyUserName != null && proxyPassword != null) { builder.setMobileProxySetting_UserName(proxyUserName); builder.setMobileProxySetting_Password(proxyPassword); } } } else { builder.setMobileProxyType(0); } if (!mcInfoCheck(mcServerUrl, mcUserName, mcPassword)) { //url name password builder.setServerUrl(mcServerUrl); builder.setUserName(mcUserName); builder.setFileSystemPassword(mcPassword); String jobUUID = map.get(RunFromFileSystemTaskConfigurator.JOB_UUID); //write the specified job info(json type) to properties JobOperation operation = new JobOperation(mcServerUrl, mcUserName, mcPassword, proxyAddress, proxyUserName, proxyPassword); String mobileInfo = null; JSONObject jobJSON = null; JSONObject dataJSON = null; JSONArray extArr = null; JSONObject applicationJSONObject = null; if (jobUUID != null) { try { jobJSON = operation.getJobById(jobUUID); } catch (HttpConnectionException e) { buildLogger.addErrorLogEntry( "********** Fail to connect mobile center, please check URL, UserName, Password, and Proxy Configuration ********** "); } if (jobJSON != null) { dataJSON = (JSONObject) jobJSON.get("data"); if (dataJSON != null) { applicationJSONObject = (JSONObject) dataJSON.get("application"); if (applicationJSONObject != null) { applicationJSONObject.remove(ICON); } extArr = (JSONArray) dataJSON.get("extraApps"); if (extArr != null) { Iterator<Object> iterator = extArr.iterator(); while (iterator.hasNext()) { JSONObject extAppJSONObject = (JSONObject) iterator.next(); extAppJSONObject.remove(ICON); } } } mobileInfo = dataJSON.toJSONString(); builder.setMobileInfo(mobileInfo); } } } } String splitMarker = "\n"; String tests = map.get(RunFromFileSystemTaskConfigurator.TESTS_PATH); String[] testNames; if (tests == null) { testNames = new String[0]; } else { testNames = tests.split(splitMarker); } for (int i = 0; i < testNames.length; i++) { builder.setTest(i + 1, testNames[i]); } return builder.getProperties(); }
From source file:gr.abiss.calipso.wicket.HeaderPanel.java
public HeaderPanel(boolean simple) { super("header"); try {/*from ww w . j a va 2s . co m*/ add(new WebMarkupContainer("user").setVisible(false)); add(new WebMarkupContainer("logout").setVisible(false)); } catch (Throwable e) { e.printStackTrace(); } boolean hideLogin = BooleanUtils.toBoolean(getCalipso().loadConfig("calipso.hideLoginLink")); boolean hideRegister = BooleanUtils.toBoolean(getCalipso().loadConfig("calipso.hideRegisterLink")); final User user = getPrincipal(); if ((user == null || user.getId() == 0)) { add(new Link("login") { public void onClick() { setResponsePage(LoginPage.class); } }.setVisible(!hideLogin)); add(new Link("register") { public void onClick() { setResponsePage(RegisterAnonymousUserFormPage.class); } }.setVisible(!hideRegister));// TODO: move to config } else { add(new WebMarkupContainer("login").setVisible(false)); add(new WebMarkupContainer("register").setVisible(false)); } add(new WebMarkupContainer("dashboard").setVisible(false)); add(new WebMarkupContainer("search").setVisible(false)); add(new WebMarkupContainer("options").setVisible(false)); // add(new WebMarkupContainer("space").setVisible(false)); // add(new WebMarkupContainer("new").setVisible(false)); }
From source file:com.onehippo.gogreen.login.HstConcurrentLoginFilter.java
@SuppressWarnings("unchecked") public void init(FilterConfig filterConfig) throws ServletException { ServletContext servletContext = filterConfig.getServletContext(); usernameHttpSessionWrapperMap = (Map<String, HttpSessionWrapper>) servletContext .getAttribute(USERNAME_SESSIONID_MAP_ATTR); if (usernameHttpSessionWrapperMap == null) { usernameHttpSessionWrapperMap = Collections.synchronizedMap(new HashMap<String, HttpSessionWrapper>()); servletContext.setAttribute(USERNAME_SESSIONID_MAP_ATTR, usernameHttpSessionWrapperMap); }//www .j a v a 2 s .c o m String[] disallowConcurrentLoginUsernamesArray = StringUtils .split(filterConfig.getInitParameter("disallowConcurrentLoginUsernames"), " ,\t\r\n"); if (disallowConcurrentLoginUsernamesArray != null && disallowConcurrentLoginUsernamesArray.length > 0) { disallowConcurrentLoginUsernames = new HashSet<String>( Arrays.asList(disallowConcurrentLoginUsernamesArray)); } log.info( "HstConcurrentLoginFilter's disallowConcurrentLoginUsernames: " + disallowConcurrentLoginUsernames); String[] allowConcurrentLoginUsernamesArray = StringUtils .split(filterConfig.getInitParameter("allowConcurrentLoginUsernames"), " ,\t\r\n"); if (allowConcurrentLoginUsernamesArray != null && allowConcurrentLoginUsernamesArray.length > 0) { allowConcurrentLoginUsernames = new HashSet<String>(Arrays.asList(allowConcurrentLoginUsernamesArray)); } earlySessionInvalidation = BooleanUtils .toBoolean(filterConfig.getInitParameter("earlySessionInvalidation")); log.info("HstConcurrentLoginFilter's allowConcurrentLoginUsernames: " + allowConcurrentLoginUsernames); }
From source file:com.redhat.rhn.frontend.action.systems.monitoring.ProbeDetailsAction.java
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest req, HttpServletResponse resp) {/* w ww . j a va2s. com*/ RequestContext rctx = new RequestContext(req); ServerProbe probe = (ServerProbe) rctx.lookupProbe(); if (probe.getTemplateProbe() != null) { req.setAttribute(IS_SUITE_PROBE, Boolean.TRUE); } else { req.setAttribute(IS_SUITE_PROBE, Boolean.FALSE); } Server server = rctx.lookupAndBindServer(); DynaActionForm form = (DynaActionForm) formIn; boolean showGraph = BooleanUtils.toBoolean((Boolean) form.get(SHOW_GRAPH)); boolean showLog = BooleanUtils.toBoolean((Boolean) form.get(SHOW_LOG)); // Process the dates, default the start date to yesterday // and end date to today. Calendar today = Calendar.getInstance(); today.setTime(new Date()); Calendar yesterday = Calendar.getInstance(); yesterday.setTime(new Date()); yesterday.add(Calendar.DAY_OF_YEAR, -1); DateRangePicker picker = new DateRangePicker(form, req, yesterday.getTime(), today.getTime(), DatePicker.YEAR_RANGE_NEGATIVE, "probedetails.jsp.start_date", "probedetails.jsp.end_date"); DatePickerResults dates = picker.processDatePickers(isSubmitted(form), false); ActionMessages errors = dates.getErrors(); // Setup the Metrics array Map l10nmetrics = new HashMap(); Metric[] marray = (Metric[]) probe.getCommand().getMetrics().toArray(new Metric[0]); LabelValueBean[] metrics = new LabelValueBean[marray.length]; for (int i = 0; i < marray.length; i++) { String label = LocalizationService.getInstance().getMessage("metrics." + marray[i].getLabel()); metrics[i] = new LabelValueBean(label, marray[i].getMetricId()); l10nmetrics.put(marray[i].getMetricId(), label); } form.set(METRICS, metrics); req.setAttribute(METRICS, metrics); // Setup and deal with selected metrics. // Always have the 1st one selected String[] selectedMetrics = new String[0]; if (marray.length > 0) { if (form.get(SELECTED_METRICS) == null || ((String[]) form.get(SELECTED_METRICS)).length <= 0) { selectedMetrics = new String[1]; selectedMetrics[0] = marray[0].getMetricId(); form.set(SELECTED_METRICS, selectedMetrics); } else { selectedMetrics = (String[]) form.get(SELECTED_METRICS); } } req.setAttribute(SELECTED_METRICS, selectedMetrics); if (showLog || showGraph) { boolean valid = errors.isEmpty(); if (valid && showGraph) { // Setup the graphing specific parameters so we can // fill out the URL on details.jsp to the ProbeGraphAction StringBuilder ssString = new StringBuilder(); // We also need to localize the labels so we can // pass them into ProbeGraphAction so it can localize // the metric lables within the graph itself. StringBuilder l10nString = new StringBuilder(); // Here we concat together the selected metrics // so we don't have to do this in the JSP. The graphing // Action can take multiple metrics so we just concat them together for (int i = 0; i < selectedMetrics.length; i++) { ssString.append("metrics="); ssString.append(selectedMetrics[i]); ssString.append("&"); l10nString.append(L10NKEY + selectedMetrics[i]); l10nString.append("="); l10nString.append(StringUtil.urlEncode((String) l10nmetrics.get(selectedMetrics[i]))); l10nString.append("&"); } req.setAttribute(SELECTED_METRICS_STRING, ssString.toString()); req.setAttribute(L10NED_SELECTED_METRICS_STRING, l10nString.toString()); req.setAttribute(STARTTS, new Long(dates.getStart().getCalendar().getTimeInMillis())); req.setAttribute(ENDTS, new Long(dates.getEnd().getCalendar().getTimeInMillis())); } if (valid && showLog) { DataResult dr = MonitoringManager.getInstance().getProbeStateChangeData(probe, new Timestamp(dates.getStart().getCalendar().getTimeInMillis()), new Timestamp(dates.getEnd().getCalendar().getTimeInMillis())); req.setAttribute(ListHelper.LIST, dr); ListHelper helper = new ListHelper(this, req); helper.execute(); } } if (!errors.isEmpty()) { addErrors(req, errors); } req.setAttribute("probe", probe); req.setAttribute("system", server); if (probe.getState() == null || probe.getState().getOutput() == null) { req.setAttribute("status", LocalizationService.getInstance().getMessage("probe.empty.status")); } else { ProbeState state = probe.getState(); String statusString = LocalizationService.getInstance().getMessage(state.getState()); if (!StringUtils.isBlank(state.getOutput())) { statusString = statusString + ", " + state.getOutput(); } statusString = StringUtil.htmlifyText(statusString); req.setAttribute("status", statusString); if (probe.getState().getState().equals(MonitoringConstants.PROBE_STATE_UNKNOWN)) { req.setAttribute("status_class", "probe-status-unknown"); } else if (probe.getState().getState().equals(MonitoringConstants.PROBE_STATE_CRITICAL)) { req.setAttribute("status_class", "probe-status-critical"); } } req.setAttribute(SHOW_GRAPH, Boolean.valueOf(showGraph)); req.setAttribute(SHOW_LOG, Boolean.valueOf(showLog)); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
From source file:com.zxy.commons.lang.conf.AbstractConfigProperties.java
/** * ?keybooleantrue/false/* w w w. j a va2 s . c om*/ * * @param key key * @return value */ public boolean getBoolean(String key) { String value = properties.getProperty(key); return BooleanUtils.toBoolean(value); }