labelingsystem-server  Version 0.1.0.0
Logging Class Reference

ERROR MESSAGE for catch exceptions. More...

Static Public Member Functions

static String getMessageXML (Exception exception, String endClass) throws ParserConfigurationException, TransformerException
 XML ERROR MESSAGE for catch exceptions. More...
 
static String getMessageJSON (Exception exception, String endClass)
 JSON ERROR MESSAGE for catch exceptions. More...
 
static String getMessageTEXT (Exception exception, String endClass)
 TEXT ERROR MESSAGE for catch exceptions. More...
 

Detailed Description

ERROR MESSAGE for catch exceptions.

Author
Florian Thiery M.Sc.
i3mainz - Institute for Spatial Information and Surveying Technology
Version
18.02.2015

Member Function Documentation

◆ getMessageJSON()

static String getMessageJSON ( Exception  exception,
String  endClass 
)
static

JSON ERROR MESSAGE for catch exceptions.

Parameters
exception
endClass
Returns
error message JSON
52  {
53  // START BUILD JSON
54  Gson gson = new GsonBuilder().setPrettyPrinting().create();
55  JSONObject jsonobj_error = new JSONObject(); // {}
56  JSONObject jsonobj_error_data = new JSONObject(); // {}
57  JSONArray jsonarray_element = new JSONArray();
58  for (StackTraceElement element : exception.getStackTrace()) {
59  JSONObject errMessage = new JSONObject();
60  errMessage.put("class", element.getClassName());
61  errMessage.put("method", element.getMethodName());
62  errMessage.put("line", element.getLineNumber());
63  jsonarray_element.add(errMessage);
64  //jsonarray_element.add(element.getClassName() + " / " + element.getMethodName() + "() / " + element.getLineNumber());
65  if (element.getClassName().equals(endClass)) {
66  break;
67  }
68  }
69  // get error code
70  String code = "";
71  String userMessage = "";
72  if (exception.toString().contains("NullPointerException")) {
73  code = "1";
74  userMessage = "some value is not available";
75  } else if (exception.toString().contains("ValidateJSONObjectException")) {
76  code = "2";
77  String[] ex = exception.toString().split(": ");
78  userMessage = "validate JSON object exception: " + ex[1];
79  }
80  // output
81  jsonobj_error.put("errors", jsonobj_error_data);
82  jsonobj_error_data.put("internalMessage", exception.toString());
83  jsonobj_error_data.put("userMessage", userMessage);
84  jsonobj_error_data.put("code", code);
85  jsonobj_error_data.put("developerInfo", jsonarray_element);
86  // OUTPUT AS pretty print JSON
87  return gson.toJson(jsonobj_error);
88  }

