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.bitium.confluence.config.SAMLConfig.java

public String getX509Certificate() {
    return StringUtils.defaultString((String) pluginSettings.get(X509_CERTIFICATE_SETTING));
}

From source file:mitm.djigzo.web.common.security.PortalUserDetails.java

@Override
public String toString() {
    return StringUtils.defaultString(username);
}

From source file:mitm.djigzo.web.components.Layout.java

public String getAdmin() {
    String name = null;/*from w w w  .  ja va 2  s. c  o m*/

    Authentication currentUser = SecurityContextHolder.getContext().getAuthentication();

    if (currentUser != null) {
        name = currentUser.getName();
    }

    return StringUtils.defaultString(name);
}

From source file:com.thoughtworks.go.server.controller.AboutController.java

private String getActiveTab(HttpServletRequest request) {
    return StringUtils.defaultString(request.getParameter("active"));
}

From source file:com.redhat.rhn.frontend.xmlrpc.channel.ChannelHandler.java

/**
 * Lists all visible software channels. For all child channels,
 * 'channel_parent_label' will be the channel label of the parent channel.
 * For all base channels, 'channel_parent_label' will be an empty string.
 * @param loggedInUser The current user/*from www .j av a  2  s .  com*/
 * @return Returns array of Maps with the following keys:
 * channel_label, channel_parent_label, channel_name, channel_end_of_life,
 * channel_arch
 *
 * @xmlrpc.doc List all visible software channels.
 * @xmlrpc.param #session_key()
 * @xmlrpc.returntype
 *  #array()
 *      #struct("channel")
 *          #prop("string", "label")
 *          #prop("string", "name")
 *          #prop("string", "parent_label")
 *          #prop("string", "end_of_life")
 *          #prop("string", "arch")
 *      #struct_end()
 *  #array_end()
 */
public List<Map<String, Object>> listSoftwareChannels(User loggedInUser) {

    List<Map<String, Object>> items = ChannelManager.allChannelsTree(loggedInUser);

    // perl just makes stuff so much harder since it
    // transforms data in a map with one line, but it's
    // still looping through the list more than once.
    // To keep backwards compatiblity I need to transform
    // this list of maps into a different list of maps.
    //
    // Just because it is ONE line it doesn't make it efficient.

    List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>(items.size());
    for (Map<String, Object> item : items) {
        // Deprecated stupid code
        // this is some really stupid code, but oh well, c'est la vie
        Map<String, Object> newItem = new HashMap<String, Object>();
        newItem.put("label", item.get("label"));
        newItem.put("parent_label", StringUtils.defaultString((String) item.get("parent_channel")));
        newItem.put("name", item.get("name"));
        newItem.put("end_of_life", StringUtils.defaultString((String) item.get("end_of_life")));
        newItem.put("arch", item.get("channel_arch"));

        returnList.add(newItem);
    }

    return returnList;
}

From source file:com.hangum.tadpole.commons.util.RequestInfoUtils.java

/**
 * user request ip//from  w  ww.  j  av a 2  s  . c o  m
 * 
 * @return
 */
public static String getRequestIP() {
    HttpServletRequest request = RWT.getRequest();

    String strIP = request.getHeader("X-Forwarded-For");
    //      if(logger.isDebugEnabled()) logger.debug("X-Forwarded-For: " + strIP);

    if (StringUtils.defaultString(strIP).length() == 0 || "unknown".equalsIgnoreCase(strIP)) {
        strIP = request.getHeader("Proxy-Client-IP");
        //          if(logger.isDebugEnabled()) logger.debug("Proxy-Client-IP[ip]" + strIP);
    }
    if (StringUtils.defaultString(strIP).length() == 0 || "unknown".equalsIgnoreCase(strIP)) {
        strIP = request.getHeader("WL-Proxy-Client-IP");
        //          if(logger.isDebugEnabled()) logger.debug("WL-Proxy-Client-IP[ip]" + strIP);
    }
    if (StringUtils.defaultString(strIP).length() == 0 || "unknown".equalsIgnoreCase(strIP)) {
        strIP = request.getHeader("HTTP_CLIENT_IP");
        //          if(logger.isDebugEnabled()) logger.debug("HTTP_CLIENT_IP[ip]" + strIP);
    }
    if (StringUtils.defaultString(strIP).length() == 0 || "unknown".equalsIgnoreCase(strIP)) {
        strIP = request.getHeader("HTTP_X_FORWARDED_FOR");
        //          if(logger.isDebugEnabled()) logger.debug("HTTP_X_FORWARDED_FOR[ip]" + strIP);
    }
    if (StringUtils.defaultString(strIP).length() == 0 || "unknown".equalsIgnoreCase(strIP)) {
        strIP = request.getRemoteAddr();
        //          if(logger.isDebugEnabled()) logger.debug("[ip]" + strIP);
    }

    return strIP;
}

From source file:de.snertlab.xdccBee.ui.dialog.EditNewIrcServerDialog.java

@Override
protected void initFields() {
    txtHostname.setText(StringUtils.defaultString(ircServer.getHostname()));
    txtPort.setText(StringUtils.defaultString(ircServer.getPort()));
    txtNickname.setText(StringUtils.defaultString(ircServer.getNickname()));
    btnDebugMode.setSelection(ircServer.isDebug());
    if (isNew) {/*from   w w  w.j  a v  a  2s  .c  om*/
        btnDebugMode.setSelection(true);
    }
    btnAutoconnect.setSelection(ircServer.isAutoconnect());
    fillTblChannels();
}

From source file:jenkins.plugins.logstash.persistence.ElasticSearchDao.java

ElasticSearchDao(HttpClientBuilder factory, String host, int port, String key, String username,
        String password) {//from  ww w.  j a  v a 2  s .co m
    super(host, port, key, username, password);

    if (StringUtils.isBlank(key)) {
        throw new IllegalArgumentException("elastic index name is required");
    }

    try {
        uri = new URIBuilder(host).setPort(port)
                // Normalizer will remove extra starting slashes, but missing slash will cause annoying failures
                .setPath("/" + key).build();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Could not create uri", e);
    }

    if (StringUtils.isBlank(uri.getScheme())) {
        throw new IllegalArgumentException("host field must specify scheme, such as 'http://'");
    }

    if (StringUtils.isNotBlank(username)) {
        auth = Base64.encodeBase64String((username + ":" + StringUtils.defaultString(password)).getBytes());
    } else {
        auth = null;
    }

    clientBuilder = factory == null ? HttpClientBuilder.create() : factory;
}

From source file:au.org.intersect.dms.bookinggw.impl.BookingGatewayServiceImpl.java

/**
 * {@inheritDoc}/*  w  ww .  j a  v  a  2  s  . c om*/
 */
@Override
@Transactional(readOnly = true, value = "bookinggw")
public boolean checkPassword(String username, String password) {
    LOG.info("checkPassword username={}, password=******", username);
    AgsUsers user = findUserByName(username);
    if (user == null) {
        return false;
    }
    if (StringUtils.defaultString(user.getPassword()).length() == 0) {
        return StringUtils.defaultString(password).length() == 0;
    }
    return user.getPassword().equals(StringUtils.defaultString(password));
}

From source file:com.thoughtworks.go.server.web.TabInterceptor.java

String[] urlToParams(String url) {
    String[] params = StringUtils.split(StringUtils.defaultString(url), '/');
    String[] decodedParams = new String[params.length];
    for (int i = 0; i < params.length; i++) {
        decodedParams[i] = decode(params[i]);
    }//from  w  w w . j a  v a 2s  . c om
    return decodedParams;
}