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:io.ecarf.core.utils.LogParser.java
/** * - Processing file: /tmp/wordnet_links.nt.gz.kryo.gz, dictionary items: 49382611, memory usage: 14.336268931627274GB, timer: 290.0 ms * /tmp/wikipedia_links_en.nt.gz.kryo.gz, dictionary items: 44, memory usage: 0.013648882508277893GB, timer: 2.636 s * START: Downloading file: interlanguage_links_chapters_en.nt.gz.kryo.gz, memory usage: 0.0GB * @param line// w ww . j ava 2 s .co m * @param after * @return */ private double[] extractAndGetMemoryDictionaryItems(String line) { double memory = 0; double items = 0; String memoryStr = null; if (line.contains(TIMER_PREFIX)) { memoryStr = StringUtils.substringBetween(line, MEM_USE, TIMER_PREFIX); if (line.contains(DIC_ITEMS)) { String itemsStr = StringUtils.trim(StringUtils.substringBetween(line, DIC_ITEMS, MEM_USE)); items = Double.parseDouble(itemsStr); } } else { memoryStr = StringUtils.substringAfter(line, MEM_USE); } if (memoryStr != null) { memoryStr = StringUtils.remove(memoryStr, "GB"); memoryStr = StringUtils.strip(memoryStr); } memory = Double.parseDouble(memoryStr); double[] values = new double[] { memory, items }; return values; }
From source file:ee.ria.xroad.signer.tokenmanager.module.ModuleConf.java
private static Set<Long> loadAllowedKeyUsageMechanisms(SubnodeConfiguration section, String key) { Set<Long> allowedMechanism = new HashSet<>(); String[] mechanisms = getStringArray(section, key); for (String m : mechanisms) { Long mechamism = SUPPORTED_KEY_ALLOWED_MECHANISMS.get(StringUtils.strip(m)); if (mechamism != null) { allowedMechanism.add(mechamism); } else {//w ww. j a va 2 s . c o m throw new ConfigurationRuntimeException( String.format("Unsupported value '%s' of '%s' for module (%s), skipping...", m, key, section.getSubnodeKey())); } } return allowedMechanism; }
From source file:com.neusoft.mid.clwapi.service.alarm.AlarmServiceImpl.java
/** * ???API//from w w w. j a v a 2s. c o m * * @param token * * @param body * * @return ?? */ @Override public Object getAlarmInfo(String token, String body) { logger.info("????"); AlarmRequ iAlarmRequ = JacksonUtils.fromJsonRuntimeException(body, AlarmRequ.class); // ?? iAlarmRequ.setAlarmId(StringUtils.strip(iAlarmRequ.getAlarmId())); iAlarmRequ.setConfTime(StringUtils.strip(iAlarmRequ.getConfTime())); // ? if (StringUtils.isEmpty(iAlarmRequ.getAlarmId()) || StringUtils.isEmpty(iAlarmRequ.getConfTime()) || StringUtils.isEmpty(iAlarmRequ.getAlarmTime())) { logger.error("???"); throw new ApplicationException(ErrorConstant.ERROR10001, Response.Status.BAD_REQUEST); } // ?? if (iAlarmRequ.getConfTime().equals(HttpConstant.TIME_ZERO)) { iAlarmRequ.setConfTime(null); } try { if (iAlarmRequ.getConfTime() != null) { TimeUtil.parseStringToDate(iAlarmRequ.getConfTime(), HttpConstant.TIME_FORMAT); } TimeUtil.parseStringToDate(iAlarmRequ.getAlarmTime(), HttpConstant.TIME_FORMAT); } catch (ParseException e) { logger.error("???"); throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST); } logger.info("???"); logger.info("???"); // ??? AlarmInfo iAlarmInfo = iAlarmMapper.getAlarmDealInfo(iAlarmRequ); logger.info("??"); if (iAlarmInfo == null) { logger.error("????"); return Response.notModified().build(); } logger.info("????"); // ???? logger.debug(iAlarmInfo.toString()); logger.info(""); logger.info("?????"); return JacksonUtils.toJsonRuntimeException(iAlarmInfo); }
From source file:com.neusoft.mid.clwapi.service.msg.MsgServiceImpl.java
/** * ???.//from ww w .j av a 2 s .c o m * * @param token * ?. * @param tempId * ??ID. * @return ETag. */ @Override public String delMsgMold(String token, String tempId) { tempId = StringUtils.strip(tempId); String userId = context.getHttpHeaders().getHeaderString(UserInfoKey.USR_ID); if (CheckRequestParam.isEmpty(userId)) { logger.info("??-ID"); throw new ApplicationException(ErrorConstant.ERROR90000, Response.Status.INTERNAL_SERVER_ERROR); } int num = msgMapper.getMsgMoldCount(tempId, userId); if (num == 0) { logger.info("??-?" + tempId + "?"); throw new ApplicationException(ErrorConstant.ERROR10010, Response.Status.NOT_FOUND); } logger.info("??-??"); MsgMoldInfo obj = new MsgMoldInfo(); obj.setId(tempId); obj.setUserId(userId); obj.setDelFlag("1"); msgMapper.updateUserMsgMold(obj); logger.info("??-??"); obj = msgMapper.getMsgMoldInfo(obj); if (CheckRequestParam.isEmpty(obj) || CheckRequestParam.isEmpty(obj.getId())) { logger.info("??-?" + tempId + "?"); throw new ApplicationException(ErrorConstant.ERROR10010, Response.Status.NOT_FOUND); } logger.info("??-??ETag"); upUserETag(token, userId, obj.getEditT()); MsgMoldResp result = new MsgMoldResp(); result.setEditT(obj.getEditT()); return JacksonUtils.toJsonRuntimeException(result); }
From source file:c5db.tablet.TabletService.java
private String createUserTable(String commandString) throws IOException, DeserializationException, RegionNotFoundException { BASE64Decoder decoder = new BASE64Decoder(); String createString = commandString.substring(commandString.indexOf(":") + 1); String[] tableCreationStrings = createString.split(","); HTableDescriptor hTableDescriptor;/*from w ww . j a v a 2s .c o m*/ ArrayList<HRegionInfo> hRegionInfos = new ArrayList<>(); List<Long> peers = new ArrayList<>(); hTableDescriptor = HTableDescriptor.parseFrom(decoder.decodeBuffer(tableCreationStrings[0])); hRegionInfos.add(HRegionInfo.parseFrom(decoder.decodeBuffer(tableCreationStrings[1]))); String[] extraHRegionStrings = Arrays.copyOfRange(tableCreationStrings, 2, tableCreationStrings.length - 1); for (String s : extraHRegionStrings) { try { byte[] potentialHRegion = decoder.decodeBuffer(s); HRegionInfo hRegion = HRegionInfo.parseFrom(potentialHRegion); hRegionInfos.add(hRegion); } catch (DeserializationException e) { // WE have gotten to the peer list break; } } for (String s : Arrays.copyOfRange(tableCreationStrings, hRegionInfos.size() + 1, tableCreationStrings.length)) { s = StringUtils.strip(s); peers.add(new Long(s)); } for (HRegionInfo hRegionInfo : hRegionInfos) { notifyCohortsForTabletCreation(peers, hTableDescriptor, hRegionInfo, 3); } for (HRegionInfo hRegionInfo : hRegionInfos) { addEntryToMeta(hRegionInfo, hTableDescriptor); } return "OK"; }
From source file:com.hangum.tadpole.manager.core.editor.executedsql.ExecutedSQLEditor.java
/** * search/*from w w w . j a v a2 s . c om*/ */ private void search() { // ? ?? . clearGrid(); mapSQLHistory.clear(); // check all db String db_seq = ""; if (!comboDatabase.getText().equals("All")) { searchUserDBDAO = (UserDBDAO) comboDatabase.getData(comboDatabase.getText()); db_seq = "" + searchUserDBDAO.getSeq(); } else { searchUserDBDAO = null; for (int i = 0; i < listUserDBDAO.size(); i++) { UserDBDAO userDB = listUserDBDAO.get(i); if (i == (listUserDBDAO.size() - 1)) db_seq += ("" + userDB.getSeq()); else db_seq += userDB.getSeq() + ","; } } Calendar cal = Calendar.getInstance(); cal.set(dateTimeStart.getYear(), dateTimeStart.getMonth(), dateTimeStart.getDay(), 0, 0, 0); long startTime = cal.getTimeInMillis(); cal.set(dateTimeEnd.getYear(), dateTimeEnd.getMonth(), dateTimeEnd.getDay(), 23, 59, 59); long endTime = cal.getTimeInMillis(); int duringExecute = Integer.parseInt(textMillis.getText()); String strSearchTxt = "%" + StringUtils.trimToEmpty(textSearch.getText()) + "%"; try { List<SQLHistoryDAO> listSQLHistory = TadpoleSystem_ExecutedSQL.getExecuteQueryHistoryDetail( comboTypes.getText(), db_seq, startTime, endTime, duringExecute, strSearchTxt); for (SQLHistoryDAO sqlHistoryDAO : listSQLHistory) { mapSQLHistory.put("" + gridHistory.getRootItemCount(), sqlHistoryDAO); GridItem item = new GridItem(gridHistory, SWT.V_SCROLL | SWT.H_SCROLL); String strSQL = StringUtils.strip(sqlHistoryDAO.getStrSQLText()); int intLine = StringUtils.countMatches(strSQL, "\n"); if (intLine >= 1) { int height = (intLine + 1) * 24; if (height > 100) item.setHeight(100); else item.setHeight(height); } item.setText(0, "" + gridHistory.getRootItemCount()); item.setText(1, sqlHistoryDAO.getDbName()); item.setText(2, Utils.dateToStr(sqlHistoryDAO.getStartDateExecute())); logger.debug(Utils.convLineToHtml(strSQL)); item.setText(3, Utils.convLineToHtml(strSQL)); item.setToolTipText(3, strSQL); item.setText(4, "" + ((sqlHistoryDAO.getEndDateExecute().getTime() - sqlHistoryDAO.getStartDateExecute().getTime()) / 1000f)); item.setText(5, "" + sqlHistoryDAO.getRows()); item.setText(6, sqlHistoryDAO.getResult()); item.setText(7, Utils.convLineToHtml(sqlHistoryDAO.getMesssage())); item.setToolTipText(7, sqlHistoryDAO.getMesssage()); item.setText(8, sqlHistoryDAO.getUserName()); item.setText(9, sqlHistoryDAO.getIpAddress()); if ("F".equals(sqlHistoryDAO.getResult())) { item.setBackground(SWTResourceManager.getColor(240, 180, 167)); } else { item.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY)); } } } catch (Exception ee) { logger.error("Executed SQL History call", ee); //$NON-NLS-1$ } }
From source file:com.activecq.tools.errorpagehandler.impl.ErrorPageHandlerImpl.java
/** * Get the configured System Error Page Path * @return/*from w ww .j a v a 2 s .co m*/ */ public String getSystemErrorPagePath() { return StringUtils.strip(this.systemErrorPagePath); }
From source file:ddf.security.expansion.impl.AbstractExpansion.java
/** * Does the work of reading the configuration file and configuring the expansion map and * attribute separator.//w w w. j a v a 2 s .c o m * * @param filename * the name of the file to be read and processed */ protected void loadConfiguration(String filename) { if (filename == null) { setExpansionMap(null); return; } // first clear out the existing table if (expansionTable != null) { expansionTable.clear(); } File file = null; filename = StringUtils.strip(filename); if (!StringUtils.startsWith(filename, "/") && !StringUtils.startsWith(filename, "\\")) { // relative path String relPath = System.getProperty("ddf.home"); if (StringUtils.isBlank(relPath)) { LOGGER.warn("ddf.home property was not set or is NULL, loading of properties may be impacted."); } file = new File(relPath, filename); } else { // absolute path file = new File(filename); } try (BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8.name()))) { if (br != null) { String line; while ((line = br.readLine()) != null) { if ((line.length() > 0) && (!line.startsWith(CFG_COMMENT_STR))) { if (line.startsWith(SEPARATOR_PREFIX)) { if (line.length() > SEPARATOR_PREFIX.length()) { attributeSeparator = line.substring(SEPARATOR_PREFIX.length()); } else { attributeSeparator = DEFAULT_VALUE_SEPARATOR; } } else { addExpansionRule(line); } } } LOGGER.info("Finished loading mapping configuration file."); } } catch (IOException e) { LOGGER.warn("Unexpected exception reading mapping configuration file {} - {}", filename, e.getMessage()); setExpansionMap(null); } }
From source file:com.netspective.axiom.sql.StoredProcedure.java
/** * Executes the stored procedure without any statistical logging * * @param cc Connection context * @param overrideIndexes parameter indexes to override * @param overrideValues parameter override values *///from www. j av a 2s. co m protected QueryResultSet executeAndIgnoreStatistics(ConnectionContext cc, int[] overrideIndexes, Object[] overrideValues, boolean scrollable) throws NamingException, SQLException { if (log.isTraceEnabled()) trace(cc, overrideIndexes, overrideValues); Connection conn = null; CallableStatement stmt = null; boolean closeConnection = true; try { getMetaData(cc); conn = cc.getConnection(); String sql = StringUtils.strip(getSqlText(cc)); if (scrollable) stmt = conn.prepareCall(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); else stmt = conn.prepareCall(sql); if (parameters != null) { parameters.apply(cc, stmt, overrideIndexes, overrideValues); stmt.execute(); parameters.extract(cc, stmt); StoredProcedureParameter rsParameter = parameters.getResultSetParameter(); if (rsParameter != null) { closeConnection = false; return (QueryResultSet) rsParameter.getExtractedValue(cc.getDatabaseValueContext()); } else return null; } else { stmt.execute(); return null; } } catch (SQLException e) { log.error(createExceptionMessage(cc, overrideIndexes, overrideValues), e); throw e; } }
From source file:io.seldon.api.state.ClientAlgorithmStore.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 w w. j a v a2 s . c o m*/ try { ObjectMapper mapper = new ObjectMapper(); List<AlgorithmStrategy> strategies = new ArrayList<>(); AlgorithmConfig config = mapper.readValue(configValue, AlgorithmConfig.class); for (Algorithm alg : config.algorithms) { strategies.add(toAlgorithmStrategy(alg)); } AlgorithmResultsCombiner combiner = applicationContext.getBean(config.combiner, AlgorithmResultsCombiner.class); Map<Integer, Double> actionWeightMap = toActionWeightMap(config.actionWeights); ClientStrategy strat = new SimpleClientStrategy(strategies, combiner, config.diversityLevel, "-", actionWeightMap); defaultStrategy = strat; logger.info("Successfully changed default strategy."); } catch (IOException e) { logger.error("Problem changing default strategy ", e); } } }