private String documentRoot() {
   if (_documentRoot == null) {
     _documentRoot = ERXProperties.stringForKey("WODocumentRoot");
     if (_documentRoot == null) {
       NSBundle bundle = NSBundle.bundleForName("JavaWebObjects");
       NSDictionary dict =
           ERXDictionaryUtilities.dictionaryFromPropertyList("WebServerConfig", bundle);
       _documentRoot = (String) dict.objectForKey("DocumentRoot");
     }
   }
   return _documentRoot;
 }
예제 #2
0
  private boolean isRobot(String userAgent) {
    synchronized (robotExpressions) {
      if (robotExpressions.count() == 0) {
        String strings =
            ERXStringUtilities.stringFromResource(
                "robots", "txt", NSBundle.bundleForName("ERExtensions"));
        for (String item : NSArray.componentsSeparatedByString(strings, "\n")) {
          if (item.trim().length() > 0 && item.charAt(0) != '#') {
            robotExpressions.addObject(Pattern.compile(item));
          }
        }
      }
      userAgent = userAgent.toLowerCase();
      for (Pattern pattern : robotExpressions) {
        if (pattern.matcher(userAgent).find()) {
          log.debug(pattern + " matches  " + userAgent);
          return true;
        }
      }
    }

    return false;
  }