use of com.enonic.xp.content.ContentId in project xp by enonic.
the class GetNearestSiteCommandTest method get_nearest_site_parent_of_parent_is_site.
@Test
public void get_nearest_site_parent_of_parent_is_site() throws Exception {
final Node node = Node.create().id(NodeId.from("test")).name("myContent").parentPath(ContentConstants.CONTENT_ROOT_PATH).build();
final ContentId contentId = ContentId.from("aaa");
final Content content = Content.create().id(contentId).name("name").parentPath(ContentPath.from("/aaa")).build();
final Content parent = Content.create().id(ContentId.from("bbb")).name("renome").parentPath(ContentPath.from("/bbb")).build();
final Site parentOfParent = Site.create().path("/mycontent").id(ContentId.from("ccc")).build();
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(node);
Mockito.when(this.nodeService.getByPath(Mockito.isA(NodePath.class))).thenReturn(node);
Mockito.when(this.translator.fromNode(node, true)).thenReturn(content, parent, parentOfParent);
assertEquals(parentOfParent, createCommand(contentId).execute());
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class TestDataFixtures method createImageComponent.
private static ImageComponent createImageComponent(final String imageId, final String imageDisplayName, final PropertyTree imageConfig) {
final ContentId id = ContentId.from(imageId);
final Content imageContent = Content.create().name("someimage").displayName(imageDisplayName).parentPath(ContentPath.ROOT).build();
return ImageComponent.create().image(id).config(imageConfig).build();
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ControllerHandlerWorker method contentExists.
private boolean contentExists(final String contentSelector) {
final ContentId contentId = ContentId.from(contentSelector.substring(1));
final ContentPath contentPath = ContentPath.from(contentSelector).asAbsolute();
return this.contentService.contentExists(contentId) || (!ContentPath.ROOT.equals(contentPath) && this.contentService.contentExists(contentPath));
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ControllerHandlerWorker method getContentOrNull.
protected final Content getContentOrNull(final String contentSelector) {
if (request.getMode() == RenderMode.EDIT) {
final ContentId contentId = ContentId.from(contentSelector.substring(1));
final Content contentById = getContentById(contentId);
if (contentById != null) {
return contentById;
}
}
final ContentPath contentPath = ContentPath.from(contentSelector).asAbsolute();
return getContentByPath(contentPath);
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ImageUrlBuilder method buildUrl.
@Override
protected void buildUrl(final StringBuilder url, final Multimap<String, String> params) {
super.buildUrl(url, params);
final ContentId id = resolveId();
final Media media = resolveMedia(id);
final String hash = resolveHash(media);
final String name = resolveName(media);
final String scale = resolveScale();
appendPart(url, id + ":" + hash);
appendPart(url, scale);
appendPart(url, name);
addParamIfNeeded(params, "quality", this.params.getQuality());
addParamIfNeeded(params, "background", this.params.getBackground());
addParamIfNeeded(params, "filter", this.params.getFilter());
}
Aggregations