Search in sources :

Example 1 with NodeVersionId

use of com.enonic.xp.node.NodeVersionId in project xp by enonic.

the class SetActiveVersionHandlerTest method testSetActiveVersionHandler.

@Test
public void testSetActiveVersionHandler() {
    final NodeVersionId nodeVersionId = NodeVersionId.from("90398ddd1");
    final ArgumentCaptor<NodeId> nodeIdCaptor = ArgumentCaptor.forClass(NodeId.class);
    final ArgumentCaptor<NodeVersionId> nodeVersionIdCaptor = ArgumentCaptor.forClass(NodeVersionId.class);
    Mockito.when(nodeService.setActiveVersion(Mockito.any(), Mockito.any())).thenReturn(nodeVersionId);
    runScript("/lib/xp/examples/node/setActiveVersion.js");
    Mockito.verify(nodeService).setActiveVersion(nodeIdCaptor.capture(), nodeVersionIdCaptor.capture());
    assertEquals("nodeId", nodeIdCaptor.getValue().toString());
    assertEquals(nodeVersionId, nodeVersionIdCaptor.getValue());
}
Also used : NodeVersionId(com.enonic.xp.node.NodeVersionId) NodeId(com.enonic.xp.node.NodeId) Test(org.junit.jupiter.api.Test)

Example 2 with NodeVersionId

use of com.enonic.xp.node.NodeVersionId in project xp by enonic.

the class GetContentByPathAndVersionIdCommand method execute.

public Content execute() {
    final NodePath nodePath = ContentNodeHelper.translateContentPathToNodePath(contentPath);
    final NodeVersionId nodeVersionId = NodeVersionId.from(contentVersionId.toString());
    try {
        final Node node = nodeService.getByPathAndVersionId(nodePath, nodeVersionId);
        final Content content = filter(translator.fromNode(node, true));
        if (content != null) {
            return content;
        }
        throw createContentNotFoundException();
    } catch (NodeNotFoundException e) {
        throw createContentNotFoundException();
    }
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeVersionId(com.enonic.xp.node.NodeVersionId) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) NodePath(com.enonic.xp.node.NodePath)

Example 3 with NodeVersionId

use of com.enonic.xp.node.NodeVersionId in project xp by enonic.

the class NodeStorageServiceImpl method store.

@Override
public Node store(final Node node, final InternalContext context) {
    final NodeVersionId nodeVersionId = new NodeVersionId();
    final NodeVersionKey nodeVersionKey = nodeVersionService.store(NodeVersion.from(node), context);
    storeVersionMetadata(node, nodeVersionId, nodeVersionKey, context);
    final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
    storeBranchMetadata(storeBranchMetadataParams);
    indexNode(node, nodeVersionId, context);
    return Node.create(node).nodeVersionId(nodeVersionId).build();
}
Also used : NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey)

Example 4 with NodeVersionId

use of com.enonic.xp.node.NodeVersionId in project xp by enonic.

the class NodeStorageServiceImpl method updateMetadata.

@Override
public Node updateMetadata(final Node node, final InternalContext context) {
    final NodeBranchEntry nodeBranchEntry = this.branchService.get(node.id(), context);
    if (nodeBranchEntry == null) {
        throw new NodeNotFoundException("Cannot find node with id: " + node.id() + " in branch " + context.getBranch());
    }
    final NodeVersionId nodeVersionId = nodeBranchEntry.getVersionId();
    final NodeVersionKey nodeVersionKey = nodeBranchEntry.getNodeVersionKey();
    final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
    storeBranchMetadata(storeBranchMetadataParams);
    indexNode(node, nodeVersionId, context);
    return Node.create(node).nodeVersionId(nodeVersionId).build();
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 5 with NodeVersionId

use of com.enonic.xp.node.NodeVersionId in project xp by enonic.

the class NodeStorageServiceImpl method load.

@Override
public Node load(final LoadNodeParams params, final InternalContext context) {
    final Node node = params.getNode();
    final NodeVersion nodeVersion = NodeVersion.create().id(node.id()).nodeType(node.getNodeType()).data(node.data()).indexConfigDocument(node.getIndexConfigDocument()).childOrder(node.getChildOrder()).manualOrderValue(node.getManualOrderValue()).permissions(node.getPermissions()).inheritPermissions(node.inheritsPermissions()).attachedBinaries(node.getAttachedBinaries()).build();
    final NodeVersionId nodeVersionId = node.getNodeVersionId();
    final NodeVersionKey nodeVersionKey = nodeVersionService.store(nodeVersion, context);
    final LoadVersionMetadataParams loadVersionMetadataParams = LoadVersionMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).nodeCommitId(params.getNodeCommitId()).context(context).build();
    loadVersionMetadata(loadVersionMetadataParams);
    final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
    storeBranchMetadata(storeBranchMetadataParams);
    indexNode(node, nodeVersionId, context);
    return Node.create(node).nodeVersionId(nodeVersionId).build();
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) Node(com.enonic.xp.node.Node)

Aggregations

NodeVersionId (com.enonic.xp.node.NodeVersionId)15 Node (com.enonic.xp.node.Node)10 NodeId (com.enonic.xp.node.NodeId)9 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)7 Test (org.junit.jupiter.api.Test)6 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)5 RoutableNodeVersionId (com.enonic.xp.node.RoutableNodeVersionId)5 InternalContext (com.enonic.xp.repo.impl.InternalContext)5 NodePath (com.enonic.xp.node.NodePath)4 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)3 NodeVersion (com.enonic.xp.node.NodeVersion)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3 Branch (com.enonic.xp.branch.Branch)2 BlobKey (com.enonic.xp.blob.BlobKey)1 BlobStore (com.enonic.xp.blob.BlobStore)1 Segment (com.enonic.xp.blob.Segment)1 SegmentLevel (com.enonic.xp.blob.SegmentLevel)1 Content (com.enonic.xp.content.Content)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1