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:gr.abiss.calipso.domain.State.java
public State(Element e) { this.element = e; this.status = Integer.parseInt(e.attributeValue(STATUS)); String xmlPlugin = e.attributeValue(PLUGIN); // plugin//from www . j ava2s . c o m if (StringUtils.isNotBlank(xmlPlugin)) { this.plugin = xmlPlugin; } String xmlAssetTypeId = e.attributeValue(ASSET_TYPE_ID); // asset type id if (StringUtils.isNotBlank(xmlAssetTypeId)) { assetTypeId = NumberUtils.toLong(xmlAssetTypeId); } String xmlExistingAssetTypeId = e.attributeValue(EXISTING_ASSET_TYPE_ID); // asset type id if (StringUtils.isNotBlank(xmlExistingAssetTypeId)) { existingAssetTypeId = NumberUtils.toLong(xmlExistingAssetTypeId); } String xmlExistingAssetTypeMultiple = e.attributeValue(EXISTING_ASSET_TYPE_MULTIPLE); if (StringUtils.isNotBlank(xmlExistingAssetTypeMultiple)) { this.existingAssetTypeMultiple = BooleanUtils.toBoolean(existingAssetTypeMultiple); } // max duration String sMaxDuration = e.attributeValue(MAX_DURATION); if (StringUtils.isNotBlank(sMaxDuration)) { this.maxDuration = NumberUtils.createLong(e.attributeValue(MAX_DURATION)); } // transition for (Object o : e.elements(TRANSITION)) { Element t = (Element) o; transitions.add(new Integer(t.attributeValue(STATUS))); } // field for (Object o : e.elements(FIELD)) { Element f = (Element) o; String mask = f.attributeValue(MASK); String fieldName = f.attributeValue(NAME); fields.put(Field.convertToName(fieldName), NumberUtils.toInt(mask, 1)); } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.ColorPickerLoader.java
protected void loadDefaultCaptionEnabled(ColorPicker component, Element element) { String defaultCaptionEnabled = element.attributeValue("defaultCaptionEnabled"); if (StringUtils.isNotEmpty(defaultCaptionEnabled)) { component.setDefaultCaptionEnabled(BooleanUtils.toBoolean(defaultCaptionEnabled)); }/*from w w w . jav a 2s. c om*/ }
From source file:gr.abiss.calipso.domain.Field.java
public Field(Element e) { setName(e.attributeValue(NAME));/*from w w w . ja v a 2 s . c o m*/ label = e.attributeValue(LABEL); this.groupId = e.attributeValue(GROUP_ID); //logger.info("loaded field "+this.getName().getText()+" with group id: "+this.groupId); // TODO: we can use the same way to add a PK for database records or // drop-down options fieldType = e.attributeValue(FIELDTYPE); validationExpressionId = NumberUtils.toLong(e.attributeValue(VALIDATIONEXPR)); if (e.attribute(OPTIONAL) != null) { optional = BooleanUtils.toBoolean(e.attributeValue(OPTIONAL)); } if (e.attribute(PRIORITY) != null) { priority = NumberUtils.toInt(e.attributeValue(PRIORITY)); } if (this.getName().isFreeText()) { if (e.attribute(MULTIVALUE) != null) { this.multivalue = BooleanUtils.toBoolean(e.attributeValue(MULTIVALUE)); } if (e.attribute(LINECOUNT) != null) { this.lineCount = Short.parseShort(e.attributeValue(LINECOUNT)); } } if (e.attribute(DEFAULT_VALUE) != null) { this.defaultValueExpression = e.attributeValue(DEFAULT_VALUE); } if (e.element("field-config") != null) { this.xmlConfig = FieldConfig.fromXML(e.element("field-config").asXML()); } // TODO: remove this, we should only load options from database instead of tree for (Object o : e.elements(OPTION)) { addOption((Element) o); } }
From source file:jp.primecloud.auto.ui.MyCloudTabs.java
MyCloudTabs() { // ??//*from ww w. j a v a 2s .co m*/ String enableLoadBalancer = Config.getProperty("ui.enableLoadBalancer"); this.enableLoadBalancer = (enableLoadBalancer == null) || (BooleanUtils.toBoolean(enableLoadBalancer)); setSizeFull(); // ??disable?????? tabDesc.setSizeFull(); tabDesc.setEnabled(false); tabDesc.addStyleName(Reindeer.TABSHEET_BORDERLESS); addStyleName(Reindeer.PANEL_LIGHT); VerticalLayout layout = (VerticalLayout) getContent(); layout.setSizeFull(); layout.setSpacing(false); layout.setMargin(false); // pnService.setSizeFull(); pnService.addStyleName(Reindeer.PANEL_LIGHT); VerticalLayout vlService = (VerticalLayout) pnService.getContent(); vlService.setSizeFull(); vlService.addStyleName("service-tab"); vlService.setSpacing(false); vlService.setMargin(false); //? SplitPanel splService = new SplitPanel(); splService.setOrientation(SplitPanel.ORIENTATION_VERTICAL); splService.setSplitPosition(40); splService.setSizeFull(); vlService.addComponent(splService); vlService.setExpandRatio(splService, 10); //? VerticalLayout layServiceUpper = new VerticalLayout(); layServiceUpper.setSizeFull(); layServiceUpper.setSpacing(false); layServiceUpper.setMargin(false); layServiceUpper.addComponent(serviceButtonsTop); layServiceUpper.addComponent(serviceTable); layServiceUpper.addComponent(serviceButtonsBottom); layServiceUpper.setExpandRatio(serviceTable, 10); splService.addComponent(layServiceUpper); //? splService.addComponent(serviceDesc); tabDesc.addTab(pnService, ViewProperties.getCaption("tab.service"), Icons.SERVICETAB.resource()); //? pnServer.setSizeFull(); pnServer.addStyleName(Reindeer.PANEL_LIGHT); VerticalLayout vlServer = (VerticalLayout) pnServer.getContent(); vlServer.setSizeFull(); vlServer.addStyleName("server-tab"); vlServer.setSpacing(false); vlServer.setMargin(false); //? SplitPanel splServer = new SplitPanel(); splServer.setOrientation(SplitPanel.ORIENTATION_VERTICAL); splServer.setSplitPosition(40); splServer.setSizeFull(); vlServer.addComponent(splServer); //? VerticalLayout layServerUpper = new VerticalLayout(); layServerUpper.setSizeFull(); layServerUpper.setSpacing(false); layServerUpper.setMargin(false); layServerUpper.addComponent(serverButtonsTop); layServerUpper.addComponent(serverTable); layServerUpper.addComponent(serverButtonsBottom); layServerUpper.setExpandRatio(serverTable, 10); splServer.addComponent(layServerUpper); //? splServer.addComponent(serverDesc); tabDesc.addTab(pnServer, ViewProperties.getCaption("tab.server"), Icons.SERVERTAB.resource()); //? pnLoadBalancer.setSizeFull(); pnLoadBalancer.addStyleName(Reindeer.PANEL_LIGHT); VerticalLayout vlLBalancer = (VerticalLayout) pnLoadBalancer.getContent(); vlLBalancer.setSizeFull(); vlLBalancer.addStyleName("loadbalancer-tab"); vlLBalancer.setSpacing(false); vlLBalancer.setMargin(false); CssLayout hLBalancer = new CssLayout(); Label lLBalancer = new Label(ViewProperties.getCaption("label.loadbalancer")); hLBalancer.setWidth("100%"); hLBalancer.setMargin(true); hLBalancer.addStyleName("loadbalancer-table-label"); hLBalancer.addComponent(lLBalancer); hLBalancer.setHeight("28px"); //? SplitPanel splLBalancer = new SplitPanel(); splLBalancer.setOrientation(SplitPanel.ORIENTATION_VERTICAL); splLBalancer.setSplitPosition(40); splLBalancer.setSizeFull(); vlLBalancer.addComponent(splLBalancer); //? VerticalLayout layLBUpper = new VerticalLayout(); layLBUpper.setSizeFull(); layLBUpper.setSpacing(false); layLBUpper.setMargin(false); layLBUpper.addComponent(hLBalancer); layLBUpper.addComponent(loadBalancerTable); layLBUpper.addComponent(loadBalancerTableOpe); layLBUpper.setExpandRatio(loadBalancerTable, 10); splLBalancer.addComponent(layLBUpper); //? splLBalancer.addComponent(loadBalancerDesc); if (this.enableLoadBalancer) { tabDesc.addTab(pnLoadBalancer, ViewProperties.getCaption("tab.loadbalancer"), Icons.LOADBALANCER_TAB.resource()); } // tabDesc.addListener(TabSheet.SelectedTabChangeEvent.class, this, "selectedTabChange"); layout.addComponent(tabDesc); Refresher timer = new Refresher(); timer.setRefreshInterval(15 * 1000); //(msec) timer.addListener(new Refresher.RefreshListener() { @Override public void refresh(Refresher source) { if (needsRefresh()) { refreshTableOnly(); } } }); layout.addComponent(timer); layout.setExpandRatio(tabDesc, 100); }
From source file:fr.hoteia.qalingo.core.service.impl.EngineSettingServiceImpl.java
public boolean getEmailFileMirroringActivated(String context) { EngineSetting engineSetting = getEmailFileMirroringActivated(); boolean emailFileMirroringActivated = false; if (engineSetting != null) { emailFileMirroringActivated = BooleanUtils.toBoolean(engineSetting.getDefaultValue()); EngineSettingValue engineSettingValue = engineSetting.getEngineSettingValue(context); if (engineSettingValue != null) { emailFileMirroringActivated = BooleanUtils.toBoolean(engineSettingValue.getValue()); }/*from w w w .j av a2 s. c o m*/ } return emailFileMirroringActivated; }
From source file:info.magnolia.cms.util.Resource.java
/** * Check for preview mode.//from w w w . ja v a 2 s . c o m * @param req HttpServletRequest as received in JSP or servlet * @return boolean , true if preview is enabled */ public static boolean showPreview(HttpServletRequest req) { // first check if its set in request scope if (req.getParameter(MGNL_PREVIEW_ATTRIBUTE) != null) { return BooleanUtils.toBoolean(req.getParameter(MGNL_PREVIEW_ATTRIBUTE)); } else { HttpSession httpsession = req.getSession(false); if (httpsession != null) { return BooleanUtils.toBoolean((Boolean) httpsession.getAttribute(MGNL_PREVIEW_ATTRIBUTE)); } } return false; }
From source file:jp.primecloud.auto.component.mysql.process.MySQLPuppetComponentProcess.java
@Override protected Map<String, Object> createComponentMap(Long componentNo, ComponentProcessContext context, boolean start) { Map<String, Object> map = super.createComponentMap(componentNo, context, start); // masterInstanceNoMap Map<Long, Long> masterInstanceNoMap = createMasterInstanceNoMap(componentNo, context, start); map.put("masterInstanceNoMap", masterInstanceNoMap); // phpMyAdmin ComponentConfig componentConfig = componentConfigDao.readByComponentNoAndConfigName(componentNo, MySQLConstants.CONFIG_NAME_PHP_MY_ADMIN); if (componentConfig != null) { boolean phpMyAdmin = BooleanUtils.toBoolean(componentConfig.getConfigValue()); map.put("phpMyAdmin", phpMyAdmin); }/*from ww w. java 2s .c o m*/ return map; }
From source file:gr.abiss.calipso.tiers.controller.AbstractModelController.java
/** * Find all resources matching the given criteria and return a paginated * collection<br/>//from ww w . ja v a 2s. c om * REST webservice published : GET * /search?page=0&size=20&properties=sortPropertyName&direction=asc * * @param page * Page number starting from 0 (default) * @param size * Number of resources by pages. default to 10 * @return OK http status code if the request has been correctly processed, * with the a paginated collection of all resource enclosed in the * body. */ @Override @RequestMapping(method = RequestMethod.GET) @ResponseBody //@ApiOperation(value = "find (paginated)", notes = "Find all resources matching the given criteria and return a paginated collection", httpMethod = "GET") public Page<T> findPaginated(@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "size", required = false, defaultValue = "10") Integer size, @RequestParam(value = "properties", required = false, defaultValue = "id") String sort, @RequestParam(value = "direction", required = false, defaultValue = "ASC") String direction) { boolean applyCurrentPrincipalIdPredicate = true; if (BooleanUtils.toBoolean(request.getParameter("skipCurrentPrincipalIdPredicate"))) { applyCurrentPrincipalIdPredicate = false; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Skipping CurrentPrincipalIdPredicate"); } } return findPaginated(page, size, sort, direction, request.getParameterMap(), applyCurrentPrincipalIdPredicate); }
From source file:com.edgenius.wiki.webapp.servlet.UploadServlet.java
@SuppressWarnings("unchecked") protected void doService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if ("GET".equalsIgnoreCase(request.getMethod())) { //just render blank page for upload String pageUuid = request.getParameter("puuid"); String spaceUname = request.getParameter("uname"); String draft = request.getParameter("draft"); request.setAttribute("pageUuid", pageUuid); request.setAttribute("spaceUname", spaceUname); request.setAttribute("draft", NumberUtils.toInt(draft, PageType.NONE_DRAFT.value())); request.getRequestDispatcher("/WEB-INF/pages/upload.jsp").forward(request, response); return;//from w ww . ja va 2 s . c om } //post - upload // if(WikiUtil.getUser().isAnonymous()){ // //anonymous can not allow to upload any files PageService pageService = getPageService(); ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); List<FileNode> files = new ArrayList<FileNode>(); String pageUuid = null, spaceUname = null; try { int status = PageType.NONE_DRAFT.value(); // index->filename Map<String, FileItem> fileMap = new HashMap<String, FileItem>(); Map<String, String> descMap = new HashMap<String, String>(); // index->index Map<String, String> indexMap = new HashMap<String, String>(); //offline submission, filename put into hidden variable rather than <input type="file> tag Map<String, String> filenameMap = new HashMap<String, String>(); //TODO: offline submission, version also upload together with file, this give a change to do failure tolerance check: //if version is same with online save, then it is OK, if greater, means it maybe duplicated upload, if less, unpexected case Map<String, String> versionMap = new HashMap<String, String>(); Map<String, Boolean> bulkMap = new HashMap<String, Boolean>(); Map<String, Boolean> sharedMap = new HashMap<String, Boolean>(); List<FileItem> items = upload.parseRequest(request); for (FileItem item : items) { String name = item.getFieldName(); if (StringUtils.equals(name, "spaceUname")) { spaceUname = item.getString(Constants.UTF8); } else if (StringUtils.equals(name, "pageUuid")) { pageUuid = item.getString(); } else if (name.startsWith("draft")) { // check this upload is from "click save button" or "auto upload in draft status" status = Integer.parseInt(item.getString()); } else if (name.startsWith("file")) { fileMap.put(name.substring(4), item); indexMap.put(name.substring(4), name.substring(4)); } else if (name.startsWith("desc")) { descMap.put(name.substring(4), item.getString(Constants.UTF8)); } else if (name.startsWith("shar")) { sharedMap.put(name.substring(4), Boolean.parseBoolean(item.getString())); } else if (name.startsWith("name")) { filenameMap.put(name.substring(4), item.getString()); } else if (name.startsWith("vers")) { versionMap.put(name.substring(4), item.getString()); } else if (name.startsWith("bulk")) { bulkMap.put(name.substring(4), BooleanUtils.toBoolean(item.getString())); } } if (StringUtils.isBlank(pageUuid)) { log.error("Attachment can not be load because of page does not save successfully."); throw new PageException("Attachment can not be load because of page does not save successfully."); } List<FileNode> bulkFiles = new ArrayList<FileNode>(); String username = request.getRemoteUser(); // put file/desc pair into final Map for (String id : fileMap.keySet()) { FileItem item = fileMap.get(id); if (item == null || item.getInputStream() == null || item.getSize() <= 0) { log.warn("Empty upload item:" + (item != null ? item.getName() : "")); continue; } FileNode node = new FileNode(); node.setComment(descMap.get(id)); node.setShared(sharedMap.get(id) == null ? false : sharedMap.get(id)); node.setFile(item.getInputStream()); String filename = item.getName(); if (StringUtils.isBlank(filename)) { //this could be offline submission, get name from map filename = filenameMap.get(id); } node.setFilename(FileUtil.getFileName(filename)); node.setContentType(item.getContentType()); node.setIndex(indexMap.get(id)); node.setType(RepositoryService.TYPE_ATTACHMENT); node.setIdentifier(pageUuid); node.setCreateor(username); node.setStatus(status); node.setSize(item.getSize()); node.setBulkZip(bulkMap.get(id) == null ? false : bulkMap.get(id)); files.add(node); if (node.isBulkZip()) bulkFiles.add(node); } if (spaceUname != null && pageUuid != null && files.size() > 0) { files = pageService.uploadAttachments(spaceUname, pageUuid, files, false); //only save non-draft uploaded attachment if (status == 0) { try { getActivityLog().logAttachmentUploaded(spaceUname, pageService.getCurrentPageByUuid(pageUuid).getTitle(), WikiUtil.getUser(), files); } catch (Exception e) { log.warn("Activity log save error for attachment upload", e); } } //as bulk files won't in return list in PageService.uploadAttachments(), here need //append to all return list, but only for client side "uploading panel" clean purpose files.addAll(bulkFiles); //TODO: if version come in together, then do check // if(versionMap.size() > 0){ // for (FileNode node: files) { // // } // } } } catch (RepositoryQuotaException e) { FileNode att = new FileNode(); att.setError(getMessageService().getMessage("err.quota.exhaust")); files = Arrays.asList(att); } catch (AuthenticationException e) { String redir = ((RedirectResponseWrapper) response).getRedirect(); if (redir == null) redir = WikiConstants.URL_LOGIN; log.info("Send Authentication redirect URL " + redir); FileNode att = new FileNode(); att.setError(getMessageService().getMessage("err.authentication.required")); files = Arrays.asList(att); } catch (AccessDeniedException e) { String redir = ((RedirectResponseWrapper) response).getRedirect(); if (redir == null) redir = WikiConstants.URL_ACCESS_DENIED; log.info("Send AccessDenied redirect URL " + redir); FileNode att = new FileNode(); att.setError(getMessageService().getMessage("err.access.denied")); files = Arrays.asList(att); } catch (Exception e) { // FileUploadException,RepositoryException log.error("File upload failed ", e); FileNode att = new FileNode(); att.setError(getMessageService().getMessage("err.upload")); files = Arrays.asList(att); } try { String json = FileNode.toAttachmentsJson(files, spaceUname, WikiUtil.getUser(), getMessageService(), getUserReadingService()); //TODO: does not compress request in Gzip, refer to //http://www.google.com/codesearch?hl=en&q=+RemoteServiceServlet+show:PAbNFg2Qpdo:akEoB_bGF1c:4aNSrXYgYQ4&sa=N&cd=1&ct=rc&cs_p=https://ssl.shinobun.org/svn/repos/trunk&cs_f=proprietary/gwt/gwt-user/src/main/java/com/google/gwt/user/server/rpc/RemoteServiceServlet.java#first byte[] reply = json.getBytes(Constants.UTF8); response.setContentLength(reply.length); response.setContentType("text/plain; charset=utf-8"); response.getOutputStream().write(reply); } catch (IOException e) { log.error(e.toString(), e); } }
From source file:com.fiveamsolutions.nci.commons.web.filter.UsernameFilter.java
/** * {@inheritDoc} */ public void init(FilterConfig filterConfig) { caseSensitive = BooleanUtils.toBoolean(filterConfig.getInitParameter("caseSensitive")); }