Search in sources :

Example 6 with NodeBranchEntry

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

the class BranchServiceImplTest method path_fetched_from_cache_after_stored.

@Test
public void path_fetched_from_cache_after_stored() throws Exception {
    final InternalContext context = InternalContext.create().branch(Branch.from("myBranch")).repositoryId(RepositoryId.from("my-repo")).build();
    final NodePath path = NodePath.create(NodePath.ROOT, "fisk").build();
    Mockito.when(this.storageDao.store(Mockito.isA(StoreRequest.class))).thenReturn("123_myBranch");
    this.branchService.store(NodeBranchEntry.create().nodeId(NodeId.from("123")).nodePath(path).nodeState(NodeState.DEFAULT).nodeVersionId(NodeVersionId.from("nodeVersionId")).nodeVersionKey(NodeVersionKey.from("nodeBlobKey", "indexConfigBlobKey", "accessControlBlobKey")).timestamp(Instant.now()).build(), context);
    Mockito.when(this.storageDao.getById(Mockito.isA(GetByIdRequest.class))).thenReturn(GetResult.create().id("123_myBranch").resultFieldValues(ReturnValues.create().add(BranchIndexPath.PATH.getPath(), "/fisk").add(BranchIndexPath.STATE.getPath(), "default").add(BranchIndexPath.VERSION_ID.getPath(), "nodeVersionId").add(BranchIndexPath.NODE_BLOB_KEY.getPath(), "nodeBlobKey").add(BranchIndexPath.INDEX_CONFIG_BLOB_KEY.getPath(), "indexConfigBlobKey").add(BranchIndexPath.ACCESS_CONTROL_BLOB_KEY.getPath(), "accessControlBlobKey").add(BranchIndexPath.NODE_ID.getPath(), "123").add(BranchIndexPath.TIMESTAMP.getPath(), Instant.now().toString()).build()).build());
    Mockito.when(this.searchDao.search(Mockito.isA(SearchRequest.class))).thenReturn(SearchResult.create().build());
    final NodeBranchEntry fetchEntry = this.branchService.get(path, context);
    assertNotNull(fetchEntry);
}
Also used : SearchRequest(com.enonic.xp.repo.impl.search.SearchRequest) InternalContext(com.enonic.xp.repo.impl.InternalContext) StoreRequest(com.enonic.xp.repo.impl.storage.StoreRequest) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 7 with NodeBranchEntry

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

the class ProjectServiceImplTest method create.

@Test
void create() {
    final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
    final Project project = doCreateProjectAsAdmin(ProjectName.from(projectRepoId));
    assertNotNull(project);
    assertEquals("test-project", project.getName().toString());
    final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
    assertNotNull(nodeBranchEntry);
    adminContext().runWith(() -> {
        final Repository pro = repositoryService.get(projectRepoId);
        assertNotNull(pro);
    });
}
Also used : Project(com.enonic.xp.project.Project) Repository(com.enonic.xp.repository.Repository) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 8 with NodeBranchEntry

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

the class NodeEventsTest method testPushed.

@Test
public void testPushed() {
    final Node pushed1 = createNode("pushed1", NodePath.create("/mynode1/pushed1").build(), "id1");
    final Node pushed2 = createNode("pushed2", NodePath.create("/mynode1/pushed2").build(), "id2");
    final Node pushed3 = createNode("pushed3Renamed", NodePath.create("/mynode1/pushed3").build(), "id3");
    final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(pushed1.id()).nodePath(pushed1.path()).nodeState(NodeState.DEFAULT).nodeVersionId(pushed1.getNodeVersionId()).build();
    final NodeBranchEntry nodeBranchEntry2 = NodeBranchEntry.create().nodeId(pushed2.id()).nodePath(pushed2.path()).nodeState(NodeState.DEFAULT).nodeVersionId(pushed2.getNodeVersionId()).build();
    final NodeBranchEntry nodeBranchEntry3 = NodeBranchEntry.create().nodeId(pushed3.id()).nodePath(pushed3.path()).nodeState(NodeState.DEFAULT).nodeVersionId(pushed3.getNodeVersionId()).build();
    final PushNodeEntries pushNodeEntries = PushNodeEntries.create().targetRepo(ContentConstants.CONTENT_REPO_ID).targetBranch(ContentConstants.BRANCH_MASTER).add(PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry).build()).add(PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry2).build()).add(PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry3).currentTargetPath(NodePath.create("/mynode1/pushed3/pushed3").build()).build()).build();
    Event event = NodeEvents.pushed(pushNodeEntries);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertTrue(event.hasValue("nodes"));
    assertEquals(NodeEvents.NODE_PUSHED_EVENT, event.getType());
    assertEquals("[{id=id1, path=/mynode1/pushed1/pushed1, branch=master, repo=com.enonic.cms.default}" + ", {id=id2, path=/mynode1/pushed2/pushed2, branch=master, repo=com.enonic.cms.default}" + ", {id=id3, path=/mynode1/pushed3/pushed3Renamed, branch=master, repo=com.enonic.cms.default, currentTargetPath=/mynode1/pushed3/pushed3}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) PushNodeEntries(com.enonic.xp.node.PushNodeEntries) Test(org.junit.jupiter.api.Test)

Example 9 with NodeBranchEntry

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

the class NodeStorageServiceImpl method get.

@Override
public Node get(final NodeId nodeId, final NodeVersionId nodeVersionId, final InternalContext context) {
    final NodeVersionMetadata nodeVersionMetadata = versionService.getVersion(nodeId, nodeVersionId, context);
    if (nodeVersionMetadata == null) {
        return null;
    }
    final NodeVersion nodeVersion = nodeVersionService.get(nodeVersionMetadata.getNodeVersionKey(), context);
    if (nodeVersion == null) {
        return null;
    }
    final NodeBranchEntry nodeBranchEntry = branchService.get(nodeVersionMetadata.getNodeId(), context);
    if (nodeBranchEntry == null) {
        return null;
    }
    return constructNode(nodeBranchEntry, nodeVersion);
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 10 with NodeBranchEntry

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

the class NodeStorageServiceImpl method push.

@Override
public void push(final Node node, final Branch target, final InternalContext context) {
    final NodeBranchEntry entry = this.branchService.get(node.id(), context);
    this.branchService.store(entry, InternalContext.create(context).branch(target).build());
    this.indexDataService.push(IndexPushNodeParams.create().nodeIds(NodeIds.from(node.id())).targetBranch(target).targetRepo(context.getRepositoryId()).build(), context);
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Aggregations

NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)25 InternalContext (com.enonic.xp.repo.impl.InternalContext)9 Test (org.junit.jupiter.api.Test)8 Node (com.enonic.xp.node.Node)7 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)6 NodeId (com.enonic.xp.node.NodeId)5 NodePath (com.enonic.xp.node.NodePath)5 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)4 NodeVersion (com.enonic.xp.node.NodeVersion)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 PushNodeEntries (com.enonic.xp.node.PushNodeEntries)4 RoutableNodeVersionId (com.enonic.xp.node.RoutableNodeVersionId)4 Event (com.enonic.xp.event.Event)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3 PushNodeEntry (com.enonic.xp.node.PushNodeEntry)3 Branch (com.enonic.xp.branch.Branch)2 Context (com.enonic.xp.context.Context)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeComparison (com.enonic.xp.node.NodeComparison)2 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)2