Class AbstractJerseyClient

java.lang.Object
org.apache.nifi.toolkit.client.impl.AbstractJerseyClient
Direct Known Subclasses:
CRUDJerseyClient, JerseyAccessClient, JerseyConnectionClient, JerseyControllerClient, JerseyControllerServicesClient, JerseyCountersClient, JerseyFlowClient, JerseyParamContextClient, JerseyParamProviderClient, JerseyPoliciesClient, JerseyProcessGroupClient, JerseyProcessorClient, JerseyProvenanceClient, JerseyRemoteProcessGroupClient, JerseyReportingTasksClient, JerseySnippetClient, JerseySystemDiagnosticsClient, JerseyTenantsClient, JerseyVersionsClient

public class AbstractJerseyClient extends Object
Base class for the client operations to share exception handling. Sub-classes should always execute a request from getRequestBuilder(target) to ensure proper headers are sent.
  • Field Details

    • EMPTY_REQUEST_CONFIG

      private static final RequestConfig EMPTY_REQUEST_CONFIG
    • requestConfig

      private final RequestConfig requestConfig
  • Constructor Details

    • AbstractJerseyClient

      public AbstractJerseyClient(RequestConfig requestConfig)
  • Method Details

    • getRequestConfig

      protected RequestConfig getRequestConfig()
    • getRequestBuilder

      protected jakarta.ws.rs.client.Invocation.Builder getRequestBuilder(jakarta.ws.rs.client.WebTarget webTarget)
      Creates a new Invocation.Builder for the given WebTarget with the headers added to the builder.
      Parameters:
      webTarget - the target for the request
      Returns:
      the builder for the target with the headers added
    • executeAction

      protected <T> T executeAction(String errorMessage, AbstractJerseyClient.NiFiAction<T> action) throws NiFiClientException, IOException
      Executes the given action and returns the result.
      Type Parameters:
      T - the return type of the action
      Parameters:
      errorMessage - the message to use if a NiFiRegistryException is thrown
      action - the action to execute
      Returns:
      the result of the action
      Throws:
      NiFiClientException - if any exception other than IOException is encountered
      IOException - if an I/O error occurs communicating with the registry
    • getIOExceptionCause

      protected Throwable getIOExceptionCause(Throwable e)
      Parameters:
      e - an exception that was encountered interacting with the registry
      Returns:
      the IOException that caused this exception, or null if the an IOException did not cause this exception
    • getContentDispositionFilename

      protected String getContentDispositionFilename(jakarta.ws.rs.core.Response response)
      Gets the filename from the content disposition header.
      Parameters:
      response - a response
      Returns:
      the filename value