Class DelegateHandler

  • All Implemented Interfaces:
    org.swisspush.gateleen.core.logging.LoggableResource, org.swisspush.gateleen.core.refresh.Refreshable

    public class DelegateHandler
    extends Object
    implements org.swisspush.gateleen.core.refresh.Refreshable, org.swisspush.gateleen.core.logging.LoggableResource
    Allows to create delegates. E.g.
    Definition of a delegate is stored in a resource called definition within the specified delegate.
    PUT /gateleen/server/delegate/v1/delegates/user-zip-copy/definition
        {
            "methods": [ "PUT", "DELETE" ],
            "pattern": "([^/]*)/(.*)",
            "requests": [
                {
                     "headers" : [],
                     "uri": "/gateleen/server/copy",
                     "method": "POST",
                     "payload": {
                        "source": "/gateleen/$1?expand=100&zip=true",
                        "destination": "/gateleen/zips/users/$1.zip"
                    }
                }
            ]
        }
    
     
    To trigger an execution, it suffice to perform a PUT request on the virtual collection execution within the specified delegate.
    PUT /gateleen/server/delegate/v1/delegates/user-zip-copy/execution/<...>
    Author:
    https://github.com/ljucam [Mario Ljuca]
    • Constructor Detail

      • DelegateHandler

        public DelegateHandler​(io.vertx.core.Vertx vertx,
                               io.vertx.core.http.HttpClient selfClient,
                               org.swisspush.gateleen.core.storage.ResourceStorage delegateStorage,
                               org.swisspush.gateleen.monitoring.MonitoringHandler monitoringHandler,
                               String delegatesUri,
                               Map<String,​Object> properties,
                               io.vertx.core.Handler<Void> doneHandler)
        Creates a new instance of the DelegateHandler.
        Parameters:
        vertx - vertx
        selfClient - selfClient
        delegateStorage - delegateStorage - only used for storing delegates
        monitoringHandler - monitoringHandler
        delegatesUri - delegate root
        properties - properties
        doneHandler - doneHandler
    • Method Detail

      • init

        public void init()
        This method initializes the Handler. It should be called after the router is successfully established.
      • getDelegateName

        protected String getDelegateName​(String uri)
        Tries to extract the name of the delegate out of the incoming uri.
        Parameters:
        uri - original request uri
        Returns:
        the name of the delegate or null if nothing matches
      • handle

        public boolean handle​(io.vertx.core.http.HttpServerRequest request)
        Checks if the DelegateHandler is responsible for this request. If so it processes the request and returns true, otherwise it returns false.
        Parameters:
        request - original request
        Returns:
        true if processed, false otherwise
      • refresh

        public void refresh()
        Specified by:
        refresh in interface org.swisspush.gateleen.core.refresh.Refreshable
      • enableResourceLogging

        public void enableResourceLogging​(boolean resourceLoggingEnabled)
        Specified by:
        enableResourceLogging in interface org.swisspush.gateleen.core.logging.LoggableResource