Package de.pisa.psa.rst.uti
Class PsaRstApiUti
java.lang.Object
de.pisa.psa.rst.uti.PsaRstApiUti
REST API: utilities
- Since:
- 20.06.2023
- Author:
- weiland
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
implementationstatic class
handler implementation parameterstatic enum
implementation types -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String
booleanToCubes
(String string) convert a string into a PisaCubes booleanstatic PsaRstApiErrFac
createCheckFailedError
(de.pisa.psc.srv.glb.PscExc pex) Create a "PsaRstApiErrCod.CHECK_FAILED" errorstatic String
dateFromCubes
(String string) Convert a PisaCubes date to a string that can be used for the JSONstatic String
dateFromCubes
(String string, boolean timezone) Convert a PisaCubes date to a string that can be used for the JSONstatic String
dateToCubes
(String string) Convert a JSON date to a PisaCubes datestatic String
generateImplementation
(de.pisa.psc.srv.glb.PscSsn ssn, String blob, PsaRstApiUti.ImplementationParameter parameter) generate an implementationstatic Optional<de.pisa.psa.ifc.PsaDtoDat>
Get a configuration recordstatic String
getDtoTitle
(de.pisa.psc.srv.glb.PscSsn ssn, String dto) get the English title for a data objectstatic Optional<de.pisa.psa.ifc.PsaDtoDat>
Get an event recordstatic Optional<de.pisa.psa.ifc.PsaDtoDat>
get a key recordstatic HeaderMap
convert a JSON into a multi valued string map (String to a list of strings)static String
getSourceBlob
(de.pisa.psc.srv.glb.PscSsn ssn, String blob) get source code from a BLOBget the query parameter from an URLstatic boolean
check if a string is an ISO datestatic String
removeQuotes
(String value) Remove leading and trailing single quotes from a stringstatic String
validUrlPath
(String path) Make sure only valid characters are in an URL path.
-
Field Details
-
EVT_TPL_BLB
BLOB: event template class- See Also:
-
OBJ_TPL_BLB
BLOB: object template class- See Also:
-
HEADER_AUTHORIZATION
HTTP Authorization header key- See Also:
-
-
Method Details
-
isIsoDate
check if a string is an ISO date- Parameters:
string
- string to check- Returns:
- true if ISO date format
-
booleanToCubes
convert a string into a PisaCubes boolean- Parameters:
string
- string to convert- Returns:
- y, n or an empty string
-
dateFromCubes
Convert a PisaCubes date to a string that can be used for the JSON- Parameters:
string
- PisaCubes date- Returns:
- UTC date as string in the format yyyy-MM-ddTHH:mm:ssZ
- Throws:
ParseException
-
dateFromCubes
Convert a PisaCubes date to a string that can be used for the JSON- Parameters:
string
- PisaCubes datetimezone
- add the timezone Z to the string?- Returns:
- UTC date as string in the format yyyy-MM-ddTHH:mm:ssZ
- Throws:
ParseException
-
dateToCubes
Convert a JSON date to a PisaCubes date- Parameters:
string
- JSON date- Returns:
- PisaCubes date
-
getConfig
public static Optional<de.pisa.psa.ifc.PsaDtoDat> getConfig(de.pisa.psc.srv.glb.PscSsn ssn, String cnf_gid) throws Exception Get a configuration record- Parameters:
ssn
- sessioncnf_gid
- PSC_GID of the configuration record- Returns:
- data
- Throws:
Exception
-
getKey
public static Optional<de.pisa.psa.ifc.PsaDtoDat> getKey(de.pisa.psc.srv.glb.PscSsn ssn, String key_gid) throws Exception get a key record- Parameters:
ssn
- sessionkey_gid
- PSC_GID of the key record- Returns:
- data
- Throws:
Exception
-
getEvent
public static Optional<de.pisa.psa.ifc.PsaDtoDat> getEvent(de.pisa.psc.srv.glb.PscSsn ssn, String evt_gid) throws Exception Get an event record- Parameters:
ssn
- sessionevt_gid
- PSC_GID of the event record- Returns:
- data
- Throws:
Exception
-
getSourceBlob
get source code from a BLOB- Parameters:
ssn
- sessionblob
- name of the BLOB- Returns:
- source code
- Throws:
Exception
-
generateImplementation
public static String generateImplementation(de.pisa.psc.srv.glb.PscSsn ssn, String blob, PsaRstApiUti.ImplementationParameter parameter) throws Exception generate an implementation- Parameters:
ssn
- sessionblob
- name of the BLOBparameter
- implementation parameter- Returns:
- source code
- Throws:
Exception
-
getUrlQueryParameter
get the query parameter from an URL- Parameters:
url
- URL to parse- Returns:
- map with keys and values
-
getMultivaluedStringMap
public static HeaderMap getMultivaluedStringMap(String json) throws com.fasterxml.jackson.core.JsonProcessingException convert a JSON into a multi valued string map (String to a list of strings)- Parameters:
json
- JSON to parse- Returns:
- map (never null)
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
validUrlPath
Make sure only valid characters are in an URL path. Invalid characters will be replaced by a -- Parameters:
path
- path to check- Returns:
- the path with only the valid characters
-
getDtoTitle
get the English title for a data object- Parameters:
ssn
- sessiondto
- data object descriptor- Returns:
- title
- Throws:
Exception
-
createCheckFailedError
Create a "PsaRstApiErrCod.CHECK_FAILED" error- Parameters:
pex
- PisaCubes exception- Returns:
- error factory
-
removeQuotes
Remove leading and trailing single quotes from a string- Parameters:
value
- value to change- Returns:
- new string without quotes
-