List of usage examples for org.apache.commons.lang StringUtils indexOf
public static int indexOf(String str, String searchStr)
Finds the first index within a String, handling null
.
From source file:com.hangum.tadpole.db.metadata.MakeContentAssistUtil.java
/** * ? ? ?? .. //from ww w . ja v a 2s.co m * content assist tester.tablename ? ?? . ? ? ? ? ?. * * @param userDB * @param strArryCursor * @return */ protected String getSchemaOrTableContentAssist(UserDBDAO userDB, String[] strArryCursor) { String strCntAsstList = getContentAssist(userDB); String strCursorText = strArryCursor[0] + strArryCursor[1]; if (StringUtils.contains(strCursorText, '.')) { String strSchemaName = StringUtils.substringBefore(strCursorText, ".") + "."; // String strTableName = StringUtils.substringAfter(strCursorText, "."); int intSep = StringUtils.indexOf(strCursorText, "."); if (logger.isDebugEnabled()) { logger.debug("[0]" + strArryCursor[0]); logger.debug("[1]" + strArryCursor[1]); logger.debug("[1][intSep]" + intSep); logger.debug("[1][strArryCursor[0].length()]" + strArryCursor[0].length()); logger.debug("==> [Return table list]" + (strArryCursor[0].length() >= intSep)); } // ? ? ? . if (strArryCursor[0].length() >= intSep) { String strNewCntAsstList = ""; String[] listGroup = StringUtils.splitByWholeSeparator(strCntAsstList, _PRE_GROUP); if (listGroup == null) return strNewCntAsstList; for (String strDefault : listGroup) { String[] listDefault = StringUtils.split(strDefault, _PRE_DEFAULT); if (listDefault != null & listDefault.length == 2) { if (StringUtils.startsWithIgnoreCase(listDefault[0], strSchemaName)) strNewCntAsstList += makeObjectPattern("", StringUtils.removeStartIgnoreCase(listDefault[0], strSchemaName), listDefault[1]); } // } return strNewCntAsstList; } } return strCntAsstList; }
From source file:controllers.modules.cas.SecureCAS.java
public static void handleLogout(String body) throws Throwable { int i = StringUtils.indexOf(body, LOGOUT_REQ_PARAMETER); String postBody = URLDecoder.decode(body, "UTF-8"); if (i == 0) { String logoutRequestMessage = StringUtils.substring(postBody, LOGOUT_REQ_PARAMETER.length() + 1); if (StringUtils.isNotEmpty(logoutRequestMessage)) { Document document = XML.getDocument(logoutRequestMessage); if (document != null) { NodeList nodeList = document.getElementsByTagName("samlp:SessionIndex"); if (nodeList != null && nodeList.getLength() > 0) { Node node = nodeList.item(0); String ticket = node.getTextContent(); String stKey = ST + "_" + ticket; String username = Cache.get(stKey, String.class); if (username != null) { Cache.delete(stKey); Cache.set(LOGOUT_TAG + "_" + username, 1, TEN_YEARS_EXPIRATION); Logger.debug("Mark that %s has been logout ", username); return; }/*from ww w. j av a 2s .com*/ } } } } Logger.warn("illegal logout message: %s", postBody); }
From source file:jenkins.plugins.tanaguru.ProjectTanaguruAction.java
private String buildAuditResultUrl(String line, String webappUrl) { String auditId = StringUtils.substring(line, StringUtils.indexOf(line, ":") + 1).trim(); if (StringUtils.endsWith(webappUrl, "/")) { return webappUrl + URL_PREFIX_RESULT + auditId; } else {//from w ww .ja v a2 s . c o m return webappUrl + "/" + URL_PREFIX_RESULT + auditId; } }
From source file:com.intel.cosbench.exporter.ScriptsLogExporter.java
private void exportScriptLog(Writer writer, String logCtx, String driver) throws IOException { int idx = StringUtils.indexOf(logCtx, ";"); if (idx < 0 || idx + 1 == logCtx.length()) return;//from www . j ava 2s. c om String scriptName = StringUtils.left(logCtx, idx); String log = StringUtils.substring(logCtx, idx + 1); writer.write("-----------------"); writer.write("-----------------"); writer.write(" driver: " + driver + " script: " + scriptName + ' '); writer.write("-----------------"); writer.write("-----------------"); writer.write('\n'); writer.write(log); }
From source file:com.flexive.war.filter.BackendAuthorizationFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { // get URI without application context path final UserTicket ticket = FxContext.getUserTicket(); if (ticket.isGuest() && servletRequest instanceof FxRequest) { final FxRequest request = (FxRequest) servletRequest; if (request.isDynamicContent()) { // not logged in at all - forward to login page FilterUtils.sendRedirect(servletRequest, servletResponse, "/pub/login.jsf" // guess whether we got a session timeout (from within the backend) or a new request + (StringUtils.indexOf(((HttpServletRequest) servletRequest).getHeader("Referer"), "/adm/") != -1 ? "?sessionExpired=true" : "")); } else {/* w w w.ja v a2s .c o m*/ // static content (e.g. images), forbid access ((HttpServletResponse) servletResponse).sendError(HttpServletResponse.SC_FORBIDDEN); } } else if (!ticket.isInRole(Role.BackendAccess)) { // logged in, but lacks role for backend access - show error page servletRequest.getRequestDispatcher("/pub/backendRestricted.jsf").forward(servletRequest, servletResponse); } else { // proceed filterChain.doFilter(servletRequest, servletResponse); } }
From source file:com.edgenius.core.service.impl.JavaMailSenderImpl.java
/** * mailProperties changed, this method will reload mail session *///from w w w . j av a 2 s. c om public void resetMailSessionByProperties() { //always reset session to null, so make "reset" meaningful. This is also a trick, as setSession() doesn't allow null //however, this.setJavaMailProperties(prop) will reset Session to null internally... this.setJavaMailProperties(new Properties()); //multiple properties separated by ";;" and, each property separated by ":" with name and value pair String[] properties = mailProperties.split(";;"); int sep; for (String property : properties) { sep = StringUtils.indexOf(property, ":"); if (sep < 0) { continue; } String name = StringUtils.trimToEmpty(property.substring(0, sep)); String value = StringUtils.trimToEmpty(property.substring(sep + 1)); Properties prop = new Properties(); if (!"".equals(name)) { prop.setProperty(name, value); } //this method will reset session to null as well this.setJavaMailProperties(prop); } }
From source file:ips1ap101.lib.core.db.util.InterpreteSqlOracle.java
@Override public String getComandoSelect(String comando, int limite) { String select = super.getComandoSelect(comando, limite); if (select != null && limite > 0) { int i, j, k; String query = select.toUpperCase(); String where = "WHERE"; String limit = "(ROWNUM <= " + limite + ")"; i = StringUtils.indexOf(query, where); j = i + where.length();/* w w w . j a v a 2 s . com*/ if (i > 0) { select = select.substring(0, j) + " " + limit + " AND " + select.substring(j); Bitacora.trace("{0}", select); } else { String order = " ORDER BY "; i = StringUtils.indexOf(query, order); if (i > 0) { select = select.substring(0, i) + " " + where + " " + limit + select.substring(i); Bitacora.trace("{0}", select); } else { select += " " + where + " " + limit; Bitacora.trace("{0}", select); } } } return select; }
From source file:com.egt.core.db.util.InterpreteSqlOracle.java
@Override public String getComandoSelect(String comando, int limite) { Bitacora.trace(InterpreteSqlOracle.class, "getComandoSelect", comando, limite); int i, j, k;/*w w w .jav a 2s . c o m*/ String select = StringUtils.stripToNull(comando); if (select != null && limite > 0) { String query = select.toUpperCase(); String where = "WHERE"; String limit = "(ROWNUM <= " + limite + ")"; i = StringUtils.indexOf(query, where); j = i + where.length(); if (i > 0) { select = select.substring(0, j) + " " + limit + " AND " + select.substring(j); Bitacora.trace("{0}", select); } else { String order = " ORDER BY "; i = StringUtils.indexOf(query, order); if (i > 0) { select = select.substring(0, i) + " " + where + " " + limit + select.substring(i); Bitacora.trace("{0}", select); } else { select += " " + where + " " + limit; Bitacora.trace("{0}", select); } } } return select; }
From source file:com.photon.maven.plugins.android.standalonemojos.RobotiumMultiDeviceExecutorMojo.java
/** * Check the deviceList parameter//from w w w . j a va 2 s .com */ private void checkDeviceList() { try { if (StringUtils.isNotBlank(deviceList)) { if (StringUtils.indexOf(deviceList, ",") > -1) { devicesListArr = deviceList.split(","); } else { devicesListArr = new String[1]; devicesListArr[0] = deviceList.trim(); } } } catch (Exception e) { // TODO Auto-generated catch block getLog().info("checkDeviceList - Exception: " + e.getMessage()); } }
From source file:com.hangum.tadpole.erd.core.relation.RelationUtil.java
/** * sqlite? relation? .//from www . j a va 2s . c om * * @param userDB * @return */ private static List<ReferencedTableDAO> makeSQLiteRelation(UserDBDAO userDB) { List<ReferencedTableDAO> listRealRefTableDAO = new ArrayList<ReferencedTableDAO>(); try { // ? ?. for (SQLiteRefTableDAO sqliteRefTableDAO : getSQLiteRefTbl(userDB)) { int indexKey = StringUtils.indexOf(sqliteRefTableDAO.getSql(), "FOREIGN KEY"); String forKey = sqliteRefTableDAO.getSql().substring(indexKey); if (logger.isDebugEnabled()) logger.debug("\t full text:" + sqliteRefTableDAO.getSql()); if (logger.isDebugEnabled()) logger.debug("\t=================>[forKeys]\n" + forKey); String[] foreignInfo = forKey.split("FOREIGN KEY"); for (int i = 1; i < foreignInfo.length; i++) { try { String strForeign = foreignInfo[i]; if (logger.isDebugEnabled()) logger.debug("\t ==========================> sub[\n" + strForeign + "]"); ReferencedTableDAO ref = new ReferencedTableDAO(); // ? ref.setTable_name(sqliteRefTableDAO.getTbl_name()); // , ( ) ??... String colName = StringUtils.substringBetween(strForeign, "(", ")"); // ?, REFERENCES ? ( String refTbName = StringUtils.substringBetween(strForeign, "REFERENCES", "("); // , refTbName? ?? ) ... String refCol = StringUtils.substringBetween(strForeign, refTbName + "(", ")"); ref.setColumn_name(moveSpec(colName)); ref.setReferenced_table_name(moveSpec(refTbName)); ref.setReferenced_column_name(moveSpec(refCol)); // sqlite ?? ? .... ?. ref.setConstraint_name(ref.toString()); listRealRefTableDAO.add(ref); } catch (Exception e) { logger.error("SQLLite Relation making", e); } } // inner if } // last for } catch (Exception e) { logger.error("SQLite Relation check 2", e); } return listRealRefTableDAO; }