Search in sources :

Example 56 with ContentId

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());
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) ContentId(com.enonic.xp.content.ContentId) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 57 with ContentId

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();
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId)

Example 58 with ContentId

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));
}
Also used : ContentId(com.enonic.xp.content.ContentId) ContentPath(com.enonic.xp.content.ContentPath)

Example 59 with ContentId

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);
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentPath(com.enonic.xp.content.ContentPath)

Example 60 with ContentId

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());
}
Also used : Media(com.enonic.xp.content.Media) ContentId(com.enonic.xp.content.ContentId)

Aggregations

ContentId (com.enonic.xp.content.ContentId)83 Content (com.enonic.xp.content.Content)34 Test (org.junit.jupiter.api.Test)33 PropertyTree (com.enonic.xp.data.PropertyTree)16 ContentPath (com.enonic.xp.content.ContentPath)14 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)13 ContentIds (com.enonic.xp.content.ContentIds)11 PropertySet (com.enonic.xp.data.PropertySet)10 NodeId (com.enonic.xp.node.NodeId)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 ContentInheritType (com.enonic.xp.content.ContentInheritType)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)7 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)6 Context (com.enonic.xp.context.Context)6 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)5 Node (com.enonic.xp.node.Node)5 Branch (com.enonic.xp.branch.Branch)4 ContentConstants (com.enonic.xp.content.ContentConstants)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4