org.appng.core.controller.handler

## Class ServiceRequestHandler

- java.lang.Object
- - org.appng.core.controller.handler.ServiceRequestHandler

- All Implemented Interfaces:
    RequestHandler

      public class ServiceRequestHandler
      extends Object
      implements RequestHandler

  A `RequestHandler` which handles `HttpServletRequest`s for different types of services.
  The schema for a complete path to a service is

  `<site-domain>/<service-path>/<site-name>/<application-name>/<service-type/<service-name>/<additional-params>`

  The service-path is configurable, see `SiteProperties.SERVICE_PATH`.
  Supported service-types are:
  - webservice
    Used for calling a `Webservice` or `AttachmentWebservice`.
    Example:
    - http://localhost:8080/service/manager/appng-manager/webservice/logViewer<get-params>
  - datasource
    Used for calling a datasource provided by a `Application`.
    Provides different formats: json,xml and html.
    Examples:
    - http://localhost:8080/service/manager/appng-manager/datasource/xml/sites
    - http://localhost:8080/service/manager/appng-manager/datasource/json/sites
  - action
    Used for calling an action provided by a `Application`.
    Provides different formats: json,xml and html.
    Examples:
    - http://localhost:8080/service/manager/appng-manager/action/xml/siteEvent/create?form_action=create
    - http://localhost:8080/service/manager/appng-manager/action/json/siteEvent/create?form_action=create
  - soap
    Used for calling a `SoapService` provided by a `Application`.
    Example (GET for the wsdl):
    - http://localhost:8080/service/manager/appng-demoapplication/soap/PersonService/PersonService.wsdl
    POST for the SOAP-Request:
    - http://localhost:8080/service/manager/appng-demoapplication/soap/PersonService
  - rest
    Used for addressing a `RestController` offered by an `Application`
    Example:
    - http://localhost:8080/service/manager/appng-manager/rest/sites
    - http://localhost:8080/service/manager/appng-manager/rest/site/1
  Author:
    Matthias Müller

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `FORMAT_JSON`
    `protected static String` | `FORMAT_XML`

    - ### Fields inherited from interface org.appng.core.controller.handler.RequestHandler

      `FORWARDED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceRequestHandler(MarshallService marshallService)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `callWebservice(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, ApplicationRequest applicationRequest, Environment env, Site site, ApplicationProvider application, String webserviceName)`
    `void` | `handle(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, Environment environment, Site site, PathInfo path)` Handles the given `HttpServletRequest`,
    `protected void` | `handleRest(AccessibleApplication application, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)`
    `protected void` | `handleSoap(Site site, AccessibleApplication application, Environment environment, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)`
    `protected String` | `writeJson(Object data)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### FORMAT_JSON

          protected static final String FORMAT_JSON

      See Also:
        Constant Field Values

    - #### FORMAT_XML

          protected static final String FORMAT_XML

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ServiceRequestHandler

          public ServiceRequestHandler(MarshallService marshallService)

  - ### Method Detail

    - #### handle

          public void handle(javax.servlet.http.HttpServletRequest servletRequest,
                             javax.servlet.http.HttpServletResponse servletResponse,
                             Environment environment,
                             Site site,
                             PathInfo path)
                      throws IOException

      Description copied from interface: `RequestHandler`
      Handles the given `HttpServletRequest`,
      Specified by:
        `handle` in interface `RequestHandler`
      Parameters:
        `servletRequest` - the current `HttpServletRequest`
        `servletResponse` - the current `HttpServletResponse`
        `environment` - the current `Environment`
        `site` - the current `Site`
        `path` - the current `PathInfo`
      Throws:
        `IOException` - if a resource could not be found

    - #### writeJson

          protected String writeJson(Object data)
                              throws IOException,
                                     com.fasterxml.jackson.core.JsonGenerationException,
                                     com.fasterxml.jackson.databind.JsonMappingException

      Throws:
        `IOException`
        `com.fasterxml.jackson.core.JsonGenerationException`
        `com.fasterxml.jackson.databind.JsonMappingException`

    - #### handleSoap

          protected void handleSoap(Site site,
                                    AccessibleApplication application,
                                    Environment environment,
                                    javax.servlet.http.HttpServletRequest servletRequest,
                                    javax.servlet.http.HttpServletResponse servletResponse)
                             throws Exception

      Throws:
        `Exception`

    - #### handleRest

          protected void handleRest(AccessibleApplication application,
                                    javax.servlet.http.HttpServletRequest servletRequest,
                                    javax.servlet.http.HttpServletResponse servletResponse)
                             throws Exception

      Throws:
        `Exception`

    - #### callWebservice

          protected void callWebservice(javax.servlet.http.HttpServletRequest servletRequest,
                                        javax.servlet.http.HttpServletResponse servletResponse,
                                        ApplicationRequest applicationRequest,
                                        Environment env,
                                        Site site,
                                        ApplicationProvider application,
                                        String webserviceName)
                                 throws BusinessException,
                                        IOException

      Throws:
        `BusinessException`
        `IOException`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.