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());
}
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();
}
}
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();
}
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();
}
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();
}
Aggregations