Search in sources :

Example 81 with ContentId

use of com.enonic.xp.content.ContentId in project xp by enonic.

the class SyncContentServiceImplTest method testWorkflowInfo.

@Test
public void testWorkflowInfo() throws Exception {
    final Content source = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    syncCreated(source.getId());
    targetContext.runWith(() -> {
        contentService.update(new UpdateContentParams().contentId(source.getId()).editor(edit -> {
            edit.workflowInfo = WorkflowInfo.ready();
            edit.data = new PropertyTree();
        }));
    });
    syncContentService.resetInheritance(ResetContentInheritParams.create().contentId(source.getId()).inherit(EnumSet.of(ContentInheritType.CONTENT)).projectName(targetProject.getName()).build());
    targetContext.runWith(() -> {
        final Content changed = contentService.getById(source.getId());
        assertTrue(changed.getInherit().contains(ContentInheritType.CONTENT));
        assertTrue(changed.getData().hasProperty("stringField"));
    });
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) ContentPath(com.enonic.xp.content.ContentPath) ProjectSyncParams(com.enonic.xp.content.ProjectSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) Test(org.junit.jupiter.api.Test) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) ContentId(com.enonic.xp.content.ContentId) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProjectName(com.enonic.xp.project.ProjectName) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EnumSet(java.util.EnumSet) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 82 with ContentId

use of com.enonic.xp.content.ContentId in project xp by enonic.

the class FragmentRenderer method getFragmentComponent.

private Component getFragmentComponent(final FragmentComponent component) {
    final ContentId contentId = component.getFragment();
    try {
        final Content fragmentContent = contentService.getById(contentId);
        if (!fragmentContent.hasPage() || !fragmentContent.getType().isFragment()) {
            return null;
        }
        final Page page = fragmentContent.getPage();
        return page.getFragment();
    } catch (ContentNotFoundException e) {
        return null;
    }
}
Also used : ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) Page(com.enonic.xp.page.Page)

Example 83 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