Search in sources :

Example 21 with Context

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

the class ScheduleAuditLogSupportImpl method delete.

@Override
public void delete(final ScheduledJobName name, final boolean result) {
    final Context context = scheduleContext();
    executor.execute(() -> doDelete(name, result, context));
}
Also used : Context(com.enonic.xp.context.Context)

Example 22 with Context

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

the class ScheduleAuditLogSupportImpl method modify.

@Override
public void modify(ModifyScheduledJobParams params, ScheduledJob job) {
    final Context context = scheduleContext();
    executor.execute(() -> doUpdate(params, job, context));
}
Also used : Context(com.enonic.xp.context.Context)

Example 23 with Context

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

the class ContentServiceImplTest_duplicate method some_metadata_reset_on_duplicate.

@Test
public void some_metadata_reset_on_duplicate() throws Exception {
    final User otherUser = User.create().key(PrincipalKey.ofUser(IdProviderKey.system(), "fisk")).login("fisk").build();
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("rootContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).permissions(AccessControlList.create().add(AccessControlEntry.create().principal(otherUser.getKey()).allowAll().build()).build()).build();
    final Content rootContent = this.contentService.create(createContentParams);
    final Context duplicateContext = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(otherUser).principals(RoleKeys.CONTENT_MANAGER_ADMIN).build()).build();
    final Content duplicateContent = duplicateContext.callWith(() -> doDuplicateContent(rootContent));
    assertTrue(rootContent.getModifiedTime().isBefore(duplicateContent.getModifiedTime()));
    assertTrue(rootContent.getCreatedTime().isBefore(duplicateContent.getCreatedTime()));
    assertEquals(otherUser.getKey(), duplicateContent.getModifier());
    assertEquals(otherUser.getKey(), duplicateContent.getOwner());
    assertEquals(otherUser.getKey(), duplicateContent.getCreator());
}
Also used : Context(com.enonic.xp.context.Context) User(com.enonic.xp.security.User) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 24 with Context

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

the class DeleteContentCommand method getCompareStatus.

private CompareStatus getCompareStatus(final NodeId nodeToDelete) {
    final Context context = ContextAccessor.current();
    final Branch currentBranch = context.getBranch();
    final NodeComparison compare;
    if (currentBranch.equals(ContentConstants.BRANCH_DRAFT)) {
        compare = this.nodeService.compare(nodeToDelete, ContentConstants.BRANCH_MASTER);
    } else {
        compare = this.nodeService.compare(nodeToDelete, ContentConstants.BRANCH_DRAFT);
    }
    return compare.getCompareStatus();
}
Also used : Context(com.enonic.xp.context.Context) NodeComparison(com.enonic.xp.node.NodeComparison) Branch(com.enonic.xp.branch.Branch)

Example 25 with Context

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

the class ContentAuditLogSupportImpl method applyPermissions.

@Override
public void applyPermissions(final ApplyContentPermissionsParams params, final ApplyContentPermissionsResult result) {
    final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
    executor.execute(() -> doApplyPermissions(params, result, 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