use of com.enonic.xp.content.FindContentByParentResult in project xp by enonic.
the class GetChildContentHandlerTest method testExample.
@Test
public void testExample() {
final Contents contents = TestDataFixtures.newContents(2);
final FindContentByParentResult findResult = FindContentByParentResult.create().hits(contents.getSize()).totalHits(20).contents(contents).build();
Mockito.when(this.contentService.findByParent(Mockito.isA(FindContentByParentParams.class))).thenReturn(findResult);
runScript("/lib/xp/examples/content/getChildren.js");
}
use of com.enonic.xp.content.FindContentByParentResult 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.FindContentByParentResult 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