Search in sources :

Example 56 with Context

use of com.enonic.xp.context.Context in project xp by enonic.

the class GetNodeByPathCommandTest method get_root.

@Test
public void get_root() throws Exception {
    final Context systemContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(SystemConstants.SYSTEM_REPO_ID).branch(SystemConstants.BRANCH_SYSTEM).build();
    final Node rootNode = systemContext.callWith(() -> doGetNodeByPath(NodePath.ROOT));
    assertNotNull(rootNode);
}
Also used : Context(com.enonic.xp.context.Context) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 57 with Context

use of com.enonic.xp.context.Context in project xp by enonic.

the class SecurityAuditLogSupportImpl method log.

private void log(final String type, final PropertyTree data, final AuditLogUris uris) {
    final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
    final PrincipalKey userPrincipalKey = context.getAuthInfo().getUser() != null ? context.getAuthInfo().getUser().getKey() : PrincipalKey.ofAnonymous();
    ContextBuilder.from(context).authInfo(AuthenticationInfo.copyOf(context.getAuthInfo()).principals(RoleKeys.AUDIT_LOG).build()).build().callWith(() -> auditLogService.log(LogAuditLogParams.create().type(type).source(SOURCE).data(data).objectUris(uris).user(userPrincipalKey).build()));
}
Also used : Context(com.enonic.xp.context.Context) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Example 58 with Context

use of com.enonic.xp.context.Context in project xp by enonic.

the class ContentAuditLogSupportImpl method setActiveContentVersion.

@Override
public void setActiveContentVersion(final ContentId contentId, final ContentVersionId versionId) {
    final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
    executor.execute(() -> doSetActiveContentVersion(contentId, versionId, context));
}
Also used : Context(com.enonic.xp.context.Context)

Example 59 with Context

use of com.enonic.xp.context.Context in project xp by enonic.

the class ContentAuditLogSupportImpl method move.

@Override
public void move(final MoveContentParams params, final MoveContentsResult result) {
    final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
    executor.execute(() -> doMove(params, result, context));
}
Also used : Context(com.enonic.xp.context.Context)

Example 60 with Context

use of com.enonic.xp.context.Context in project xp by enonic.

the class ContentAuditLogSupportImpl method update.

@Override
public void update(final UpdateContentParams params, final Content content) {
    final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
    executor.execute(() -> doUpdate(params, content, context));
}
Also used : Context(com.enonic.xp.context.Context)

Aggregations

Context (com.enonic.xp.context.Context)101 Test (org.junit.jupiter.api.Test)35 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)21 Node (com.enonic.xp.node.Node)16 InternalContext (com.enonic.xp.repo.impl.InternalContext)16 User (com.enonic.xp.security.User)13 Content (com.enonic.xp.content.Content)11 PropertyTree (com.enonic.xp.data.PropertyTree)11 PrincipalKey (com.enonic.xp.security.PrincipalKey)10 Branch (com.enonic.xp.branch.Branch)9 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)9 ContextAccessor (com.enonic.xp.context.ContextAccessor)8 NodePath (com.enonic.xp.node.NodePath)8 ContextBuilder (com.enonic.xp.context.ContextBuilder)7 ContentId (com.enonic.xp.content.ContentId)6 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)6 Repository (com.enonic.xp.repository.Repository)6 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)5 ProcessUpdateParams (com.enonic.xp.content.processor.ProcessUpdateParams)5 NodeComparison (com.enonic.xp.node.NodeComparison)5