Ejemplo n.º 1
0
 public String getPluginName() {
   if (definitionMap.containsKey(KEY_PLUGIN_NAME)) {
     return definitionMap.getString(KEY_PLUGIN_NAME);
   } else {
     return getDefaultPluginName();
   }
 }
Ejemplo n.º 2
0
 public String getDefaultArticleMimeType() {
   String ret = definitionMap.getString(KEY_DEFAULT_ARTICLE_MIME_TYPE, null);
   log.debug3("DefaultArticleMimeType " + ret);
   if (ret == null) {
     ret = super.getDefaultArticleMimeType();
     log.debug3("DefaultArticleMimeType from super " + ret);
   }
   return ret;
 }
Ejemplo n.º 3
0
 /**
  * Returns the plugin's article iterator factory, if any
  *
  * @return the ArticleIteratorFactory
  */
 public ArticleIteratorFactory getArticleIteratorFactory() {
   if (articleIteratorFact == null) {
     String factClass = definitionMap.getString(KEY_PLUGIN_ARTICLE_ITERATOR_FACTORY, null);
     if (factClass != null) {
       articleIteratorFact =
           (ArticleIteratorFactory) newAuxClass(factClass, ArticleIteratorFactory.class);
     }
   }
   return articleIteratorFact;
 }
Ejemplo n.º 4
0
 protected ExploderHelper getExploderHelper() {
   if (exploderHelper == null) {
     String helperClass =
         definitionMap.getString(DefinableArchivalUnit.KEY_AU_EXPLODER_HELPER, null);
     if (helperClass != null) {
       exploderHelper = (ExploderHelper) newAuxClass(helperClass, ExploderHelper.class);
     }
   }
   return exploderHelper;
 }
Ejemplo n.º 5
0
 protected CrawlUrlComparatorFactory getCrawlUrlComparatorFactory() {
   if (crawlUrlComparatorFactory == null) {
     String factClass =
         definitionMap.getString(DefinablePlugin.KEY_PLUGIN_CRAWL_URL_COMPARATOR_FACTORY, null);
     if (factClass != null) {
       crawlUrlComparatorFactory =
           (CrawlUrlComparatorFactory) newAuxClass(factClass, CrawlUrlComparatorFactory.class);
     }
   }
   return crawlUrlComparatorFactory;
 }
Ejemplo n.º 6
0
 protected LoginPageChecker makeLoginPageChecker() {
   if (loginChecker == null) {
     String loginPageCheckerClass =
         definitionMap.getString(DefinableArchivalUnit.KEY_AU_LOGIN_PAGE_CHECKER, null);
     if (loginPageCheckerClass != null) {
       loginChecker =
           (LoginPageChecker) newAuxClass(loginPageCheckerClass, LoginPageChecker.class);
     }
   }
   return loginChecker;
 }
Ejemplo n.º 7
0
 /**
  * Returns the article iterator factory for the content type, if any
  *
  * @param contentType the content type
  * @return the ArticleIteratorFactory
  */
 public ArticleMetadataExtractorFactory getArticleMetadataExtractorFactory(MetadataTarget target) {
   if (articleMetadataFact == null) {
     String factClass =
         definitionMap.getString(KEY_PLUGIN_ARTICLE_METADATA_EXTRACTOR_FACTORY, null);
     if (factClass != null) {
       articleMetadataFact =
           (ArticleMetadataExtractorFactory)
               newAuxClass(factClass, ArticleMetadataExtractorFactory.class);
     }
   }
   return articleMetadataFact;
 }
Ejemplo n.º 8
0
 protected UrlNormalizer getUrlNormalizer() {
   if (urlNorm == null) {
     String normalizerClass =
         definitionMap.getString(DefinableArchivalUnit.KEY_AU_URL_NORMALIZER, null);
     if (normalizerClass != null) {
       urlNorm = (UrlNormalizer) newAuxClass(normalizerClass, UrlNormalizer.class);
     } else {
       urlNorm = NullUrlNormalizer.INSTANCE;
     }
   }
   return urlNorm;
 }
Ejemplo n.º 9
0
 protected PermissionCheckerFactory getPermissionCheckerFactory() {
   if (permissionCheckerFact == null) {
     String permissionCheckerFactoryClass =
         definitionMap.getString(DefinableArchivalUnit.KEY_AU_PERMISSION_CHECKER_FACTORY, null);
     if (permissionCheckerFactoryClass != null) {
       permissionCheckerFact =
           (PermissionCheckerFactory)
               newAuxClass(permissionCheckerFactoryClass, PermissionCheckerFactory.class);
       log.debug2("Loaded PermissionCheckerFactory: " + permissionCheckerFact);
     }
   }
   return permissionCheckerFact;
 }
Ejemplo n.º 10
0
 /** Create a CrawlWindow if necessary and return it. The CrawlWindow must be thread-safe. */
 protected CrawlWindow makeCrawlWindow() {
   if (crawlWindow != null) {
     return crawlWindow;
   }
   CrawlWindow window =
       (CrawlWindow) definitionMap.getMapElement(DefinableArchivalUnit.KEY_AU_CRAWL_WINDOW_SER);
   if (window == null) {
     String window_class =
         definitionMap.getString(DefinableArchivalUnit.KEY_AU_CRAWL_WINDOW, null);
     if (window_class != null) {
       ConfigurableCrawlWindow ccw =
           (ConfigurableCrawlWindow) newAuxClass(window_class, ConfigurableCrawlWindow.class);
       try {
         window = ccw.makeCrawlWindow();
       } catch (PluginException e) {
         throw new RuntimeException(e);
       }
     }
   }
   crawlWindow = window;
   return window;
 }
