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.redhat.rhn.domain.monitoring.Probe.java
/** * Setter for notifyWarning/*from ww w . jav a2 s .c om*/ * @param notifyWarningIn to set */ public void setNotifyWarning(Boolean notifyWarningIn) { setNotifyWarning(BooleanUtils.toBoolean(notifyWarningIn) ? '1' : null); }
From source file:com.baasbox.controllers.Document.java
private static String prepareResponseToJson(List<ODocument> listOfDoc) throws IOException { response().setContentType("application/json"); Formats format;//from ww w . ja va2s .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(listOfDoc, format, true); } else { format = JSONFormats.Formats.DOCUMENT; return JSONFormats.prepareResponseToJson(listOfDoc, format); } } finally { DbHelper.filterOUserPasswords(false); } }
From source file:eionet.eunis.servlets.StatisticalResultRedirectServlet.java
/** * * @param req/*from www. j av a 2 s . com*/ * @param res * @throws ServletException * @throws IOException */ private void handleRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Chm62edtCountryPersist country = null; String servletPath = req.getServletPath(); if (servletPath == null) { return; } else if (servletPath.endsWith("sites-statistical-result.jsp") || servletPath.endsWith("habitats-country-result.jsp")) { String countryNameEn = req.getParameter("country"); if (StringUtils.isNotBlank(countryNameEn)) { country = CountryUtil.findCountry(countryNameEn); } } else if (servletPath.endsWith("species-country-result.jsp")) { int countryId = NumberUtils.toInt(req.getParameter("country")); if (countryId > 0) { country = CountryUtil.findCountry(countryId); } else { String countryNameEn = req.getParameter("countryName"); if (StringUtils.isNotBlank(countryNameEn)) { country = CountryUtil.findCountry(countryNameEn); } } } if (country == null) { res.sendRedirect(req.getContextPath() + "/countries/NOT_FOUND"); } else { String redirUrl = req.getContextPath() + "/countries/" + country.getEunisAreaCode(); if (servletPath.endsWith("sites-statistical-result.jsp")) { boolean showDesignations = BooleanUtils.toBoolean(req.getParameter("showDesignations")); if (showDesignations) { redirUrl = redirUrl + "/" + CountryFactsheetActionBean.Tab.DESIG_TYPES; } redirUrl = redirUrl + reconstructQueryString(req.getParameterMap(), "country", "showDesignations"); } else if (servletPath.endsWith("species-country-result.jsp")) { redirUrl = redirUrl + "/" + CountryFactsheetActionBean.Tab.SPECIES; redirUrl = redirUrl + reconstructQueryString(req.getParameterMap()); } else if (servletPath.endsWith("habitats-country-result.jsp")) { redirUrl = redirUrl + "/" + CountryFactsheetActionBean.Tab.HABITAT_TYPES; redirUrl = redirUrl + reconstructQueryString(req.getParameterMap()); } res.sendRedirect(redirUrl); } }
From source file:com.redhat.rhn.manager.kickstart.KickstartSessionCreateCommand.java
/** * Constructor//from w w w.ja v a 2 s. c om * @param owner who creates the session * @param ksdata KickstartData profile used for this session * @param clientIp Client IP of the kickstarting system. */ public KickstartSessionCreateCommand(Org owner, KickstartData ksdata, String clientIp) { this.ksession = new KickstartSession(); this.ksession.setKickstartMode(KickstartSession.MODE_DEFAULT_SESSION); this.ksession.setOrg(owner); this.ksession.setDeployConfigs(Boolean.FALSE); this.ksession.setPackageFetchCount(new Long(0)); this.ksession.setKsdata(ksdata); this.ksession.setVirtualizationType(ksdata.getKickstartDefaults().getVirtualizationType()); this.ksession.setKstree(ksdata.getTree()); this.ksession.setLastAction(new Date()); this.ksession.setState(KickstartFactory.SESSION_STATE_CREATED); this.ksession.setClientIp(clientIp); log.debug("serverProfile on ksdata: " + ksdata.getKickstartDefaults().getProfile()); if (ksdata.getKickstartDefaults().getProfile() != null) { Profile p = ProfileManager.lookupByIdAndOrg(ksdata.getKickstartDefaults().getProfile().getId(), owner); log.debug("setting serverProfile on session: " + p.getId()); this.ksession.setServerProfile(p); } log.debug("Saving new KickstartSession: " + this.ksession.getId()); KickstartFactory.saveKickstartSession(this.ksession); log.debug("Saved new KickstartSession: " + this.ksession.getId()); // Now create one time ActivationKey User user = UserFactory.findRandomOrgAdmin(owner); log.debug("Got random orgadmin: " + user.getLogin()); String note = LocalizationService.getInstance().getMessage("kickstart.session.newtokennote", " "); Channel toolsChannel = KickstartScheduleCommand.getToolsChannel(ksdata, user, null); log.debug("creating one-time-activation key: " + user.getLogin()); ActivationKey key = KickstartScheduleCommand.createKickstartActivationKey(user, ksdata, null, this.ksession, toolsChannel, BooleanUtils.toBoolean(ksdata.getKickstartDefaults().getCfgManagementFlag()), null, note); log.debug("added key: " + key.getKey()); // Need to add child channels to the key so when kickstarting the // system from bare metal we will have the proper child channel subscriptions. if (ksdata.getKickstartDefaults().getProfile() != null) { log.debug("Checking child channels for packages in profile."); addChildChannelsForProfile(ksdata.getKickstartDefaults().getProfile(), ksdata.getChannel(), key); } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.GridLayoutLoader.java
@Override public void createComponent() { resultComponent = (GridLayout) factory.createComponent(GridLayout.NAME); loadId(resultComponent, element);/*from ww w .j a v a2s . c om*/ Element columnsElement = element.element("columns"); if (columnsElement == null) { throw new GuiDevelopmentException("'grid' element must contain 'columns' element", context.getFullFrameId(), "Grid ID", resultComponent.getId()); } Element rowsElement = element.element("rows"); if (rowsElement == null) { throw new GuiDevelopmentException("'grid' element must contain 'rows' element", context.getFullFrameId(), "Grid ID", resultComponent.getId()); } int columnCount; @SuppressWarnings("unchecked") final List<Element> columnElements = columnsElement.elements("column"); if (columnElements.size() == 0) { try { columnCount = Integer.parseInt(columnsElement.attributeValue("count")); } catch (NumberFormatException e) { throw new GuiDevelopmentException( "'grid' element must contain either a set of 'column' elements or a 'count' attribute", context.getFullFrameId(), "Grid ID", resultComponent.getId()); } resultComponent.setColumns(columnCount); for (int i = 0; i < columnCount; i++) { resultComponent.setColumnExpandRatio(i, 1); } } else { String countAttr = columnsElement.attributeValue("count"); if (StringUtils.isNotEmpty(countAttr)) { throw new GuiDevelopmentException( "'grid' element can't contain a set of 'column' elements and a 'count' attribute", context.getFullFrameId(), "Grid ID", resultComponent.getId()); } columnCount = columnElements.size(); resultComponent.setColumns(columnCount); int i = 0; for (Element columnElement : columnElements) { String flex = columnElement.attributeValue("flex"); if (!StringUtils.isEmpty(flex)) { resultComponent.setColumnExpandRatio(i, Float.parseFloat(flex)); } i++; } } @SuppressWarnings("unchecked") List<Element> rowElements = rowsElement.elements("row"); Set<Element> invisibleRows = new HashSet<>(); int rowCount = 0; for (Element rowElement : rowElements) { String visible = rowElement.attributeValue("visible"); if (!StringUtils.isEmpty(visible)) { Boolean value = Boolean.valueOf(visible); if (BooleanUtils.toBoolean(value)) { rowCount++; } else { invisibleRows.add(rowElement); } } else { rowCount++; } } resultComponent.setRows(rowCount); int j = 0; for (Element rowElement : rowElements) { final String flex = rowElement.attributeValue("flex"); if (!StringUtils.isEmpty(flex)) { resultComponent.setRowExpandRatio(j, Float.parseFloat(flex)); } j++; } spanMatrix = new boolean[columnCount][rowElements.size()]; int row = 0; for (Element rowElement : rowElements) { if (!invisibleRows.contains(rowElement)) { createSubComponents(resultComponent, rowElement, row); row++; } } }
From source file:com.edgenius.wiki.Shell.java
/** * @return//from w w w .j av a 2 s . c o m * @throws IOException */ public static void load() { Shell.enabled = false; log.info("Loading shell.properties ..."); String root = DataRoot.getDataRoot(); if (!FileUtil.exist(root + Shell.FILE)) { try { //copy from defaultExternalResource FileOutputStream dest = FileUtil.getFileOutputStream(root + Shell.FILE); IOUtils.copy(FileUtil.getFileInputStream(FILE_DEFAULT), dest); IOUtils.closeQuietly(dest); } catch (IOException e) { log.error("Copy default shell.properties file failed", e); } } try { filelock.readLock().lock(); Properties props = FileUtil.loadProperties(root + Shell.FILE); Shell.enabled = BooleanUtils.toBoolean(props.getProperty("shell.enabled")); Shell.autoEnabled = BooleanUtils.toBoolean(props.getProperty("shell.auto.enable.at.space.creating")); Shell.rootUrl = StringUtils.trimToEmpty(props.getProperty("shell.url")); Shell.timeout = NumberUtils.toInt(props.getProperty("connection.timeout"), DEFAULT_TIMEOUT); //default 20s Shell.key = StringUtils.trimToEmpty(props.getProperty("shell.key")); //fix to add end slash if (!Shell.rootUrl.endsWith("/")) Shell.rootUrl += "/"; updateUrl(); } catch (IOException e) { log.error("Load shell.properties failed", e); } finally { filelock.readLock().unlock(); } }
From source file:info.magnolia.repository.definition.RepositoryMappingDefinitionReader.java
private void parseRepository(Element repositoryElement, RepositoryMappingDefinition definition) { String name = repositoryElement.getAttributeValue(ATTRIBUTE_NAME); String loadOnStartup = repositoryElement.getAttributeValue(ATTRIBUTE_LOAD_ON_STARTUP); String provider = repositoryElement.getAttributeValue(ATTRIBUTE_PROVIDER); RepositoryDefinition repository = new RepositoryDefinition(); repository.setName(name);/* w w w . j a v a 2s. c o m*/ repository.setProvider(provider); repository.setLoadOnStartup(BooleanUtils.toBoolean(loadOnStartup)); // parse repository parameters Map<String, String> parameters = new HashMap<String, String>(); for (Object element : repositoryElement.getChildren(ELEMENT_PARAM)) { Element parameterElement = (Element) element; String parameterName = parameterElement.getAttributeValue(ATTRIBUTE_NAME); String value = parameterElement.getAttributeValue(ATTRIBUTE_VALUE); parameters.put(parameterName, value); } // TODO : it looks like params here are not interpolated repository.setParameters(parameters); // parse workspace names @SuppressWarnings("unchecked") List<Element> workspaces = repositoryElement.getChildren(ELEMENT_WORKSPACE); if (workspaces == null || workspaces.isEmpty()) { // TODO this does not belong in the parser repository.addWorkspace(DEFAULT_WORKSPACE_NAME); } else { for (Element element : workspaces) { String workspaceName = element.getAttributeValue(ATTRIBUTE_NAME); repository.addWorkspace(workspaceName); } } definition.addRepository(repository); }
From source file:info.magnolia.cms.beans.config.Subscriber.java
/** * Cache listener content from the config repository. *///from ww w . j av a 2 s . co m private static void cacheContent(Collection subs) { Iterator ipList = subs.iterator(); // start by setting the subscribersEnabled property to false, will be reset when an active subscriber is found subscribersEnabled = false; while (ipList.hasNext()) { Content c = (Content) ipList.next(); Subscriber si = new Subscriber(); si.url = c.getNodeData("URL").getString(); //$NON-NLS-1$ if (StringUtils.isEmpty(si.url)) { String address = c.getNodeData("address").getString(); //$NON-NLS-1$ String protocol = c.getNodeData("protocol").getString(); //$NON-NLS-1$ log.warn( "Deprecated: subscriber is missing the URL property. Please use URL instead of address and domain"); if (StringUtils.isEmpty(protocol)) { protocol = "http"; si.url = protocol + "://" + address; } } if (!si.url.endsWith("/")) { si.url = si.url + "/"; } si.senderURL = c.getNodeData("senderURL").getString(); //$NON-NLS-1$ si.requestConfirmation = c.getNodeData("requestConfirmation").getBoolean(); //$NON-NLS-1$ si.name = c.getName(); // don't use getBoolean since subscribers without an "active" node should be enabled by default String activeString = c.getNodeData("active").getString(); //$NON-NLS-1$ if (StringUtils.isNotEmpty(activeString)) { si.active = BooleanUtils.toBoolean(activeString); } else { si.active = true; } if (si.active) { // at least one subscriber is enabled subscribersEnabled = true; } // all context info try { addContext(si, c); } catch (RepositoryException e) { // valid } Subscriber.cachedContent.put(c.getName(), si); } ipList = null; }
From source file:com.edgenius.wiki.render.handler.TOCHandler.java
@SuppressWarnings("unchecked") public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) { TreeMap<Integer, HeadingModel> tree = new TreeMap<Integer, HeadingModel>(new CompareToComparator()); List<HeadingModel> list = (List<HeadingModel>) renderContext.getGlobalParam(TOCMacro.class.getName()); //hi, here cannot simple return even list is null because the TOCMacro place holder need remove in following code. if (list != null) { for (HeadingModel headingModel : list) { //OK, find heading model, then put it into sorted list tree.put(headingModel.getOrder(), headingModel); }/*from w w w . j av a 2s. c o m*/ //in buildTOCHTML() method, {toc} will replace to "no head exist" string } Collection<HeadingModel> headTree = tree.values(); //replace all TOCMacro(GlobalFilter) object in renderPiece by TOC HTML string. int deep = 3; String align = null; boolean ordered = true; Map<String, String> map = new HashMap<String, String>(); if (values != null) { //get back deep, order and align value. String deepStr = values.get(NameConstants.DEEP); String orderStr = values.get(NameConstants.ORDERED); align = values.get(NameConstants.ALIGN); map.put(NameConstants.DEEP, deepStr); map.put(NameConstants.ALIGN, align); map.put(NameConstants.ORDERED, orderStr); deep = NumberUtils.toInt(deepStr, 3); if (orderStr == null) { //default value is true! show ordered list ordered = true; } else { ordered = BooleanUtils.toBoolean(values.get(NameConstants.ORDERED)); } } String wajax = ""; if (map.size() > 0) wajax = RichTagUtil.buildWajaxAttributeString(this.getClass().getName(), map); List<RenderPiece> pieces = new ArrayList<RenderPiece>(); pieces.addAll(buildTOCHTML(renderContext, headTree, deep, align, !ordered, wajax)); return pieces; }
From source file:com.autonomy.aci.client.services.impl.AbstractStAXProcessor.java
/** * This constructor gets a new {@link XMLInputFactory} instance that is reused every time * {@link #process(com.autonomy.aci.client.transport.AciResponseInputStream)} is called, this * should be faster than creating a new instance every time this method is called. * <p>//from w w w. j av a 2 s .co m * The properties are set to the following defaults if they are not specified as system properties: * <table summary=""> * <tr><th>Property</th><th>Default</th></tr> * <tr><td>XMLInputFactory.IS_NAMESPACE_AWARE</td><td><tt>false</tt></td></tr> * <tr><td>XMLInputFactory.IS_VALIDATING<tt>false</tt></td></tr> * <tr><td>XMLInputFactory.IS_COALESCING<tt>false</tt></td></tr> * <tr><td>XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES<tt>true</tt></td></tr> * <tr><td>XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES<tt>false</tt></td></tr> * <tr><td>XMLInputFactory.SUPPORT_DTD<tt>true</tt></td></tr> * </table> */ protected AbstractStAXProcessor() { // See if the various XMLInputFactory properties are set as system properties... namespaceAware = BooleanUtils.toBoolean( StringUtils.defaultString(System.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE), "false")); validating = BooleanUtils .toBoolean(StringUtils.defaultString(System.getProperty(XMLInputFactory.IS_VALIDATING), "false")); coalescing = BooleanUtils .toBoolean(StringUtils.defaultString(System.getProperty(XMLInputFactory.IS_COALESCING), "false")); replacingEntityReferences = BooleanUtils.toBoolean(StringUtils .defaultString(System.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES), "true")); supportingExternalEntities = BooleanUtils.toBoolean(StringUtils .defaultString(System.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES), "false")); supportDtd = BooleanUtils .toBoolean(StringUtils.defaultString(System.getProperty(XMLInputFactory.SUPPORT_DTD), "true")); // Create the XMLStreamReader factory... xmlInputFactory = XMLInputFactory.newInstance(); }