public class ApiSerializer extends Object
| Constructor and Description |
|---|
ApiSerializer(LoggerFacade logger) |
| Modifier and Type | Method and Description |
|---|---|
Optional<org.json.JSONObject> |
findByConfigName(org.json.JSONArray configs,
String configName)
returns the JSONObject for the item in configs with "Name" matching name if found;
otherwise Optional.empty()
|
Optional<Boolean> |
getBooleansFrom(org.json.JSONObject jsonObject,
String... keys)
returns true if all given keys in jsonObject are true
|
Optional<List<ClientIdNamePair>> |
getClientIdNamePairs(org.json.JSONArray clients)
returns a list of ClientIdNamePair objects extracted from given JSONArray
|
Optional<List<String>> |
getConfigNames(org.json.JSONArray configs)
returns List{String} of all scan config names found in configs
|
boolean |
getIsSuccess(org.json.JSONObject jsonObject)
returns the value of "IsSuccess" from the provided jsonObject if non-null; otherwise, false
|
boolean |
getResultIsSuccess(org.json.JSONObject jsonObject)
returns the value of "IsSuccess" and "Result" from the provided jsonObject if non-null; otherwise, false
|
Optional<String> |
getScanConfigId(org.json.JSONObject config) |
String |
getScanConfigXml(freemarker.template.Template template,
String name,
URL targetURL)
constructs scan config XML document using template with provided name and target
|
ScanResult |
getScanResult(org.json.JSONObject jsonObject) |
Optional<String> |
getStatus(org.json.JSONObject jsonObject)
returns the value of "Status" from the provided jsonObject if non-null and Status is not empty;
otherwise
|
Optional<String> |
getTokenOrEmpty(org.json.JSONObject jsonObject)
if jsonObject contains "IsSuccess" with value of true then value of "Token"
if non-empty is returned within an Optional; otherwise Optional.empty()
|
public ApiSerializer(LoggerFacade logger)
public Optional<String> getTokenOrEmpty(org.json.JSONObject jsonObject)
jsonObject - JSON object containing "IsSuccess" and "Token"public boolean getIsSuccess(org.json.JSONObject jsonObject)
jsonObject - JSON object containing the "IsSuccess" value to extractpublic ScanResult getScanResult(org.json.JSONObject jsonObject)
public boolean getResultIsSuccess(org.json.JSONObject jsonObject)
jsonObject - JSON object containing the "IsSuccess" value to extractpublic Optional<String> getStatus(org.json.JSONObject jsonObject)
jsonObject - JSON object containing "Status" keypublic Optional<List<String>> getConfigNames(org.json.JSONArray configs)
configs - JSONArray of scan config JSONObjects containing "Name" keypublic String getScanConfigXml(freemarker.template.Template template, String name, URL targetURL) throws IOException, freemarker.template.TemplateException
template - template used to produce XMLname - name of the new scan configtargetURL - target of the scan configIOException - thrown if I/O error occurs during template processingfreemarker.template.TemplateException - if a problem occurs during template processingIllegalArgumentException - if any of the provided arguments are null, or in the case of Strings emptyMalformedURLException - if target is not a vapublic Optional<org.json.JSONObject> findByConfigName(org.json.JSONArray configs, String configName)
configs - JSONArray to search throughconfigName - name of config to findpublic Optional<Boolean> getBooleansFrom(org.json.JSONObject jsonObject, String... keys)
jsonObject - json object containing keyskeys - keys for the boolean fields of jsonObjectpublic Optional<List<ClientIdNamePair>> getClientIdNamePairs(org.json.JSONArray clients)
clients - JSONArray containing items with format { ClientId = String, ClientName = String }Copyright © 2016–2021. All rights reserved.