Ejemplo n.º 1
0
  /**
   * Parses a {@link SimpleConcept} from a String
   *
   * @param concept
   * @return
   * @author jmayaalv
   */
  public static SimpleConcept parse(String concept) {
    if (StringUtils.isBlank(concept)) {
      return null;
    }

    concept = StringUtils.trim(concept);
    if ((StringUtils.countMatches(concept, "(") == (StringUtils.countMatches(concept, ")")))
        && StringUtils.startsWith(concept, "(")
        && StringUtils.endsWith(concept, ")")) {
      concept = StringUtils.substring(concept, 1, concept.length() - 1);
    }

    boolean negated = false;
    if (concept.startsWith(".NO")) {
      negated = true;
      concept = StringUtils.remove(concept, ".NO");
      concept = StringUtils.trim(concept);
    }

    if (StringUtils.isBlank(concept)) {
      throw new RuntimeException("Concept can't be parsed: " + concept);
    }

    if ((StringUtils.countMatches(concept, "(") == (StringUtils.countMatches(concept, ")")))
        && StringUtils.startsWith(concept, "(")
        && StringUtils.endsWith(concept, ")")) {
      concept = StringUtils.substring(concept, 1, concept.length() - 1);
    }

    if (StringUtils.contains(concept, " ")) {
      return null; // not a SimpleConcep
    }

    return new SimpleConcept(Integer.parseInt(concept), negated);
  }
  /**
   * 对源代码进行格式化,格式化失败返回原格式
   *
   * @param sourceCode
   * @return
   */
  public static String formatCode(String sourceCode) {

    BufferedReader reader = new BufferedReader(new StringReader(sourceCode));
    try {
      StringBuilder header = new StringBuilder();
      StringBuilder content = new StringBuilder();
      String lineSeparator = System.getProperty("line.separator", "\n");
      boolean isHeader = true;
      String line;
      while ((line = reader.readLine()) != null) {
        line = StringUtils.trim(line);
        if (StringUtils.isBlank(line)) {
          continue;
        }
        if (isHeader
            && (StringUtils.startsWith(line, "package")
                || StringUtils.startsWith(line, "import"))) {
          header.append(line).append(lineSeparator);
        } else {
          isHeader = false;
          content.append(line).append(lineSeparator);
        }
      }
      String finalCode = StringUtils.trim(content.toString());
      finalCode = formatBodyCode(finalCode);
      return header.append(finalCode).toString();

    } catch (Exception e) {
      LOG.error("格式化源代码失败", e);
      // 忽略,返回原格式
    } finally {
      IOUtils.closeQuietly(reader);
    }
    return sourceCode;
  }
Ejemplo n.º 3
0
  @Override
  public void postHandle(
      HttpServletRequest request,
      HttpServletResponse response,
      Object handler,
      ModelAndView modelAndView)
      throws Exception {
    Long executeTime = (Long) request.getAttribute(EXECUTE_TIME_ATTRIBUTE_NAME);
    if (executeTime == null) {
      Long startTime = (Long) request.getAttribute(START_TIME_ATTRIBUTE_NAME);
      Long endTime = System.currentTimeMillis();
      executeTime = endTime - startTime;
      request.setAttribute(START_TIME_ATTRIBUTE_NAME, startTime);
    }

    if (modelAndView != null) {
      String viewName = modelAndView.getViewName();
      if (!StringUtils.startsWith(viewName, REDIRECT_VIEW_NAME_PREFIX)) {
        modelAndView.addObject(EXECUTE_TIME_ATTRIBUTE_NAME, executeTime);
      }
    }
    if (logger.isDebugEnabled()) {
      logger.debug("[" + handler + "] executeTime: " + executeTime + "ms");
    }
  }
Ejemplo n.º 4
0
  /**
   * 转换成骆驼命名法返回
   *
   * @param name
   * @return
   */
  public static String getCamelName(String name) {
    if (StringUtils.isBlank(name)) {
      return null;
    }
    name = StringUtils.lowerCase(name);
    // 去掉前面的_
    while (StringUtils.startsWith(name, "_")) {
      name = StringUtils.substring(name, 1);
    }
    // 去掉后面的_
    while (StringUtils.endsWith(name, "_")) {
      name = StringUtils.substring(name, 0, name.length() - 1);
    }

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < name.length(); i++) {

      char c = name.charAt(i);

      if (c == '_') {
        i++;
        sb.append(Character.toUpperCase(name.charAt(i)));
        continue;
      }
      sb.append(c);
    }

    return sb.toString();
  }
