List of usage examples for org.apache.commons.lang StringUtils removeStartIgnoreCase
public static String removeStartIgnoreCase(String str, String remove)
Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.
From source file:adalid.commons.util.FilUtils.java
public static String getCurrentEnvironmentalWorkspaceFolderPath() { if (StringUtils.isBlank(HOME_DIR) && StringUtils.isBlank(USER_HOME)) { return workspace_folder_path; }//from w ww . j ava 2s .co m if (StringUtils.startsWithIgnoreCase(workspace_folder_path, HOME_DIR)) { return HOME_VAR + StringUtils.removeStartIgnoreCase(workspace_folder_path, HOME_DIR); } if (StringUtils.startsWithIgnoreCase(workspace_folder_path, USER_HOME)) { return HOME_VAR + StringUtils.removeStartIgnoreCase(workspace_folder_path, USER_HOME); } return workspace_folder_path; }
From source file:ar.sgt.resolver.filter.ResolverFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { log.trace("Entering filter processing"); HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; String path = req.getRequestURI(); if (!req.getContextPath().isEmpty()) { path = StringUtils.removeStartIgnoreCase(path, req.getContextPath()); }//from w w w .j a v a2s . com if (path.startsWith("//")) { path = path.substring(1); } if (this.excludePath != null) { String fp = StringUtils.left(path, path.indexOf("/", 1)); if (this.excludePath.contains(fp)) { log.trace("Skip path {}", path); chain.doFilter(request, response); return; } } if (this.appendBackSlash) { if (!path.endsWith("/")) path = path + "/"; } log.debug("Resolve path: {}", path); Rule rule = resolverConfig.findRule(path); if (rule != null) { log.debug("Found rule {} using processor {}", rule.getName() == null ? "Unnamed" : rule.getName(), rule.getProcessor()); if (rule.getName() != null) { req.setAttribute(RuleConstant.CURRENT_RULE, rule.getName()); req.setAttribute(RuleConstant.CURRENT_PATH, req.getRequestURI()); } ResolverContext context = new ResolverContext(filterConfig.getServletContext(), req, resp, rule.parseParams(), req.getMethod()); String redirect = null; if (rule.getRedirect() != null) { // check first if there is a named rule matching if (rule.getProcessor().equals(PermanentRedirectProcessor.class.getName())) { redirect = rule.getRedirect(); } else { UrlReverse reverse = new UrlReverse(resolverConfig); try { redirect = req.getContextPath() + reverse.resolve(rule.getRedirect()); log.trace("Using named rule {}", rule.getRedirect()); } catch (ReverseException e) { log.error(e.getMessage()); redirect = rule.getRedirect(); } catch (RuleNotFoundException e) { log.trace("Rule with name {} not found. Simple url redirect", rule.getRedirect()); redirect = rule.getRedirect(); } } } ProcessorContext processorContext = new ProcessorContext(rule, redirect); Processor processor; try { processor = loadClass(rule.getProcessor()); processor.process(processorContext, context); } catch (HttpError e) { log.debug("Handling HTTP ERROR {}", e.getHttpErrorCode()); resp.sendError(e.getHttpErrorCode()); } catch (Exception e) { log.error(e.getMessage()); throw new ServletException(e); } } else { log.trace("No matching rule found"); chain.doFilter(request, response); } }
From source file:com.hangum.tadpole.db.metadata.MakeContentAssistUtil.java
/** * ? ? ?? .. /* w w w . j a va2 s . c o 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:iddb.web.security.service.UserServiceFilter.java
/** * @param s/* w w w. j a v a 2 s .c o m*/ * @param request * @return * @throws IOException */ private boolean haveAccess(Subject s, HttpServletRequest req, HttpServletResponse resp) throws IOException { String path = req.getRequestURI(); log.debug("Check path {}", path); if (!req.getContextPath().isEmpty()) { path = StringUtils.removeStartIgnoreCase(path, req.getContextPath()); } if (!path.startsWith("/")) { path = "/" + path; } else if (path.startsWith("//")) { path = path.substring(1); } for (String p : urls.keySet()) { if (p.endsWith("**")) { if (path.startsWith(p.substring(0, p.length() - 2))) { return checkRoles(s, req, resp, p); } } else { if (path.equalsIgnoreCase(p)) { return checkRoles(s, req, resp, p); } } } return true; }
From source file:ips1ap101.lib.core.app.FiltroBusqueda.java
private void populate(long filtro) { FiltroFuncionBase ff = EJBL.getFiltroFuncionFacade().find(filtro, true); if (ff != null) { long funcion = ff.getIdFuncion().getIdFuncion(); boolean filtrarConRestricciones = TLC.getControlador().esFuncionConParametrosRestringidos(funcion); Collection<? extends FiltroFuncionParBase> parametros = ff .getFiltroFuncionParByIdFiltroFuncionCollection(); if (parametros != null && !parametros.isEmpty()) { String dominio = ff.getIdFuncion().getIdDominio().getCodigoDominio(); String codigo1;//from w ww . j a v a2s.com String codigo2; String columna; Integer i; OperadorComEnumeration operadorCom; TipoValorEnumeration tipoValor; TipoDatoParEnumeration tipoDatoPar; String string; Object objeto; // String prefijo1 = dominio + "."; String prefijo2 = dominio + "." + DB.SELECT + "."; for (FiltroFuncionParBase ffp : parametros) { Boolean criterioBusqueda = ffp.getIdFuncionParametro().getCriterioBusqueda(); if (criterioBusqueda == null || !criterioBusqueda) { continue; } codigo1 = ffp.getIdFuncionParametro().getIdParametro().getCodigoParametro(); codigo2 = ffp.getIdFuncionParametro().getCodigoFuncionParametro(); // columna = StringUtils.removeStartIgnoreCase(codigo1, prefijo1); columna = StringUtils.removeStartIgnoreCase(codigo2, prefijo2); if (filtrarConRestricciones && !TLC.getControlador().esParametroAutorizado(columna, funcion)) { TLC.getBitacora().warn(CBM.SELECT_FILTER_EXCEPTION_1, BundleParametros.getLabel(codigo1)); continue; } i = ffp.getNumeroOperadorCom().getNumeroOperadorCom(); operadorCom = OperadorComEnumeration.valueOf(i); i = ffp.getIdFuncionParametro().getNumeroTipoValor().getNumeroTipoValor(); tipoValor = TipoValorEnumeration.valueOf(i); i = ffp.getIdFuncionParametro().getNumeroTipoDatoPar().getNumeroTipoDatoPar(); tipoDatoPar = TipoDatoParEnumeration.valueOf(i); if (tipoValor == null) { objeto = null; } else { switch (tipoValor) { case CONTINUO: if (TipoDatoParEnumeration.FECHA_HORA.equals(tipoDatoPar)) { string = ffp.getValor(); objeto = ffp.getValorFechaHora(); if (string != null && objeto == null) { TemporalAddend addend = new TemporalAddend(string); if (addend.isValid()) { objeto = addend; } } } else { string = ffp.getValor(); objeto = STP.getObjeto(string, tipoDatoPar); } break; case RECURSO: objeto = ffp.getIdRecursoValor(); break; default: objeto = null; break; } } if (this.isCriterioValido(operadorCom, tipoValor, tipoDatoPar)) { this.addCriterio(columna, operadorCom, objeto); } } } } }
From source file:adalid.util.io.FileBrowser.java
private void printDetail(String type) { if (detailAll || matches(type)) { Charset charset;// w ww . ja v a 2 s . c o m String extension; String baseFolderPathString = baseFolderPath.toString(); String tab = type.contains("/") ? "\t" : ""; for (SmallFile sf : files.values()) { charset = sf.getCharset(); extension = StringUtils.defaultIfBlank(sf.getExtension(), "?"); if (charset != null && type.equals(charset + " / " + extension)) { logger.info(tab + "\t" + StringUtils.removeStartIgnoreCase(sf.getName(), baseFolderPathString)); } } } }
From source file:com.adobe.acs.tools.explain_query.impl.ExplainQueryServlet.java
@Override protected final void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { boolean logCollectorRegistered = false; final ResourceResolver resourceResolver = request.getResourceResolver(); String statement = StringUtils.removeStartIgnoreCase(request.getParameter("statement"), "EXPLAIN "); String language = request.getParameter("language"); final Session session = resourceResolver.adaptTo(Session.class); try {/* www . java2 s. c o m*/ // Mark this thread as an Explain Query thread for TurboFiltering registerLogCollector(); logCollectorRegistered = true; final JSONObject json = new JSONObject(); json.put("statement", statement); json.put("language", language); json.put("explain", explainQuery(session, statement, language)); boolean collectExecutionTime = "true" .equals(StringUtils.defaultIfEmpty(request.getParameter("executionTime"), "false")); boolean collectCount = "true" .equals(StringUtils.defaultIfEmpty(request.getParameter("resultCount"), "false")); if (collectExecutionTime) { json.put("heuristics", this.getHeuristics(session, statement, language, collectCount)); } response.setContentType("application/json"); response.getWriter().print(json.toString()); } catch (RepositoryException e) { log.error(e.getMessage()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (JSONException e) { log.error(e.getMessage()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } finally { if (logCollectorRegistered) { unregisterLogCollector(); } } }
From source file:io.apiman.plugins.keycloak_oauth_policy.KeycloakOauthPolicy.java
private String getRawAuthToken(ApiRequest request) { String rawToken = StringUtils.strip(request.getHeaders().get(AUTHORIZATION_KEY)); if (rawToken != null && StringUtils.startsWithIgnoreCase(rawToken, BEARER)) { rawToken = StringUtils.removeStartIgnoreCase(rawToken, BEARER); } else {/*w w w .j ava2s .c o m*/ rawToken = request.getQueryParams().get(ACCESS_TOKEN_QUERY_KEY); } return rawToken; }
From source file:com.aspose.showcase.qrcodegen.web.api.controller.QRCodeManagementController.java
private ImageFormatDTO getRequestedImageFormat(HttpHeaders responseHeaders, String acceptHeaderValue, String format) {//from w w w .jav a 2 s .c om ImageFormatDTO generatedImageFormat = new ImageFormatDTO(ImageFormat.getPng(), MediaType.IMAGE_PNG, com.aspose.barcode.BarCodeImageFormat.Png); responseHeaders.setContentType(MediaType.IMAGE_PNG); if (StringUtils.isBlank(acceptHeaderValue) && StringUtils.isBlank(format)) { return new ImageFormatDTO(ImageFormat.getPng(), MediaType.IMAGE_PNG, com.aspose.barcode.BarCodeImageFormat.Png); } String requestedFormat = "Png"; if (StringUtils.isNotBlank(format)) { requestedFormat = format.trim(); } else if (StringUtils.isNotBlank(acceptHeaderValue)) { requestedFormat = StringUtils.removeStartIgnoreCase(acceptHeaderValue.trim(), "image/"); } if ("Jpeg".equalsIgnoreCase(requestedFormat)) { generatedImageFormat = new ImageFormatDTO(ImageFormat.getJpeg(), MediaType.IMAGE_JPEG, com.aspose.barcode.BarCodeImageFormat.Jpeg); responseHeaders.setContentType(MediaType.IMAGE_JPEG); } else if ("Png".equalsIgnoreCase(requestedFormat)) { generatedImageFormat = new ImageFormatDTO(ImageFormat.getPng(), MediaType.IMAGE_PNG, com.aspose.barcode.BarCodeImageFormat.Png); responseHeaders.setContentType(MediaType.IMAGE_PNG); } else if ("Gif".equalsIgnoreCase(requestedFormat)) { generatedImageFormat = new ImageFormatDTO(ImageFormat.getGif(), MediaType.IMAGE_GIF, com.aspose.barcode.BarCodeImageFormat.Gif); responseHeaders.setContentType(MediaType.IMAGE_GIF); } else if ("Tiff".equalsIgnoreCase(requestedFormat)) { generatedImageFormat = new ImageFormatDTO(ImageFormat.getTiff(), new MediaType(MEDIATYPE_IMAGE, MEDIATYPE_IMAGE_TIFF), com.aspose.barcode.BarCodeImageFormat.Tiff); responseHeaders.setContentType(new MediaType("image", MEDIATYPE_IMAGE_TIFF)); } else if ("Bmp".equalsIgnoreCase(requestedFormat)) { generatedImageFormat = new ImageFormatDTO(ImageFormat.getBmp(), new MediaType(MEDIATYPE_IMAGE, MEDIATYPE_IMAGE_BMP), com.aspose.barcode.BarCodeImageFormat.Bmp); responseHeaders.setContentType(new MediaType("image", MEDIATYPE_IMAGE_BMP)); } else { generatedImageFormat = new ImageFormatDTO(ImageFormat.getPng(), MediaType.IMAGE_PNG, com.aspose.barcode.BarCodeImageFormat.Png); responseHeaders.setContentType(MediaType.IMAGE_PNG); } return generatedImageFormat; }
From source file:adalid.util.velocity.MavenArchetypeBuilder.java
private boolean copyTextFiles() { Collection<File> files = FileUtils.listFiles(projectFolder, textFileFilter(), textDirFilter()); // ColUtils.sort(files); String source, target, targetParent, template, clazz; boolean java; Charset cs;/*from w w w. ja v a2 s . c o m*/ SmallFile smallSource; for (File file : files) { source = file.getPath(); java = StringUtils.endsWithIgnoreCase(source, ".java"); target = source.replace(projectFolderPath, velocityTemplatesTargetFolderPath); template = StringUtils.removeStart(target, velocityTemplatesTargetFolderPath + FS).replace('\\', '/'); clazz = StringUtils .removeStartIgnoreCase(StringUtils.removeEndIgnoreCase(template, ".java"), "src/main/java/") .replace('/', '.'); if (java) { classes.add(clazz); sources.add(template); } else { resources.add(template); } } String alias = alias(false); String ALIAS = alias(true); String packageX1 = packageName + "."; String packageX2 = packageName + ";"; List<String> sourceLines; List<String> targetLines = new ArrayList<>(); for (File file : files) { source = file.getPath(); java = StringUtils.endsWithIgnoreCase(source, ".java"); target = source.replace(projectFolderPath, velocityTemplatesTargetFolderPath); targetParent = StringUtils.substringBeforeLast(target, FS); targetLines.clear(); FilUtils.mkdirs(targetParent); smallSource = new SmallFile(source); sourceLines = smallSource.read(); check(smallSource); if (smallSource.isNotEmpty()) { for (String line : sourceLines) { if (StringUtils.isNotBlank(line)) { line = line.replace(group, "${groupId}"); line = line.replace(artifact, "${artifactId}"); line = line.replace(project + "ap", alias + "ap"); line = line.replace(PROJECT + "AP", ALIAS + "AP"); line = line.replace("package " + packageX1, "package ${package}." + packageX1); line = line.replace("package " + packageX2, "package ${package}." + packageX2); for (String name : classes) { if (name.startsWith(packageX1)) { line = line.replace(name, "${package}." + name); } } } targetLines.add(line); } } cs = java ? StandardCharsets.UTF_8 : WINDOWS_CHARSET; if (write(target, targetLines, cs)) { textFilesCopied++; } } return true; }