Class RemoteBase

java.lang.Object
org.opencastproject.serviceregistry.api.RemoteBase
Direct Known Subclasses:
AwsS3DistributionServiceRemoteImpl, CaptionServiceRemoteImpl, ComposerServiceRemoteImpl, ConfigurablePublicationServiceRemoteImpl, CoverImageServiceRemoteImpl, CropServiceRemoteImpl, DownloadDistributionServiceRemoteImpl, EditorServiceRemoteImpl, ExecuteServiceRemoteImpl, IngestDownloadServiceRemoteImpl, LtiServiceRemoteImpl, MediaInspectionServiceRemoteImpl, OaiPmhPublicationServiceRemoteImpl, OaiPmhServerInfoRemoteImpl, SchedulerServiceRemoteImpl, SeriesServiceRemoteImpl, SilenceDetectionServiceRemote, SpeechToTextServiceRemoteImpl, StatisticsServiceRemoteImpl, StreamingDistributionServiceRemoteImpl, TextAnalysisRemoteImpl, TimelinePreviewsServiceRemote, VideoEditorServiceRemote, VideoGridServiceRemoteImpl, VideoSegmenterRemoteImpl, WaveformServiceRemote, WorkflowServiceRemoteImpl, YouTubePublicationServiceRemoteImpl

public class RemoteBase extends Object
Base class serving as a convenience implementation for remote services.
  • Field Details

    • serviceType

      protected String serviceType
      The service type, used to look up remote implementations
    • client

      protected TrustedHttpClient client
      The http client to use when connecting to remote servers
    • remoteServiceManager

      protected ServiceRegistry remoteServiceManager
      The http client
    • elementsFromHttpResponse

      public static final Function<org.apache.http.HttpResponse,Option<List<MediaPackageElement>>> elementsFromHttpResponse
  • Constructor Details

    • RemoteBase

      protected RemoteBase(String type)
      Creates a remote implementation for the given type of service.
      Parameters:
      type - the service type
  • Method Details

    • setTrustedHttpClient

      public void setTrustedHttpClient(TrustedHttpClient client)
      Sets the trusted http client
      Parameters:
      client -
    • setRemoteServiceManager

      public void setRemoteServiceManager(ServiceRegistry remoteServiceManager)
      Sets the remote service manager.
      Parameters:
      remoteServiceManager -
    • runRequest

      protected <A> Option<A> runRequest(org.apache.http.client.methods.HttpRequestBase req, Function<org.apache.http.HttpResponse,A> f)
    • getResponse

      protected org.apache.http.HttpResponse getResponse(org.apache.http.client.methods.HttpRequestBase httpRequest)
      Makes a request to all available remote services and returns the response as soon as the first of them returns the HttpStatus.SC_OK as the status code.
      Parameters:
      httpRequest - the http request. If the URI is specified, it should include only the path beyond the service endpoint. For example, a request intended for http://{host}/{service}/extra/path/info.xml should include the URI "/extra/path/info.xml".
      Returns:
      the response object, or null if we can not connect to any services
    • getResponse

      protected org.apache.http.HttpResponse getResponse(org.apache.http.client.methods.HttpRequestBase httpRequest, Integer... expectedHttpStatus)
      Makes a request to all available remote services and returns the response as soon as the first of them returns the expected http status code.
      Parameters:
      httpRequest - the http request. If the URI is specified, it should include only the path beyond the service endpoint. For example, a request intended for http://{host}/{service}/extra/path/info.xml should include the URI "/extra/path/info.xml".
      expectedHttpStatus - any expected status codes to include in the return.
      Returns:
      the response object, or null if we can not connect to any services
    • closeConnection

      protected void closeConnection(org.apache.http.HttpResponse response)
      Closes any http connections kept open by this http response.