Search in sources :

Example 21 with Node

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

the class ApplicationServiceImplTest method install_global_denied.

@Test
public void install_global_denied() throws Exception {
    when(appFilterService.accept(any(ApplicationKey.class))).thenReturn(false);
    final Node applicationNode = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
    final String bundleName = "my-bundle";
    mockRepoCreateNode(applicationNode);
    mockRepoGetNode(applicationNode, bundleName);
    final ByteSource byteSource = createBundleSource(bundleName);
    assertThrows(ApplicationInstallException.class, () -> this.service.installGlobalApplication(byteSource, bundleName));
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Node(com.enonic.xp.node.Node) ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 22 with Node

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

the class ApplicationServiceImplTest method install_local_invalid.

@Test
public void install_local_invalid() throws Exception {
    final Node applicationNode = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
    final String bundleName = "my-bundle";
    mockRepoCreateNode(applicationNode);
    mockRepoGetNode(applicationNode, bundleName);
    final ByteSource source = createBundleSource(bundleName, false);
    assertThrows(ApplicationInstallException.class, () -> this.service.installLocalApplication(source, bundleName));
}
Also used : Node(com.enonic.xp.node.Node) ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 23 with Node

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

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

the class ArchiveContentCommand method doExecute.

private ArchiveContentsResult doExecute() {
    validateLocation();
    unpublish();
    final Node nodeToArchive = updateProperties(NodeId.from(params.getContentId()));
    rename(nodeToArchive);
    move(nodeToArchive.id());
    commitNode(nodeToArchive.id(), ContentConstants.ARCHIVE_COMMIT_PREFIX);
    return ArchiveContentsResult.create().addArchived(params.getContentId()).build();
}
Also used : Node(com.enonic.xp.node.Node)

Example 25 with Node

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

the class ContentServiceImpl method setChildOrder.

@Override
public Content setChildOrder(final SetContentChildOrderParams params) {
    try {
        final SetNodeChildOrderParams.Builder builder = SetNodeChildOrderParams.create().nodeId(NodeId.from(params.getContentId())).childOrder(params.getChildOrder());
        if (params.stopInherit()) {
            builder.processor(new SetContentChildOrderProcessor());
        }
        final Node node = nodeService.setChildOrder(builder.build());
        final Content content = translator.fromNode(node, true);
        contentAuditLogSupport.setChildOrder(params, content);
        return content;
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : NodeAccessException(com.enonic.xp.node.NodeAccessException) SetNodeChildOrderParams(com.enonic.xp.node.SetNodeChildOrderParams) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Aggregations

Node (com.enonic.xp.node.Node)521 Test (org.junit.jupiter.api.Test)371 PropertyTree (com.enonic.xp.data.PropertyTree)114 NodeId (com.enonic.xp.node.NodeId)52 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)51 NodePath (com.enonic.xp.node.NodePath)45 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)42 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)34 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)32 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)29 NodeQuery (com.enonic.xp.node.NodeQuery)27 AccessControlList (com.enonic.xp.security.acl.AccessControlList)27 BinaryReference (com.enonic.xp.util.BinaryReference)26 ByteSource (com.google.common.io.ByteSource)24 Content (com.enonic.xp.content.Content)23 PropertySet (com.enonic.xp.data.PropertySet)20 NodeIds (com.enonic.xp.node.NodeIds)18 Context (com.enonic.xp.context.Context)17 InternalContext (com.enonic.xp.repo.impl.InternalContext)17 Application (com.enonic.xp.app.Application)16