Ejemplo n.º 5
0
 /**
  * 根据metric的名字,返回写入cat上的key
  *
  * @param spoutMetricName
  * @return
  */
 public static String getCatMetricKey(String spoutMetricName) {
   if (StringUtils.isBlank(spoutMetricName)
       || !StringUtils.startsWith(spoutMetricName, CAT_METRIC_NAME_PREFIX)) {
     return "default";
   }
   return StringUtils.substringAfter(spoutMetricName, CAT_METRIC_NAME_PREFIX);
 }
    public List<CompilerMessage> parseStream(String data) {

      List<CompilerMessage> messages = new ArrayList<CompilerMessage>();

      Matcher matcher = pattern.matcher(data);

      if (matcher.find()) {
        String filename = matcher.group(1);
        String url = CompilationTaskWorker.generateFileUrl(basePath, filename);
        messages.add(
            new CompilerMessage(
                CompilerMessageCategory.ERROR,
                matcher.group(3),
                url,
                Integer.parseInt(matcher.group(2)),
                -1));
      } else {

        // Ignore error lines that start with the compiler as the line that follows this contains
        // the error that
        // we're interested in. Otherwise, the error is more severe and we should display it
        if (!StringUtils.startsWith(data, GoSdkUtil.getCompilerName(goSdkData.TARGET_ARCH))) {
          messages.add(new CompilerMessage(CompilerMessageCategory.ERROR, data, null, -1, -1));
        }
      }

      return messages;
    }
Ejemplo n.º 7
0
  /**
   * 根据条件查询公司
   *
   * @return
   */
  @RequestMapping(value = "/queryCompanyByConditions.htm", produces = "application/json")
  @ResponseBody
  public JsonResult queryCompanyByConditions(TravelCompanyQuery query, Integer limit) {
    List<TravelCompanyDO> list = companyService.listQuery(query);

    List<Map<String, ?>> mapList = CollectionUtils.toMapList(list, "cId", "cName", "cSpell");
    // StringBuilder sb = new StringBuilder();
    String cond = query.getQ() == null ? StringUtils.EMPTY : query.getQ();
    cond = cond.toLowerCase();
    // String temp;
    int maxSize = getLimit(limit);
    int size = 0;
    List<Map<String, ?>> result = new LinkedList<Map<String, ?>>();
    String property = cond.matches("[a-zA-Z]+") ? "cSpell" : "cName";
    for (Map<String, ?> map : mapList) {
      Object cName = null;
      for (Entry<String, ?> entry : map.entrySet()) {
        if (StringUtils.equals(entry.getKey(), property)) {
          cName = entry.getValue();
        }
      }
      if (cond.matches("[a-zA-Z]+")
          ? StringUtils.startsWith((String) cName, cond)
          : StringUtils.containsIgnoreCase((String) cName, cond)) {
        result.add(map);
        size++;
        if (size > maxSize) {
          break;
        }
      }
    }
    return JsonResultUtils.success(result);
  }
