use of com.enonic.xp.context.Context in project xp by enonic.
the class ContentAuditLogSupportImpl method publish.
@Override
public void publish(final PushContentParams params, final PublishContentResult result) {
final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
executor.execute(() -> doPublish(params, result, context));
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class ContentAuditLogSupportImpl method unpublishContent.
@Override
public void unpublishContent(final UnpublishContentParams params, final UnpublishContentsResult result) {
final Context context = ContextBuilder.copyOf(ContextAccessor.current()).build();
executor.execute(() -> doUnpublishContent(params, result, context));
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class NodesHasPermissionResolver method execute.
public boolean execute() {
final Context context = ContextAccessor.current();
if (context.getAuthInfo().hasRole(RoleKeys.ADMIN)) {
return true;
}
if (nodeIds.isEmpty()) {
return false;
}
final NodeQuery query = NodeQuery.create().addQueryFilter(IdFilter.create().fieldName(NodeIndexPath.ID.getPath()).values(nodeIds).build()).addQueryFilter(ValueFilter.create().fieldName(getPermissionFieldName().getPath()).addValues(context.getAuthInfo().getPrincipals().stream().map(PrincipalKey::toString).collect(Collectors.toList())).build()).searchMode(SearchMode.COUNT).build();
final FindNodesByQueryResult result = FindNodesByQueryCommand.create(this).query(query).build().execute();
return result.getTotalHits() == nodeIds.getSize();
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class PushNodesCommand method targetAlreadyExists.
private boolean targetAlreadyExists(final NodePath nodePath, final NodeComparisons comparisons, final Context currentContext) {
// Checks if a node exist
final Context targetContext = createTargetContext(currentContext);
final NodeId nodeId = targetContext.callWith(() -> GetNodeIdByPathCommand.create(this).nodePath(nodePath).build().execute());
// If the node does not exist, returns false
if (nodeId == null) {
return false;
}
// Else, if the existing node is being deleted or moved during the current push, returns false
final NodeComparison nodeComparison = comparisons.get(nodeId);
return nodeComparison == null || (CompareStatus.MOVED != nodeComparison.getCompareStatus() && CompareStatus.PENDING_DELETE != nodeComparison.getCompareStatus());
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class NodeServiceImpl method getByNodeVersionKey.
@Override
public NodeVersion getByNodeVersionKey(final NodeVersionKey nodeVersionKey) {
verifyContext();
final Context currentContext = ContextAccessor.current();
return this.nodeStorageService.getNodeVersion(nodeVersionKey, InternalContext.from(currentContext));
}
Aggregations