List of usage examples for org.apache.commons.lang StringUtils defaultString
public static String defaultString(String str)
Returns either the passed in String, or if the String is null
, an empty String ("").
From source file:gtu._work.ui.ObnfInsertCreaterUI.java
private void manualDefineDbFieldBtnAction() { String manualDefineText = manualDefineArea.getText(); String manualDefinePkText = StringUtils.defaultString(manualDefinePkArea.getText()); if (StringUtils.isBlank(manualDefineText)) { JCommonUtil._jOptionPane_showMessageDialog_error("?"); return;/*from w ww . jav a 2s. c o m*/ } Set<String> useList = new HashSet<String>(); StringTokenizer tok = new StringTokenizer(manualDefineText); while (tok.hasMoreElements()) { String f = (String) tok.nextElement(); useList.add(f); } Set<String> pkList = new HashSet<String>(); StringTokenizer tok2 = new StringTokenizer(manualDefinePkText); while (tok2.hasMoreElements()) { String f = (String) tok2.nextElement(); pkList.add(f); } Map<String, String> pkMap = new HashMap<String, String>(); Map<String, String> columnMap = new HashMap<String, String>(); DefaultListModel dbFieldListModel = (DefaultListModel) dbFieldList.getModel(); if (dbFieldListModel.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error("\"?ObnfString\""); return; } for (Enumeration<?> enu = dbFieldListModel.elements(); enu.hasMoreElements();) { KeyValue kv = (KeyValue) enu.nextElement(); if (!pkList.isEmpty() && pkList.contains(kv.getKey())) { pkMap.put(kv.getKey(), kv.value); } else if (pkList.isEmpty() && kv.pk) { pkMap.put(kv.getKey(), kv.value); } else { columnMap.put(kv.getKey(), kv.value); } } StringBuffer sb = new StringBuffer(); sb.append("COLUMN=>\n"); this.keepKey(columnMap, useList, sb); JCommonUtil._jOptionPane_showMessageDialog_info(sb); this.putToDbFieldList(pkMap, columnMap); }
From source file:info.magnolia.module.admininterface.AdminTreeMVCHandler.java
/** * Create the html for the tree. Calls tree.getHtml after calling prepareTree. * @param html/*ww w . j a v a 2 s . c om*/ */ protected void renderTree(StringBuffer html) { String mode = StringUtils.defaultString(this.getRequest().getParameter("treeMode")); //$NON-NLS-1$ boolean snippetMode = mode.equals("snippet"); //$NON-NLS-1$ Tree tree = getTree(); tree.setJavascriptTree("mgnlTreeControl"); //$NON-NLS-1$ tree.setBrowseMode(this.isBrowseMode()); if (!snippetMode) { html.append("<html><head>"); //$NON-NLS-1$ html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"); //$NON-NLS-1$ renderHeaderIncludes(html); html.append("<title>Magnolia</title>"); //$NON-NLS-1$ html.append("<script>window.onresize = mgnlTreeResize;</script>"); //$NON-NLS-1$ html.append("</head>"); //$NON-NLS-1$ html.append("<body class=\"mgnlBgDark\" onload=\""); html.append(tree.getJavascriptTree()); html.append(".resizeOnload();\" >"); } tree.setSnippetMode(snippetMode); tree.setHeight(50); tree.setPath(path); this.getConfiguration().prepareTree(tree, this.isBrowseMode(), this.getRequest()); this.getConfiguration().prepareContextMenu(tree, this.isBrowseMode(), this.getRequest()); this.getConfiguration().prepareFunctionBar(tree, this.isBrowseMode(), this.getRequest()); if (!snippetMode) { html.append("<div id=\""); html.append(tree.getJavascriptTree()); html.append("_DivSuper\" style=\"display:block;\">"); } html.append(tree.getHtml()); if (!snippetMode) { html.append("</div>"); //$NON-NLS-1$ } if (!snippetMode) { html.append("</body></html>"); //$NON-NLS-1$ } }
From source file:info.magnolia.link.LinkUtil.java
/** * Converts provided Link to an UUID link pattern. * @param link Link to convert.// w w w . j ava 2s.com * @return UUID link pattern representation of provided link. */ public static String toPattern(Link link) { return "${link:{" + "uuid:{" + link.getUUID() + "}," + "repository:{" + link.getWorkspace() + "}," + "path:{" + link.getPath() + "}," // original handle represented by the uuid + "nodeData:{" + StringUtils.defaultString(link.getNodeDataName()) + "}," // in case of binaries + "extension:{" + StringUtils.defaultString(link.getExtension()) + "}" // the extension to use if no extension can be resolved otherwise + "}}" + (StringUtils.isNotEmpty(link.getAnchor()) ? "#" + link.getAnchor() : "") + (StringUtils.isNotEmpty(link.getParameters()) ? "?" + link.getParameters() : ""); }
From source file:com.htmlhifive.tools.wizard.download.DownloadModule.java
/** * ZIP?.// w ww . j a va2 s . c o m * * @param libraryNode * @param perLibWork libWork * @param folder * @param monitor * @param logger . * @return ???????. * @throws IOException IO * @throws CoreException */ private boolean downloadZip(LibraryNode libraryNode, int perLibWork, IContainer folder, IProgressMonitor monitor, ResultStatus logger) throws IOException, CoreException { boolean result = true; boolean addStatus = false; ZipFile cachedZipFile = null; String cachedSite = null; Library library = libraryNode.getValue(); if (!library.getSite().isEmpty()) { int perSiteWork = Math.max(1, perLibWork / library.getSite().size()); for (Site site : library.getSite()) { String siteUrl = site.getUrl(); String path = H5IOUtils.getURLPath(siteUrl); if (path == null) { logger.log(Messages.SE0082, siteUrl); continue; } boolean setWorked = false; IContainer savedFolder = folder; if (site.getExtractPath() != null) { savedFolder = savedFolder.getFolder(Path.fromOSString(site.getExtractPath())); } // ?. IFile iFile = null; if (path.endsWith(".zip") || path.endsWith(".jar") || site.getFilePattern() != null) { // Zip // ?????????. if (!siteUrl.equals(cachedSite)) { cachedZipFile = download(monitor, perSiteWork, logger, null, siteUrl); setWorked = true; if (!lastDownloadStatus || cachedZipFile == null) { libraryNode.setInError(true); result = false; break; } cachedSite = siteUrl; } final ZipFile zipFile = cachedZipFile; // int perZipWork = Math.max(1, perSiteWork / zipFile.size()); // Zip. for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) { final ZipEntry zipEntry = e.nextElement(); if (site.getFilePattern() != null && !FilenameUtils.wildcardMatch(zipEntry.getName(), site.getFilePattern())) { // ???. continue; } IContainer savedFolder2 = savedFolder; String wildCardStr = StringUtils.defaultString(site.getFilePattern()); if (wildCardStr.contains("*") && wildCardStr.contains("/")) { // ??????. wildCardStr = StringUtils.substringBeforeLast(site.getFilePattern(), "/"); } String entryName = zipEntry.getName(); if (entryName.startsWith(wildCardStr + "/")) { entryName = entryName.substring(wildCardStr.length() + 1); } if (zipEntry.isDirectory()) { // zip?????. if (StringUtils.isNotEmpty(entryName)) { // ?. savedFolder2 = savedFolder2.getFolder(Path.fromOSString(entryName)); if (libraryNode.isAddable() && !savedFolder2.exists()) { logger.log(Messages.SE0091, savedFolder2.getFullPath()); H5IOUtils.createParentFolder(savedFolder2, null); logger.log(Messages.SE0092, savedFolder2.getFullPath()); } else if (libraryNode.getState() == LibraryState.REMOVE && savedFolder2.exists()) { // . logger.log(Messages.SE0095, savedFolder2.getFullPath()); H5IOUtils.createParentFolder(savedFolder2, null); logger.log(Messages.SE0096, savedFolder2.getFullPath()); } } } else { // zip. // ???. if (site.getReplaceFileName() != null) { iFile = savedFolder2.getFile(Path.fromOSString(site.getReplaceFileName())); } else { iFile = savedFolder2.getFile(Path.fromOSString(entryName)); } // ?. updateFile(monitor, 0, logger, iFile, new ZipFileContentsHandler(zipFile, zipEntry)); addStatus = true; } } if (savedFolder.exists() && savedFolder.members().length == 0) { // ????. savedFolder.delete(true, monitor); } } else { // ???. if (site.getReplaceFileName() != null) { iFile = savedFolder.getFile(Path.fromOSString(site.getReplaceFileName())); } else { // . iFile = savedFolder.getFile(Path.fromOSString(StringUtils.substringAfterLast(path, "/"))); } // . download(monitor, perSiteWork, logger, iFile, siteUrl); setWorked = true; if (!lastDownloadStatus) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(Messages.SE0101, iFile != null ? iFile.getFullPath().toString() : StringUtils.defaultString(site.getFilePattern()), site.getUrl(), site.getFilePattern()); libraryNode.setInError(true); } else { addStatus = true; } } // ?????. // . if (!addStatus) { // SE0099=ERROR,???????URL={1}, File={2} logger.log(Messages.SE0099, site.getUrl(), iFile != null ? iFile.getFullPath().toString() : StringUtils.defaultString(site.getFilePattern())); libraryNode.setInError(true); result = false; } // folder.refreshLocal(IResource.DEPTH_ZERO, null); // // SE0102=INFO,???? // logger.log(Messages.SE0102); // logger.log(Messages.SE0068, iFile.getFullPath()); if (!setWorked) { monitor.worked(perSiteWork); } } } else { monitor.worked(perLibWork); } return result; }
From source file:fr.paris.lutece.plugins.mylutece.modules.wssodatabase.authentication.web.WssodatabaseJspBean.java
/** * Returns users management form//from ww w . j ava 2 s . co m * * @param request The Http request * @return Html form */ public String getManageUsers(HttpServletRequest request) { setPageTitleProperty(PROPERTY_PAGE_TITLE_MANAGE_USERS); AdminUser user = AdminUserService.getAdminUser(request); boolean rightRoles = false; if (user.checkRight(RIGHT_MANAGE_WSSO_ROLES)) { rightRoles = true; } String strEmail = StringUtils.defaultString(request.getParameter(MARK_EMAIL)); String strUserLastName = StringUtils.defaultString(request.getParameter(MARK_LAST_NAME)); String strUserFirstName = StringUtils.defaultString(request.getParameter(MARK_FIRST_NAME)); Collection<WssoUser> userList = WssoUserHome.findWssoUsersByLastNameOrFirstNameOrEmailByProfil( strUserLastName, strUserFirstName, strEmail, getPlugin()); Map<String, Object> model = new HashMap<String, Object>(); model.put(MARK_USERS_LIST, userList); model.put(MARK_PLUGIN_NAME, getPlugin().getName()); model.put(MARK_RIGHT_MANAGE_ROLES, rightRoles); model.put(MARK_EMAIL, strEmail); model.put(MARK_LAST_NAME, strUserLastName); model.put(MARK_FIRST_NAME, strUserFirstName); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MANAGE_USERS, getLocale(), model); return getAdminPage(template.getHtml()); }
From source file:com.flexive.faces.components.input.AbstractEditModeHelper.java
protected void renderReferencePopupButton(UIComponent parent, String inputId) { final HtmlOutputLink link = (HtmlOutputLink) FxJsfUtils.addChildComponent(parent, stripForm(inputId) + "_refButtonLink", HtmlOutputLink.COMPONENT_TYPE, true); link.setValue(/* w w w . j a va 2s .com*/ "javascript:flexive.input.openReferenceQueryPopup('" + StringUtils.defaultString(value.getXPath()) + "', '" + inputId + "', '" + getForm(inputId) + "')"); final HtmlGraphicImage button = (HtmlGraphicImage) FxJsfUtils.addChildComponent(link, stripForm(inputId) + "_refButton", HtmlGraphicImage.COMPONENT_TYPE, true); component.setPackagedImageUrl(button, "/images/findReferences.png"); button.setStyle("border:0"); button.setStyleClass(AbstractFxValueInputRenderer.CSS_FIND_REFERENCES); }
From source file:com.redhat.rhn.frontend.taglibs.list.ListTag.java
private void renderSortableHiddenFields() throws JspException { String sortByLabel = ListTagUtil.makeSortByLabel(getUniqueName()); String sortDirLabel = ListTagUtil.makeSortDirLabel(getUniqueName()); HtmlTag sortByInputTag = new HtmlTag("input"); sortByInputTag.setAttribute("type", "hidden"); sortByInputTag.setAttribute("name", sortByLabel); sortByInputTag.setAttribute("id", ListTagUtil.makeSortById(getUniqueName())); sortByInputTag.setAttribute("value", StringEscapeUtils .escapeHtml(StringUtils.defaultString(pageContext.getRequest().getParameter(sortByLabel)))); HtmlTag sortByDirTag = new HtmlTag("input"); sortByDirTag.setAttribute("type", "hidden"); sortByDirTag.setAttribute("name", sortDirLabel); sortByDirTag.setAttribute("id", ListTagUtil.makeSortDirId(getUniqueName())); String dir = StringUtils.defaultString(pageContext.getRequest().getParameter(sortDirLabel)); if (dir.equals(RequestContext.SORT_ASC)) { sortByDirTag.setAttribute("value", RequestContext.SORT_ASC); } else if (dir.equals(RequestContext.SORT_DESC)) { sortByDirTag.setAttribute("value", RequestContext.SORT_DESC); } else {// w ww. j av a 2 s. c o m sortByDirTag.setAttribute("value", ""); } ListTagUtil.write(pageContext, sortByInputTag.render()); ListTagUtil.write(pageContext, sortByDirTag.render()); }
From source file:dk.dma.msiproxy.provider.dkmsi.service.DkMsiProviderService.java
/** * Append the description to the message description field * @param msg the message//w w w. j ava2 s. c o m * @param lang the language * @param subtitle an optional subtitle * @param description the description to append */ private void appendDescription(Message msg, String lang, String subtitle, String description) { String desc = StringUtils.defaultString(msg.getDesc(lang).getDescription()); if (StringUtils.isNotBlank(subtitle)) { desc += String.format("<p><i>%s</i></p>", subtitle); } if (StringUtils.isNotBlank(description)) { desc += String.format("<p>%s</p>", description); } msg.getDesc(lang).setDescription(desc); }
From source file:ca.uhn.hl7v2.testpanel.model.msg.Hl7V2MessageCollection.java
private void updateMessageDescription() { String oldValue = myMessageDescription; Matcher matcher = FIRSTLINE_COMMENT_PATTERN.matcher(StringUtils.defaultString(mySourceMessage)); if (matcher.find()) { myMessageDescription = matcher.group(1).trim(); } else if (mySaveFileName == null) { int msgs = 0; AbstractMessage<?> firstNonComment = null; for (AbstractMessage<?> next : myMessages) { if (!(next instanceof Comment)) { if (msgs == 0) { firstNonComment = next; }/* w ww. java2s . co m*/ msgs++; } } if (msgs == 0) { myMessageDescription = "None"; } else if (msgs == 1) { if (firstNonComment instanceof UnknownMessage) { myMessageDescription = "Unknown"; } else if (firstNonComment instanceof Hl7V2MessageBase) { myMessageDescription = ((Hl7V2MessageBase) firstNonComment).getMessageDescription(); } else { myMessageDescription = "None"; } } else { myMessageDescription = msgs + " messages"; } } else { myMessageDescription = mySaveFileName.replaceAll(".*(\\\\|\\/)", ""); } firePropertyChange(PROP_DESCRIPTION, oldValue, myMessageDescription); }
From source file:gtu._work.mvn.MavenRepositoryUI.java
DocumentListener getDocumentListener(final JList list, final Set<PomFile> pomfilelist) { return JCommonUtil.getDocumentListener(new HandleDocumentEvent() { public void process(DocumentEvent event) { if (pomfilelist == null || pomfilelist.isEmpty()) { return; }/* w w w . j a v a 2 s. com*/ String text = JCommonUtil.getDocumentText(event); DefaultListModel model = new DefaultListModel(); for (PomFile pomfile : pomfilelist) { if (pomfile.xmlFile.getName().contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.modelVersion).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.groupId).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.artifactId).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.packaging).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.name).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.version).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.url).contains(text)) { model.addElement(pomfile); continue; } if (StringUtils.defaultString(pomfile.pom.description).contains(text)) { model.addElement(pomfile); continue; } } list.setModel(model); } }); }