Ejemplo n.º 8
0
  /**
   * Initialize the workload. Called once, in the main client thread, before any operations are
   * started.
   *
   * @throws IOException
   * @throws ClassNotFoundException
   */
  public void init(Props props) throws IOException {
    CmdProvider cmdProvider;
    int readPercent = props.getInt(Benchmark.SELECT, 0);
    int writePercent = props.getInt(Benchmark.INSERT, 0);

    double readProportion = (double) readPercent / (double) 100;
    double writeProportion = (double) writePercent / (double) 100;

    if (readProportion + writeProportion > 0) {
      double sum = readProportion + writeProportion;
      readProportion = readProportion / sum;
      writeProportion = writeProportion / sum;
    }

    if (readProportion > 0) {
      cmdProvider = new QueryProvider(props);
      operationChooser.addValue(readProportion, cmdProvider.getName());
      operations.put(cmdProvider.getName(), cmdProvider);
    }
    if (writeProportion > 0) {
      cmdProvider = new InsertProvider(props);
      operationChooser.addValue(writeProportion, cmdProvider.getName());
      operations.put(cmdProvider.getName(), cmdProvider);
    }
    if (props.containsKey(Benchmark.RECORD_FILE)) {
      String cmd = props.getString(Benchmark.CMD_PROVIDER, "");
      if (StringUtils.startsWith(cmd, "ctu_minisearch")) {
        cmdProvider = new CtuMiniSearchProvider(props);
      } else {
        cmdProvider = new SqlFileProvider(props);
      }
      operationChooser.addValue(1.0, cmdProvider.getName());
      operations.put(cmdProvider.getName(), cmdProvider);
    }
  }
 private void populateVirtualP2Values(
     P2TypeSpecificConfigModel model, VirtualRepoDescriptor descriptor) {
   if (descriptor.getP2() == null || descriptor.getP2().getUrls() == null) {
     return;
   }
   Map<String, String> urlToRepoKeyMap = getUrlToRepoKeyMapping(descriptor.getRepositories());
   List<P2Repo> p2Repos = Lists.newArrayList();
   descriptor
       .getP2()
       .getUrls()
       .stream()
       .forEach(
           url -> {
             if (StringUtils.startsWith(url, "local://")) {
               Optional.ofNullable(resolveLocalP2RepoFromUrl(url)).ifPresent(p2Repos::add);
             } else {
               urlToRepoKeyMap
                   .keySet()
                   .stream()
                   .map(RepoConfigDescriptorBuilder::getUrlWithoutSubpath)
                   .filter(
                       p2Url ->
                           RepoConfigDescriptorBuilder.getUrlWithoutSubpath(url).equals(p2Url))
                   .findAny()
                   .ifPresent(
                       containingUrl ->
                           p2Repos.add(new P2Repo(null, urlToRepoKeyMap.get(containingUrl), url)));
             }
           });
   model.setP2Repos(p2Repos);
 }
Ejemplo n.º 10
0
  /**
   * Find files that match the given patterns
   *
   * @param currentSolution The VS solution being analyzed by sonar
   * @param defaultWorkDir A working directory
   * @param patternArray A list of paths or ant style patterns
   * @return The files found on the filesystem
   */
  @SuppressWarnings("unchecked")
  public static Collection<File> findFiles(
      VisualStudioSolution currentSolution, File defaultWorkDir, String... patternArray) {

    if (patternArray == null || patternArray.length == 0) {
      return Collections.EMPTY_LIST;
    }

    Set<File> result = new HashSet<File>();
    for (String pattern : patternArray) {
      String currentPattern = convertSlash(pattern);
      File workDir = defaultWorkDir;
      if (StringUtils.startsWith(pattern, SOLUTION_DIR_KEY)) {
        workDir = currentSolution.getSolutionDir();
        currentPattern = StringUtils.substringAfter(currentPattern, SOLUTION_DIR_KEY);
      }
      while (StringUtils.startsWith(currentPattern, PARENT_DIRECTORY)) {
        workDir = workDir.getParentFile();
        if (workDir == null) {
          LOG.warn("The following pattern is not correct: " + pattern);
          break;
        }
        currentPattern = StringUtils.substringAfter(currentPattern, PARENT_DIRECTORY);
      }
      if (workDir == null) {
        continue;
      } else if (StringUtils.contains(currentPattern, '*')) {
        String prefix = StringUtils.substringBefore(currentPattern, "*");
        if (StringUtils.contains(prefix, '/')) {
          workDir = browse(workDir, prefix);
          currentPattern = "*" + StringUtils.substringAfter(currentPattern, "*");
        }
        IOFileFilter externalFilter = new PatternFilter(workDir, currentPattern);
        listFiles(result, workDir, externalFilter);

      } else {
        File file = browse(workDir, currentPattern);
        if (file.exists()) {
          result.add(browse(workDir, currentPattern));
        }
      }
    }

    logResults(result, patternArray);

    return result;
  }
Ejemplo n.º 11
0
 public List<String> getKeysStartingWith(String prefix) {
   List<String> result = new ArrayList<>();
   for (String key : properties.keySet()) {
     if (StringUtils.startsWith(key, prefix)) {
       result.add(key);
     }
   }
   return result;
 }
  public static boolean isExclude(String category) {
    for (String exclude : EXCLUDES) {
      if (StringUtils.startsWith(category, exclude)) {
        return true;
      }
    }

    return false;
  }
