Class HttpConnector

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, Connector
    Direct Known Subclasses:
    AlfrescoConnector

    public class HttpConnector
    extends AbstractConnector
    Basic Connector implementation that can be used to perform simple HTTP and HTTP communication with a remote endpoint. This connector supports basic HTTP authentication via the RemoteClient.
    Author:
    muzquiano, kevinr
    • Constructor Detail

      • HttpConnector

        public HttpConnector​(RemoteConfigElement.ConnectorDescriptor descriptor,
                             java.lang.String endpoint)
        Instantiates a new http connector.
        Parameters:
        descriptor - the descriptor
        endpoint - the endpoint
    • Method Detail

      • call

        public Response call​(java.lang.String uri,
                             ConnectorContext context)
        Description copied from interface: Connector
        Invokes a URI on a remote service. If the context is null, then it will not be utilized. The response data is buffered into a data element on the returned object of type Response.
        Parameters:
        uri - the uri
        context - the context of the invoke
        Returns:
        the response
      • call

        public Response call​(java.lang.String uri,
                             ConnectorContext context,
                             java.io.InputStream in)
        Description copied from interface: Connector
        Invokes a URI on a remote service, passing the input as supplied via a POST/PUT. If the context is null, then it will not be utilized and POST will be assumed. The response data is buffered into a data element on the returned object of type Response.
        Parameters:
        uri - the uri
        context - the context of the invoke
        in - the input stream
        Returns:
        the response
      • call

        public Response call​(java.lang.String uri,
                             ConnectorContext context,
                             java.io.InputStream in,
                             java.io.OutputStream out)
        Description copied from interface: Connector
        Invokes a URI on a remote service. Data is streamed back from the response into the provided output stream. Headers and response state is maintained on the Response object. If the context is null, then it will not be utilized. The response data is not buffered
        Parameters:
        uri - the uri
        context - the context of the invoke
        in - the input stream
        out - the output stream
        Returns:
        the response
      • call

        public Response call​(java.lang.String uri,
                             ConnectorContext context,
                             javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse res)
        Description copied from interface: Connector
        Invokes a URI on a remote service and streams back results to the provided response object. This method makes sure that the full response is propagated into the servlet response, including headers, exception states and more. If the context is null, then it will not be utilized. The response data is not buffered.
        Parameters:
        uri - the uri
        context - the context of the invoke
        req - Request to proxy from
        res - Response to proxy onto
        Returns:
        the response
      • applyRequestHeaders

        protected void applyRequestHeaders​(RemoteClient remoteClient,
                                           ConnectorContext context)
        Stamps headers onto the remote client
        Parameters:
        remoteClient - RemoteClient
        context - ConnectorContext
      • applyRequestAuthentication

        protected void applyRequestAuthentication​(RemoteClient remoteClient,
                                                  ConnectorContext context)
        Stamps Credentials values onto the remote client
        Parameters:
        remoteClient - RemoteClient
        context - ConnectorContext
      • processResponse

        protected void processResponse​(RemoteClient remoteClient,
                                       Response response)
        Retrieves cookie headers from response and stores back onto the Connector Session
        Parameters:
        remoteClient - RemoteClient
        response - Response
      • initRemoteClient

        protected RemoteClient initRemoteClient​(ConnectorContext context)
        Init the RemoteClient object based on the Connector Context. Applies Request headers and authentication as required.
        Returns:
        RemoteClient