Package ch.entwine.weblounge.contentrepository.impl.index

Examples of ch.entwine.weblounge.contentrepository.impl.index.ContentRepositoryIndex


    FileUtils.deleteDirectory(idxRoot);

    ElasticSearchUtils.createIndexConfigurationAt(idxRoot);
    System.setProperty("weblounge.home", idxRoot.getAbsolutePath());
    TestUtils.startTesting();
    idx = new ContentRepositoryIndex(site, searchIdx);
  }
View Full Code Here


  /**
   * Test method for {@link ContentRepositoryIndex#ContentRepositoryIndex(Site, ch.entwine.weblounge.common.search.SearchIndex)}
   */
  @Test(expected = IllegalArgumentException.class)
  public void testConstructorWithNullSite() throws Exception {
    new ContentRepositoryIndex(null, searchIdx);
  }
View Full Code Here

  /**
   * Test method for {@link ContentRepositoryIndex#ContentRepositoryIndex(Site, ch.entwine.weblounge.common.search.SearchIndex)}
   */
  @Test(expected = IllegalArgumentException.class)
  public void testConstructorWithNullSearchIndex() throws Exception {
    new ContentRepositoryIndex(site, null);
  }
View Full Code Here

    boolean oldReadOnly = readOnly;
    readOnly = true;
    logger.info("Switching site '{}' to read only mode", site);

    ContentRepositoryIndex newIndex = null;

    // Clear previews directory
    logger.info("Removing cached preview images");
    File previewsDir = new File(PathUtils.concat(System.getProperty("java.io.tmpdir"), "sites", site.getIdentifier(), "images"));
    FileUtils.deleteQuietly(previewsDir);

    // Create the new index
    try {
      newIndex = new ContentRepositoryIndex(site, searchIndex);
      indexingOffsite = true;
      rebuildIndex(newIndex);
    } catch (IOException e) {
      indexingOffsite = false;
      throw new ContentRepositoryException("Error creating index " + site.getIdentifier(), e);
    } finally {
      try {
        if (newIndex != null)
          newIndex.close();
      } catch (IOException e) {
        throw new ContentRepositoryException("Error closing new index " + site.getIdentifier(), e);
      }
    }

    try {
      indexing = true;
      index.close();
      logger.info("Loading new index");
      index = new ContentRepositoryIndex(site, searchIndex);
    } catch (IOException e) {
      Throwable cause = e.getCause();
      if (cause == null)
        cause = e;
      throw new ContentRepositoryException("Error during reindex of '" + site.getIdentifier() + "'", cause);
View Full Code Here

  @Override
  protected ContentRepositoryIndex loadIndex() throws IOException,
      ContentRepositoryException {
    logger.debug("Trying to load site index");

    ContentRepositoryIndex idx = null;

    logger.debug("Loading site index '{}'", site.getIdentifier());

    // Add content if there is any
    idx = new ContentRepositoryIndex(site, searchIndex);

    // Create the idx if there is nothing in place so far
    if (idx.getResourceCount() <= 0) {
      logger.info("Index of '{}' is empty, triggering reindex", site.getIdentifier());
      buildIndex(idx);
    }

    // Make sure the version matches the implementation
    else if (idx.getIndexVersion() < SearchIndex.INDEX_VERSION) {
      logger.info("Index of '{}' needs to be updated, triggering reindex", site.getIdentifier());
      buildIndex(idx);
    } else if (idx.getIndexVersion() != SearchIndex.INDEX_VERSION) {
      logger.warn("Index '{}' needs to be downgraded, triggering reindex", site.getIdentifier());
      buildIndex(idx);
    }

    // Is there an existing idex?
    long resourceCount = idx.getResourceCount();
    long resourceVersionCount = idx.getRevisionCount();
    logger.info("Loaded site idx with {} resources and {} revisions", resourceCount, resourceVersionCount - resourceCount);

    return idx;
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.contentrepository.impl.index.ContentRepositoryIndex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.