Ejemplo n.º 1
0
 private Analyzer getLuceneAnalyzer() throws ProviderException {
   try {
     Class clazz = ClassUtil.findClass("", m_analyzerClass);
     Constructor constructor = clazz.getConstructor(Version.LUCENE_36.getClass());
     Analyzer analyzer = (Analyzer) constructor.newInstance(Version.LUCENE_36);
     return analyzer;
   } catch (Exception e) {
     String msg = "Could not get LuceneAnalyzer class " + m_analyzerClass + ", reason: ";
     log.error(msg, e);
     throw new ProviderException(msg + e);
   }
 }
Ejemplo n.º 2
0
 /**
  * Called by WikiEngine to initialise this instance. Tries to use class given by the
  * PROP_PAGE_NAME_COMPARATOR property as the page name comparator. Uses a default comparator if
  * this property is not set or there is any problem loading the specified class.
  *
  * @param props this WikiEngine's properties.
  */
 @SuppressWarnings("unchecked")
 public void initialize(Properties props) {
   // Default is Java natural order
   m_comparator = JavaNaturalComparator.DEFAULT_JAVA_COMPARATOR;
   String className = props.getProperty(PROP_PAGE_NAME_COMPARATOR);
   if (className != null && className.length() > 0)
     try {
       m_comparator =
           (Comparator<String>)
               ClassUtil.findClass("org.apache.wiki.util.comparators", className).newInstance();
     } catch (Exception e) {
       log.error("Falling back to default \"natural\" comparator", e);
     }
 }
Ejemplo n.º 3
0
  // FIXME: Perhaps this should fail somehow.
  public AttachmentManager(WikiEngine engine, Properties props) {
    String classname;

    m_engine = engine;

    //
    //  If user wants to use a cache, then we'll use the CachingProvider.
    //
    boolean useCache = "true".equals(props.getProperty(PageManager.PROP_USECACHE));

    if (useCache) {
      classname = "org.apache.wiki.providers.CachingAttachmentProvider";
    } else {
      classname = props.getProperty(PROP_PROVIDER);
    }

    //
    //  If no class defined, then will just simply fail.
    //
    if (classname == null) {
      log.info("No attachment provider defined - disabling attachment support.");
      return;
    }

    //
    //  Create and initialize the provider.
    //
    try {
      Class<?> providerclass = ClassUtil.findClass("org.apache.wiki.providers", classname);

      m_provider = (WikiAttachmentProvider) providerclass.newInstance();

      m_provider.initialize(m_engine, props);
    } catch (ClassNotFoundException e) {
      log.error("Attachment provider class not found", e);
    } catch (InstantiationException e) {
      log.error("Attachment provider could not be created", e);
    } catch (IllegalAccessException e) {
      log.error("You may not access the attachment provider class", e);
    } catch (NoRequiredPropertyException e) {
      log.error("Attachment provider did not find a property that it needed: " + e.getMessage(), e);
      m_provider = null; // No, it did not work.
    } catch (IOException e) {
      log.error("Attachment provider reports IO error", e);
      m_provider = null;
    }
  }