Example usage for org.apache.commons.lang StringUtils defaultString

List of usage examples for org.apache.commons.lang StringUtils defaultString

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils defaultString.

Prototype

public static String defaultString(String str) 

Source Link

Document

Returns either the passed in String, or if the String is null, an empty String ("").

Usage

From source file:com.flexive.faces.components.WriteWebletIncludes.java

@Override
public void encodeBegin(FacesContext facesContext) throws IOException {
    super.encodeBegin(facesContext);
    final ResponseWriter out = facesContext.getResponseWriter();
    if (FxJsfUtils.getRequest().getAttribute(REQ_RENDERED) == null) {
        // render weblet includes only once
        for (String weblet : weblets.keySet()) {
            out.write(PADDING);/*w  w  w.  j a v  a  2  s.  com*/
            out.write(StringUtils.defaultString(getWebletInclude(weblet)));
        }
        FxJsfUtils.getRequest().setAttribute(REQ_RENDERED, true);
    }
    // init flexiveComponents.js
    beginJavascript(out);
    final SystemBean systemBean = FxJsfUtils.getManagedBean(SystemBean.class);
    out.write("flexive.baseUrl='" + systemBean.getDocumentBase() + "';\n");
    out.write("flexive.componentsWebletUrl='" + systemBean.getServerBase()
            + FacesWebletUtils.getURL(facesContext, "com.flexive.faces.weblets", "") + "';\n");
    out.write("flexive.yuiBase=flexive.componentsWebletUrl + 'js/yui/';\n");
    final String languageIso = FxContext.getUserTicket().getLanguage().getIso2digit().toLowerCase();
    out.write("flexive.locale='" + languageIso + "';\n");
    out.write("flexive.guiTranslation='" + (FxSharedUtils.isTranslatedLocale(languageIso) ? languageIso : "en")
            + "';\n");
    endJavascript(out);
    if (isHtmlEditor()) {
        renderWebletInclude(out, WEBLET_TINYMCE);
        out.write(PADDING);
        beginJavascript(out);
        final String config = getHtmlEditorConfig();
        out.write("flexive.input.initHtmlEditor(false, "
                + (StringUtils.isNotBlank(config) ? "'" + FxFormatUtils.escapeForJavaScript(config) + "'"
                        : "null")
                + ");");
        endJavascript(out);
    }
    if (isYui()) {
        renderWebletInclude(out, WEBLET_YUI);
    }
    if (isJsonRpc()) {
        renderWebletInclude(out, WEBLET_JSONRPC);
    }
}

From source file:com.atlassian.jira.security.xsrf.SimpleXsrfTokenGenerator.java

private boolean isOurServerId(String token) {
    StringTokenizer st = new StringTokenizer(token, "|");
    return StringUtils.defaultString(jiraServerIdProvider.getServerId()).equals(st.nextToken());
}

From source file:net.erdfelt.android.sdkfido.configer.Configer.java

private final void walkFields(String prefix, Class<?> clazz, String scope) {
    for (Field field : clazz.getDeclaredFields()) {
        ConfigOption opt = field.getAnnotation(ConfigOption.class);
        if (opt == null) {
            continue; // skip
        }/*from www  .j  av  a 2s  .c  o m*/

        String key = StringUtils.defaultString(prefix) + field.getName();
        if (opt.suboption()) {
            walkFields(key + ".", field.getType(), opt.scope());
        } else {
            Configurable cfgrbl = new Configurable(field, opt, key, scope);
            configurables.put(key, cfgrbl);

            scopes.add(cfgrbl.getScope());

            if (field.getType().isEnum()) {
                // register converter for this field type.
                Class<?> enumclass = field.getType();
                this.bub.getConvertUtils().register(new EnumConverter(enumclass), enumclass);
            }
        }
    }
}

From source file:com.pedra.storefront.controllers.misc.StoreSessionController.java

protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old,
        final String current) {
    final String referer = request.getHeader("Referer");
    if (referer != null && !referer.isEmpty()) {
        return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old, "/" + current);
    }//www.  j  av  a 2 s . c o m
    final String encodingAttributes = (String) request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    return REDIRECT_PREFIX + StringUtils.defaultString(encodingAttributes) + '/';
}

From source file:com.redhat.rhn.frontend.taglibs.list.SelectableColumnTag.java

private void renderOnClickForSelectAll() throws JspException {
    ListTagUtil.write(pageContext, "<input type=\"checkbox\" ");
    ListTagUtil.write(pageContext, " name=\"");
    ListTagUtil.write(pageContext, makeSelectAllCheckboxName(listName));
    ListTagUtil.write(pageContext, "\" ");

    ListTagUtil.write(pageContext, " id=\"");
    ListTagUtil.write(pageContext, makeSelectAllCheckboxId(listName));
    ListTagUtil.write(pageContext, "\" ");

    ListTagUtil.write(pageContext, "onclick=\"");
    String script = String.format(CHECK_ALL_SCRIPT, StringUtils.defaultString(rhnSet),
            "this.form." + ListTagUtil.makeSelectedItemsName(listName), "this.checked",
            getIgnorableParentIds());//from   ww w.j a v  a2  s . c o  m
    ListTagUtil.write(pageContext, script);
    ListTagUtil.write(pageContext, "\" />");
}

