Package ch.entwine.weblounge.common.content

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


   */
  public long[] getRevisions(ResourceURI uri) throws ContentRepositoryException {
    String id = getIdentifier(uri);
    if (id == null)
      return new long[] {};
    SearchQuery q = new SearchQueryImpl(site).withIdentifier(id).withField(VERSION);
    SearchResultItem[] items = searchIdx.getByQuery(q).getItems();
    long[] versions = new long[items.length];
    for (int i = 0; i < items.length; i++) {
      versions[i] = (Long) ((ResourceSearchResultItem) items[i]).getMetadataByKey(VERSION).getValue();
    }
View Full Code Here


    String path = StringUtils.trimToNull(uri.getPath());
    if (path == null)
      throw new IllegalArgumentException("ResourceURI must contain a path");

    // Load the identifier from the index
    SearchQuery q = new SearchQueryImpl(site).withPath(path);
    if (uri.getType() != null)
      q.withTypes(uri.getType());
    SearchResultItem[] items = searchIdx.getByQuery(q).getItems();
    if (items.length == 0) {
      logger.debug("Attempt to locate id for non-existing path {}", path);
      return null;
    }
View Full Code Here

    String id = uri.getIdentifier();
    if (id == null)
      throw new IllegalArgumentException("ResourceURI must contain an identifier");

    // Load the path from the index
    SearchQuery q = new SearchQueryImpl(site).withIdentifier(id);
    if (uri.getType() != null)
      q.withTypes(uri.getType());
    SearchResultItem[] items = searchIdx.getByQuery(q).getItems();
    if (items.length == 0) {
      logger.debug("Attempt to locate path for non existing resource '{}'", id);
      return null;
    }
View Full Code Here

    if (uri.getType() != null)
      return uri.getType();

    String id = uri.getIdentifier();
    String path = uri.getPath();
    SearchQuery q = null;

    if (id != null)
      q = new SearchQueryImpl(site).withIdentifier(id).withLimit(1);
    else if (path != null)
      q = new SearchQueryImpl(site).withPath(path).withLimit(1);
View Full Code Here

   */
  public boolean exists(ResourceURI uri) throws ContentRepositoryException {
    String id = getIdentifier(uri);
    if (id == null)
      return false;
    SearchQuery q = new SearchQueryImpl(site).withIdentifier(id).withVersion(uri.getVersion()).withField(RESOURCE_ID);
    if (uri.getType() != null)
      q.withTypes(uri.getType());
    return searchIdx.getByQuery(q).getDocumentCount() > 0;
  }
View Full Code Here

  public boolean existsInAnyVersion(ResourceURI uri)
      throws ContentRepositoryException {
    String id = getIdentifier(uri);
    if (id == null)
      return false;
    SearchQuery q = new SearchQueryImpl(site).withIdentifier(id).withLimit(1).withField(RESOURCE_ID);
    if (uri.getType() != null)
      q.withTypes(uri.getType());
    return searchIdx.getByQuery(q).getDocumentCount() > 0;
  }
View Full Code Here

    if (repository == null) {
      return Response.status(Status.SERVICE_UNAVAILABLE).build();
    }

    // Create the search expression and the query
    SearchQuery query = new SearchQueryImpl(site);
    try {
      query.withFulltext(true, URLDecoder.decode(terms, "utf-8"));
      query.withVersion(Resource.LIVE);
      query.withOffset(offset);
      query.withLimit(limit);
    } catch (UnsupportedEncodingException e) {
      throw new WebApplicationException(e);
    }

    // Return the result
View Full Code Here

    if (page == null) {
      return Response.status(Status.NOT_FOUND).build();
    }

    Site site = getSite(request);
    SearchQuery q = new SearchQueryImpl(site);
    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);
View Full Code Here

    // Check the parameters
    if (pageId == null)
      return Response.status(Status.BAD_REQUEST).build();

    Site site = getSite(request);
    SearchQuery q = new SearchQueryImpl(site);
    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);
View Full Code Here

    if (uri.getIdentifier() == null && StringUtils.isNotBlank(uri.getPath())) {
      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;
View Full Code Here

TOP

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

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.