Exemplo n.º 1
0
  /**
   * Performs velocity and plink rendering on a given string.
   *
   * @param source
   */
  public String render(String source) throws CRException {
    // replace plinks (if configured to do so)
    if (this.doPlinks && this.pr != null) {
      source = PortalConnectorHelper.replacePLinks(source, this.pr);
    }

    if (this.doVelocity) {

      // Initialize Velocity Context
      ITemplateManager myTemplateManager = conf.getTemplateManager();

      source = myTemplateManager.render("attribute", source);
    }
    return source;
  }
  /**
   * Create a new Instance of LuceneSingleIndexLocation. This is the Default IndexLocation for
   * Lucene.
   *
   * @param config configuration
   */
  public LuceneSingleIndexLocation(final CRConfig config) {
    super(config);
    indexLocation = getFirstIndexLocation(config);
    dir = createDirectory(indexLocation, config);
    // Create index accessor
    IndexAccessorFactory iAFactory = IndexAccessorFactory.getInstance();
    if (!iAFactory.hasAccessor(dir)) {
      try {
        iAFactory.createAccessor(dir, getConfiguredAnalyzer());
      } catch (IOException ex) {
        log.fatal("COULD NOT CREATE INDEX ACCESSOR" + ex.getMessage());
      }
    } else {
      log.debug("Accessor already present.");
    }

    // check if facets are activated and create a TaxonomyAccessor if necessary
    useFacets = config.getBoolean(FACET_FLAG_KEY, useFacets);
    if (useFacets) {
      log.debug("Facets are active");
      taxonomyLocation = retrieveTaxonomyLocation(config);
      taxonomyDir = createDirectory(taxonomyLocation, config);
      TaxonomyAccessorFactory taFactory = TaxonomyAccessorFactory.getInstance();
      if (!taFactory.hasAccessor(taxonomyDir)) {
        try {
          taFactory.createAccessor(config, taxonomyDir);
        } catch (IOException e) {
          log.fatal("COULD NOT CREATE TAXONOMY ACCESSOR" + e.getMessage());
        }
      } else {
        log.debug("TaxonomyAccessor already present.");
      }
    } else {
      log.debug("Facets are not active");
    }
  }
 /**
  * retrieves the Taxonomy location from the config
  *
  * @param config
  * @return
  */
 protected static String retrieveTaxonomyLocation(CRConfig config) {
   String path = config.getString(FACET_CONFIG_KEY.concat(".").concat(FACET_CONFIG_PATH_KEY));
   return path;
 }