Search in sources :

Example 1 with NodeId

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

the class DiffBranchesHandler method execute.

@Override
public Object execute() {
    final NodeId nodeId = getNodeId(this.nodeKey);
    if (nodeId == null) {
        throw new NodeNotFoundException("Node with key [" + this.nodeKey + "] not found");
    }
    final ResolveSyncWorkResult result = this.nodeService.resolveSyncWork(SyncWorkResolverParams.create().includeChildren(includeChildren).nodeId(nodeId).branch(targetBranch).build());
    return new ResolveSyncWorkResultMapper(result);
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) ResolveSyncWorkResultMapper(com.enonic.xp.lib.node.mapper.ResolveSyncWorkResultMapper) NodeId(com.enonic.xp.node.NodeId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Example 2 with NodeId

use of com.enonic.xp.node.NodeId 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 3 with NodeId

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

the class PushNodesResultMapper method addDeleted.

private void addDeleted(final MapGenerator gen) {
    gen.array("deleted");
    for (final NodeId entry : deleted) {
        gen.value(entry);
    }
    gen.end();
}
Also used : NodeId(com.enonic.xp.node.NodeId)

Example 4 with NodeId

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

the class CreateAuditLogCommand method createNode.

private Node createNode() {
    NodeId id = new NodeId();
    CreateNodeParams createNodeParams = AuditLogSerializer.toCreateNodeParams(params).setNodeId(id).name(id.toString()).parent(NodePath.ROOT).childOrder(AuditLogConstants.AUDIT_LOG_REPO_DEFAULT_CHILD_ORDER).build();
    Node node = nodeService.create(createNodeParams);
    nodeService.refresh(RefreshMode.ALL);
    return node;
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) CreateNodeParams(com.enonic.xp.node.CreateNodeParams)

Example 5 with NodeId

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

the class AuditLogServiceImplTest method cleanUpOneBatch.

@Test
public void cleanUpOneBatch() {
    when(nodeService.deleteById(ArgumentMatchers.isA(NodeId.class))).thenAnswer(answer -> NodeIds.from((NodeId) answer.getArgument(0)));
    when(config.ageThreshold()).thenReturn("PT1s");
    final FindNodesByQueryResult.Builder queryResult = FindNodesByQueryResult.create().totalHits(3).hits(3);
    createHits(3).forEach(queryResult::addNodeHit);
    when(nodeService.findByQuery(any(NodeQuery.class))).thenReturn(queryResult.build()).thenReturn(FindNodesByQueryResult.create().build());
    final CleanUpAuditLogListener listener = mock(CleanUpAuditLogListener.class);
    final CleanUpAuditLogResult result = auditLogService.cleanUp(CleanUpAuditLogParams.create().listener(listener).build());
    assertEquals(3, result.getDeleted());
    verify(listener, times(1)).start(10_000);
    verify(listener, times(3)).processed();
    verify(listener, times(1)).finished();
}
Also used : CleanUpAuditLogResult(com.enonic.xp.audit.CleanUpAuditLogResult) CleanUpAuditLogListener(com.enonic.xp.audit.CleanUpAuditLogListener) FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) NodeId(com.enonic.xp.node.NodeId) Test(org.junit.jupiter.api.Test)

Aggregations

NodeId (com.enonic.xp.node.NodeId)91 Node (com.enonic.xp.node.Node)44 Test (org.junit.jupiter.api.Test)36 NodePath (com.enonic.xp.node.NodePath)23 InternalContext (com.enonic.xp.repo.impl.InternalContext)18 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)15 NodeIds (com.enonic.xp.node.NodeIds)14 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)11 Context (com.enonic.xp.context.Context)10 PropertyTree (com.enonic.xp.data.PropertyTree)10 Branch (com.enonic.xp.branch.Branch)9 ContextAccessor (com.enonic.xp.context.ContextAccessor)9 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)9 NodeVersionId (com.enonic.xp.node.NodeVersionId)9 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)8 RefreshMode (com.enonic.xp.node.RefreshMode)8 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)8 ContextBuilder (com.enonic.xp.context.ContextBuilder)6 Event (com.enonic.xp.event.Event)6 RenameNodeParams (com.enonic.xp.node.RenameNodeParams)6