Beispiel #1
0
 /**
  * set the value collection The logical collection name that is the target of the search operation
  * or an external collection with fully qualified path.
  *
  * @param collection value to set
  * @throws PageException
  */
 public void setCollection(String collection) throws PageException {
   String[] collNames =
       ListUtil.toStringArrayTrim(ListUtil.listToArrayRemoveEmpty(collection, ','));
   collections = new SearchCollection[collNames.length];
   SearchEngine se = pageContext.getConfig().getSearchEngine(pageContext);
   try {
     for (int i = 0; i < collections.length; i++) {
       collections[i] = se.getCollectionByName(collNames[i]);
     }
   } catch (SearchException e) {
     collections = null;
     throw Caster.toPageException(e);
   }
 }
Beispiel #2
0
  @Override
  public SearchEngine getSearchEngine(PageContext pc) throws PageException {
    if (searchEngine == null) {
      try {
        Object o = ClassUtil.loadInstance(getSearchEngineClassDefinition().getClazz());
        if (o instanceof SearchEngine) searchEngine = (SearchEngine) o;
        else
          throw new ApplicationException(
              "class ["
                  + o.getClass().getName()
                  + "] does not implement the interface SearchEngine");

        searchEngine.init(
            this,
            ConfigWebUtil.getFile(
                getConfigDir(),
                ConfigWebUtil.translateOldPath(getSearchEngineDirectory()),
                "search",
                getConfigDir(),
                FileUtil.TYPE_DIR,
                this));
      } catch (Exception e) {
        throw Caster.toPageException(e);
      }
    }
    return searchEngine;
  }