use of com.enonic.xp.node.NodeVersionMetadata in project xp by enonic.
the class NodeVersionsQueryResultMapper method serialize.
private void serialize(final MapGenerator gen, final NodeVersionsMetadata nodeVersions) {
gen.array("hits");
for (NodeVersionMetadata nodeVersion : nodeVersions) {
gen.map();
new NodeVersionMapper(nodeVersion).serialize(gen);
gen.end();
}
gen.end();
}
use of com.enonic.xp.node.NodeVersionMetadata in project xp by enonic.
the class GetActiveVersionHandlerTest method testGetActiveVersionsHandler.
@Test
public void testGetActiveVersionsHandler() {
final NodeVersionMetadata nodeVersionMeta = NodeVersionMetadata.create().nodeId(NodeId.from("nodeId1")).nodeVersionId(NodeVersionId.from("nodeVersionId1")).nodePath(NodePath.ROOT).timestamp(Instant.ofEpochSecond(1000)).build();
final GetActiveNodeVersionsResult getActiveNodeVersionsResult = GetActiveNodeVersionsResult.create().add(Branch.from("master"), nodeVersionMeta).build();
final ArgumentCaptor<GetActiveNodeVersionsParams> getActiveNodeVersionsParamsCaptor = ArgumentCaptor.forClass(GetActiveNodeVersionsParams.class);
Mockito.when(nodeService.getActiveVersions(Mockito.any())).thenReturn(getActiveNodeVersionsResult);
runScript("/lib/xp/examples/node/getActiveVersion.js");
Mockito.verify(nodeService).getActiveVersions(getActiveNodeVersionsParamsCaptor.capture());
final GetActiveNodeVersionsParams params = getActiveNodeVersionsParamsCaptor.getValue();
assertEquals("nodeId", params.getNodeId().toString());
assertTrue(params.getBranches().contains(Branch.from("master")));
}
use of com.enonic.xp.node.NodeVersionMetadata in project xp by enonic.
the class GetActiveContentVersionsCommand method execute.
public GetActiveContentVersionsResult execute() {
this.nodeService.refresh(RefreshMode.STORAGE);
final NodeId nodeId = NodeId.from(contentId.toString());
final GetActiveNodeVersionsResult activeNodeVersions = this.nodeService.getActiveVersions(GetActiveNodeVersionsParams.create().nodeId(nodeId).branches(this.branches).build());
final ContentVersionFactory contentVersionFactory = new ContentVersionFactory(this.nodeService);
final GetActiveContentVersionsResult.Builder builder = GetActiveContentVersionsResult.create();
final ImmutableMap<Branch, NodeVersionMetadata> nodeVersionsMap = activeNodeVersions.getNodeVersions();
for (final Branch branch : nodeVersionsMap.keySet()) {
final NodeVersionMetadata nodeVersionMetadata = nodeVersionsMap.get(branch);
builder.add(ActiveContentVersionEntry.from(branch, contentVersionFactory.create(nodeVersionMetadata)));
}
return builder.build();
}
use of com.enonic.xp.node.NodeVersionMetadata in project xp by enonic.
the class RepoDumper method dumpVersions.
private void dumpVersions(final Collection<NodeId> dumpedNodes) {
writer.openVersionsMeta(repository.getId());
try {
for (NodeId nodeId : dumpedNodes) {
final VersionsDumpEntry.Builder builder = VersionsDumpEntry.create(nodeId);
final NodeVersionQueryResult versions = getVersions(nodeId);
for (final NodeVersionMetadata metaData : versions.getNodeVersionsMetadata()) {
doStoreVersion(builder, metaData, this.dumpResult);
this.dumpResult.addedVersion();
}
writer.writeVersionsEntry(builder.build());
}
} finally {
writer.closeMeta();
}
}
use of com.enonic.xp.node.NodeVersionMetadata in project xp by enonic.
the class RepoDumper method createDumpEntry.
private BranchDumpEntry createDumpEntry(final NodeId nodeId) {
final BranchDumpEntry.Builder builder = BranchDumpEntry.create().nodeId(nodeId);
final Node currentNode = this.nodeService.getById(nodeId);
final NodeVersionMetadata currentVersionMetaData = getActiveVersion(nodeId);
builder.meta(VersionMetaFactory.create(currentNode, currentVersionMetaData));
if (this.includeBinaries) {
builder.addBinaryReferences(currentNode.getAttachedBinaries().stream().map(AttachedBinary::getBlobKey).collect(Collectors.toSet()));
}
return builder.build();
}
Aggregations