use of com.enonic.xp.context.Context in project xp by enonic.
the class RepositoryServiceImpl method pushRootNode.
private void pushRootNode(final Repository currentRepo, final Branch branch) {
final Context context = ContextAccessor.current();
final InternalContext internalContext = InternalContext.create(context).branch(RepositoryConstants.MASTER_BRANCH).build();
final Node rootNode = this.nodeStorageService.get(Node.ROOT_UUID, internalContext);
if (rootNode == null) {
throw new NodeNotFoundException("Cannot find root-node in repository [" + currentRepo + "]");
}
this.nodeStorageService.push(rootNode, branch, internalContext);
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class RepositoryServiceImpl method getRootNode.
private Node getRootNode(final RepositoryId repositoryId, final Branch branch) {
final Context rootNodeContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(repositoryId).branch(branch).build();
final InternalContext rootNodeInternalContext = InternalContext.create(rootNodeContext).build();
return this.nodeStorageService.get(Node.ROOT_UUID, rootNodeInternalContext);
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class GetActiveNodeVersionsCommandTest method updateNode.
private void updateNode(final Node node, Context context) {
UpdateNodeParams updateNodeParams = UpdateNodeParams.create().id(node.id()).editor(toBeEdited -> toBeEdited.data.setString("myString", "edit")).build();
context.runWith(() -> UpdateNodeCommand.create().params(updateNodeParams).indexServiceInternal(this.indexServiceInternal).binaryService(this.binaryService).storageService(this.storageService).searchService(this.searchService).build().execute());
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class JsonExceptionMapper method createContextJson.
private static ObjectNode createContextJson() {
final Context context = ContextAccessor.current();
final AuthenticationInfo authInfo = context.getAuthInfo();
final ObjectNode node = JsonNodeFactory.instance.objectNode();
node.put("authenticated", (authInfo != null) && authInfo.isAuthenticated());
final ArrayNode principals = node.putArray("principals");
if (authInfo != null) {
for (final PrincipalKey principal : authInfo.getPrincipals()) {
principals.add(principal.toString());
}
}
return node;
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class IdProviderControllerServiceImpl method runWithAdminRole.
private <T> T runWithAdminRole(final Callable<T> callable) {
final Context context = ContextAccessor.current();
final AuthenticationInfo authenticationInfo = AuthenticationInfo.copyOf(context.getAuthInfo()).principals(RoleKeys.ADMIN).build();
return ContextBuilder.from(context).authInfo(authenticationInfo).build().callWith(callable);
}
Aggregations