List of usage examples for org.apache.commons.lang StringUtils strip
public static String strip(String str)
Strips whitespace from the start and end of a String.
From source file:com.abiquo.appliancemanager.transport.TemplateDto.java
public void setCategoryName(final String categoryName) { this.categoryName = StringUtils.strip(categoryName); }
From source file:com.neusoft.mid.clwapi.interceptor.OauthTokenCheckInterceptor.java
/** * token?.//from w w w . j a va2s. co m * * @param message */ @Override public void handleMessage(Message message) throws Fault { logger.info("???"); String token = ""; boolean isExistToken = false; Response response = null; Map<String, List<String>> reqHeaders = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS)); if (reqHeaders != null) { for (Map.Entry<String, List<String>> e : reqHeaders.entrySet()) { if (ACCESS_TOKEN.equalsIgnoreCase(e.getKey())) { token = e.getValue().get(0); isExistToken = true; } } } else { logger.info("HTTP???HEADER?"); response = Response.status(Response.Status.BAD_REQUEST).entity(ErrorConstant.ERROR10001.toJson()) .header("Content-Type", "application/json;charset=UTF-8").build(); } if (!isExistToken || StringUtils.isEmpty(StringUtils.strip(token))) { logger.info("HTTP?HEADER??\"access_token\"?"); response = Response.status(Response.Status.BAD_REQUEST).entity(ErrorConstant.ERROR20000.toJson()) .header("Content-Type", "application/json;charset=UTF-8").build(); } else { logger.info("?access_token=" + token); if (checkToken(token)) { try { MobileUsrAllInfo userInfo = usrOauthService.getMblUsrInfoByToken(token); if (null == userInfo) { logger.info("access_token?"); response = Response.status(Response.Status.UNAUTHORIZED) .entity(ErrorConstant.ERROR20001.toJson()) .header("Content-Type", "application/json;charset=UTF-8").build(); } else { if ("0".equals(userInfo.getIsMobileAllow())) { logger.info("?ID[" + userInfo.getEnterpriseId() + "]?"); response = Response.status(297).entity(ErrorConstant.ERROR10107.toJson()).build(); oauthMapper.logoutUsrOauth(userInfo.getAccessToken(), userInfo.getUsrId()); logger.info("??"); } else if (userInfo.getValidSeconds() > 0) { // token??HTTPHeader. addUserInfo2HttpHeaderInfo(reqHeaders, userInfo); message.put(Message.PROTOCOL_HEADERS, reqHeaders); } else { logger.info( "access_token?,?"); response = Response.status(298).build(); } } } catch (Exception e) { logger.error("?token??", e); response = Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(ErrorConstant.ERROR90000.toJson()) .header("Content-Type", "application/json;charset=UTF-8").build(); } } else { logger.info("HTTP?HEADER\"access_token\"???"); response = Response.status(Response.Status.BAD_REQUEST).entity(ErrorConstant.ERROR10002.toJson()) .header("Content-Type", "application/json;charset=UTF-8").build(); } } message.getExchange().put(Response.class, response); }
From source file:de.tudarmstadt.ukp.csniper.resbuild.stuff.PennTreesToCsvWriter.java
/** * Taken from commons-lang:2.6//from w w w . j ava2 s. co m */ private String normalizeSpace(String str) { str = StringUtils.strip(str); if (str == null || str.length() <= 2) { return str; } StrBuilder b = new StrBuilder(str.length()); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (Character.isWhitespace(c)) { if (i > 0 && !Character.isWhitespace(str.charAt(i - 1))) { b.append(' '); } } else { b.append(c); } } return b.toString(); }
From source file:io.seldon.api.state.PredictionAlgorithmStore.java
@Override public void configUpdated(String configKey, String configValue) { configValue = StringUtils.strip(configValue); logger.info("KEY WAS " + configKey); logger.info("Received new default strategy: " + configValue); if (StringUtils.length(configValue) == 0) { logger.warn("*WARNING* no default strategy is set!"); } else {/*from w ww. j a v a 2 s . c o m*/ try { ObjectMapper mapper = new ObjectMapper(); List<PredictionAlgorithmStrategy> strategies = new ArrayList<>(); AlgorithmConfig config = mapper.readValue(configValue, AlgorithmConfig.class); for (Algorithm algorithm : config.algorithms) { PredictionAlgorithmStrategy strategy = toAlgorithmStrategy(algorithm); strategies.add(strategy); } List<FeatureTransformerStrategy> featureTransformerStrategies = new ArrayList<>(); for (Transformer transformer : config.transformers) { FeatureTransformerStrategy strategy = toFeatureTransformerStrategy(transformer); featureTransformerStrategies.add(strategy); } defaultStrategy = new SimplePredictionStrategy(PredictionStrategy.DEFAULT_NAME, Collections.unmodifiableList(featureTransformerStrategies), Collections.unmodifiableList(strategies)); logger.info("Successfully added new default prediction strategy"); } catch (IOException | BeansException e) { logger.error("Couldn't update default prediction strategy", e); } } }
From source file:com.neusoft.mid.clwapi.service.tacks.TacksServiceImpl.java
/** * ??./*from w ww . jav a2s . c o m*/ * * @param token * ?. * * @param vin * vin?. * * @param startTime * ,?yyyymmddhh24miss. * * @param endTime * ,?yyyymmddhh24miss. * @return ?. */ @Override public Response getVinTacksDetail(String token, String vin, String startTime, String endTime) { vin = StringUtils.strip(vin); startTime = StringUtils.strip(startTime); endTime = StringUtils.strip(endTime); logger.info("-vin?:" + vin + ",:" + startTime + ",:" + endTime); Date sTime; Date eTime; try { sTime = TimeUtil.parseStringToDate(startTime, HttpConstant.TIME_FORMAT); eTime = TimeUtil.parseStringToDate(endTime, HttpConstant.TIME_FORMAT); } catch (ParseException e) { logger.info("-?" + startTime + "" + endTime + "??yyyyMMddHHmmss"); throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST); } if (sTime.after(eTime)) { logger.info("-?" + startTime + "" + endTime + ",?"); throw new ApplicationException(ErrorConstant.ERROR10003, Response.Status.BAD_REQUEST); } List<TackDetailInfo> resultList = getTackPonits(vin, startTime, endTime); if (CheckRequestParam.isEmpty(resultList)) { logger.info("-VIN:" + vin + "" + startTime + "-" + endTime + ""); return Response.status(Response.Status.NO_CONTENT).header(HttpHeaders.CACHE_CONTROL, "no-store") .header("Pragma", "no-cache").build(); } TackDetailResp resp = new TackDetailResp(); resp.setResultList(resultList); return Response.ok(JacksonUtils.toJsonRuntimeException(resp)).header(HttpHeaders.CACHE_CONTROL, "no-store") .header("Pragma", "no-cache").build(); }
From source file:io.apiman.plugins.simpleheaderpolicy.beans.SimpleHeaderPolicyDefBean.java
@SuppressWarnings("nls") private Pattern buildRegex(List<StripHeaderBean> itemList) { StringBuilder sb = new StringBuilder(); String divider = ""; for (StripHeaderBean stripHeader : itemList) { String pattern = StringUtils.strip(stripHeader.getPattern()); sb.append(divider);/*from w ww.java 2 s. c o m*/ sb.append(pattern); divider = "|"; } return Pattern.compile(sb.toString(), Pattern.CASE_INSENSITIVE); }
From source file:hudson.plugins.robot.RobotPublisher.java
/** * Create new publisher for Robot Framework results * * @param outputPath/* ww w.j av a2s .co m*/ * Path to Robot Framework's output files * @param outputFileName * Name of Robot output xml * @param disableArchiveOutput * Disable Archiving output xml file to server * @param reportFileName * Name of Robot report html * @param logFileName * Name of Robot log html * @param passThreshold * Threshold of test pass percentage for successful builds * @param unstableThreshold * Threhold of test pass percentage for unstable builds * @param onlyCritical * True if only critical tests are included in pass percentage */ @DataBoundConstructor public RobotPublisher(String outputPath, String outputFileName, boolean disableArchiveOutput, String reportFileName, String logFileName, double passThreshold, double unstableThreshold, boolean onlyCritical, String otherFiles) { this.outputPath = outputPath; this.outputFileName = outputFileName; this.disableArchiveOutput = disableArchiveOutput; this.reportFileName = reportFileName; this.passThreshold = passThreshold; this.unstableThreshold = unstableThreshold; this.logFileName = logFileName; this.onlyCritical = onlyCritical; String[] filemasks = otherFiles.split(","); for (int i = 0; i < filemasks.length; i++) { filemasks[i] = StringUtils.strip(filemasks[i]); } this.otherFiles = filemasks; }
From source file:com.commercehub.dropwizard.BuildInfoServlet.java
private static ImmutableSet<String> getAttributeBlacklist(ServletConfig config) { String attributeBlacklistParam = config.getInitParameter(ATTRIBUTE_BLACKLIST_INIT_PARAM); if (StringUtils.isNotBlank(attributeBlacklistParam)) { Set<String> blacklist = Sets.newHashSet(); for (String attribute : StringUtils.split(attributeBlacklistParam, ATTRIBUTE_BLACKLIST_SEPARATOR)) { blacklist.add(StringUtils.strip(attribute)); }/*from ww w .j av a 2s . com*/ return ImmutableSet.copyOf(blacklist); } return ImmutableSet.of(); }
From source file:com.neusoft.mid.clwapi.service.msg.MsgServiceImpl.java
/** * ???.//ww w .j a v a 2s . c o m * * @param reqTypeCont * @return */ private String parseTtmsgType(String reqTypeCont) { StringBuffer strBuff = new StringBuffer(); String setinfo0 = "0"; String setinfo1 = "0"; String setinfo2 = "0"; String setinfo3 = "0"; String[] typeArray = StringUtils.split(StringUtils.strip(reqTypeCont), "|"); for (String set : typeArray) { String type = StringUtils.strip(set); if ("00".equals(type)) { // 00 setinfo3 = "1"; } else if ("01".equals(type)) { // 00 setinfo1 = "1"; } else if ("02".equals(type)) { // 00? setinfo0 = "1"; } else if ("03".equals(type)) { // 00 setinfo2 = "1"; } else { logger.info("??:" + type + "??"); throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST); } } strBuff.append(setinfo0).append(setinfo1).append(setinfo2).append(setinfo3).append("0000"); String msgType = strBuff.toString(); logger.info("???:" + msgType); return msgType; }
From source file:com.haulmont.cuba.core.global.QueryParserAstBased.java
@Override public String getEntityName() { IdentificationVariableNode mainEntityIdentification = getQueryAnalyzer().getMainEntityIdentification(); if (mainEntityIdentification != null) { return mainEntityIdentification.getEntityNameFromQuery(); }/* w w w . ja v a2s .c o m*/ throw new RuntimeException(format("Unable to find entity name [%s]", StringUtils.strip(query))); }