Search in sources :

Example 6 with NodeVersion

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

the class NodeStorageServiceImplTest method testGetNode.

@Test
public void testGetNode() {
    final NodePath nodePath = NodePath.create("path").build();
    final NodeVersionMetadata nodeVersionMetadata = NodeVersionMetadata.create().nodeVersionId(nodeVersionId).nodeVersionKey(versionKey).nodePath(nodePath).build();
    final NodeVersion nodeVersion = NodeVersion.create().permissions(AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()).build()).build();
    when(versionService.getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class))).thenReturn(nodeVersionMetadata);
    when(nodeVersionService.get(any(NodeVersionKey.class), any(InternalContext.class))).thenReturn(nodeVersion);
    final Node result = instance.getNode(nodeId, nodeVersionId, context);
    assertNotNull(result);
    verify(versionService, times(1)).getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class));
    verify(nodeVersionService, times(1)).get(any(NodeVersionKey.class), any(InternalContext.class));
    verifyNoMoreInteractions(versionService, nodeVersionService);
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) NodeVersionId(com.enonic.xp.node.NodeVersionId) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 7 with NodeVersion

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

the class HtmlAreaNodeDataUpgraderTest method testUpgrade.

@Test
public void testUpgrade() throws IOException {
    final PropertyTree data = new PropertyTree();
    data.setString("data.htmlarea", readTestResource("htmlarea-source.xml"));
    final NodeVersion nodeVersion = NodeVersion.create().nodeType(ContentConstants.CONTENT_NODE_COLLECTION).data(data).build();
    final PatternIndexConfigDocument indexConfigDocument = createIndexConfigDocument();
    final DumpUpgradeStepResult.Builder result = DumpUpgradeStepResult.create();
    final boolean upgraded = htmlAreaNodeDataUpgrader.upgrade(nodeVersion, indexConfigDocument, result);
    assertTrue(upgraded);
    final PropertyTree upgradedData = nodeVersion.getData();
    final Collection<Reference> upgradedProcessedReferences = (Collection<Reference>) upgradedData.getReferences("processedReferences");
    assertEquals(5, upgradedProcessedReferences.size());
    final List<Reference> expectedReferences = Arrays.stream(new String[] { "e1f57280-d672-4cd8-b674-98e26e5b69ae", "be1ca151-cf61-4a54-9ea4-c8d01ce83e0e", "81b1e3cd-575f-4565-a618-3c85d56224f6", "43d54e23-d8ce-4058-befb-777abe1a0d9f", "32169e70-49e1-444c-a6ac-d38f22438134" }).map(Reference::from).collect(Collectors.toList());
    assertTrue(expectedReferences.containsAll(upgradedProcessedReferences));
    assertEquals(readTestResource("htmlarea-expected.xml"), upgradedData.getString("data.htmlarea"));
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) DumpUpgradeStepResult(com.enonic.xp.dump.DumpUpgradeStepResult) Reference(com.enonic.xp.util.Reference) PropertyTree(com.enonic.xp.data.PropertyTree) Collection(java.util.Collection) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 8 with NodeVersion

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

the class FlattenedPageDumpUpgrader method upgradeBlobRecord.

private void upgradeBlobRecord(final DumpBlobRecord dumpBlobRecord, final FlattenedPageDataUpgrader dataUpgrader) {
    final NodeVersion nodeVersion = getNodeVersion(dumpBlobRecord);
    final boolean upgraded = dataUpgrader.upgrade(nodeVersion.getData());
    if (upgraded) {
        writeNodeVersion(nodeVersion, dumpBlobRecord);
    }
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion)

Example 9 with NodeVersion

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

the class ReindexExecutor method doReindexBranchNew.

private void doReindexBranchNew(final RepositoryId repositoryId, final ReindexResult.Builder builder, final Branch branch) {
    final NodeBranchEntries nodeBranchEntries = GetBranchDataCommand.create().branch(branch).repositoryId(repositoryId).nodeSearchService(this.nodeSearchService).build().execute();
    if (listener != null) {
        listener.branch(repositoryId, branch, nodeBranchEntries.getSize());
    }
    for (final NodeBranchEntry nodeBranchEntry : nodeBranchEntries) {
        final InternalContext context = InternalContext.create(ContextAccessor.current()).repositoryId(repositoryId).branch(branch).build();
        final NodeVersion nodeVersion = this.nodeVersionService.get(nodeBranchEntry.getNodeVersionKey(), context);
        final Node node = NodeFactory.create(nodeVersion, nodeBranchEntry);
        this.indexDataService.store(node, context);
        builder.add(node.id());
        if (listener != null) {
            listener.branchEntry(nodeBranchEntry);
        }
    }
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeVersion(com.enonic.xp.node.NodeVersion) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 10 with NodeVersion

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

the class NodeVersionServiceImplTest method getVersion.

@Test
public void getVersion() throws Exception {
    final CreateNodeParams createNodeParams = CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).build();
    final Node createdNode = createNode(createNodeParams);
    final NodeVersion nodeVersion = nodeDao.get(getNodeVersionKey(createdNode), createInternalContext());
    assertEquals(createdNode.id(), nodeVersion.getId());
    assertEquals(createdNode.data(), nodeVersion.getData());
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) Node(com.enonic.xp.node.Node) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

NodeVersion (com.enonic.xp.node.NodeVersion)23 Node (com.enonic.xp.node.Node)9 Test (org.junit.jupiter.api.Test)8 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)6 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)6 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)4 NodeId (com.enonic.xp.node.NodeId)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 InternalContext (com.enonic.xp.repo.impl.InternalContext)4 PropertyTree (com.enonic.xp.data.PropertyTree)3 NodePath (com.enonic.xp.node.NodePath)3 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)3 BlobKey (com.enonic.xp.blob.BlobKey)2 BlobRecord (com.enonic.xp.blob.BlobRecord)2 DumpUpgradeStepResult (com.enonic.xp.dump.DumpUpgradeStepResult)2 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)2 MemoryBlobRecord (com.enonic.xp.internal.blobstore.MemoryBlobRecord)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2