List of usage examples for org.apache.commons.lang3 StringUtils defaultString
public static String defaultString(final String str)
Returns either the passed in String, or if the String is null , an empty String ("").
StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
From source file:com.netsteadfast.greenstep.publish.impl.SystemMessagePublishServiceImpl.java
@Override public WebMessagePublishBaseObj execute(SysMsgNoticeConfigVO config, ServletRequest request) throws ServiceException, Exception { this.request = request; WebMessagePublishBaseObj publishObj = new WebMessagePublishBaseObj(); String account = request.getParameter("account"); String refreshUUID = StringUtils.defaultString(request.getParameter("refreshUUID")).trim(); String sessionId = ((HttpServletRequest) request).getSession().getId(); AccountVO accountObj = (AccountVO) UserAccountHttpSessionSupport.get((HttpServletRequest) request); if (StringUtils.isBlank(this.getId()) || StringUtils.isBlank(account) || accountObj == null) { // no login return publishObj; }//from w ww. ja v a 2s .c o m if (!account.equals(accountObj.getAccount())) { // not same account request return publishObj; } List<TbSysMsgNotice> globalSysMsgNoticeList = this.loadGlobalSysMsgNoticeData(config.getMsgId(), "*"); List<TbSysMsgNotice> accountSysMsgNoticeList = this.loadAccountSysMsgNoticeData(config.getMsgId(), account); String globalMsg = this.process(sessionId, refreshUUID, globalSysMsgNoticeList); String personalMsg = this.process(sessionId, refreshUUID, accountSysMsgNoticeList); publishObj.setIsAuthorize(YesNo.YES); publishObj.setLogin(YesNo.YES); publishObj.setSuccess(YesNo.YES); publishObj.setMessage(globalMsg + personalMsg); return publishObj; }
From source file:de.micromata.genome.gwiki.page.impl.wiki.blueprint.GWikiFormInputMacro.java
protected boolean getFormSource(StringBuilder sb) { if (GWikiContext.getCurrent() == null) { return false; }/*from w ww . j av a 2 s . co m*/ if (GWikiContext.getCurrent().getRequestAttribute(EVAL_FORM) != Boolean.TRUE) { return false; } String t = StringUtils.defaultString(inputType); if (t.equals("label") == true || t.equals("radio") == true || t.equals("checkbox") == true) { return true; } String v = GWikiContext.getCurrent().getRequestParameter(name); if (v == null) { return false; } sb.append(v); return true; }
From source file:com.netsteadfast.greenstep.bsc.command.SwotDataProvideCommand.java
private void initIssues(SwotDataVO swotData, String visId, String orgId) throws Exception { String sep = BscConstants.SWOT_TEXT_INPUT_ID_SEPARATE; for (BbPerspective perspective : swotData.getPerspectives()) { SwotIssuesVO issues = new SwotIssuesVO(); BbSwot sMain = null;//from w w w .j av a 2 s . c om BbSwot wMain = null; BbSwot oMain = null; BbSwot tMain = null; String sStr = ""; String wStr = ""; String oStr = ""; String tStr = ""; String sId = "BSC_PROG002D0008Q"; String wId = "BSC_PROG002D0008Q"; String oId = "BSC_PROG002D0008Q"; String tId = "BSC_PROG002D0008Q"; for (String type : BscSwotCode.CODES) { if (BscSwotCode.STRENGTHS_CODE.equals(type)) { sMain = this.getIssuesMain(perspective.getPerId(), type, swotData.getContents()); if (sMain != null) { sStr = StringUtils.defaultString(sMain.getIssues()); } sId += sep + type + sep + visId + sep + perspective.getPerId() + sep + orgId; } if (BscSwotCode.WEAKNESSES_CODE.equals(type)) { wMain = this.getIssuesMain(perspective.getPerId(), type, swotData.getContents()); if (wMain != null) { wStr = StringUtils.defaultString(wMain.getIssues()); } wId += sep + type + sep + visId + sep + perspective.getPerId() + sep + orgId; } if (BscSwotCode.OPPORTUNITIES_CODE.equals(type)) { oMain = this.getIssuesMain(perspective.getPerId(), type, swotData.getContents()); if (oMain != null) { oStr = StringUtils.defaultString(oMain.getIssues()); } oId += sep + type + sep + visId + sep + perspective.getPerId() + sep + orgId; } if (BscSwotCode.THREATS_CODE.equals(type)) { tMain = this.getIssuesMain(perspective.getPerId(), type, swotData.getContents()); if (tMain != null) { tStr = StringUtils.defaultString(tMain.getIssues()); } tId += sep + type + sep + visId + sep + perspective.getPerId() + sep + orgId; } } issues.setPerspectiveName(perspective.getName()); issues.setStrengthsMain(sMain); issues.setStrengths(sStr); issues.setWeaknessesMain(wMain); issues.setWeaknesses(wStr); issues.setOpportunitiesMain(oMain); issues.setOpportunities(oStr); issues.setThreatsMain(tMain); issues.setThreats(tStr); issues.setStrengthsTextId(sId); issues.setWeaknessesTextId(wId); issues.setOpportunitiesTextId(oId); issues.setThreatsTextId(tId); swotData.getIssues().add(issues); } }
From source file:com.sonicle.webtop.core.app.SettingsManager.java
/** * Gets the setting (domain) value indicated by the specified key. * Returns a null value if the key is not found. * @param domainId The domain ID.//from w w w .j a va 2 s . c om * @param serviceId The service ID. * @param key The name of the setting. * @return The string value of the setting. */ private String getSetting(String domainId, String serviceId, String key) { DomainSettingDAO dao = DomainSettingDAO.getInstance(); Connection con = null; ODomainSetting item = null; try { con = wta.getConnectionManager().getConnection(CoreManifest.ID); item = dao.selectByDomainServiceKey(con, domainId, serviceId, key); return (item != null) ? StringUtils.defaultString(item.getValue()) : null; } catch (Exception ex) { WebTopApp.logger.error("Unable to read setting (domain) [{}, {}, {}]", domainId, serviceId, key, ex); throw new RuntimeException(ex); } finally { DbUtils.closeQuietly(con); } }
From source file:io.wcm.handler.url.impl.UrlHandlerImpl.java
String externalizeResourceUrl(final String url, final Resource targetResource, final UrlMode urlMode) { // check for empty path if (StringUtils.isEmpty(url)) { return null; }/* w w w . j a v a 2 s. c o m*/ // do not externalize urls again that are already externalized if (Externalizer.isExternalized(url)) { return url; } // try to resolve the target resource from url/path if it was not given initially (only below /content) Resource resource = targetResource; if (resource == null && StringUtils.startsWith(url, "/content/")) { resource = resolver.resolve(url); // accept NonExistingResource as well } // apply sling mapping when externalizing URLs String externalizedUrl = Externalizer.externalizeUrl(url, resolver, request); // add resource URL prefix (scheme/hostname or integrator placeholder) if required String resourceUrlPrefix = getResourceUrlPrefix(urlMode, resource); externalizedUrl = StringUtils.defaultString(resourceUrlPrefix) + externalizedUrl; //NOPMD return externalizedUrl; }
From source file:de.micromata.genome.gwiki.plugin.confluenceimporter_1_0.GWikiConfluenceImporterActionBean.java
protected QueryResult query() { if (StringUtils.isBlank(tmpDirName) == true) { wikiContext.addSimpleValidationError("Keine Dateien gefunden"); return null; }//from w w w . j ava 2 s. co m String searchExpr = ""; try { List<GWikiElementInfo> elems = wikiContext.getWikiWeb().getStorage().loadPageInfos(tmpDirName); List<SearchResult> sr = new ArrayList<SearchResult>(elems.size()); for (GWikiElementInfo wi : elems) { String oei = getPageIdNoTemp(wi); CompareStatus st = getCompareStatus(wikiContext, wi, oei); wi.getProps().setStringValue("IMPSTATUS", st.name()); sr.add(new SearchResult(wi)); } searchExpr = getSearchExpression(); SearchQuery query = new SearchQuery(StringUtils.defaultString(searchExpr), false, sr); QueryResult qr = filter(query); return qr; } catch (Exception ex) { wikiContext.append(ex.getMessage() + " for " + searchExpr); return null; } }
From source file:io.brooklyn.entity.nosql.etcd.EtcdNodeSshDriver.java
protected String getAdditionalOptions() { return StringUtils.defaultString(entity.config().get(EtcdNode.ADDITIONAL_OPTIONS)).trim(); }
From source file:com.linkedin.urls.Url.java
public String getQuery() { if (_query == null) { _query = getPart(UrlPart.QUERY); } return StringUtils.defaultString(_query); }
From source file:de.blizzy.documentr.markdown.MarkdownProcessor.java
private String markdownToHtml(RootNode rootNode, String projectName, String branchName, String path, Authentication authentication, boolean nonCacheableMacros, String contextPath) { HtmlSerializerContext context = new HtmlSerializerContext(projectName, branchName, path, this, authentication, pageStore, systemSettingsStore, contextPath); HtmlSerializer serializer = new HtmlSerializer(context); String html = serializer.toHtml(rootNode); List<MacroInvocation> macroInvocations = context.getMacroInvocations(); int nonCacheableMacroIdx = 1; for (MacroInvocation invocation : macroInvocations) { IMacro macro = macroFactory.get(invocation.getMacroName()); if (macro == null) { macro = new UnknownMacroMacro(); }/* w ww . ja v a 2 s . c om*/ IMacroDescriptor macroDescriptor = macro.getDescriptor(); String startMarker = invocation.getStartMarker(); String endMarker = invocation.getEndMarker(); String body = StringUtils.substringBetween(html, startMarker, endMarker); if (macroDescriptor.isCacheable()) { MacroContext macroContext = MacroContext.create(invocation.getMacroName(), invocation.getParameters(), body, context, beanFactory); IMacroRunnable macroRunnable = macro.createRunnable(); String macroHtml = StringUtils.defaultString(macroRunnable.getHtml(macroContext)); html = StringUtils.replace(html, startMarker + body + endMarker, macroHtml); } else if (nonCacheableMacros) { String macroName = invocation.getMacroName(); String params = invocation.getParameters(); String idx = String.valueOf(nonCacheableMacroIdx++); html = StringUtils.replace(html, startMarker + body + endMarker, "__" + NON_CACHEABLE_MACRO_MARKER + "_" + idx + "__" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ macroName + " " + StringUtils.defaultString(params) + //$NON-NLS-1$ "__" + NON_CACHEABLE_MACRO_BODY_MARKER + "__" + //$NON-NLS-1$ //$NON-NLS-2$ body + "__/" + NON_CACHEABLE_MACRO_MARKER + "_" + idx + "__"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else { html = StringUtils.replace(html, startMarker + body + endMarker, StringUtils.EMPTY); } } html = cleanupHtml(html, macroInvocations, true); return html; }
From source file:com.xpn.xwiki.stats.impl.VisitStats.java
/** * @param cookie the cookie id of the user. */ public void setCookie(String cookie) { setStringValue(Property.cookie.toString(), StringUtils.defaultString(cookie)); }