Klasse PsaRstApiEvtHdl

java.lang.Object
de.pisa.psa.rst.hdl.PsaRstApiEvtHdl
Alle implementierten Schnittstellen:
AutoCloseable
Bekannte direkte Unterklassen:
PsaRstApiEvtHdlIn, PsaRstApiEvtHdlOut

public abstract class PsaRstApiEvtHdl extends Object implements AutoCloseable
REST API: event handler
Seit:
21.06.2023
Autor:
weiland
  • Felddetails

    • Max_Records

      protected int Max_Records
      the maximum number of records that are returned
    • Default_User

      protected String Default_User
      default session user
    • Default_External_Language

      protected String Default_External_Language
      the default language for external logins
    • Force_IAM_User

      protected boolean Force_IAM_User
      if IAM is used, the email should belong to an unique user
  • Konstruktordetails

    • PsaRstApiEvtHdl

      public PsaRstApiEvtHdl(PsaRstApiEvtHdlDat data)
      Constructor
      Parameter:
      data - event data
  • Methodendetails

    • handleEvent

      public abstract javax.ws.rs.core.Response handleEvent() throws Exception
      Handle the event
      Gibt zurück:
      response
      Löst aus:
      Exception
    • setActiveEventHandler

      public static void setActiveEventHandler(de.pisa.psc.srv.glb.PscSsn ssn, PsaRstApiEvtHdl handler)
      set the active event handler for a session
      Parameter:
      ssn - session
      handler -
    • getActiveEventHandler

      public static PsaRstApiEvtHdl getActiveEventHandler(de.pisa.psc.srv.glb.PscSsn ssn)
      get the active event handler from a session
      Parameter:
      ssn - session
      Gibt zurück:
      handler instance. null if currently no active event handler
    • noEventLogging

      public boolean noEventLogging()
      don't log the event
      Gibt zurück:
      if true the event and all logs will be deleted
    • getSsn

      public de.pisa.psc.srv.glb.PscSsn getSsn() throws Exception
      get a session
      Gibt zurück:
      session
      Löst aus:
      Exception
    • getSysSsn

      protected de.pisa.psc.srv.glb.PscSsn getSysSsn() throws Exception
      get a SYSTEM session
      Gibt zurück:
      session
      Löst aus:
      Exception
    • getSsnUsr

      protected String getSsnUsr() throws Exception
      get the user for the database session
      Gibt zurück:
      user name
      Löst aus:
      Exception
    • getIAMUser

      protected String getIAMUser() throws Exception
      get the session user from the IAM token
      Gibt zurück:
      user name, null if no IAM token used
      Löst aus:
      Exception
    • setExternalLanguage

      protected void setExternalLanguage() throws Exception
      set the event language based on the IAM login
      Löst aus:
      Exception
    • getExternalCommunicationLanguage

      protected String getExternalCommunicationLanguage(de.pisa.psc.srv.glb.PscSsn ssn) throws Exception
      get the communication language from an external login
      Parameter:
      ssn - session
      Gibt zurück:
      language identifier
      Löst aus:
      Exception
    • findEmail

      public Set<String> findEmail(String email)
      find a contact by the email address
      Parameter:
      email - email to search
      Gibt zurück:
      set of contact gids that are associated to this email address
    • isIAMUser

      public boolean isIAMUser()
      check if the session user is based on IAM
      Gibt zurück:
      true if IAM user
    • fetchIAMContact

      public de.pisa.psc.srv.dto.PscDto fetchIAMContact(String dto_dsc) throws Exception
      fetch a contact based on the IAM email address
      Parameter:
      dto_dsc - descriptor of the contact data object
      Gibt zurück:
      contact data abject with one row
      Löst aus:
      Exception - if the contact was not found or is ambiguous
    • fetchContact

      public de.pisa.psc.srv.dto.PscDto fetchContact(String email, String dto_dsc) throws Exception
      fetch a contact based on an email address
      Parameter:
      email - email address to search
      dto_dsc - descriptor of the contact data object
      Gibt zurück:
      contact data abject with one row
      Löst aus:
      Exception - if the contact was not found or is ambiguous
    • cloneRecords

      protected de.pisa.psc.srv.dto.PscDto cloneRecords(String dto_dsc, Set<String> gid_set, int max) throws Exception
      clone records into a data object
      Parameter:
      dto_dsc - the descriptor of the data object
      gid_set - a set of PSC_GIDs
      max - maximum number of records to clone
      Gibt zurück:
      the data object with the records
      Löst aus:
      Exception
    • getData

      public PsaRstApiEvtHdlDat getData()
      get the event data
      Gibt zurück:
      data
    • getMessage

      public String getMessage(String descriptor, String... parameters) throws Exception
      get a message in the language of the request
      Parameter:
      descriptor - message descriptor
      parameters - parameters (placeholders) of the message
      Gibt zurück:
      message text. may be empty if the message is not found
      Löst aus:
      Exception
    • setJsonIncludeEmpty

      public void setJsonIncludeEmpty(boolean include)
      include empty values in the JSON?
      Parameter:
      include - true to include empty values (default=false)
    • getJsonIncludeEmpty

      public boolean getJsonIncludeEmpty()
      are empty values included in the JSON?
      Gibt zurück:
      true if empty values are included
    • addJsonMixin

      public void addJsonMixin(Class<?> target, Class<?> mixin)
      Mix-in annotations to the JSON generation
      Parameter:
      target - Class (or interface) whose annotations to effectively override
      mixin - Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary
    • toJson

      public String toJson(Object object) throws Exception
      convert an object to JSON
      Parameter:
      object - object to convert
      Gibt zurück:
      JSON
      Löst aus:
      Exception
    • getValueBuffer

      public ValueBuffer getValueBuffer()
      get the value buffer of this event handler
      Gibt zurück:
      buffer
    • close

      public void close() throws Exception
      Angegeben von:
      close in Schnittstelle AutoCloseable
      Löst aus:
      Exception
      Siehe auch:
    • newDto

      public de.pisa.psc.srv.dto.PscDto newDto(String dsc) throws Exception
      create a new data object
      Parameter:
      dsc - descriptor of the data object
      Gibt zurück:
      data object
      Löst aus:
      Exception
    • newObject

      protected PsaRstApiObjBas newObject(Class<? extends PsaRstApiObjBas> object_class) throws Exception
      create a new JSON object
      Parameter:
      object_class - class of the JSON object
      Gibt zurück:
      object
      Löst aus:
      Exception
    • fetchRecord

      protected de.pisa.psc.srv.dto.PscDto fetchRecord() throws Exception
      fetch the record that is defined by the dataobject and GID in the event record
      Gibt zurück:
      dataobject with the record
      Löst aus:
      Exception
      javax.ws.rs.WebApplicationException - is the record was not found or more than one record was found
    • getFetchRecordKeyField

      protected String getFetchRecordKeyField(de.pisa.psc.srv.dto.PscDto dto)
      get the key field to search on in fetchRecord
      Parameter:
      dto - data object
      Gibt zurück:
      field descriptor
    • fetchRecord

      protected javax.ws.rs.core.Response fetchRecord(Class<? extends PsaRstApiObjBas> object_class) throws Exception
      fetch a record and return the JSON response
      Parameter:
      object_class - class of the JSON object
      Gibt zurück:
      response
      Löst aus:
      Exception
    • loadRecord

      protected javax.ws.rs.core.Response loadRecord(de.pisa.psc.srv.dto.PscDto dto, int row, Class<? extends PsaRstApiObjBas> object_class) throws Exception
      load a record into to a JSON response
      Parameter:
      dto - data object
      row - row to load
      object_class - class of the JSON object
      Gibt zurück:
      response
      Löst aus:
      Exception
    • buildResponse

      protected javax.ws.rs.core.Response buildResponse(String json)
      build the response
      Parameter:
      json - entity data
      Gibt zurück:
      a 200 OK status with an application/json entity
    • queryRecords

      protected de.pisa.psc.srv.dto.PscDto queryRecords(PsaRstApiQue query, Class<?> object_class) throws Exception
      set the query on a data object based on the request query
      Parameter:
      query - query
      object_class - class of JSON object
      Gibt zurück:
      data object with a query and an order
      Löst aus:
      Exception
    • queryRecordsSetQuery

      protected void queryRecordsSetQuery(PsaRstApiQue query, de.pisa.psc.srv.dto.PscDto dto, List<PsaRstApiMapFld.MapEntry> field_mapping) throws Exception
      Set the queries on a data object
      Parameter:
      query - query
      dto - data object
      field_mapping - field mapping
      Löst aus:
      Exception
    • mapQuery

      protected Optional<String> mapQuery(de.pisa.psc.srv.dto.PscDto dto, de.pisa.psc.srv.dto.PscFld field, String query) throws Exception
      map a query string to a string that can be used by the data object
      Parameter:
      dto - data object
      field - field
      query - query
      Gibt zurück:
      mapped query
      Löst aus:
      Exception
    • queryRecordsAddSort

      protected void queryRecordsAddSort(PsaRstApiQue query, de.pisa.psc.srv.dto.PscDto dto, List<PsaRstApiMapFld.MapEntry> field_mapping) throws de.pisa.psc.srv.glb.PscExc
      Add the sorting to a data object
      Parameter:
      query - query
      dto - data object
      field_mapping - field mapping
      Löst aus:
      de.pisa.psc.srv.glb.PscExc
    • queryRecord

      protected de.pisa.psc.srv.dto.PscDto queryRecord() throws Exception
      set the primary key query on a data object
      Gibt zurück:
      new data object with the query
      Löst aus:
      Exception
    • getQuery

      protected PsaRstApiQue getQuery() throws Exception
      get the query from the event data
      Gibt zurück:
      query
      Löst aus:
      Exception
    • getContinuation

      protected String getContinuation() throws Exception
      get the continuation key
      Gibt zurück:
      key
      Löst aus:
      Exception
    • fetchRecords

      protected javax.ws.rs.core.Response fetchRecords(Class<? extends PsaRstApiObjBas> object_class) throws Exception
      fetch records and return the JSON response
      Parameter:
      object_class - class of the JSON object
      Gibt zurück:
      response
      Löst aus:
      Exception
    • getMaxRecords

      protected int getMaxRecords(de.pisa.psc.srv.dto.PscDto dto) throws Exception
      get the maximum number of records to fetch
      Parameter:
      dto - data object to fetch
      Gibt zurück:
      number of records
      Löst aus:
      Exception
    • newPsaRstApiObjLis

      protected <T> PsaRstApiObjLis<T> newPsaRstApiObjLis()
      create a new result list object
      Typparameter:
      T - type of the objects in the list
      Gibt zurück:
      list
    • fetchEurekaRecords

      protected javax.ws.rs.core.Response fetchEurekaRecords(PsaRstApiQue query, Class<? extends PsaRstApiObjBas> object_class) throws Exception
      fetch records with the use of EUREKA and return the JSON response
      Parameter:
      query - query
      object_class - class of the JSON object
      Gibt zurück:
      response
      Löst aus:
      Exception
    • queryEurekaRecords

      protected void queryEurekaRecords(PsaRstApiQue query, de.pisa.psc.srv.dto.PscDto dto, de.pisa.psa.dto.PsaRecClo rec_clo, List<PsaRstApiMapFld.MapEntry> field_mapping) throws Exception
      set queries for EUREKA
      Parameter:
      query - query
      dto - target data object
      rec_clo - record cloner
      field_mapping - field mapping
      Löst aus:
      Exception
    • getEurekaHighlighting

      protected PsaRstApiEvtHdl.EurekaHighlighting getEurekaHighlighting() throws Exception
      get the highlight configuration for the EUREKA search
      Gibt zurück:
      configuration
      Löst aus:
      Exception
    • fetchEureka

      protected javax.ws.rs.core.Response fetchEureka() throws Exception
      fetch ERUEKA result and return the JSON response
      Gibt zurück:
      response
      Löst aus:
      Exception
    • getEurekaDtoQuery

      protected EurekaDtoQuery getEurekaDtoQuery() throws Exception
      get the EUREKA query conditions for the configured data object
      Gibt zurück:
      query
      Löst aus:
      Exception
    • queryEureka

      protected EurekaResult queryEureka(String query, String[] dto_query, String key_001, String key_002, String key_003, PsaRstApiEvtHdl.EurekaHighlighting eureka_highlighting) throws Exception
      query the EUREKA index
      Parameter:
      query - query string
      dto_query - dataobject query
      key_001 - KEY_001 query
      key_002 - KEY_002 query
      key_003 - KEY_003 query
      eureka_highlighting - highlighting configuration for the occurrences in the preview
      Gibt zurück:
      search result
      Löst aus:
      Exception
    • getEurekaQueryField

      protected de.pisa.psa.dto.psa_idx.itf.DocFld getEurekaQueryField()
      get the field to query with EUREKA
      Gibt zurück:
      document field
    • getField

      protected de.pisa.psc.srv.dto.PscFld getField(de.pisa.psc.srv.dto.PscDto dto, String field_name, List<PsaRstApiMapFld.MapEntry> field_mapping) throws de.pisa.psc.srv.glb.PscExc
      get the data object field for a JSON field name
      Parameter:
      dto - data object
      field_name - JSON field name
      field_mapping - field mapping
      Gibt zurück:
      field
      Löst aus:
      de.pisa.psc.srv.glb.PscExc
      javax.ws.rs.ClientErrorException - if the field was not found