Ejemplo n.º 11
0
 private ExternalizableMap loadMap(String extMapName, ClassLoader loader)
     throws FileNotFoundException {
   String first = null;
   String next = extMapName;
   List<String> urls = new ArrayList<String>();
   ExternalizableMap res = null;
   while (next != null) {
     // convert the plugin class name to an xml file name
     String mapFile = next.replace('.', '/') + MAP_SUFFIX;
     URL url = loader.getResource(mapFile);
     if (url != null && urls.contains(url.toString())) {
       throw new PluginException.InvalidDefinition("Plugin inheritance loop: " + next);
     }
     // load into map
     ExternalizableMap oneMap = new ExternalizableMap();
     oneMap.loadMapFromResource(mapFile, loader);
     urls.add(url.toString());
     // apply overrides one plugin at a time in inheritance chain
     processOverrides(oneMap);
     if (res == null) {
       res = oneMap;
     } else {
       for (Map.Entry ent : oneMap.entrySet()) {
         String key = (String) ent.getKey();
         Object val = ent.getValue();
         if (!res.containsKey(key)) {
           res.setMapElement(key, val);
         }
       }
     }
     if (oneMap.containsKey(KEY_PLUGIN_PARENT)) {
       next = oneMap.getString(KEY_PLUGIN_PARENT);
     } else {
       next = null;
     }
   }
   loadedFromUrls = urls;
   return res;
 }
Ejemplo n.º 12
0
  protected void initResultMap() throws PluginException.InvalidDefinition {
    HttpResultMap hResultMap = new HttpResultMap();
    // XXX Currently this only allows a CacheResultHandler class to
    // initialize the result map.  Instead, don't use a CacheResultMap
    // directly, use either the plugin's CacheResultHandler, if specified,
    // or a default one that wraps the CacheResultMap

    String handler_class = null;
    handler_class = definitionMap.getString(KEY_EXCEPTION_HANDLER, null);
    if (handler_class != null) {
      try {
        resultHandler = (CacheResultHandler) newAuxClass(handler_class, CacheResultHandler.class);
        resultHandler.init(hResultMap);
      } catch (Exception ex) {
        throw new PluginException.InvalidDefinition(
            mapName + " has invalid Exception handler: " + handler_class, ex);
      } catch (LinkageError le) {
        throw new PluginException.InvalidDefinition(
            mapName + " has invalid Exception handler: " + handler_class, le);
      }
    } else {
      // Expect a list of mappings from either result code or exception
      // name to CacheException name
      Collection<String> mappings = definitionMap.getCollection(KEY_EXCEPTION_LIST, null);
      if (mappings != null) {
        // add each entry
        for (String entry : mappings) {
          if (log.isDebug2()) {
            log.debug2("initMap(" + entry + ")");
          }
          String first;
          String ceName;
          try {
            List<String> pair = StringUtil.breakAt(entry, '=', 2, true, true);
            first = pair.get(0);
            ceName = pair.get(1);
          } catch (Exception ex) {
            throw new PluginException.InvalidDefinition(
                "Invalid syntax: " + entry + "in " + mapName);
          }
          Object val;

          // Value should be either a CacheException or CacheResultHandler
          // class name.
          PluginFetchEventResponse resp =
              (PluginFetchEventResponse) newAuxClass(ceName, PluginFetchEventResponse.class, null);
          if (resp instanceof CacheException) {
            val = resp.getClass();
          } else if (resp instanceof CacheResultHandler) {
            val = WrapperUtil.wrap((CacheResultHandler) resp, CacheResultHandler.class);
          } else {
            throw new PluginException.InvalidDefinition(
                "Second arg not a "
                    + "CacheException or "
                    + "CacheResultHandler class: "
                    + entry
                    + ", in "
                    + mapName);
          }
          try {
            int code = Integer.parseInt(first);
            // If parseable as an integer, it's a result code.
            hResultMap.storeMapEntry(code, val);
          } catch (NumberFormatException e) {
            try {
              Class eClass = Class.forName(first);
              // If a class name, it should be an exception class
              if (Exception.class.isAssignableFrom(eClass)) {
                hResultMap.storeMapEntry(eClass, val);
              } else {
                throw new PluginException.InvalidDefinition(
                    "First arg not an " + "Exception class: " + entry + ", in " + mapName);
              }
            } catch (Exception ex) {
              throw new PluginException.InvalidDefinition(
                  "First arg not a " + "number or class: " + entry + ", in " + mapName);
            } catch (LinkageError le) {
              throw new PluginException.InvalidDefinition("Can't load " + first, le);
            }
          }
        }
      }
    }
    resultMap = hResultMap;
  }
Ejemplo n.º 13
0
 public String getPluginNotes() {
   return definitionMap.getString(KEY_PLUGIN_NOTES, null);
 }
Ejemplo n.º 14
0
 public String getPublishingPlatform() {
   return definitionMap.getString(KEY_PUBLISHING_PLATFORM, null);
 }
Ejemplo n.º 15
0
 public String getRequiredDaemonVersion() {
   return definitionMap.getString(KEY_REQUIRED_DAEMON_VERSION, DEFAULT_REQUIRED_DAEMON_VERSION);
 }
Ejemplo n.º 16
0
 public String getVersion() {
   return definitionMap.getString(KEY_PLUGIN_VERSION, DEFAULT_PLUGIN_VERSION);
 }