Ejemplo n.º 1
0
  /**
   * Check if I should accept this file into the index database
   *
   * @param file the file to check
   * @return true if the file should be included, false otherwise
   */
  private boolean accept(File file) {

    if (!includedNames.isEmpty()
        && // the filter should not affect directory names
        (!(file.isDirectory() || includedNames.match(file)))) {
      return false;
    }

    String absolutePath = file.getAbsolutePath();

    if (ignoredNames.ignore(file)) {
      LOGGER.log(Level.FINER, "ignoring {0}", absolutePath);
      return false;
    }

    if (!file.canRead()) {
      LOGGER.log(Level.WARNING, "Could not read {0}", absolutePath);
      return false;
    }

    try {
      String canonicalPath = file.getCanonicalPath();
      if (!absolutePath.equals(canonicalPath) && !acceptSymlink(absolutePath, canonicalPath)) {

        LOGGER.log(
            Level.FINE,
            "Skipped symlink ''{0}'' -> ''{1}''",
            new Object[] {absolutePath, canonicalPath});
        return false;
      }
      // below will only let go files and directories, anything else is considered special and is
      // not added
      if (!file.isFile() && !file.isDirectory()) {
        LOGGER.log(Level.WARNING, "Ignored special file {0}", absolutePath);
        return false;
      }
    } catch (IOException exp) {
      LOGGER.log(Level.WARNING, "Failed to resolve name: {0}", absolutePath);
      LOGGER.log(Level.FINE, "Stack Trace: ", exp);
    }

    if (file.isDirectory()) {
      // always accept directories so that their files can be examined
      return true;
    }

    if (HistoryGuru.getInstance().hasHistory(file)) {
      // versioned files should always be accepted
      return true;
    }

    // this is an unversioned file, check if it should be indexed
    return !RuntimeEnvironment.getInstance().isIndexVersionedFilesOnly();
  }
Ejemplo n.º 2
0
 /*
  * (non-Javadoc)
  *
  * @see jletty.ldapstack.ldapops.Filter#match(javax.naming.directory.Attributes)
  */
 public MatchResult match(LdapEntry entry) {
   // A filter of the "or" choice is FALSE if all
   // of the filters in the SET OF evaluate to FALSE, TRUE if at least
   // one filter is TRUE, and Undefined otherwise.
   final List filters = this.setOfFilters;
   boolean allFalse = true;
   for (Iterator iter = filters.iterator(); iter.hasNext(); ) {
     Filter f = (Filter) iter.next();
     MatchResult result = f.match(entry);
     if (MatchResult.TRUE.equals(result)) {
       return MatchResult.TRUE;
     }
     if (!MatchResult.FALSE.equals(result)) {
       allFalse = false;
     }
   }
   if (allFalse) {
     return MatchResult.FALSE;
   } else {
     return MatchResult.UNDEF;
   }
 }