Ejemplo n.º 13
0
  /**
   * Extracts Image from a Data URL
   *
   * @param mimeType
   */
  public static Base64EncodedImage extractImageFromDataURL(final String dataURL) {
    String fileExtension = "";
    String base64EncodedString = null;
    if (StringUtils.startsWith(dataURL, IMAGE_DATA_URI_SUFFIX.GIF.getValue())) {
      base64EncodedString = dataURL.replaceAll(IMAGE_DATA_URI_SUFFIX.GIF.getValue(), "");
      fileExtension = IMAGE_FILE_EXTENSION.GIF.getValue();
    } else if (StringUtils.startsWith(dataURL, IMAGE_DATA_URI_SUFFIX.PNG.getValue())) {
      base64EncodedString = dataURL.replaceAll(IMAGE_DATA_URI_SUFFIX.PNG.getValue(), "");
      fileExtension = IMAGE_FILE_EXTENSION.PNG.getValue();
    } else if (StringUtils.startsWith(dataURL, IMAGE_DATA_URI_SUFFIX.JPEG.getValue())) {
      base64EncodedString = dataURL.replaceAll(IMAGE_DATA_URI_SUFFIX.JPEG.getValue(), "");
      fileExtension = IMAGE_FILE_EXTENSION.JPEG.getValue();
    } else {
      throw new ImageDataURLNotValidException();
    }

    return new Base64EncodedImage(base64EncodedString, fileExtension);
  }
Ejemplo n.º 14
0
 public void postHandle(
     HttpServletRequest request,
     HttpServletResponse response,
     Object handler,
     ModelAndView modelAndView) {
   if ((modelAndView != null) && (modelAndView.isReference())) {
     String str1 = modelAndView.getViewName();
     if (StringUtils.startsWith(str1, REDIRECT)) {
       String str2 = CookieUtils.getCookie(request, LIST_QUERY);
       if (StringUtils.isNotEmpty(str2)) {
         if (StringUtils.startsWith(str2, "?")) str2 = str2.substring(1);
         if (StringUtils.contains(str1, "?")) modelAndView.setViewName(str1 + "&" + str2);
         else modelAndView.setViewName(str1 + "?" + str2);
         CookieUtils.removeCookie(request, response, LIST_QUERY);
       }
     }
   }
 }
Ejemplo n.º 15
0
 /**
  * Only if the path template starts with the datadir, return a path relative to it, otherwise
  * return an absolute path.
  */
 protected String getFilePathRelativeToDataDirIfPossible() {
   String template = getFilePathTemplate();
   if (StringUtils.startsWith(template, "$datadir$")) {
     template = StringUtils.replace(template, "$datadir$", "");
     template = StringUtils.removeStart(template, "/");
   } else {
     template = substituteDatadir(template);
   }
   return substituteScan(template);
 }
Ejemplo n.º 16
0
  private String buildAuthorizationString(HttpResponse request) {
    List<String> auths = request.headers().getAll("WWW-Authenticate");
    for (String auth : auths) {
      if (StringUtils.startsWith(auth, "Basic")) {
        String user = rtspStack.getUser();
        String pass = rtspStack.getPasswd();
        byte[] bytes =
            org.apache.commons.codec.binary.Base64.encodeBase64(
                new String(user + ":" + (pass != null ? pass : "")).getBytes());
        String authValue = "Basic " + new String(bytes);
        return authValue;

      } else if (StringUtils.startsWith(auth, "Digest")) {

      }
    }

    throw new UnsupportedOperationException("fail use WWW-Authenticate:" + auths.toString());
  }
Ejemplo n.º 17
0
 protected String destURL(File rootPath, File file, String src, String dest) {
   String trimmedPattern = rtrimStandardrizedWildcardTokens(src);
   if (StringUtils.equals(normalizePath(trimmedPattern), normalizePath(src))) {
     return dest;
   }
   String trimmedPath = removeStart(subtractPath(rootPath, file), normalizePath(trimmedPattern));
   if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) {
     trimmedPath = "/" + trimmedPath;
   }
   return dest + trimmedPath;
 }
 public M2ReleaseVersionInfo(final String version, final String nextDevelopmentVersionMode)
     throws VersionParseException {
   super(version);
   // custom field (set next version mode index, acceptable are 1,2 and 3)
   // if latest is coming, we keep there DefaultVersionInfo behavior
   if (StringUtils.startsWith(nextDevelopmentVersionMode, INDEX_PREFIX)) {
     final String indexStr =
         StringUtils.substring(nextDevelopmentVersionMode, INDEX_PREFIX.length());
     nextVersionModeIndex = NumberUtils.toInt(indexStr) - 1;
   }
 }