From source file:de.thischwa.pmcms.gui.dialog.pojo.DialogFieldsGalleryComp.java

private void initializeTitleAndName() {
    String filename = StringUtils.defaultString(gallery.getName());
    GridData gridDataLabel = new GridData();
    gridDataLabel.widthHint = 100;/*from   w  w  w . j  a va 2s  .co  m*/
    gridDataLabel.verticalAlignment = GridData.CENTER;
    gridDataLabel.horizontalAlignment = GridData.END;
    GridData gridDataText = new GridData();
    gridDataText.heightHint = -1;
    gridDataText.widthHint = 150;
    Label labelTitle = new Label(this, SWT.RIGHT);
    labelTitle.setText(LabelHolder.get("dialog.pojo.page.fields.title")); //$NON-NLS-1$
    labelTitle.setLayoutData(gridDataLabel);
    textTitle = new Text(this, SWT.BORDER);
    textTitle.setTextLimit(256);
    textTitle.setLayoutData(gridDataText);
    textTitle.setText(StringUtils.defaultString(gallery.getTitle()));
    Label labelName = new Label(this, SWT.RIGHT);
    labelName.setText("*   ".concat(LabelHolder.get("dialog.pojo.page.fields.name"))); //$NON-NLS-1$ //$NON-NLS-2$
    labelName.setLayoutData(gridDataLabel);
    textName = new Text(this, SWT.BORDER);
    textName.setTextLimit(256);
    textName.setLayoutData(gridDataText);
    textName.setText(filename);
    textName.addVerifyListener(new FileNameVerifier());
    textName.addModifyListener(new ModifyListenerClearErrorMessages(dialogCreator));

    Collection<String> forbiddenNames = new ArrayList<String>();
    Collection<Page> sisters = gallery.getParent().getPages();
    if (CollectionUtils.isNotEmpty(sisters))
        for (Page page : sisters)
            forbiddenNames.add(page.getName());

    Map<String, Gallery> galleries = PoInfo.getGalleries(PoInfo.getSite(gallery));
    if (galleries != null && !galleries.keySet().isEmpty()) {
        for (String name : galleries.keySet())
            forbiddenNames.add(name);
    }
    if (StringUtils.isNotBlank(filename))
        forbiddenNames.remove(filename);
    textTitle.addModifyListener(new FilenameSuggestorListener(dialogCreator, textName, forbiddenNames));
}

From source file:mitm.application.djigzo.ws.impl.CertificateRequestStoreWSImpl.java

@Override
@StartTransaction//w w w.  java  2s . co  m
public void rescheduleRequest(long id) throws WebServiceCheckedException {
    try {
        CertificateRequest request = store.getRequest(id);

        if (request != null) {
            request.setNextUpdate(new Date());

            logger.info("Certificate request for email " + StringUtils.defaultString(request.getEmail())
                    + " was rescheduled.");
        } else {
            logger.warn("Request with id " + id + " not found.");
        }
    } catch (Exception e) {
        logger.error("rescheduleRequest failed.", e);

        throw new WebServiceCheckedException(ExceptionUtils.getRootCauseMessage(e));
    }
}

From source file:mitm.application.djigzo.tools.ProxyManager.java

private void handleGet() throws MalformedURLException, WSProxyFactoryException, WebServiceCheckedException,
        HierarchicalPropertiesException {
    GlobalPreferencesManagerWS globalPreferencesManager = createGlobalPreferencesManagerWS();
    HierarchicalPropertiesWS hierarchicalProperties = createHierarchicalPropertiesWS();

    UserPreferencesDTO globalPreferences = globalPreferencesManager.getGlobalUserPreferences();

    HierarchicalProperties globalProperties = new SaveableHierarchicalPropertiesImpl(hierarchicalProperties,
            globalPreferences);//ww w  .j ava2 s .c o  m

    ProxySettings proxySettings = new PropertiesProxySettings(globalProperties);

    StrBuilder sb = new StrBuilder();

    if (proxySettings.isEnabled()) {
        String proxyUsername = proxySettings.getUsername();
        String proxyPassword = proxySettings.getPassword();

        sb.append("http://");

        if (StringUtils.isNotBlank(proxyUsername)) {
            sb.append(proxyUsername);
            sb.append(":");
            sb.append(StringUtils.defaultString(proxyPassword)).append("@");
        }

        sb.append(proxySettings.getHost());
        sb.append(":");
        sb.append(proxySettings.getPort());
    }

    System.out.println(sb.toString());
}

From source file:de.forsthaus.backend.util.IpLocator.java

/**
 * @return the country//from w  ww .j  ava  2s .  c o  m
 */
public String getCountryCode() {
    return StringUtils.defaultString(StringUtils.substringBetween(this.country, "(", ")"));
}

From source file:jp.co.nemuzuka.service.impl.MemberServiceImpl.java

@Override
public void put(PersonForm form) {
    //??//from   ww  w .j  ava 2s  .com
    Key key = Datastore.stringToKey(form.keyToString);
    Long version = ConvertUtils.toLong(form.versionNo);
    //version?Key??
    MemberModel model = memberDao.get(key, version);
    if (model == null) {
        //??????Exceptionthrow
        throw new ConcurrentModificationException();
    }
    //???
    model.setName(form.name);
    model.setMemo(new Text(StringUtils.defaultString(form.memo)));
    memberDao.put(model);
}