Interface ProjectResolver

All Superinterfaces:
ProjectIdResolver
All Known Implementing Classes:
AbstractProjectResolver, DefaultProjectResolver

public interface ProjectResolver extends ProjectIdResolver
This exposes methods for accessing project-scoped data from the global one. The project in question is implied from the thread context.
  • Method Details

    • getProjectMetadata

      default ProjectMetadata getProjectMetadata(Metadata metadata)
    • getProjectMetadata

      default ProjectMetadata getProjectMetadata(ClusterState clusterState)
    • hasProject

      default boolean hasProject(ClusterState clusterState)
    • hasProject

      default boolean hasProject(Metadata metadata)
    • getProjectState

      default ProjectState getProjectState(ClusterState clusterState)
    • getProjectIds

      default Collection<ProjectId> getProjectIds(ClusterState clusterState)
      Returns the identifiers of all projects on which this request should operate. In practice, this will either be:
      • If the request is tied to a single project, then a collection with a single item that is the same as ProjectIdResolver.getProjectId() if the project exists in the cluster state
      • If the request is not tied to a single project and it is allowed to access all projects, then a collection of all the project ids in the cluster
      • Otherwise an exception is thrown
      Returns:
      A readonly collection of all the project ids on which this request should operate
      Throws:
      SecurityException - if this request is required to provide a project id, but none was provided
    • executeOnProject

      <E extends Exception> void executeOnProject(ProjectId projectId, CheckedRunnable<E> body) throws E
      Execute a block in the context of a specific project. This method:
      1. Configures the execution (thread) context so that any calls to resolve a project (e.g. ProjectIdResolver.getProjectId() or getProjectMetadata(Metadata)) will return the project specified by projectId.
      2. Executes the CheckedRunnable.run() method on the supplied body
      3. Restores the context to its original state
      Throws:
      IllegalStateException - If there is already a project-id set in the execution context. It is an error to attempt to override the active project-id
      E