use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class PublishContentResultMapper method serializeFailedContent.
private void serializeFailedContent(final MapGenerator gen, final String name, final ContentIds contents) {
gen.array(name);
for (ContentId id : contents) {
gen.value(id.toString());
}
for (ContentPath path : this.contentNotFound) {
gen.value(path.toString());
}
gen.end();
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class GetContentHandlerTest method getByPath_notFound.
@Test
public void getByPath_notFound() throws Exception {
final ContentPath path = ContentPath.from("/a/b/mycontent");
Mockito.when(this.contentService.getByPath(path)).thenThrow(new ContentNotFoundException(path, null));
runFunction("/test/GetContentHandlerTest.js", "getByPath_notFound");
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ReprocessRunnableTask method run.
@Override
public void run(final TaskId id, final ProgressReporter progressReporter) {
final List<ContentPath> updated = new ArrayList<>();
final List<String> errors = new ArrayList<>();
final Content content = this.contentService.getByPath(params.getSourceBranchPath().getContentPath());
try {
if (!params.isSkipChildren()) {
String nodePath = CONTENT_ROOT_PATH.asAbsolute().toString();
final ContentPath contentPath = params.getSourceBranchPath().getContentPath();
if (!ContentPath.ROOT.equals(contentPath)) {
nodePath += content.getPath().asAbsolute().toString();
}
final ConstraintExpr pathExpr = CompareExpr.like(FieldExpr.from("_path"), ValueExpr.string(nodePath + "/*"));
final ContentQuery countChildren = ContentQuery.create().queryExpr(QueryExpr.from(pathExpr)).size(0).build();
total = (int) contentService.find(countChildren).getTotalHits() + 1;
}
reprocessContent(content, params.isSkipChildren(), updated, errors, progressReporter);
} catch (Exception e) {
errors.add(String.format("Content '%s' - %s: %s", content.getPath().toString(), e.getClass().getCanonicalName(), e.getMessage()));
LOG.warn("Error reprocessing content [" + content.getPath() + "]", e);
}
progressReporter.info(new ReprocessContentResultJson(ContentPaths.from(updated), errors).toString());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class MappingHandlerTest method setupContentAndSite.
private void setupContentAndSite(final ControllerMappingDescriptor mapping) {
final Content content = createPage("id", "site/somesite/content", "myapplication:ctype", true);
final Site site = createSite("id", "site", "myapplication:contenttypename");
final ContentPath path = ContentPath.from("site/somesite/content").asAbsolute();
when(this.contentService.getByPath(path)).thenReturn(content);
when(this.contentService.findNearestSiteByPath(eq(path))).thenReturn(site);
when(this.contentService.getById(content.getId())).thenReturn(content);
final ControllerMappingDescriptors mappings = ControllerMappingDescriptors.from(mapping);
final SiteDescriptor siteDescriptor = SiteDescriptor.create().mappingDescriptors(mappings).build();
when(this.siteService.getDescriptor(any(ApplicationKey.class))).thenReturn(siteDescriptor);
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ComponentHandlerTest method getSiteNotFound.
@Test
public void getSiteNotFound() {
setupContent();
this.request.setEndpointPath("/_/component/main-region/666");
final ContentPath path = ContentPath.from("/site/somepath/content");
Mockito.when(this.contentService.findNearestSiteByPath(path)).thenReturn(null);
this.request.setContentPath(path);
final WebException e = assertThrows(WebException.class, () -> this.handler.handle(this.request, PortalResponse.create().build(), null));
assertEquals(HttpStatus.NOT_FOUND, e.getStatus());
assertEquals("Site for [/site/somepath/content] not found", e.getMessage());
}
Aggregations