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 @@ -3,11 +3,8 @@
import java.time.Instant;
import java.util.Objects;

import com.enonic.xp.context.Context;
import com.enonic.xp.context.ContextAccessor;
import com.enonic.xp.data.PropertyTree;
import com.enonic.xp.security.PrincipalKey;
import com.enonic.xp.security.User;

public final class LogAuditLogParams
{
Expand All @@ -25,21 +22,14 @@ public final class LogAuditLogParams

private LogAuditLogParams( final Builder builder )
{
type = Objects.requireNonNull( builder.type, "AuditLogParams type cannot be null" );
type = Objects.requireNonNull( builder.type, "LogAuditLogParams type cannot be null" );
time = Objects.requireNonNullElseGet( builder.time, Instant::now );
source = Objects.requireNonNullElse( builder.source, "" );
user = Objects.requireNonNullElseGet( builder.user, this::getUserKey );
user = builder.user;
objectUris = Objects.requireNonNullElse( builder.objectUris, AuditLogUris.empty() );
data = Objects.requireNonNullElse( builder.data, new PropertyTree() );
}

private PrincipalKey getUserKey()
{
final Context context = ContextAccessor.current();
final User user = context.getAuthInfo().getUser() != null ? context.getAuthInfo().getUser() : User.ANONYMOUS;
return user.getKey();
}

public String getType()
{
return type;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.common.base.Preconditions;

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.node.ApplyPermissionsScope;
import com.enonic.xp.security.acl.AccessControlList;

import static java.util.Objects.requireNonNull;
Expand All @@ -20,14 +19,14 @@ public final class ApplyContentPermissionsParams

private final AccessControlList removePermissions;

private final ApplyPermissionsScope applyPermissionsScope;
private final ApplyContentPermissionsScope applyPermissionsScope;

private final ApplyPermissionsListener listener;

private ApplyContentPermissionsParams( Builder builder )
{
contentId = requireNonNull( builder.contentId );
applyPermissionsScope = requireNonNullElse( builder.applyPermissionsScope, ApplyPermissionsScope.SINGLE );
applyPermissionsScope = requireNonNullElse( builder.applyPermissionsScope, ApplyContentPermissionsScope.SINGLE );
permissions = builder.permissions.build();
addPermissions = builder.addPermissions.build();
removePermissions = builder.removePermissions.build();
Expand All @@ -47,7 +46,7 @@ public ContentId getContentId()
return contentId;
}

public ApplyPermissionsScope getScope()
public ApplyContentPermissionsScope getScope()
{
return applyPermissionsScope;
}
Expand Down Expand Up @@ -82,7 +81,7 @@ public static final class Builder

private final AccessControlList.Builder removePermissions = AccessControlList.create();

private ApplyPermissionsScope applyPermissionsScope;
private ApplyContentPermissionsScope applyPermissionsScope;

private ApplyPermissionsListener listener;

Expand All @@ -96,7 +95,7 @@ public Builder contentId( final ContentId contentId )
return this;
}

public Builder applyPermissionsScope( final ApplyPermissionsScope applyPermissionsScope )
public Builder applyPermissionsScope( final ApplyContentPermissionsScope applyPermissionsScope )
{
this.applyPermissionsScope = applyPermissionsScope;
return this;
Expand Down Expand Up @@ -140,5 +139,4 @@ public ApplyContentPermissionsParams build()
return new ApplyContentPermissionsParams( this );
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.enonic.xp.content;

public enum ApplyContentPermissionsScope
{
SINGLE, TREE, SUBTREE
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,5 @@
@PublicApi
public enum CompareStatus
{
NEW( false, "Offline" ), NEW_TARGET( false, "New in prod" ), NEWER( false, "Modified" ), OLDER( false, "Out-of-date" ), EQUAL( false,
"Online" ), MOVED(
false, "Moved" ), CONFLICT_PATH_EXISTS( true, "Conflict" ), CONFLICT_VERSION_BRANCH_DIVERGS( true, "Conflict version" );

private final boolean conflict;

private final String status;

CompareStatus( final boolean conflict, final String formattedStatus )
{
this.conflict = conflict;
this.status = formattedStatus;
}

public boolean isConflict()
{
return this.conflict;
}

public String getFormattedStatus()
{
return this.status;
}
NEW, NEW_TARGET, NEWER, OLDER, EQUAL, MOVED
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.exception.BaseException;
import com.enonic.xp.node.NodeAccessException;
import com.enonic.xp.node.NodePath;
import com.enonic.xp.security.User;
import com.enonic.xp.security.acl.Permission;

Expand All @@ -19,18 +17,7 @@ public final class ContentAccessException

private final Permission permission;

public ContentAccessException( final NodeAccessException nodeAccessException )
{
this( nodeAccessException, nodeAccessException.getUser(), translateNodePathToContentPath( nodeAccessException.getNodePath() ),
nodeAccessException.getPermission() );
}

public ContentAccessException( final User user, final ContentPath contentPath, final Permission permission )
{
this( null, user, contentPath, permission );
}

private ContentAccessException( final Throwable cause, final User user, final ContentPath contentPath, final Permission permission )
public ContentAccessException( final Throwable cause, final User user, final ContentPath contentPath, final Permission permission )
{
super( cause, MessageFormat.format( "Access denied to [{0}] for [{1}] by user [{2}] {3}", contentPath, permission,
user == null ? "unknown" : user.getKey(),
Expand All @@ -54,17 +41,4 @@ public Permission getPermission()
{
return permission;
}

private static ContentPath translateNodePathToContentPath( final NodePath nodePath )
{
final int beginIndex = nodePath.toString().indexOf( '/', 1 );
if ( beginIndex == -1 )
{
return ContentPath.ROOT;
}
else
{
return ContentPath.from( nodePath.toString().substring( beginIndex ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.branch.Branch;
import com.enonic.xp.exception.NotFoundException;
import com.enonic.xp.exception.DuplicateElementException;
import com.enonic.xp.repository.RepositoryId;

@PublicApi
public final class ContentAlreadyExistsException
extends NotFoundException
extends DuplicateElementException
{
private final ContentPath path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public final class ContentConstants

public static final String CONTENT_ROOT_NAME = "content";

public static final NodePath CONTENT_ROOT_PARENT = NodePath.ROOT;

public static final NodePath CONTENT_ROOT_PATH = new NodePath( CONTENT_ROOT_PARENT, NodeName.from( CONTENT_ROOT_NAME ) );
public static final NodePath CONTENT_ROOT_PATH = new NodePath( NodePath.ROOT, NodeName.from( CONTENT_ROOT_NAME ) );

public static final NodeType CONTENT_NODE_COLLECTION = NodeType.from( "content" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public interface ContentService

FindContentVersionsResult getVersions( FindContentVersionsParams params );

GetActiveContentVersionsResult getActiveVersions( GetActiveContentVersionsParams params );

ByteSource getBinary( ContentId contentId, BinaryReference binaryReference );

ByteSource getBinary( ContentId contentId, ContentVersionId contentVersionId, BinaryReference binaryReference );
Expand Down
Loading
Loading