Class PsaRstApiSvcBas

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COOKIE_JRAUTH
      cookie name: IAM authentication token
      protected java.lang.String IAM_Key
      key for the IAM properties
      protected java.lang.String IAM_Service
      service URL for the IAM token
      protected org.glassfish.jersey.server.ContainerRequest Request
      container request context
      protected java.lang.String User
      the session user
    • Constructor Summary

      Constructors 
      Constructor Description
      PsaRstApiSvcBas()
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void createEvent​(de.pisa.psc.srv.glb.PscSsn ssn, java.lang.String gid, java.lang.String body, java.lang.String user, java.lang.String language, boolean store)
      create an event record
      protected java.lang.String[] getAuthorizationHeader()
      get the value of the Authorization header
      PsaRstApiEvtHdlDat getData()
      get the request data
      protected de.pisa.psa.com.ext_ema.neoletter.json.UserInfo getIAMUserInfo()
      get the current IAM user information
      protected de.pisa.psa.com.ext_ema.neoletter.json.UserInfo getIAMUserInfo​(de.pisa.psc.srv.glb.PscSsn ssn, java.lang.String account_id, java.lang.String token)
      get the IAM user information
      protected java.lang.String getLanguageFromRequest​(de.pisa.psc.srv.glb.PscSsn ssn)
      get the language identifier from the requests accepted languages
      protected java.util.Optional<javax.ws.rs.core.Cookie> getRequestCookie​(java.lang.String name)
      get a cookie from the request
      protected java.lang.String getRequestHeader​(java.lang.String key)
      get a request header value
      protected javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> getRequestHeaders()
      get all request header
      protected java.util.List<java.lang.String> getRequestLanguages()
      get the acceptable languages for this request
      protected java.lang.String getRequestMethod()
      get the request method
      protected java.lang.String getRequestPath()
      get the request path
      protected java.lang.String getRequestQuery()
      get the request query string
      protected javax.ws.rs.core.Response handleRequest​(java.lang.String gid, java.lang.String body, java.lang.String user, java.lang.String language)
      handle an incoming request
      protected void initialize​(de.pisa.psc.srv.glb.PscSsn ssn)
      initialize the request
      protected boolean isSynchronous()
      check if the request should be handled synchronously
      protected de.pisa.psa.ifc.PsaDtoDat loadConfiguration​(de.pisa.psc.srv.glb.PscSsn ssn, java.lang.String method, java.util.List<java.lang.String> path_tokens)
      load the configuration
      protected de.pisa.psc.srv.glb.PscSsn newSsn()
      get a new session
      javax.ws.rs.core.Response processEvent()
      start processing the current event
      void setConfig​(de.pisa.psa.ifc.PsaDtoDat config)
      set the configuration
      void setEvent​(de.pisa.psa.ifc.PsaDtoDat event)
      set the event
      protected void validateIAM​(de.pisa.psc.srv.glb.PscSsn ssn)
      validate the IAM token
      protected void validateKey​(de.pisa.psc.srv.glb.PscSsn ssn)
      validate the authorization key
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • Request

        @Context
        protected org.glassfish.jersey.server.ContainerRequest Request
        container request context
      • User

        protected java.lang.String User
        the session user
      • IAM_Key

        protected java.lang.String IAM_Key
        key for the IAM properties
      • IAM_Service

        protected java.lang.String IAM_Service
        service URL for the IAM token
      • COOKIE_JRAUTH

        public static final java.lang.String COOKIE_JRAUTH
        cookie name: IAM authentication token
        See Also:
        Constant Field Values
    • Constructor Detail

      • PsaRstApiSvcBas

        public PsaRstApiSvcBas()
        Constructor
    • Method Detail

      • setConfig

        public final void setConfig​(de.pisa.psa.ifc.PsaDtoDat config)
        set the configuration
        Parameters:
        config - configuration object
      • setEvent

        public final void setEvent​(de.pisa.psa.ifc.PsaDtoDat event)
        set the event
        Parameters:
        event - event object
      • getRequestHeader

        protected java.lang.String getRequestHeader​(java.lang.String key)
        get a request header value
        Parameters:
        key - key of the header
        Returns:
        value
      • getRequestHeaders

        protected javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> getRequestHeaders()
        get all request header
        Returns:
        headers
      • getRequestCookie

        protected java.util.Optional<javax.ws.rs.core.Cookie> getRequestCookie​(java.lang.String name)
        get a cookie from the request
        Parameters:
        name - name of the cookie
        Returns:
        cookie
      • getRequestPath

        protected java.lang.String getRequestPath()
        get the request path
        Returns:
        path
      • getRequestMethod

        protected java.lang.String getRequestMethod()
        get the request method
        Returns:
        method
      • getRequestQuery

        protected java.lang.String getRequestQuery()
        get the request query string
        Returns:
        query
      • getRequestLanguages

        protected java.util.List<java.lang.String> getRequestLanguages()
        get the acceptable languages for this request
        Returns:
        list of locale (e.g. de_DE, en_US)
      • getAuthorizationHeader

        protected java.lang.String[] getAuthorizationHeader()
        get the value of the Authorization header
        Returns:
        prefix and token (Strings are never null)
      • newSsn

        protected de.pisa.psc.srv.glb.PscSsn newSsn()
                                             throws java.lang.Exception
        get a new session
        Returns:
        session
        Throws:
        java.lang.Exception
      • handleRequest

        protected javax.ws.rs.core.Response handleRequest​(java.lang.String gid,
                                                          java.lang.String body,
                                                          java.lang.String user,
                                                          java.lang.String language)
                                                   throws java.lang.Exception
        handle an incoming request
        Parameters:
        gid - PSC_GID of the requested record
        body - body of the request
        user - the session user for the event
        language - language of the data to return
        Returns:
        the generated response
        Throws:
        java.lang.Exception
      • initialize

        protected void initialize​(de.pisa.psc.srv.glb.PscSsn ssn)
                           throws java.lang.Exception
        initialize the request
        Parameters:
        ssn - session
        Throws:
        java.lang.Exception
      • loadConfiguration

        protected de.pisa.psa.ifc.PsaDtoDat loadConfiguration​(de.pisa.psc.srv.glb.PscSsn ssn,
                                                              java.lang.String method,
                                                              java.util.List<java.lang.String> path_tokens)
                                                       throws java.lang.Exception
        load the configuration
        Parameters:
        ssn - session
        method - request method
        path_tokens - request path tokens
        Returns:
        configuration dto
        Throws:
        java.lang.Exception
      • validateKey

        protected void validateKey​(de.pisa.psc.srv.glb.PscSsn ssn)
                            throws java.lang.Exception
        validate the authorization key
        Parameters:
        ssn - session
        Throws:
        java.lang.Exception
      • validateIAM

        protected void validateIAM​(de.pisa.psc.srv.glb.PscSsn ssn)
                            throws java.lang.Exception
        validate the IAM token
        Parameters:
        ssn - session
        Throws:
        java.lang.Exception
      • getIAMUserInfo

        protected de.pisa.psa.com.ext_ema.neoletter.json.UserInfo getIAMUserInfo​(de.pisa.psc.srv.glb.PscSsn ssn,
                                                                                 java.lang.String account_id,
                                                                                 java.lang.String token)
                                                                          throws java.lang.Exception
        get the IAM user information
        Parameters:
        ssn - session
        account_id - IAM account ID
        token - IAM token
        Returns:
        information
        Throws:
        java.lang.Exception - if the token is invalid
      • getIAMUserInfo

        protected final de.pisa.psa.com.ext_ema.neoletter.json.UserInfo getIAMUserInfo()
        get the current IAM user information
        Returns:
        information
      • createEvent

        protected void createEvent​(de.pisa.psc.srv.glb.PscSsn ssn,
                                   java.lang.String gid,
                                   java.lang.String body,
                                   java.lang.String user,
                                   java.lang.String language,
                                   boolean store)
                            throws java.lang.Exception
        create an event record
        Parameters:
        ssn - session
        gid - PSC_GID of the requested record
        body - body of the request
        user - the session user for the event
        language - language of the data to return
        store - store the event record in the database?
        Throws:
        java.lang.Exception
      • getLanguageFromRequest

        protected java.lang.String getLanguageFromRequest​(de.pisa.psc.srv.glb.PscSsn ssn)
                                                   throws java.lang.Exception
        get the language identifier from the requests accepted languages
        Parameters:
        ssn - session
        Returns:
        identifier or an empty string if the locale is unknown
        Throws:
        java.lang.Exception
      • isSynchronous

        protected boolean isSynchronous()
                                 throws java.lang.Exception
        check if the request should be handled synchronously
        Returns:
        true for a synchronous handling
        Throws:
        java.lang.Exception
      • processEvent

        public javax.ws.rs.core.Response processEvent()
                                               throws java.lang.Exception
        start processing the current event
        Returns:
        the generated response
        Throws:
        java.lang.Exception