labelingsystem-server  Version 0.1.0.0
Retcat_HTML Class Reference

Static Public Member Functions

static Map< String, SuggestionItem > query (String url) throws IOException, RepositoryException, MalformedQueryException, QueryEvaluationException, SesameSparqlException, ResourceNotAvailableException, ParseException
 
static JSONObject info (String url) throws IOException, RepositoryException, MalformedQueryException, QueryEvaluationException, SesameSparqlException, ResourceNotAvailableException, ParseException, RetcatException
 

Member Function Documentation

◆ info()

static JSONObject info ( String  url) throws IOException, RepositoryException, MalformedQueryException, QueryEvaluationException, SesameSparqlException, ResourceNotAvailableException, ParseException, RetcatException
static
38  {
39  try {
40  String outputUrl = url;
41  url = GeneralFunctions.encodeURIUmlaut(url);
42  Document doc = Jsoup.connect(url).get();
43  Elements titleTag = doc.select("title");
44  JSONObject jsonOut = new JSONObject();
45  String out = titleTag.text();
46  jsonOut.put("label", out);
47  jsonOut.put("lang", "");
48  jsonOut.put("type", "wayback");
49  jsonOut.put("quality", "low");
50  jsonOut.put("group", "wayback");
51  jsonOut.put("uri", outputUrl);
52  JSONArray broader = new JSONArray();
53  JSONArray narrower = new JSONArray();
54  jsonOut.put("broaderTerms", broader);
55  jsonOut.put("narrowerTerms", narrower);
56  jsonOut.put("description", "");
57  jsonOut.put("scheme", "");
58  if (jsonOut.get("label") != null && !jsonOut.get("label").equals("")) {
59  return jsonOut;
60  } else {
61  throw new RetcatException("no label for this uri available");
62  }
63  } catch (Exception e) {
64  return new JSONObject();
65  }
66  }

References GeneralFunctions.encodeURIUmlaut().

Referenced by RetcatResource.getInfoExtern().

◆ query()

static Map<String, SuggestionItem> query ( String  url) throws IOException, RepositoryException, MalformedQueryException, QueryEvaluationException, SesameSparqlException, ResourceNotAvailableException, ParseException
static
23  {
24  Map<String, SuggestionItem> autosuggests = new HashMap<String, SuggestionItem>();
25  SuggestionItem tmpAutosuggest = new SuggestionItem(url);
26  String urlEncoded = GeneralFunctions.encodeURIUmlaut(url);
27  Document doc = Jsoup.connect(urlEncoded).get();
28  Elements titleTag = doc.select("title");
29  String titleStr = titleTag.text();
30  tmpAutosuggest.setLabel(titleStr);
31  tmpAutosuggest.setGroup("wayback");
32  tmpAutosuggest.setQuality("low");
33  tmpAutosuggest.setType("wayback");
34  autosuggests.put(url, tmpAutosuggest);
35  return autosuggests;
36  }

References GeneralFunctions.encodeURIUmlaut().

Referenced by RetcatResource.getQueryResultsHTML().

Exception