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
Base class serving as a convenience implementation for remote services.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA stream wrapper that closes the http response when the stream is closed. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TrustedHttpClientThe http client to use when connecting to remote serversstatic final Function<org.apache.http.HttpResponse, Option<List<MediaPackageElement>>> protected ServiceRegistryThe http clientprotected StringThe service type, used to look up remote implementations -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRemoteBase(String type) Creates a remote implementation for the given type of service. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcloseConnection(org.apache.http.HttpResponse response) Closes any http connections kept open by this http response.protected org.apache.http.HttpResponsegetResponse(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 theHttpStatus.SC_OKas the status code.protected org.apache.http.HttpResponsegetResponse(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.protected <A> Option<A> runRequest(org.apache.http.client.methods.HttpRequestBase req, Function<org.apache.http.HttpResponse, A> f) voidsetRemoteServiceManager(ServiceRegistry remoteServiceManager) Sets the remote service manager.voidSets the trusted http client
-
Field Details
-
serviceType
The service type, used to look up remote implementations -
client
The http client to use when connecting to remote servers -
remoteServiceManager
The http client -
elementsFromHttpResponse
public static final Function<org.apache.http.HttpResponse,Option<List<MediaPackageElement>>> elementsFromHttpResponse
-
-
Constructor Details
-
RemoteBase
Creates a remote implementation for the given type of service.- Parameters:
type- the service type
-
-
Method Details
-
setTrustedHttpClient
Sets the trusted http client- Parameters:
client-
-
setRemoteServiceManager
Sets the remote service manager.- Parameters:
remoteServiceManager-
-
runRequest
-
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 theHttpStatus.SC_OKas 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.
-