Class ResultScopeHeaderEmitter

java.lang.Object
org.gcube.informationsystem.resourceregistry.http.headers.scope.ResultScopeHeaderEmitter

public final class ResultScopeHeaderEmitter extends Object
Emits a single X-Result-Scope header combining all accumulated ResultScope tokens as a comma-separated list, in canonical (enum declaration) order.

Unlike X-Warning, which emits one header line per warning with anti-DoS capping (an open-ended, user-influenced cardinality), X-Result-Scope is bounded to a fixed, small enum, so a single combined header with no capping is sufficient.

Author:
Luca Frosini (ISTI - CNR)
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addResultScopeHeader(jakarta.ws.rs.core.MultivaluedMap<String,Object> headers, Set<org.gcube.informationsystem.resourceregistry.api.rest.ResultScope> scopes)
    Emits the X-Result-Scope header into the given JAX-RS multivalued map, if non-empty.
    static void
    addResultScopeHeader(jakarta.ws.rs.core.Response.ResponseBuilder rb, Set<org.gcube.informationsystem.resourceregistry.api.rest.ResultScope> scopes)
    Emits the X-Result-Scope header into the given response builder, if non-empty.
    static String
    toHeaderValue(Set<org.gcube.informationsystem.resourceregistry.api.rest.ResultScope> scopes)
    Formats the accumulated scopes as the comma-separated header value, in canonical (enum declaration) order regardless of the order scopes were added in.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • addResultScopeHeader

      public static void addResultScopeHeader(jakarta.ws.rs.core.Response.ResponseBuilder rb, Set<org.gcube.informationsystem.resourceregistry.api.rest.ResultScope> scopes)
      Emits the X-Result-Scope header into the given response builder, if non-empty.
      Parameters:
      rb - the response builder to add the header to
      scopes - the accumulated result scopes
    • addResultScopeHeader

      public static void addResultScopeHeader(jakarta.ws.rs.core.MultivaluedMap<String,Object> headers, Set<org.gcube.informationsystem.resourceregistry.api.rest.ResultScope> scopes)
      Emits the X-Result-Scope header into the given JAX-RS multivalued map, if non-empty.
      Parameters:
      headers - the multivalued headers map to add the header to
      scopes - the accumulated result scopes
    • toHeaderValue

      public static String toHeaderValue(Set<org.gcube.informationsystem.resourceregistry.api.rest.ResultScope> scopes)
      Formats the accumulated scopes as the comma-separated header value, in canonical (enum declaration) order regardless of the order scopes were added in.
      Parameters:
      scopes - the accumulated result scopes
      Returns:
      the formatted header value, or null if scopes is null/empty