Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public interface ContentService

Content getByIdAndVersionId( ContentId contentId, ContentVersionId versionId );

@Deprecated
Content getByPathAndVersionId( ContentPath contentPath, ContentVersionId versionId );

ImportContentResult importContent( ImportContentParams params );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.enonic.xp.node;

import com.google.common.base.Preconditions;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public final class DeleteNodeParams
{
private final NodeId nodeId;

private final RefreshMode refresh;

private final DeleteNodeListener deleteNodeListener;

private DeleteNodeParams( final Builder builder )
{
this.nodeId = builder.nodeId;
this.refresh = builder.refresh;
this.deleteNodeListener = builder.deleteNodeListener;
}

public NodeId getNodeId()
{
return nodeId;
}

public RefreshMode getRefresh()
{
return refresh;
}

public DeleteNodeListener getDeleteNodeListener()
{
return deleteNodeListener;
}

public static Builder create()
{
return new DeleteNodeParams.Builder();
}

public static final class Builder
{
private NodeId nodeId;

private RefreshMode refresh;

private DeleteNodeListener deleteNodeListener;

private Builder()
{
}

public Builder nodeId( final NodeId nodeId )
{
this.nodeId = nodeId;
return this;
}

public Builder refresh( final RefreshMode refresh )
{
this.refresh = refresh;
return this;
}

public Builder deleteNodeListener( final DeleteNodeListener deleteNodeListener )
{
this.deleteNodeListener = deleteNodeListener;
return this;
}

public DeleteNodeParams build()
{
Preconditions.checkNotNull( this.nodeId, "id cannot be null" );
return new DeleteNodeParams( this );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.enonic.xp.node;

public final class DeleteNodeResult
{
private final NodeBranchEntries nodeBranchEntries;

private DeleteNodeResult( final Builder builder )
{
this.nodeBranchEntries = builder.nodeBranchEntries;
}

public NodeBranchEntries getNodeBranchEntries()
{
return nodeBranchEntries;
}

public static Builder create()
{
return new DeleteNodeResult.Builder();
}

public static class Builder
{

private NodeBranchEntries nodeBranchEntries;

private Builder()
{
}

public Builder nodeBranchEntries( final NodeBranchEntries nodeBranchEntries )
{
this.nodeBranchEntries = nodeBranchEntries;
return this;
}

public DeleteNodeResult build()
{
return new DeleteNodeResult( this );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,9 @@ public class MoveNodeResult
{
private final List<MovedNode> movedNodes;

private final Node sourceNode;

private MoveNodeResult( Builder builder )
private MoveNodeResult( final Builder builder )
{
this.sourceNode = builder.sourceNode;

final List<MovedNode> movedNodes = builder.movedNodes.build();
if ( builder.sourceNode != null && builder.targetNode != null && movedNodes.isEmpty() )
{
this.movedNodes = List.of( MovedNode.create().node( builder.targetNode ).previousPath( builder.sourceNode.path() ).build() );
}
else
{
this.movedNodes = builder.movedNodes.build();
}
this.movedNodes = builder.movedNodes.build();
}

public static Builder create()
Expand All @@ -39,7 +27,7 @@ public List<MovedNode> getMovedNodes()
@Deprecated
public Node getSourceNode()
{
return sourceNode;
return null;
}

@Deprecated
Expand Down Expand Up @@ -111,10 +99,6 @@ public static final class Builder
{
private final ImmutableList.Builder<MovedNode> movedNodes = ImmutableList.builder();

private Node sourceNode;

private Node targetNode;

private Builder()
{
}
Expand All @@ -128,24 +112,17 @@ public Builder addMovedNode( final MovedNode node )
@Deprecated
public Builder sourceNode( final Node sourceNode )
{
this.sourceNode = sourceNode;
return this;
}

@Deprecated
public Builder targetNode( final Node targetNode )
{
this.targetNode = targetNode;
return this;
}

private void validate()
{
}

public MoveNodeResult build()
{
this.validate();
return new MoveNodeResult( this );
}
}
Expand Down
12 changes: 2 additions & 10 deletions modules/core/core-api/src/main/java/com/enonic/xp/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,8 @@ else if ( builder.parentPath != null && builder.name != null )
this.path = null;
}

if ( builder.indexConfigDocument != null )
{
this.indexConfigDocument = builder.indexConfigDocument;
}
else
{
this.indexConfigDocument = PatternIndexConfigDocument.create().
defaultConfig( IndexConfig.BY_TYPE ).
build();
}
this.indexConfigDocument = Objects.requireNonNullElseGet( builder.indexConfigDocument, PatternIndexConfigDocument.create()
.defaultConfig( IndexConfig.BY_TYPE )::build );
}

public boolean isRoot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface NodeService

NodeIds deleteByPath( NodePath path );

DeleteNodeResult delete( DeleteNodeParams deleteNodeParams );

Node getById( NodeId id );

Node getByIdAndVersionId( NodeId id, NodeVersionId versionId );
Expand All @@ -35,6 +37,7 @@ public interface NodeService

Node getByPath( NodePath path );

@Deprecated
Node getByPathAndVersionId( NodePath path, NodeVersionId versionId );

Nodes getByPaths( NodePaths paths );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.enonic.xp.node;

import java.util.Objects;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public final class NodeType
{
public static final NodeType DEFAULT_NODE_COLLECTION = NodeType.from( "default" );
public static final NodeType DEFAULT_NODE_COLLECTION = new NodeType( "default" );

private final String name;

private NodeType( final String name )
{
this.name = name;
this.name = Objects.requireNonNull( name );
}

public static NodeType from( final String name )
Expand All @@ -38,13 +40,13 @@ public boolean equals( final Object o )

final NodeType that = (NodeType) o;

return name != null ? name.equals( that.name ) : that.name == null;
return name.equals( that.name );
}

@Override
public int hashCode()
{
return name != null ? name.hashCode() : 0;
return name.hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.enonic.xp.repository.RepositoryId;
import com.enonic.xp.support.AbstractImmutableEntitySet;

@Deprecated
public class PushNodeEntries
extends AbstractImmutableEntitySet<PushNodeEntry>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.enonic.xp.node;

import java.util.List;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public class PushNodesResult
{
private final NodeBranchEntries successful;
private final ImmutableList<PushNodeEntry> successful;

private final ImmutableSet<Failed> failed;
private final ImmutableList<Failed> failed;

protected PushNodesResult( Builder<?> builder )
{
Expand All @@ -18,33 +21,55 @@ protected PushNodesResult( Builder<?> builder )
}

public NodeBranchEntries getSuccessful()
{
final NodeBranchEntries.Builder builder = NodeBranchEntries.create();
successful.stream().map( PushNodeEntry::getNodeBranchEntry ).forEach( builder::add );
return builder.build();
}

public List<PushNodeEntry> getSuccessfulEntries()
{
return successful;
}

public ImmutableSet<Failed> getFailed()
public List<Failed> getFailedEntries()
{
return failed;
}

@Deprecated
public ImmutableSet<Failed> getFailed()
{
return ImmutableSet.copyOf( failed );
}

public static Builder create()
{
return new Builder();
}

public static class Builder<T extends Builder>
{
private final NodeBranchEntries.Builder successful = NodeBranchEntries.create();
private final ImmutableList.Builder<PushNodeEntry> successful = ImmutableList.builder();

private final ImmutableSet.Builder<Failed> failed = ImmutableSet.builder();
private final ImmutableList.Builder<Failed> failed = ImmutableList.builder();

protected Builder()
{
}

public T addSuccess( final NodeBranchEntry nodeBranchEntry, NodePath currentTargetPath )
{
successful.add( PushNodeEntry.create().
nodeBranchEntry( nodeBranchEntry ).
currentTargetPath( currentTargetPath ).
build() );
return (T) this;
}

@Deprecated
public T addSuccess( final NodeBranchEntry success )
{
this.successful.add( success );
return (T) this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public Iterable<Permission> getDeniedPermissions()
return deniedPermissions;
}

public boolean isAllowed( final Permission permission )
{
return this.allowedPermissions.contains( permission );
}

public boolean isAllowed( final Permission... permissions )
{
return this.allowedPermissions.containsAll( Arrays.asList( permissions ) );
Expand Down
Loading