Search in sources :

Example 1 with IQueryRestriction

use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.

the class ArticleLuceneQueryBuilder method getSubsSpaceRestriction.

QueryRestrictionGroup getSubsSpaceRestriction(ArticleLoadParameter param, SpaceReference spaceRef) throws XWikiException {
    QueryRestrictionGroup subsSpaceGrp = null;
    boolean hasEditRights = rightsAccess.hasAccessLevel(spaceRef, EAccessLevel.EDIT);
    IQueryRestriction dateRestr = getDateRestrictions(param.getDateModes(), param.getExecutionDate(), hasEditRights);
    IQueryRestriction artSubsRestr = getArticleSubsRestrictions(param.getSubscriptionModes(), param.getBlogDocRef(), hasEditRights);
    if ((artSubsRestr != null) && (dateRestr != null)) {
        subsSpaceGrp = searchService.createRestrictionGroup(Type.AND);
        subsSpaceGrp.add(searchService.createSpaceRestriction(spaceRef));
        subsSpaceGrp.add(dateRestr);
        subsSpaceGrp.add(artSubsRestr);
    } else {
        LOGGER.debug("no date restriction '" + dateRestr + "' or article subs " + "restriction '" + artSubsRestr + "' for space '" + spaceRef + "' with edit righs '" + hasEditRights + "'");
    }
    LOGGER.trace("got space restriction '" + subsSpaceGrp + "' for space: " + spaceRef);
    return subsSpaceGrp;
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup)

Example 2 with IQueryRestriction

use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.

the class ArticleLuceneQueryBuilder method getBlogRestriction.

IQueryRestriction getBlogRestriction(ArticleLoadParameter param) throws XWikiException {
    QueryRestrictionGroup restr = null;
    SpaceReference blogSpaceRef = blogService.getBlogSpaceRef(param.getBlogDocRef());
    if (param.isWithBlogArticles() && rightsAccess.hasAccessLevel(blogSpaceRef, EAccessLevel.VIEW)) {
        IQueryRestriction dateRestr = getDateRestrictions(param.getDateModes(), param.getExecutionDate(), rightsAccess.hasAccessLevel(blogSpaceRef, EAccessLevel.EDIT));
        if (dateRestr != null) {
            restr = searchService.createRestrictionGroup(Type.AND);
            restr.add(searchService.createSpaceRestriction(blogSpaceRef));
            restr.add(dateRestr);
        }
    }
    LOGGER.trace("got blog restriction " + restr + "' for '" + param + "'");
    return restr;
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup)

Example 3 with IQueryRestriction

use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_noEdit_future.

@Test
public void testGetBlogRestriction_noEdit_future() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setDateModes(Arrays.asList(DateMode.FUTURE.name()));
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
    expectSpaceRightsCheck(spaceRef, true, false);
    replayDefault();
    IQueryRestriction ret = builder.getBlogRestriction(param);
    verifyDefault();
    assertNull(ret);
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 4 with IQueryRestriction

use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_noView.

@Test
public void testGetBlogRestriction_noView() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
    expectSpaceRightsCheck(spaceRef, false, null);
    replayDefault();
    IQueryRestriction ret = builder.getBlogRestriction(param);
    verifyDefault();
    assertNull(ret);
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 5 with IQueryRestriction

use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_withoutBlogArticles.

@Test
public void testGetBlogRestriction_withoutBlogArticles() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setWithBlogArticles(false);
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
    replayDefault();
    IQueryRestriction ret = builder.getBlogRestriction(param);
    verifyDefault();
    assertNull(ret);
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Aggregations

IQueryRestriction (com.celements.search.lucene.query.IQueryRestriction)13 Test (org.junit.Test)9 SpaceReference (org.xwiki.model.reference.SpaceReference)6 AbstractComponentTest (com.celements.common.test.AbstractComponentTest)4 QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)4 QueryRestriction (com.celements.search.lucene.query.QueryRestriction)1