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