Package ch.entwine.weblounge.common.repository

Examples of ch.entwine.weblounge.common.repository.ContentRepository


    User user = securityService.getUser();
    if (!SecurityUtils.userHasRole(user, SystemRole.SITEADMIN))
      throw new WebApplicationException(Status.FORBIDDEN);

    Site site = getSite(request);
    ContentRepository repository = getContentRepository(site, false);
    if (repository == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    SearchQuery q = null;
    StringBuffer result = new StringBuffer();

    result.append("<index");
    result.append(" state=\"").append(repository.isIndexing() ? "indexing" : "normal").append("\"");
    result.append(" readonly=\"").append(repository.isReadOnly() ? "true" : "false").append("\"");
    result.append(">");

    try {
      result.append("<resources>").append(repository.getResourceCount()).append("</resources>");
      result.append("<revisions>").append(repository.getVersionCount() - repository.getResourceCount()).append("</revisions>");

      q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPreferredVersion(Resource.LIVE);
      result.append("<pages>").append(repository.find(q).getDocumentCount()).append("</pages>");
      q = new SearchQueryImpl(site).withTypes(FileResource.TYPE).withPreferredVersion(Resource.LIVE);
      result.append("<files>").append(repository.find(q).getDocumentCount()).append("</files>");
      q = new SearchQueryImpl(site).withTypes(ImageResource.TYPE).withPreferredVersion(Resource.LIVE);
      result.append("<images>").append(repository.find(q).getDocumentCount()).append("</images>");
      q = new SearchQueryImpl(site).withTypes(MovieResource.TYPE).withPreferredVersion(Resource.LIVE);
      result.append("<movies>").append(repository.find(q).getDocumentCount()).append("</movies>");
    } catch (ContentRepositoryException e) {
      throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }

    result.append("</index>");
View Full Code Here


    User user = securityService.getUser();
    if (!SecurityUtils.userHasRole(user, SystemRole.SITEADMIN))
      throw new WebApplicationException(Status.FORBIDDEN);

    Site site = getSite(request);
    ContentRepository repository = getContentRepository(site, true);
    if (repository == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    // Make sure this is a writable repository
    if (!(repository instanceof WritableContentRepository))
      throw new WebApplicationException(Status.PRECONDITION_FAILED);
    final WritableContentRepository writableRepository = (WritableContentRepository) repository;

    // Is the repository already being indexed?
    if (repository.isIndexing())
      throw new WebApplicationException(Status.CONFLICT);

    // Start indexing
    new Thread(new Runnable() {
      public void run() {
View Full Code Here

    SearchQuery q = new SearchQueryImpl(site);
    q.withVersion(Resource.LIVE);
    q.withTypes(Page.TYPE);
    q.withProperty("resourceid", resourceId);

    ContentRepository repository = getContentRepository(site, false);
    SearchResult result = null;
    try {
      result = repository.find(q);
    } catch (ContentRepositoryException e) {
      return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }

    StringBuffer buf = new StringBuffer("<pages>");
View Full Code Here

   * @throws WebApplicationException
   *           if the content repository is unavailable or if the content can't
   *           be loaded
   */
  private String loadResultSet(SearchQuery q) throws WebApplicationException {
    ContentRepository repository = getContentRepository(q.getSite(), false);
    if (repository == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    SearchResult result = null;
    try {
      result = repository.find(q);
    } catch (ContentRepositoryException e) {
      logger.warn(e.getMessage());
      throw new WebApplicationException();
    }

View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.repository.ContentRepository

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.