Class InvokableAPIDescriptor

    • Constructor Detail

      • InvokableAPIDescriptor

        public InvokableAPIDescriptor​(@Nonnull
                                      IAPIDescriptor aDescriptor,
                                      @Nonnull @Nonempty
                                      String sPath,
                                      @Nonnull
                                      com.helger.commons.collection.impl.ICommonsOrderedMap<String,​String> aPathVariables)
        Constructor
        Parameters:
        aDescriptor - The matching IAPIDescriptor. Never null.
        sPath - The URL path requested by the user, relative to the servlet.
        aPathVariables - All resolved path variables, if the path descriptor contains variable elements.
    • Method Detail

      • getAPIDescriptor

        @Nonnull
        public final IAPIDescriptor getAPIDescriptor()
        Returns:
        The original API descriptor. Never null.
      • getPath

        @Nonnull
        @Nonempty
        public final String getPath()
        Returns:
        The URL path requested by the user, relative to the servlet. Never null nor empty.
      • getAllPathVariables

        @Nonnull
        @ReturnsMutableCopy
        public final com.helger.commons.collection.impl.ICommonsOrderedMap<String,​String> getAllPathVariables()
        Returns:
        All resolved path variables, if the path descriptor contains variable elements. Never null but maybe empty.
      • canExecute

        public boolean canExecute​(@Nonnull
                                  com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope,
                                  @Nonnull
                                  com.helger.commons.mutable.MutableInt aStatusCode)
        Check if all pre-requisites are handled correctly. This checks if all required headers and params are present.
        Parameters:
        aRequestScope - The request scope to validate.
        aStatusCode - The mutable int to hold the status code to be returned in case of error. Default is HTTP 400, bad request.
        Returns:
        true if all prerequisites are fulfilled.
      • invokeAPI

        public void invokeAPI​(@Nonnull
                              com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope,
                              @Nonnull
                              com.helger.servlet.response.UnifiedResponse aUnifiedResponse)
                       throws Exception
        Invoke the Java callback underlying this API descriptor. Note: this method may only be invoked after canExecute(IRequestWebScopeWithoutResponse,MutableInt) returned true!
        Parameters:
        aRequestScope - Current request scope. Never null.
        aUnifiedResponse - Current response. Never null.
        Throws:
        Exception - In case the Java callback throws one
        IllegalStateException - In case the executor factory creates a null executor.