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:de.tudarmstadt.ukp.clarin.webanno.brat.controller.TypeUtil.java
/** * Construct the label text used in the brat user interface. * * @param aAdapter the adapter./*from w ww . jav a2 s . co m*/ * @param aFs the annotation. * @param aFeatures the features. * @return the label. */ public static String getBratLabelText(TypeAdapter aAdapter, AnnotationFS aFs, List<AnnotationFeature> aFeatures) { StringBuilder bratLabelText = new StringBuilder(); for (AnnotationFeature feature : aFeatures) { if (!feature.isEnabled() || !feature.isVisible() || !MultiValueMode.NONE.equals(feature.getMultiValueMode())) { continue; } Feature labelFeature = aFs.getType().getFeatureByBaseName(feature.getName()); if (bratLabelText.length() > 0) { bratLabelText.append(TypeAdapter.FEATURE_SEPARATOR); } bratLabelText.append(StringUtils.defaultString(aFs.getFeatureValueAsString(labelFeature))); } if (bratLabelText.length() > 0) { return bratLabelText.toString(); } else { // If there are no label features at all, then use the layer UI name return "(" + aAdapter.getLayer().getUiName() + ")"; } }
From source file:com.thoughtworks.go.domain.JobInstanceLog.java
public String getBuildError() { Object obj = props.get("stacktrace.error"); if (obj == null) { return ""; }// ww w . j ava 2 s . c om return StringUtils.defaultString(obj.toString()); }
From source file:net.duckling.ddl.web.api.rest.TeamController.java
@RequestMapping(method = RequestMethod.POST) public void create(@RequestParam("teamCode") String teamCode, @RequestParam("displayName") String displayName, @RequestParam("description") String description, @RequestParam(value = "accessType", required = false) String accessType, @RequestParam(value = "autoTeamCode", required = false) Boolean autoTeamCode, @RequestParam(value = "type", required = false) String type, HttpServletRequest request, HttpServletResponse response) {// w ww . j av a2 s . c om String uid = getCurrentUid(request); accessType = StringUtils.defaultIfBlank(accessType, Team.ACCESS_PRIVATE); autoTeamCode = autoTeamCode == null ? false : autoTeamCode; teamCode = StringUtils.defaultString(teamCode).trim(); LOG.info("create team start... {uid:" + uid + ",teamCode:" + teamCode + ",displayName:" + displayName + ",accessType:" + accessType + ",autoTeamCode:" + autoTeamCode + ",type:" + type + "}"); //?? if (!ClientValidator.validate(request)) { LOG.warn("client is not allowed. {teamCode:" + teamCode + ",type:" + type + ",host:" + ClientValidator.getRealIp(request) + ",pattern:" + ClientValidator.getClientIpPattern(request) + "}"); response.setStatus(HttpServletResponse.SC_FORBIDDEN); JsonUtil.write(response, ErrorMsg.NEED_PERMISSION); return; } if (Team.CONFERENCE_TEAM.equals(type)) { //nothing } else { // type = Team.COMMON_TEAM; } if (autoTeamCode) { teamCode = tidyTeamCode(teamCode); if ("".equals(teamCode)) { teamCode = getRandomString(5); } teamCode = teamCodeIncrement(teamCode, 0); } if (!checkParams(teamCode, displayName, description, accessType, response)) { return; } Map<String, String> params = getParamsForCreate(uid, teamCode, displayName, description, accessType, type); int teamId = teamService.createAndStartTeam(uid, params); teamService.addTeamMembers(teamId, new String[] { uid }, new String[] { super.getCurrentUsername(request) }, Team.AUTH_ADMIN); LOG.info("create team success. {uid:" + uid + ", tid:" + teamId + ", parmas:" + params + "}"); response.setStatus(HttpServletResponse.SC_CREATED); JsonUtil.write(response, VoUtil.getTeamVo(teamService.getTeamByID(teamId))); }
From source file:com.bitium.confluence.config.SAMLConfig.java
public String getBaseUrl() { return StringUtils.defaultString(defaultBaseURL); }
From source file:com.flexive.rest.ExceptionHandler.java
public Response toResponse(Throwable throwable) { final FxRestApiResponse response; if (throwable instanceof FxRestApiTokenExpiredException) { if (LOG.isDebugEnabled()) { LOG.debug("Invalid or expired REST-API token: " + ((FxRestApiTokenExpiredException) throwable).getToken()); }// ww w . ja v a 2 s . c o m response = FxRestApiResponse.error(FxRestApiConst.STATUS_TOKEN_INVALID, "Invalid REST-API token or token expired"); } else if (throwable instanceof GuestAccessDisabledException) { response = FxRestApiResponse.error(FxRestApiConst.STATUS_ERROR_GENERIC, "No security token provided and guest access is disabled"); } else { LOG.error("Error during REST-API request", throwable); response = FxRestApiResponse.error(throwable.getMessage()); } if (FxRestApiUtils.isRequestContextAvailable()) { return FxRestApiUtils.buildResponse(response); } else { // no context available, so not a flexive API request or a missing/invalid path // if a response format was explicitly requested via the format query parameter, use it final String queryString = StringUtils.defaultString(FxBasicFilter.getRequestQueryString()); final Response.ResponseBuilder builder = Response.ok(response) .status(Response.Status.INTERNAL_SERVER_ERROR); if (queryString.contains("format=json")) { builder.type(MediaType.APPLICATION_JSON_TYPE); } else if (queryString.contains("format=xml")) { builder.type(MediaType.APPLICATION_XML); } return builder.build(); } }
From source file:com.opengamma.core.position.impl.SimplePortfolioNode.java
/** * Creates a portfolio node with a given name. * //from w ww .jav a2s .co m * @param name the name of the portfolio node, null treated as empty */ public SimplePortfolioNode(String name) { _name = StringUtils.defaultString(name); }
From source file:com.bitium.confluence.config.SAMLConfluenceConfig.java
public String getRedirectUrl() { return StringUtils.defaultString((String) pluginSettings.get(REDIRECT_URL_SETTING)); }
From source file:com.thoughtworks.go.domain.JobInstanceLog.java
public String stacktrace() { String stacktrace = (String) props.get("stacktrace.stacktrace"); return StringUtils.defaultString(stacktrace); }
From source file:mitm.application.djigzo.net.ProxyInjectorImpl.java
@Override public void setProxy(HttpClient httpClient) throws ProxyException { try {/*w w w .j av a 2 s. co m*/ if (httpClient == null) { return; } ProxySettings proxySettings = new PropertiesProxySettings( globalPreferencesManager.getGlobalUserPreferences().getProperties()); if (proxySettings.isEnabled()) { if (logger.isDebugEnabled()) { logger.debug("Setting proxy. Host: " + proxySettings.getHost() + ", Port: " + proxySettings.getPort() + ", Username: " + proxySettings.getUsername()); } httpClient.getHostConfiguration().setProxy(proxySettings.getHost(), proxySettings.getPort()); Credentials credentials = new NTCredentials(StringUtils.defaultString(proxySettings.getUsername()), proxySettings.getPassword(), StringUtils.defaultString(proxySettings.getDomain()), StringUtils.defaultString(proxySettings.getHost())); httpClient.getState().setProxyCredentials(AuthScope.ANY, credentials); } else { httpClient.getHostConfiguration().setProxyHost(null); } } catch (HierarchicalPropertiesException e) { throw new ProxyException(e); } }
From source file:mitm.common.security.certificate.X500PrincipalInspector.java
private String rDNToString(RDN rdn) { String result = null;/* w w w. ja v a 2 s.co m*/ if (rdn.isMultiValued()) { /* * We currently do not support multi-value RDNs so if multi valued, combine them into one * string with + */ AttributeTypeAndValue[] values = rdn.getTypesAndValues(); StrBuilder sb = new StrBuilder(); for (AttributeTypeAndValue value : values) { sb.appendSeparator('+'); sb.append(IETFUtils.valueToString(value.getValue())); result = sb.toString(); } } else { result = IETFUtils.valueToString(rdn.getFirst().getValue()); } return StringUtils.defaultString(result); }