List of usage examples for org.apache.commons.lang StringUtils isBlank
public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
From source file:com.ewcms.publication.freemarker.directive.page.PageOut.java
public PageOut(Integer count, Integer number, String label, String url, boolean active) { this.count = count; this.number = (++number); this.label = (StringUtils.isBlank(label) ? number.toString() : label); this.url = (url == null ? "" : url); this.active = active; }
From source file:com.intuit.tank.vm.common.util.TimingPageName.java
/** * @param pageName/*from w w w. j a v a2 s . c o m*/ */ public TimingPageName(String pageName) { super(); String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(pageName, ReportUtil.PAGE_NAME_SEPERATOR); if (split.length > 0 && !StringUtils.isBlank(split[0])) { this.id = split[0].trim(); } if (split.length > 1 && !StringUtils.isBlank(split[1])) { this.name = split[1].trim(); } if (name == null && id == null) { id = pageName.trim(); name = pageName.trim(); } if (id == null) { id = name; } if (name == null) { name = id; } if (split.length > 2) { String indStr = split[2].trim(); if (NumberUtils.isDigits(indStr)) { try { index = Integer.parseInt(indStr); } catch (NumberFormatException e) { LOG.warn("Error parsing index " + indStr + ": " + e); } } } }
From source file:com.intuit.tank.http.json.JsonRequest.java
/** * /* ww w .ja v a 2 s. c o m*/ * @{inheritDoc */ @Override public String getBody() { String result = body; if (StringUtils.isBlank(result)) { try { result = builder.toJsonString(); return result; } catch (Exception ex) { logger.error(ex.getMessage()); } } return result != null ? result : ""; }
From source file:com.enonic.cms.web.filter.CharacterEncodingFilter.java
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (request.getCharacterEncoding() == null) { request.setCharacterEncoding(encoding); }//from www . ja v a 2 s .c om final String forcedCharset = request.getParameter("_charset"); if (!StringUtils.isBlank(forcedCharset)) { response.setCharacterEncoding(forcedCharset); } else { response.setCharacterEncoding(encoding); } filterChain.doFilter(request, response); }
From source file:com.chadekin.jadys.commons.expression.SqlExpressionCleaning.java
public default String cleanExpression(String expression) { if (StringUtils.isBlank(expression)) return StringUtils.EMPTY; if (expression.startsWith(JadysSqlOperation.AND.toString())) { expression = expression.replaceFirst(JadysSqlOperation.AND.toString(), StringUtils.EMPTY); } else if (expression.startsWith(JadysSqlOperation.OR.toString())) { expression = expression.replaceFirst(JadysSqlOperation.OR.toString(), StringUtils.EMPTY); }//ww w .j a va 2 s. com return expression.trim(); }
From source file:com.adobe.acs.commons.util.CookieUtil.java
/** * Get the named cookie from the HTTP Request * * @param request Request to get the Cookie from * @param cookieName name of Cookie to get * @return the named Cookie, null if the named Cookie cannot be found *//*from w ww . j a va 2s .com*/ public static Cookie getCookie(final HttpServletRequest request, final String cookieName) { if (StringUtils.isBlank(cookieName)) { return null; } final Cookie[] cookies = request.getCookies(); if (cookies == null) { return null; } if (cookies.length > 0) { for (final Cookie cookie : cookies) { if (StringUtils.equals(cookieName, cookie.getName())) { return cookie; } } } return null; }
From source file:com.daimler.spm.storefront.util.CSRFTokenManager.java
/** * Returns the CSRF token for the provided httpSession. * * @param httpSession//from w ww. j a v a2s . c om * @return the CSRF token */ public static String getTokenForSession(final HttpSession httpSession) { String sessionCsrfToken = null; synchronized (httpSession) { sessionCsrfToken = (String) httpSession.getAttribute(CSRF_TOKEN_SESSION_ATTRIBUTE); if (StringUtils.isBlank(sessionCsrfToken)) { sessionCsrfToken = generateToken(); httpSession.setAttribute(CSRF_TOKEN_SESSION_ATTRIBUTE, sessionCsrfToken); } } return sessionCsrfToken; }
From source file:com.hp.autonomy.frontend.find.core.configuration.QueryManipulationConfig.java
public void basicValidate() throws ConfigException { if (StringUtils.isBlank(profile)) { throw new ConfigException(SECTION, "Query profile is required"); }/*from ww w .j a v a 2 s. c o m*/ if (StringUtils.isBlank(index)) { throw new ConfigException(SECTION, "Query manipulation index is required"); } }
From source file:cd.go.contrib.elasticagents.docker.executors.GoServerURLField.java
@Override public String doValidate(String input) { if (StringUtils.isBlank(input)) { return this.displayName + " must not be blank."; }/*w w w . j a v a 2 s. c o m*/ URIBuilder uriBuilder = null; try { uriBuilder = new URIBuilder(input); } catch (URISyntaxException e) { return this.displayName + " must be a valid URL (https://example.com:8154/go)"; } if (!uriBuilder.getScheme().equalsIgnoreCase("https")) { return this.displayName + " must be a valid HTTPs URL (https://example.com:8154/go)"; } if (uriBuilder.getHost().equalsIgnoreCase("localhost") || uriBuilder.getHost().equalsIgnoreCase("127.0.0.1")) { return this.displayName + " must not be localhost, since this gets resolved on the agents"; } return null; }
From source file:com.ms.commons.utilities.HttpClientUtils.java
public static String getResponseBodyAsString(HttpMethod method, Integer tryTimes, String responseCharSet, Integer maximumResponseByteSize, Integer soTimeoutMill) { init();/*from w w w.ja v a2s. c o m*/ if (tryTimes == null) { tryTimes = 1; } if (StringUtils.isBlank(responseCharSet)) { responseCharSet = "utf-8"; } if (maximumResponseByteSize == null) { maximumResponseByteSize = 50 * 1024 * 1024; } if (soTimeoutMill == null) { soTimeoutMill = 20000; } method.getParams().setSoTimeout(soTimeoutMill); InputStream httpInputStream = null; for (int i = 0; i < tryTimes; i++) { try { int responseCode = client.executeMethod(method); if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_MOVED_PERMANENTLY || responseCode == HttpStatus.SC_MOVED_TEMPORARILY) { if (method instanceof HttpMethodBase) { responseCharSet = ((HttpMethodBase) method).getResponseCharSet(); } int read = 0; byte[] cbuf = new byte[4096]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); httpInputStream = method.getResponseBodyAsStream(); while ((read = httpInputStream.read(cbuf)) >= 0) { baos.write(cbuf, 0, read); if (baos.size() >= maximumResponseByteSize) { break; } } String content = baos.toString(responseCharSet); return content; } logger.error(String.format( "getResponseBodyAsString failed, responseCode: %s, should be 200, 301, 302", responseCode)); return ""; } catch (Exception e) { logger.error("getResponseBodyAsString failed", e); } finally { IOUtils.closeQuietly(httpInputStream); method.releaseConnection(); } } return ""; }