Package ch.entwine.weblounge.common.content

Examples of ch.entwine.weblounge.common.content.SearchResult


      throw new WebApplicationException(e);
    }

    // Return the result
    try {
      SearchResult result = repository.find(query);
      return Response.ok(result.toXml()).build();
    } catch (ContentRepositoryException e) {
      logger.error("Error trying to access the content repository", e);
      throw new WebApplicationException(e);
    }
View Full Code Here


    q.withVersion(Resource.LIVE);
    q.withTypes(Page.TYPE);
    q.withPathPrefix(page.getURI().getPath());

    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>");
    for (SearchResultItem item : result.getItems()) {
      if (pageId.equals(item.getId()))
        continue;
      String headerXml = ((PageSearchResultItemImpl) item).getPageHeaderXml();
      buf.append(headerXml);
    }
View Full Code Here

    q.withTypes(Page.TYPE);
    q.withVersion(Resource.LIVE);
    q.withProperty("resourceid", pageId);

    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>");
    for (SearchResultItem item : result.getItems()) {
      String headerXml = ((PageSearchResultItemImpl) item).getPageHeaderXml();
      buf.append(headerXml);
    }
    buf.append("</pages>");
View Full Code Here

      throws WebApplicationException {
    ContentRepository repository = getContentRepository(q.getSite(), false);
    if (repository == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    SearchResult result = null;
    Page pageByPath = null;
    try {
      if (q.getVersion() == Resource.WORK && q.getPath() != null) {
        ResourceURI uri = new PageURIImpl(q.getSite(), q.getPath(), q.getVersion());
        pageByPath = (Page) repository.get(uri);
        int count = pageByPath != null ? 1 : 0;
        result = new SearchResultImpl(q, count, count);
      } else {
        result = repository.find(q);
      }
    } catch (ContentRepositoryException e) {
      throw new WebApplicationException(e);
    }

    StringBuffer buf = new StringBuffer("<pages ");
    buf.append("hits=\"").append(result.getHitCount()).append("\" ");
    buf.append("offset=\"").append(result.getOffset()).append("\" ");
    if (q.getLimit() > 0)
      buf.append("limit=\"").append(result.getLimit()).append("\" ");
    buf.append("page=\"").append(result.getPage()).append("\" ");
    buf.append("pagesize=\"").append(result.getPageSize()).append("\"");
    buf.append(">");
    if (pageByPath != null) {
      String xml = pageByPath.toXml();
      if (!details) {
        xml = xml.replaceAll("<body>.*</body>", "");
        xml = xml.replaceAll("<body/>", "");
      }
      buf.append(xml);
    } else {
      for (SearchResultItem item : result.getItems()) {
        String xml = null;
        if (details)
          xml = ((PageSearchResultItemImpl) item).getResourceXml();
        else
          xml = ((PageSearchResultItemImpl) item).getPageHeaderXml();
View Full Code Here

      uri.setIdentifier(index.getIdentifier(uri));
    }

    // Load the resource
    SearchQuery q = new SearchQueryImpl(site).withVersion(uri.getVersion()).withIdentifier(uri.getIdentifier());
    SearchResult result = searchIndex.getByQuery(q);

    if (result.getDocumentCount() > 0) {
      ResourceSearchResultItem searchResultItem = (ResourceSearchResultItem) result.getItems()[0];
      InputStream is = null;
      try {
        ResourceSerializer<?, ?> serializer = getSerializerByType(uri.getType());
        if (serializer == null) {
          logger.warn("No resource serializer for type '{}' found", uri.getType());
View Full Code Here

    // Also move children?
    if (moveChildren) {
      SearchQuery q = new SearchQueryImpl(site).withPreferredVersion(Resource.LIVE);
      q.withPathPrefix(originalPathPrefix);

      SearchResult result = searchIndex.getByQuery(q);
      if (result.getDocumentCount() == 0) {
        logger.warn("Trying to move non existing resource {}", uri);
        return;
      }

      // We need to check the prefix again, since the search query will also
      // match parts of the originalPathPrefix
      for (SearchResultItem searchResult : result.getItems()) {
        if (!(searchResult instanceof ResourceSearchResultItem))
          continue;
        ResourceSearchResultItem rsri = (ResourceSearchResultItem) searchResult;
        String resourcePath = rsri.getResourceURI().getPath();
View Full Code Here

    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>");
    for (SearchResultItem item : result.getItems()) {
      if (resourceId.equals(item.getId()))
        continue;
      String headerXml = ((PageSearchResultItemImpl) item).getPageHeaderXml();
      buf.append(headerXml);
    }
View Full Code Here

  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();
    }

    StringBuffer buf = new StringBuffer("<files ");
    buf.append("hits=\"").append(result.getHitCount()).append("\" ");
    buf.append("offset=\"").append(result.getOffset()).append("\" ");
    if (q.getLimit() > 0)
      buf.append("limit=\"").append(result.getLimit()).append("\" ");
    buf.append("page=\"").append(result.getPage()).append("\" ");
    buf.append("pagesize=\"").append(result.getPageSize()).append("\"");
    buf.append(">");
    for (SearchResultItem item : result.getItems()) {
      String xml = ((ResourceSearchResultItem) item).getResourceXml();

      // TODO: Remove this hack once the importer is fixed
      xml = xml.replace("292278994-08-17T07:12:55Z", "2010-08-17T07:12:55Z");
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.SearchResult

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.