Package org.lockss.ws

Class BaseServiceImpl

All Implemented Interfaces:
LockssConfigurableService
Direct Known Subclasses:
AuControlServiceImpl, ContentConfigurationServiceImpl, ContentServiceImpl, DaemonStatusServiceImpl, ExportServiceImpl, HasherServiceImpl, ImportServiceImpl

public class BaseServiceImpl extends BaseSpringApiServiceImpl implements LockssConfigurableService
Base class for the various SOAP web service implementations.
  • Field Details

    • PREFIX

      public static final String PREFIX
      See Also:
    • PARAM_REPO_NAMESPACE

      public static final String PARAM_REPO_NAMESPACE
      Repository namespace.
      See Also:
    • DEFAULT_REPO_NAMESPACE

      public static final String DEFAULT_REPO_NAMESPACE
    • PARAM_CONNECTION_TIMEOUT

      public static final String PARAM_CONNECTION_TIMEOUT
      Connection timeout.
      See Also:
    • DEFAULT_CONNECTION_TIMEOUT

      public static final long DEFAULT_CONNECTION_TIMEOUT
      See Also:
    • PARAM_READ_TIMEOUT

      public static final String PARAM_READ_TIMEOUT
      Read timeout.
      See Also:
    • DEFAULT_READ_TIMEOUT

      public static final long DEFAULT_READ_TIMEOUT
      See Also:
    • restTemplate

      @Autowired protected org.springframework.web.client.RestTemplate restTemplate
    • connectionTimeout

      protected long connectionTimeout
    • readTimeout

      protected long readTimeout
    • repoNamespace

      protected String repoNamespace
  • Constructor Details

    • BaseServiceImpl

      public BaseServiceImpl()
  • Method Details

    • getServiceBinding

      protected org.lockss.app.ServiceBinding getServiceBinding(org.lockss.app.ServiceDescr sd)
    • getServiceEndpoint

      public String getServiceEndpoint(org.lockss.app.ServiceDescr sd)
    • getConnectionTimeout

      protected Long getConnectionTimeout()
      Provides the configured connection timeout in milliseconds.
      Returns:
      a Long with the configured connection timeout in milliseconds.
    • getReadTimeout

      protected Long getReadTimeout()
      Provides the configured read timeout in milliseconds.
      Returns:
      a Long with the configured read timeout in milliseconds.
    • getAuthHeaders

      protected org.springframework.http.HttpHeaders getAuthHeaders()
    • getSoapRequestAuthorizationHeader

      protected static String getSoapRequestAuthorizationHeader()
      Provides the Authorization header in the current SOAP request message, if any.
      Returns:
      a String with the Authorization header.
    • getRequestorIpAddress

      protected static String getRequestorIpAddress()
      Provides the requestor IP of the current SOAP request message
      Returns:
      a String with the requestor IP.
    • getRestLockssRepository

      protected org.lockss.util.rest.repo.RestLockssRepository getRestLockssRepository() throws MalformedURLException
      Provides access to the REST Repository service.
      Returns:
      a RestLockssRepository that allows access to the REST Repository service.
      Throws:
      MalformedURLException - if there are problems with the REST Repository service URL.
    • getSoapRequestCredentials

      protected static String[] getSoapRequestCredentials()
      Provides the credentials in the current SOAP request message, if any.
      Returns:
      a String[] with the credentials.
    • callRestServiceEndpoint

      protected <T> org.springframework.http.ResponseEntity<String> callRestServiceEndpoint(String serviceUrl, String endPointPath, Map<String,String> uriVariables, Map<String,String> queryParams, org.springframework.http.HttpMethod httpMethod, T body, String exceptionMessage) throws org.lockss.util.rest.exception.LockssRestException
      Makes a call to a REST service endpoint.
      Parameters:
      serviceUrl - A String with the URL of the service.
      endPointPath - A String with the URI path to the endpoint.
      uriVariables - A Map<String, String> with any variables to be interpolated in the URI.
      queryParams - A Map<String, String> with any query parameters.
      httpMethod - An HttpMethod with HTTP method used to make the call to the REST service.
      body - A T with the contents of the body to be included with the request, if any.
      exceptionMessage - A String with the message to be returned with any exception.
      Returns:
      a ResponseEntity with the response from the REST service.
      Throws:
      org.lockss.util.rest.exception.LockssRestException - if any problems arise in the call to the REST service.
    • callRestServiceUri

      protected <T> org.springframework.http.ResponseEntity<String> callRestServiceUri(String uriString, Map<String,String> uriVariables, Map<String,String> queryParams, org.springframework.http.HttpMethod httpMethod, T body, String exceptionMessage) throws org.lockss.util.rest.exception.LockssRestException
      Makes a call to a REST service URI.
      Parameters:
      uriString - A String with the URI of the request to the REST service.
      uriVariables - A Map<String, String> with any variables to be interpolated in the URI.
      queryParams - A Map<String, String> with any query parameters.
      httpMethod - An HttpMethod with HTTP method used to make the call to the REST service.
      body - A T with the contents of the body to be included with the request, if any.
      exceptionMessage - A String with the message to be returned with any exception.
      Returns:
      a ResponseEntity with the response from the REST service.
      Throws:
      org.lockss.util.rest.exception.LockssRestException - if any problems arise in the call to the REST service.
    • callRestServiceUri

      protected <T> org.springframework.http.ResponseEntity<String> callRestServiceUri(String uriString, Map<String,String> uriVariables, Map<String,String> queryParams, org.springframework.http.HttpMethod httpMethod, org.springframework.http.HttpHeaders requestHeaders, T body, String exceptionMessage) throws org.lockss.util.rest.exception.LockssRestException
      Makes a call to a REST service URI.
      Parameters:
      uriString - A String with the URI of the request to the REST service.
      uriVariables - A Map<String, String> with any variables to be interpolated in the URI.
      queryParams - A Map<String, String> with any query parameters.
      httpMethod - An HttpMethod with HTTP method used to make the call to the REST service.
      requestHeaders - An HttpHeaders with HTTP request headers used to make the call to the REST service.
      body - A T with the contents of the body to be included with the request, if any.
      exceptionMessage - A String with the message to be returned with any exception.
      Returns:
      a ResponseEntity with the response from the REST service.
      Throws:
      org.lockss.util.rest.exception.LockssRestException - if any problems arise in the call to the REST service.
    • getMultipartResponse

      protected <T> org.lockss.util.rest.multipart.MultipartResponse getMultipartResponse(String serviceUrl, String endPointPath, Map<String,String> uriVariables, Map<String,String> queryParams, org.springframework.http.HttpHeaders requestHeaders, org.springframework.http.HttpMethod httpMethod, T body) throws IOException, javax.mail.MessagingException
      Makes a call to a REST service endpoint that returns a multipart response.
      Parameters:
      serviceUrl - A String with the URL of the service.
      endPointPath - A String with the URI path to the endpoint.
      uriVariables - A Map<String, String> with any variables to be interpolated in the URI.
      queryParams - A Map<String, String> with any query parameters.
      requestHeaders - An HttpHeaders with HTTP request headers used to make the call to the REST service.
      httpMethod - An HttpMethod with HTTP method used to make the call to the REST service.
      body - A T with the contents of the body to be included with the request, if any.
      Returns:
      a MultipartResponse with the response from the REST service.
      Throws:
      org.lockss.util.rest.exception.LockssRestException - if any problems arise in the call to the REST service.
      IOException
      javax.mail.MessagingException
    • separatedString

      protected static StringBuilder separatedString(Collection c, String separatorFirst, String separatorInner, String separatorLast, StringBuilder sb)
      Concatenate elements of collection into string, adding separators, delimiting each element
      Parameters:
      c - - Collection of object (on which toString() will be called)
      separatorFirst - - String to place before first element
      separatorInner - - String with which to separate elements
      separatorLast - - String to place after last element
      sb - - StringBuilder to write result into
      Returns:
      sb
    • setConfig

      public void setConfig(org.lockss.config.Configuration newConfig, org.lockss.config.Configuration prevConfig, org.lockss.config.Configuration.Differences changedKeys)
      Specified by:
      setConfig in interface LockssConfigurableService