Ejemplo n.º 19
0
  /**
   * Get status of the availability of secured (with secure vault) properties
   *
   * @return availability of secured properties
   */
  private static boolean isSecuredPropertyAvailable(Properties properties) {

    Enumeration propertyNames = properties.propertyNames();

    while (propertyNames.hasMoreElements()) {
      String key = (String) propertyNames.nextElement();
      if (StringUtils.startsWith(properties.getProperty(key), SECRET_ALIAS)) {
        return true;
      }
    }
    return false;
  }
 public static String sanitize(String mavenArtifactId) {
   String key = mavenArtifactId;
   if (StringUtils.startsWith(mavenArtifactId, SONAR_PREFIX)
       && StringUtils.endsWith(mavenArtifactId, PLUGIN_SUFFIX)) {
     key =
         StringUtils.removeEnd(
             StringUtils.removeStart(mavenArtifactId, SONAR_PREFIX), PLUGIN_SUFFIX);
   } else if (StringUtils.endsWith(mavenArtifactId, SONAR_PLUGIN_SUFFIX)) {
     key = StringUtils.removeEnd(mavenArtifactId, SONAR_PLUGIN_SUFFIX);
   }
   return keepLettersAndDigits(key);
 }
  /**
   * 自动格式化 会尝试判断格式 python等语言不支持
   *
   * @param source
   * @return
   */
  public static String formatEscapeCode(String source) {

    source = StringUtils.trim(source);
    // 需要先还原,因为提交过来页面显示的代码都是转义后的
    source = TextUtils.reverseSpecialChars(source);
    if (StringUtils.startsWith(source, "<")) {
      source = formatXML(source);
    } else {
      source = formatCode(source);
    }
    // 还原成转义后
    return TextUtils.convertSpecialChars(source);
  }
Ejemplo n.º 22
0
 public void resetMedications() {
   PropertyDescriptor[] propertyDescriptors =
       PropertyUtils.getPropertyDescriptors(this.getClass());
   for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
     try {
       String name = propertyDescriptor.getName();
       if (StringUtils.startsWith(name, "on"))
         PropertyUtils.setProperty(this, name, Boolean.FALSE);
     } catch (Exception e) {
       log.error("Unable to read property: " + propertyDescriptor.getName() + "!", e);
     }
   }
 }
Ejemplo n.º 23
0
 @Override
 public void postHandle(
     HttpServletRequest request,
     HttpServletResponse response,
     Object handler,
     ModelAndView modelAndView)
     throws Exception {
   if (modelAndView != null) {
     String viewName = modelAndView.getViewName();
     if (!StringUtils.startsWith(viewName, REDIRECT_VIEW_NAME_PREFIX)) {
       modelAndView.addObject(MEMBER_ATTRIBUTE_NAME, memberService.getCurrent());
     }
   }
 }
  protected String calculateIndexRemoteUrl(RemoteRepository remoteRepository) {
    if (StringUtils.startsWith(remoteRepository.getRemoteIndexUrl(), "http")) {
      String baseUrl = remoteRepository.getRemoteIndexUrl();
      return baseUrl.endsWith("/") ? StringUtils.substringBeforeLast(baseUrl, "/") : baseUrl;
    }
    String baseUrl =
        StringUtils.endsWith(remoteRepository.getUrl(), "/")
            ? StringUtils.substringBeforeLast(remoteRepository.getUrl(), "/")
            : remoteRepository.getUrl();

    baseUrl =
        StringUtils.isEmpty(remoteRepository.getRemoteIndexUrl())
            ? baseUrl + "/.index"
            : baseUrl + "/" + remoteRepository.getRemoteIndexUrl();
    return baseUrl;
  }
