Search in sources :

Example 31 with ContentId

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

the class RestoreContentHandler method executeRestore.

private List<String> executeRestore() {
    final ContentId sourceId;
    final ContentPath sourcePath;
    if (this.content.startsWith("/")) {
        // source is path
        sourcePath = ContentPath.from(this.content);
        final Content sourceContent = contentService.getByPath(sourcePath);
        sourceId = sourceContent.getId();
    } else {
        // source is key
        sourceId = ContentId.from(this.content);
    }
    final ContentPath pathToRestore = nullToEmpty(path).isBlank() ? null : ContentPath.from(path);
    return restore(sourceId, pathToRestore);
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentPath(com.enonic.xp.content.ContentPath)

Example 32 with ContentId

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

the class HighlightMapper method serializeHighlight.

private static void serializeHighlight(final MapGenerator gen, final ImmutableMap<ContentId, HighlightedProperties> value) {
    for (ContentId id : value.keySet()) {
        gen.map(id.toString());
        value.get(id).forEach(highlightedField -> {
            gen.array(highlightedField.getName());
            highlightedField.getFragments().forEach(gen::value);
            gen.end();
        });
        gen.end();
    }
}
Also used : ContentId(com.enonic.xp.content.ContentId)

Example 33 with ContentId

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

the class GetAttachmentStreamHandlerTest method getById_notFound.

@Test
public void getById_notFound() throws Exception {
    final ContentId id = ContentId.from("123456");
    Mockito.when(this.contentService.getById(id)).thenThrow(new ContentNotFoundException(id, null));
    runFunction("/test/GetAttachmentStreamHandlerTest.js", "getAttachmentStreamById_notFound");
}
Also used : ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) ContentId(com.enonic.xp.content.ContentId) Test(org.junit.jupiter.api.Test)

Example 34 with ContentId

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

the class GetAttachmentsHandlerTest method getById_notFound.

@Test
public void getById_notFound() throws Exception {
    final ContentId id = ContentId.from("123456");
    Mockito.when(this.contentService.getById(id)).thenThrow(new ContentNotFoundException(id, null));
    runFunction("/test/GetAttachmentsHandlerTest.js", "getById_notFound");
}
Also used : ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) ContentId(com.enonic.xp.content.ContentId) Test(org.junit.jupiter.api.Test)

Example 35 with ContentId

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

the class PublishContentResultMapper method serializeContentIds.

private void serializeContentIds(final MapGenerator gen, final String name, final ContentIds contents) {
    gen.array(name);
    for (ContentId id : contents) {
        gen.value(id.toString());
    }
    gen.end();
}
Also used : 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