Package de.pisa.psa.rst.svc
Class PsaRstApiSvcBas
- java.lang.Object
-
- de.pisa.psa.rst.svc.PsaRstApiSvcBas
-
- Direct Known Subclasses:
IplWsvPsaRstApiSvc
,IplWsvPsaRstApiTestSvc
public class PsaRstApiSvcBas extends java.lang.Object
REST API: service base class- Since:
- 23.05.2023
- Author:
- weiland
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COOKIE_JRAUTH
cookie name: IAM authentication tokenprotected java.lang.String
IAM_Key
key for the IAM propertiesprotected java.lang.String
IAM_Service
service URL for the IAM tokenprotected org.glassfish.jersey.server.ContainerRequest
Request
container request contextprotected 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 recordprotected java.lang.String[]
getAuthorizationHeader()
get the value of the Authorization headerPsaRstApiEvtHdlDat
getData()
get the request dataprotected de.pisa.psa.com.ext_ema.neoletter.json.UserInfo
getIAMUserInfo()
get the current IAM user informationprotected 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 informationprotected java.lang.String
getLanguageFromRequest(de.pisa.psc.srv.glb.PscSsn ssn)
get the language identifier from the requests accepted languagesprotected java.util.Optional<javax.ws.rs.core.Cookie>
getRequestCookie(java.lang.String name)
get a cookie from the requestprotected java.lang.String
getRequestHeader(java.lang.String key)
get a request header valueprotected javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String>
getRequestHeaders()
get all request headerprotected java.util.List<java.lang.String>
getRequestLanguages()
get the acceptable languages for this requestprotected java.lang.String
getRequestMethod()
get the request methodprotected java.lang.String
getRequestPath()
get the request pathprotected java.lang.String
getRequestQuery()
get the request query stringprotected 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 requestprotected void
initialize(de.pisa.psc.srv.glb.PscSsn ssn)
initialize the requestprotected boolean
isSynchronous()
check if the request should be handled synchronouslyprotected 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 configurationprotected de.pisa.psc.srv.glb.PscSsn
newSsn()
get a new sessionjavax.ws.rs.core.Response
processEvent()
start processing the current eventvoid
setConfig(de.pisa.psa.ifc.PsaDtoDat config)
set the configurationvoid
setEvent(de.pisa.psa.ifc.PsaDtoDat event)
set the eventprotected void
validateIAM(de.pisa.psc.srv.glb.PscSsn ssn)
validate the IAM tokenprotected void
validateKey(de.pisa.psc.srv.glb.PscSsn ssn)
validate the authorization key
-
-
-
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
-
-
Method Detail
-
getData
public final PsaRstApiEvtHdlDat getData()
get the request data- Returns:
- data
-
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 recordbody
- body of the requestuser
- the session user for the eventlanguage
- 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
- sessionmethod
- request methodpath_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
- sessionaccount_id
- IAM account IDtoken
- 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
- sessiongid
- PSC_GID of the requested recordbody
- body of the requestuser
- the session user for the eventlanguage
- language of the data to returnstore
- 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
-
-