public int checkAccess ( String path ) { timeLastAccessed = System . currentTimeMillis ( ) ; int result = UNDEFINED ; String myUA = config . getUserAgentName ( ) ; boolean ignoreUADisc = config . getIgnoreUADiscrimination ( ) ; // When checking rules, the list of rules is already ordered based on the // match of the user-agent of the clause with the user-agent of the crawler. // The most specific match should come first. // // Only the most specific match is obeyed, unless ignoreUADiscrimination is // enabled. In that case, any matching non-wildcard clause that explicitly // disallows the path is obeyed. If no such rule exists and any UA in the list // is allowed access, that rule is obeyed. for ( UserAgentDirectives ua : rules ) { int score = ua . match ( myUA ) ; // If ignoreUADisc is disabled and the current UA doesn't match, // the rest will not match so we are done here. if ( score == 0 && ! ignoreUADisc ) { break ; } // Match the rule to the path result = ua . checkAccess ( path , userAgent ) ; // If the result is ALLOWED or UNDEFINED, or if // this is a wildcard rule and ignoreUADisc is disabled, // this is the final verdict. if ( result != DISALLOWED || ( ! ua . isWildcard ( ) || ! ignoreUADisc ) ) { break ; } // This is a wildcard rule that disallows access. The verdict is stored, // but the other rules will also be checked to see if any specific UA is allowed // access to this path. If so, that positive UA discrimination is ignored // and we crawl the page anyway. } return result ; }
Check if any of the rules say anything about the specified path