Ejemplo n.º 25
0
 public static void main(String[] args) {
   //		String requrl = "http://127.0.0.1:8080/ms/sysMenu/menu.shtml";
   //		requrl = "https://127.0.0.1:8080/ms/sysMenu/menu.shtml?A=1&B=2#111";
   //		String uri = getReqUri(requrl);
   //		System.out.println(uri);
   //		System.out.println(StringUtils.remove(uri, "/ms/"));
   //		System.err.println(getReqUri(requrl));\
   String menu = "/sysMneu/dataList.do";
   String url = "save.do| action.do |/user/manger/abcd.do";
   String[] actions = StringUtils.split(url, "|");
   String menuUri = StringUtils.substringBeforeLast(menu, "/");
   for (String action : actions) {
     action = StringUtils.trim(action);
     if (StringUtils.startsWith(action, "/")) System.out.println(action);
     else System.out.println(menuUri + "/" + action);
   }
 }
  /**
   * Retrieve all Clearcase UCM component (with pvob suffix) for a stream
   *
   * @param stream the stream name like 'P_EngDesk_Product_3.2_int@\P_ORC'
   * @param clearTool the clearcase launcher
   * @return component list attached to the stream like
   *     ['DocGen_PapeeteDoc@\P_ORC','DocMgt_Modulo@\P_ORC']
   * @throws IOException
   * @throws InterruptedException
   */
  private List<String> getComponentList(ClearTool clearTool, String stream)
      throws IOException, InterruptedException {
    String output = clearTool.lsstream(stream, null, "\"%[components]XCp\"");
    String comp[] = output.split(",\\s");
    List<String> result = new ArrayList<String>();
    final String prefix = "component:";
    for (String c : comp) {
      if (StringUtils.startsWith(c, prefix)) {
        result.add(StringUtils.difference(prefix, c));
      } else {
        throw new IOException(
            "Invalid format for component in output. Must starts with 'component:' : " + c);
      }
    }

    return result;
  }
Ejemplo n.º 27
0
  public static File browse(File workDir, String path) {
    if (StringUtils.isEmpty(path)) {
      return workDir;
    }
    File file = new File(path);
    if (!file.exists() || !file.isAbsolute()) {
      File currentWorkDir = workDir;
      String currentPath = path;
      while (StringUtils.startsWith(currentPath, PARENT_DIRECTORY)) {
        currentWorkDir = currentWorkDir.getParentFile();
        currentPath = StringUtils.substringAfter(currentPath, PARENT_DIRECTORY);
      }
      file = new File(currentWorkDir, currentPath);
    }

    return file;
  }
Ejemplo n.º 28
0
 /**
  * 获取排除了指定参数之后的查询字符串
  *
  * @param req HttpServletRequest object
  * @param excludeParams 被排除的参数名称
  * @return 查询字符串 queryString,例如status=1&test=2
  */
 public static String getQueryString(HttpServletRequest req, String[] excludeParams) {
   String queryString = req.getQueryString();
   if (queryString == null || queryString.length() == 0) {
     return "";
   }
   StringBuilder sb = new StringBuilder(queryString.length());
   OUTER:
   for (String s : StringUtils.split(queryString, '&')) {
     for (String exclude : excludeParams) {
       if (StringUtils.startsWith(s, exclude + "=")) {
         continue OUTER;
       }
     }
     sb.append('&');
     sb.append(s);
   }
   return sb.length() == 0 ? "" : sb.substring(1);
 }
  public final void setContentType(String contentType) {
    // If something tries to change the content type of the response by setting a content type of
    // "text/html; charset=...", just ignore it. This happens in Tomcat and Jetty JSPs.
    if (StringUtils.startsWith(contentType, "text/html")
        && contentType.length() > "text/html".length()) {
      return;
    }

    // Ensure that the charset parameter is appended if we're called with just "text/html".
    // This happens on WebLogic.
    if (StringUtils.trimToEmpty(contentType).equals("text/html")) {
      super.setContentType(contentType + ";charset=" + getResponse().getCharacterEncoding());
      return;
    }

    // for all other content types, just set the value
    super.setContentType(contentType);
  }
Ejemplo n.º 30
0
  public void doFilter(
      final ServletRequest theRequest, final ServletResponse theResponse, final FilterChain chain)
      throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) theRequest;
    HttpServletResponse response = (HttpServletResponse) theResponse;
    String servletPath = request.getServletPath();

    if (StringUtils.startsWith(servletPath, filterProcessesUrl)) {
      boolean validated = validateCaptchaChallenge(request);
      if (validated) {
        chain.doFilter(request, response);
      } else {
        redirectFailureUrl(request, response);
      }
    } else {
      genernateCaptchaImage(request, response);
    }
  }