use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.
the class ContentServiceImplTest_findIdsByParent method hasChildResolved.
@Test
public void hasChildResolved() throws Exception {
final Content parentContent = createContent(ContentPath.ROOT);
final Content content1 = createContent(parentContent.getPath());
createContent(content1.getPath());
this.nodeService.refresh(RefreshMode.SEARCH);
final FindContentByParentParams params = FindContentByParentParams.create().from(0).size(30).parentId(parentContent.getId()).build();
final FindContentIdsByParentResult result = contentService.findIdsByParent(params);
assertNotNull(result);
assertEquals(1, result.getTotalHits());
final Content content1Result = this.contentService.getById(result.getContentIds().first());
assertTrue(content1Result.hasChildren());
}
use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.
the class ReprocessRunnableTask method reprocessContent.
private void reprocessContent(final Content content, final boolean skipChildren, final List<ContentPath> updated, final List<String> errors, final ProgressReporter progressReporter) {
final Content reprocessedContent = this.contentService.reprocess(content.getId());
if (!reprocessedContent.equals(content)) {
updated.add(content.getPath());
}
progressReporter.progress(++current, total);
if (skipChildren) {
return;
}
int from = 0;
int resultCount;
do {
final FindContentByParentParams findParams = FindContentByParentParams.create().parentId(content.getId()).from(from).size(5).build();
final FindContentByParentResult results = this.contentService.findByParent(findParams);
for (Content child : results.getContents()) {
try {
reprocessContent(child, false, updated, errors, progressReporter);
} catch (Exception e) {
errors.add(String.format("Content '%s' - %s: %s", child.getPath().toString(), e.getClass().getCanonicalName(), e.getMessage()));
LOG.warn("Error reprocessing content [" + child.getPath() + "]", e);
}
}
resultCount = Math.toIntExact(results.getHits());
from = from + resultCount;
} while (resultCount > 0);
}
use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.
the class ContentResource method reprocessContent.
@Deprecated
private void reprocessContent(final Content content, final boolean skipChildren, final List<ContentPath> updated, final List<String> errors) {
final Content reprocessedContent = this.contentService.reprocess(content.getId());
if (!reprocessedContent.equals(content)) {
updated.add(content.getPath());
}
if (skipChildren) {
return;
}
int from = 0;
int resultCount;
do {
final FindContentByParentParams findParams = FindContentByParentParams.create().parentId(content.getId()).from(from).size(5).build();
final FindContentByParentResult results = this.contentService.findByParent(findParams);
for (Content child : results.getContents()) {
try {
reprocessContent(child, false, updated, errors);
} catch (Exception e) {
errors.add(String.format("Content '%s' - %s: %s", child.getPath().toString(), e.getClass().getCanonicalName(), e.getMessage()));
LOG.warn("Error reprocessing content [" + child.getPath() + "]", e);
}
}
resultCount = Math.toIntExact(results.getHits());
from = from + resultCount;
} while (resultCount > 0);
}
Aggregations