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:gov.nih.nci.caarray.web.fileupload.MonitoredMultiPartRequest.java

/**
 * Retrieves the identifier for the current upload request.
 * @param request the current HTTP request
 * @return an identifier used to refer to this upload when checking for progress
 *//*  w ww . jav a2  s . com*/
public static String getUploadKey(HttpServletRequest request) {
    String uploadId = request.getParameter(UPLOAD_ID_ATTRIBUTE);
    if (uploadId == null) {
        uploadId = StringUtils.defaultString((String) request.getAttribute(UPLOAD_ID_ATTRIBUTE));
    }
    return ProgressMonitor.SESSION_PROGRESS_MONITOR + uploadId;
}

From source file:com.opengamma.web.security.WebSecurityVersionResource.java

/**
 * Builds a URI for this resource./*from  w ww.  ja v a 2s  .  c  om*/
 * @param data  the data, not null
 * @param overrideVersionId  the override version id, null uses information from data
 * @return the URI, not null
 */
public static URI uri(final WebSecuritiesData data, final UniqueId overrideVersionId) {
    String securityId = data.getBestSecurityUriId(null);
    String versionId = StringUtils
            .defaultString(overrideVersionId != null ? overrideVersionId.getVersion() : data.getUriVersionId());
    return data.getUriInfo().getBaseUriBuilder().path(WebSecurityVersionResource.class).build(securityId,
            versionId);
}

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

@Override
public void setSkipList(String list) throws WebServiceCheckedException {
    try {/*  w w w  . jav a  2s.c o m*/
        wordSkipper.setSkipList(StringUtils.defaultString(list));
    } catch (IOException e) {
        throw new WebServiceCheckedException(list);
    }
}

From source file:com.bitium.confluence.config.SAMLConfig.java

public boolean getIdpRequiredFlag() {
    if (StringUtils.defaultString((String) pluginSettings.get(IDP_REQUIRED_SETTING)).equals("true")) {
        return true;
    } else {//  w w w . j  a  v  a  2 s . c om
        return false;
    }
}

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

@Override
protected void initFields() {
    txtChannelName.setText(StringUtils.defaultString(ircChannel.getChannelName()));
    btnAutoconnect.setSelection(ircChannel.isAutoconnect());
}

From source file:mitm.application.djigzo.james.matchers.IsRecipient.java

@Override
public void init() {
    getLogger().info("Initializing matcher: " + getMatcherName());

    pattern = Pattern.compile(StringUtils.defaultString(StringUtils.trimToNull(getCondition())));
}

From source file:com.envision.envservice.filter.AccessLogFilter.java

private void logAccessAPI(HttpServletRequest request) {
    try {/*from   w w  w  .  j  a  va  2  s .c om*/
        UserBo user = (UserBo) request.getSession().getAttribute(Constants.SESSION_USER);
        String userId = user != null ? user.getUser_id() : "NOT_LOGIN";
        String remoteAddr = IPUtil.getRemoteAddr(request);
        String method = request.getMethod();
        String requestURI = request.getRequestURI();
        String userAgent = StringUtils.defaultString(request.getHeader("User-Agent"));

        String queryString = request.getQueryString();
        if (queryString != null) {
            queryString = URLDecoder.decode(request.getQueryString(), Constants.CHARSET);
        }
        requestURI = requestURI
                + (StringUtils.isNotEmpty(queryString) ? ("?" + queryString) : StringUtils.EMPTY);

        EnvLog.getAccessAPILogger().info(
                String.format("[%s] [%s] [%s] %s [%s]", userId, remoteAddr, method, requestURI, userAgent));
    } catch (Exception e) {
        EnvLog.getAccessAPILogger().warn("AccessAPI logger error: " + e.getMessage(), e);
    }
}

From source file:info.magnolia.cms.security.auth.login.FormLogin.java

@Override
public LoginResult handle(HttpServletRequest request, HttpServletResponse response) {
    String userid = request.getParameter(PARAMETER_USER_ID);
    log.debug("handle login for {}", userid);
    if (StringUtils.isNotEmpty(userid)) {
        String pswd = StringUtils.defaultString(request.getParameter(PARAMETER_PSWD));
        String realm = StringUtils.defaultString(request.getParameter(PARAMETER_REALM));

        CredentialsCallbackHandler callbackHandler = new PlainTextCallbackHandler(userid, pswd.toCharArray(),
                realm);/*from   www  .  j av  a  2  s.c o  m*/
        return authenticate(callbackHandler, getJaasChain());
    }
    return LoginResult.NOT_HANDLED;
}

From source file:com.hack23.cia.web.impl.ui.application.action.PageActionEventHelperImpl.java

@Override
public void createPageEvent(final ViewAction viewAction, final ApplicationEventGroup applicationEventGroup,
        final String page, final String pageMode, final String elementId) {

    String pageModeToUse;//from  w  w  w. ja v a  2  s  .com

    if (pageMode != null && elementId != null && pageMode.contains(elementId)) {
        pageModeToUse = pageMode.replace(elementId, "").replace("/", "");
    } else {
        pageModeToUse = pageMode;
    }

    if ((pageModeToUse == null || "".equals(pageModeToUse))
            && ApplicationEventGroup.USER == applicationEventGroup) {
        pageModeToUse = "Overview";
    }

    final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
    serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());

    serviceRequest.setEventGroup(applicationEventGroup);
    serviceRequest.setApplicationOperation(ApplicationOperationType.READ);

    serviceRequest.setPage(StringUtils.defaultString(page));
    serviceRequest.setPageMode(StringUtils.defaultString(pageModeToUse));
    serviceRequest.setElementId(StringUtils.defaultString(elementId));

    serviceRequest.setActionName(viewAction.toString());

    serviceRequest.setUserId(UserContextUtil.getUserIdFromSecurityContext());

    serviceRequest.setApplicationMessage(viewAction.toString());

    applicationManager.service(serviceRequest);
}

From source file:com.redhat.rhn.frontend.dto.PackageOverview.java

/**
 * @return Returns the description.
 */
public String getDescription() {
    return StringUtils.defaultString(description).trim();
}