Referenced by ImportcsvResource.csvUpload(), ImportcsvResource.csvUploadDirectResponse(), ImportcsvResource.csvUploadUpdate(), AgentsResource.deleteAgent(), LabelsResource.deleteLabel(), VocabsResource.deleteVocabulary(), AgentsResource.getAgent(), AgentsResource.getAgent_JSON(), AgentsResource.getAgent_XML(), AgentsResource.getAgentRDF_JSONLD(), AgentsResource.getAgentRDF_JSONRDF(), AgentsResource.getAgentRDF_N3(), AgentsResource.getAgentRDF_Turtle(), AgentsResource.getAgentRDF_XML(), AgentsResource.getAgents(), RestResource.getAPIpage(), InfoResource.getAPIpage(), DumpResource.getDump(), AuthResource.getHash(), RetcatResource.getInfoArchwort(), RetcatResource.getInfoBGS(), RetcatResource.getInfoChronontology(), RetcatResource.getInfoDBpedia(), RetcatResource.getInfoExtern(), RetcatResource.getInfoGeoNames(), RetcatResource.getInfoGetty(), RetcatResource.getInfoHeritageData(), RetcatResource.getInfoLabelingSystem(), RetcatResource.getInfoPelagios(), RetcatResource.getInfoPersonDB(), RetcatResource.getInfoSkosmosFao(), RetcatResource.getInfoSkosmosFinto(), RetcatResource.getInfoSkosmosUnesco(), RetcatResource.getInfoWikidata(), LabelsResource.getLabel(), LabelsResource.getLabel_BNR(), LabelsResource.getLabel_JSON(), LabelsResource.getLabel_Relations(), LabelsResource.getLabel_XML(), LabelsResource.getLabelRDF_JSONLD(), LabelsResource.getLabelRDF_JSONRDF(), LabelsResource.getLabelRDF_N3(), LabelsResource.getLabelRDF_Turtle(), LabelsResource.getLabelRDF_XML(), LabelsResource.getLabels(), LanguagesResource.getLanguages(), LicensesResource.getLicenses(), DumpResource.getList(), RetcatResource.getQueryResultsARCHWORT(), RetcatResource.getQueryResultsBGS(), RetcatResource.getQueryResultsCHRONONTOLOGY(), RetcatResource.getQueryResultsDBPEDIA(), RetcatResource.getQueryResultsGEONAMES(), RetcatResource.getQueryResultsGettyAAT(), RetcatResource.getQueryResultsGettyTGN(), RetcatResource.getQueryResultsGettyULAN(), RetcatResource.getQueryResultsHeritagedataHE(), RetcatResource.getQueryResultsHeritagedataRCAHMS(), RetcatResource.getQueryResultsHeritagedataRCAHMW(), RetcatResource.getQueryResultsHTML(), RetcatResource.getQueryResultsLabelingSystem(), RetcatResource.getQueryResultsLabelingSystemVocabulary(), RetcatResource.getQueryResultsPELAGIOS(), RetcatResource.getQueryResultsPERSONDB(), RetcatResource.getQueryResultsSkosmosFAO(), RetcatResource.getQueryResultsSkosmosFINTO(), RetcatResource.getQueryResultsSkosmosUNESCO(), RetcatResource.getQueryResultsWIKIDATA(), SearchResource.getResultsLabelingSystem(), RetcatResource.getRetcatDetails(), RetcatResource.getRetcatGroups(), RetcatResource.getRetcatList(), RetcatResource.getRetcatListByVocabulary(), RetcatResource.getRetcatListByVocabularyForList(), RetcatResource.getRetcatQualities(), RetcatResource.getRetcatTypes(), RevisionsResource.getRevision(), RevisionsResource.getRevision_JSON(), RevisionsResource.getRevision_XML(), RevisionsResource.getRevisionRDF_JSONLD(), RevisionsResource.getRevisionRDF_JSONRDF(), RevisionsResource.getRevisionRDF_N3(), RevisionsResource.getRevisionRDF_Turtle(), RevisionsResource.getRevisionRDF_XML(), RevisionsResource.getRevisions(), SparqlResource.getSPARQLresultsGET(), SparqlResource.getSPARQLresultsPOST(), DumpResource.getStatus(), AutocompleteResource.getSuggestionsForAgents(), AutocompleteResource.getSuggestionsForLabels(), AutocompleteResource.getSuggestionsForLabelsFilter(), AutocompleteResource.getSuggestionsForVocabs(), VocabsResource.getVocabularies(), VocabsResource.getVocabulary(), VocabsResource.getVocabulary_JSON(), VocabsResource.getVocabulary_XML(), VocabsResource.getVocabularyRDF_JSONLD(), VocabsResource.getVocabularyRDF_JSONRDF(), VocabsResource.getVocabularyRDF_N3(), VocabsResource.getVocabularyRDF_SKOS(), VocabsResource.getVocabularyRDF_Turtle(), VocabsResource.getVocabularyRDF_XML(), RetcatResource.getWaybackLink(), TestsResource.initTest(), AuthResource.loginUser(), AuthResource.logoutUser(), AgentsResource.postAgent(), LabelsResource.postLabel(), VocabsResource.postVocabulary(), RetcatResource.setRetcatForVocabulary(), RetcatResource.setRetcatForVocabularyForList(), DumpResource.startDumping(), AuthResource.statusUser(), DumpResource.stopDumping(), AgentsResource.updateAgent(), LabelsResource.updateLabel(), RetcatResource.updateRetcatForVocabulary(), RetcatResource.updateRetcatForVocabularyForList(), and VocabsResource.updateVocabulary().

◆ getMessageTEXT()

static String getMessageTEXT ( Exception  exception,
String  endClass 
)
static

TEXT ERROR MESSAGE for catch exceptions.

Parameters
exception
endClass
Returns
error message TEXT
97  {
98  String message = "error\n";
99  message += "message: \"" + exception.toString() + "\"";
100  for (StackTraceElement element : exception.getStackTrace()) {
101  message += "\ndescription: \"" + element.getClassName() + " / " + element.getMethodName() + "() / " + element.getLineNumber() + "\"";
102  if (element.getClassName().equals(endClass)) {
103  break;
104  }
105  }
106  return message;
107  }

◆ getMessageXML()

static String getMessageXML ( Exception  exception,
String  endClass 
) throws ParserConfigurationException, TransformerException
static

XML ERROR MESSAGE for catch exceptions.

Parameters
exception
endClass
Returns
error message XML
Exceptions
javax.xml.parsers.ParserConfigurationException
javax.xml.transform.TransformerException
29  {
30  XMLBuilder xml = XMLBuilder.create("error")
31  .e("message")
32  .t(exception.toString())
33  .up();
34  for (StackTraceElement element : exception.getStackTrace()) {
35  xml.e("description")
36  .t(element.getClassName() + " / " + element.getMethodName() + "() / " + element.getLineNumber())
37  .up();
38  if (element.getClassName().equals(endClass)) {
39  break;
40  }
41  }
42  return xml.asString();
43  }