labelingsystem-server  Version 0.1.0.0
ResourceQueryResource Class Reference

Public Member Functions

Response redirectToRetcat (@QueryParam("retcat") String retcat, @QueryParam("query") String query) throws URISyntaxException, IOException, RepositoryException, MalformedQueryException, QueryEvaluationException, SesameSparqlException, ResourceNotAvailableException, org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException, org.eclipse.rdf4j.query.QueryEvaluationException, link.labeling.retcat.exceptions.ResourceNotAvailableException
 

Member Function Documentation

◆ redirectToRetcat()

Response redirectToRetcat ( @QueryParam("retcat") String  retcat,
@QueryParam("query") String  query 
) throws URISyntaxException, IOException, RepositoryException, MalformedQueryException, QueryEvaluationException, SesameSparqlException, ResourceNotAvailableException, org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException, org.eclipse.rdf4j.query.QueryEvaluationException, link.labeling.retcat.exceptions.ResourceNotAvailableException
27  {
28  List<RetcatItem> retcatlist = LocalRetcatItems.getLocalCatalogue();
29  boolean match = false;
30  if (retcat != null) {
31  //ckeck if own vocab
32  if (retcat.contains("this.")) {
33  String vocab = retcat.split("this.")[1];
34  query = GeneralFunctions.encodeURIComponent(query);
35  URI targetURIForRedirection = new URI(ConfigProperties.getPropertyParam("api") + "/v1/rtc/query/labelingsystem/" + vocab + "?query=" + query);
36  return Response.temporaryRedirect(targetURIForRedirection).build();
37  }
38  // look for other endpoints
39  for (RetcatItem item : retcatlist) {
40  if (retcat.contains(item.getName())) {
41  query = GeneralFunctions.encodeURIComponent(query);
42  URI targetURIForRedirection = new URI(ConfigProperties.getPropertyParam("api") + item.getQueryURL() + "?query=" + query);
43  return Response.temporaryRedirect(targetURIForRedirection).build();
44  }
45  }
46  }
47  if (!match) {
48  URI targetURIForRedirection = new URI(ConfigProperties.getPropertyParam("api") + "/v1/rtc/query/html" + "?url=" + query);
49  return Response.temporaryRedirect(targetURIForRedirection).build();
50  }
51  return Response.ok().build();
52  }

References GeneralFunctions.encodeURIComponent(), LocalRetcatItems.getLocalCatalogue(), and ConfigProperties.getPropertyParam().