labelingsystem-server  Version 0.1.0.0
VocabsResource Class Reference

Public Member Functions

Response getVocabularies ( @HeaderParam("Accept") String acceptHeader, @HeaderParam("Accept-Encoding") String acceptEncoding, @QueryParam("pretty") boolean pretty, @QueryParam("sort") String sort, @QueryParam("fields") String fields, @QueryParam("offset") String offset, @QueryParam("limit") String limit, @QueryParam("creator") String creator, @QueryParam("releaseType") String releaseType, @QueryParam("draft") String draft, @QueryParam("statistics") String statistics, @QueryParam("creatorInfo") String creatorInfo) throws IOException, JDOMException, ConfigException, ParserConfigurationException, TransformerException
 
Response getVocabulary (@PathParam("vocabulary") String vocabulary, @HeaderParam("Accept") String acceptHeader, @QueryParam("statistics") String statistics, @QueryParam("creatorInfo") String creatorInfo, @QueryParam("pretty") boolean pretty, @HeaderParam("Accept-Encoding") String acceptEncoding) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
 
Response getVocabulary_JSON (@PathParam("vocabulary") String vocabulary, @QueryParam("pretty") boolean pretty, @QueryParam("statistics") String statistics, @QueryParam("creatorInfo") String creatorInfo, @HeaderParam("Accept-Encoding") String acceptEncoding) throws IOException, JDOMException, TransformerException, ParserConfigurationException
 
Response getVocabulary_XML (@PathParam("vocabulary") String vocabulary) throws IOException, JDOMException, TransformerException, ParserConfigurationException
 
Response getVocabularyRDF_XML (@PathParam("vocabulary") String vocabulary) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
 
Response getVocabularyRDF_Turtle (@PathParam("vocabulary") String vocabulary) throws IOException, JDOMException, TransformerException, ParserConfigurationException
 
Response getVocabularyRDF_N3 (@PathParam("vocabulary") String vocabulary) throws IOException, JDOMException, TransformerException, ParserConfigurationException
 
Response getVocabularyRDF_JSONRDF (@PathParam("vocabulary") String vocabulary, @QueryParam("pretty") boolean pretty) throws IOException, JDOMException, TransformerException, ParserConfigurationException
 
Response getVocabularyRDF_JSONLD (@PathParam("vocabulary") String vocabulary, @QueryParam("pretty") boolean pretty) throws IOException, JDOMException, TransformerException, ParserConfigurationException
 
Response getVocabularyRDF_SKOS (@PathParam("vocabulary") String vocabulary) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
 
Response postVocabulary (String json) throws IOException, JDOMException, ConfigException, ParserConfigurationException, TransformerException
 
Response updateVocabulary (@PathParam("vocabulary") String vocabulary, String json) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
 
Response deleteVocabulary (@PathParam("vocabulary") String vocabulary) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
 

Static Private Member Functions

static String createVocabularySPARQLUPDATE (String item, String itemid, String creator) throws ConfigException, IOException, UniqueIdentifierException
 
static String modifySPARQLUPDATE (String item, String itemid) throws ConfigException, IOException, UniqueIdentifierException
 
static String deleteItemsSPARQLUPDATE (String id) throws IOException
 
static String deleteVocabularySPARQLUPDATE (String id) throws IOException
 
static String deleteLabelsSPARQLUPDATE (String vocabid) throws IOException
 
static OutputStream GZIP (String input, OutputStream baos) throws IOException
 

Member Function Documentation

◆ createVocabularySPARQLUPDATE()

static String createVocabularySPARQLUPDATE ( String  item,
String  itemid,
String  creator 
) throws ConfigException, IOException, UniqueIdentifierException
staticprivate
787  {
788  Calendar calender = Calendar.getInstance();
789  Date d = calender.getTime();
790  DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
791  String date = formatter.format(d);
792  RDF rdf = new RDF();
793  String prefixes = rdf.getPREFIXSPARQL();
794  String triples = prefixes + "INSERT DATA { ";
795  triples += item + ":" + itemid + " a ls:Vocabulary . ";
796  triples += item + ":" + itemid + " a skos:ConceptScheme . ";
797  triples += item + ":" + itemid + " dc:creator \"" + creator + "\"" + " . ";
798  triples += item + ":" + itemid + " dct:creator ls_age:" + creator + " . ";
799  triples += item + ":" + itemid + " dc:identifier \"" + itemid + "\"" + " . ";
800  triples += item + ":" + itemid + " dc:created \"" + date + "\"" + " . ";
801  triples += item + ":" + itemid + " dc:modified \"" + date + "\"" + " . ";
802  triples += item + ":" + itemid + " ls:hasReleaseType ls:Draft . ";
803  triples += " }";
804  return triples;
805  }

◆ deleteItemsSPARQLUPDATE()

static String deleteItemsSPARQLUPDATE ( String  id) throws IOException
staticprivate
820  {
821  RDF rdf = new RDF();
822  String prefixes = rdf.getPREFIXSPARQL();
823  String update = prefixes
824  + "DELETE { ?vocabulary ?p ?o. } "
825  + "WHERE { "
826  + "?vocabulary ?p ?o. "
827  + "?vocabulary dc:identifier ?identifier. "
828  + "FILTER (?identifier=\"$identifier\") "
829  + "FILTER (?p IN (dc:title,dc:description,dc:language,ls:hasReleaseType,dct:license,dc:rights)) "
830  + "}";
831  update = update.replace("$identifier", id);
832  return update;
833  }

◆ deleteLabelsSPARQLUPDATE()

static String deleteLabelsSPARQLUPDATE ( String  vocabid) throws IOException
staticprivate
849  {
850  RDF rdf = new RDF();
851  String prefixes = rdf.getPREFIXSPARQL();
852  String update = prefixes
853  + "DELETE { ?label ?p ?o. } "
854  + "WHERE { "
855  + "?label ?p ?o. "
856  + "?label skos:inScheme ?scheme. "
857  + "FILTER (?scheme=<" + rdf.getPrefixItem("ls_voc:" + vocabid) + ">) "
858  + "}";
859  return update;
860  }

◆ deleteVocabulary()

Response deleteVocabulary ( @PathParam("vocabulary") String  vocabulary) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
762  {
763  try {
764  String item = "ls_voc";
765  // check if resource exists
766  String queryExist = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
767  List<BindingSet> resultExist = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), queryExist);
768  if (resultExist.size() < 1) {
769  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
770  }
771  // delete data
772  RDF4J_20.SPARQLupdate(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), deleteVocabularySPARQLUPDATE(vocabulary));
773  // delete labels if available
774  String queryLabels = GeneralFunctions.getAllLabelsForVocabulary(vocabulary);
775  List<BindingSet> resultLabels = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), queryLabels);
776  if (resultLabels.size() > 0) {
777  RDF4J_20.SPARQLupdate(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), deleteLabelsSPARQLUPDATE(vocabulary));
778  }
779  String out = Transformer.empty_JSON("vocab").toJSONString();
780  return Response.status(Response.Status.CREATED).entity(out).build();
781  } catch (Exception e) {
782  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
783  .header("Content-Type", "application/json;charset=UTF-8").build();
784  }
785  }

References Transformer.empty_JSON(), GeneralFunctions.getAllElementsForItemID(), GeneralFunctions.getAllLabelsForVocabulary(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ deleteVocabularySPARQLUPDATE()

static String deleteVocabularySPARQLUPDATE ( String  id) throws IOException
staticprivate
835  {
836  RDF rdf = new RDF();
837  String prefixes = rdf.getPREFIXSPARQL();
838  String update = prefixes
839  + "DELETE { ?vocabulary ?p ?o. } "
840  + "WHERE { "
841  + "?vocabulary ?p ?o. "
842  + "?vocabulary dc:identifier ?identifier. "
843  + "FILTER (?identifier=\"$identifier\") "
844  + "}";
845  update = update.replace("$identifier", id);
846  return update;
847  }

◆ getVocabularies()

Response getVocabularies ( @HeaderParam("Accept") String  acceptHeader,
@HeaderParam("Accept-Encoding") String  acceptEncoding,
@QueryParam("pretty") boolean  pretty,
@QueryParam("sort") String  sort,
@QueryParam("fields") String  fields,
@QueryParam("offset") String  offset,
@QueryParam("limit") String  limit,
@QueryParam("creator") String  creator,
@QueryParam("releaseType") String  releaseType,
@QueryParam("draft") String  draft,
@QueryParam("statistics") String  statistics,
@QueryParam("creatorInfo") String  creatorInfo 
) throws IOException, JDOMException, ConfigException, ParserConfigurationException, TransformerException
70  {
71  try {
72  String OUTSTRING = "";
73  // QUERY STRING
74  RDF rdf = new RDF();
75  String query = rdf.getPREFIXSPARQL();
76  query += "SELECT * WHERE { "
77  + "?s ?p ?o . "
78  + "?s a ls:Vocabulary . "
79  + "?s dc:identifier ?identifier . "
80  + "OPTIONAL { ?s dc:creator ?creator . } " // because of sorting, filtering
81  + "OPTIONAL { ?s dc:title ?title . } "; // because of sorting
82  // FILTERING
83  if (draft == null) {
84  query += "?s ls:hasReleaseType ls:Public . ";
85  }
86  if (creator != null) {
87  query += "FILTER(?creator=\"" + creator + "\") ";
88  }
89  if (releaseType != null) {
90  query += "FILTER(?releaseType=<" + rdf.getPrefixItem("ls:" + releaseType) + ">) ";
91  }
92  query += " } ";
93  // SORTING
94  List<String> sortList = new ArrayList<String>();
95  if (sort != null) {
96  String sortArray[] = sort.split(",");
97  for (String element : sortArray) {
98  if (sort != null) {
99  String sortDirection = element.substring(0, 1);
100  if (sortDirection.equals("+")) {
101  sortDirection = "ASC";
102  } else {
103  sortDirection = "DESC";
104  }
105  element = element.substring(1);
106  sortList.add(sortDirection + "(?" + element + ") ");
107  }
108  }
109  query += "ORDER BY ";
110  for (String element : sortList) {
111  query += element;
112  }
113  }
114  // PAGING
115  if (limit != null && offset != null) {
116  query += "LIMIT " + limit + " OFFSET " + offset;
117  }
118  // QUERY TRIPLESTORE
119  long ctm_start = System.currentTimeMillis();
120  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
121  List<String> s = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "s");
122  List<String> p = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
123  List<String> o = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
124  if (result.size() < 1) {
125  throw new ResourceNotAvailableException("resource is not available");
126  }
127  for (int i = 0; i < s.size(); i++) {
128  rdf.setModelTriple(s.get(i), p.get(i), o.get(i));
129  }
130  JSONArray outArray = new JSONArray();
131  if (acceptHeader.contains("application/json") || acceptHeader.contains("text/html")) {
132  JSONObject jsonObject = (JSONObject) new JSONParser().parse(rdf.getModel("RDF/JSON"));
133  Set keys = jsonObject.keySet();
134  Iterator a = keys.iterator();
135  while (a.hasNext()) {
136  String key = (String) a.next();
137  JSONObject tmpObject = (JSONObject) jsonObject.get(key);
138  JSONArray idArray = (JSONArray) tmpObject.get(rdf.getPrefixItem("dc:identifier"));
139  JSONObject idObject = (JSONObject) idArray.get(0);
140  String h = (String) idObject.get("value");
141  JSONObject tmpObject2 = new JSONObject();
142  tmpObject2.put(key, tmpObject);
143  String hh = tmpObject2.toString();
144  JSONObject tmp = Transformer.vocabulary_GET(hh, h, fields, statistics, creatorInfo);
145  outArray.add(tmp);
146  }
147  }
148  if (acceptHeader.contains("application/json")) {
149  if (pretty) {
150  JsonParser parser = new JsonParser();
151  JsonObject json = parser.parse(outArray.toString()).getAsJsonObject();
152  Gson gson = new GsonBuilder().setPrettyPrinting().create();
153  return Response.ok(gson.toJson(json)).build();
154  } else {
155  OUTSTRING = outArray.toString();
156  if (acceptEncoding.contains("gzip")) {
157  // set outputstream
158  final String OUTSTRING_FINAL = OUTSTRING;
159  StreamingOutput stream;
160  stream = new StreamingOutput() {
161  @Override
162  public void write(OutputStream output) throws IOException, WebApplicationException {
163  try {
164  output = GZIP(OUTSTRING_FINAL, output);
165  } catch (Exception e) {
166  System.out.println(e.toString());
167  }
168  }
169  };
170  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
171  } else {
172  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
173  }
174  }
175  } else if (acceptHeader.contains("application/rdf+json")) {
176  return Response.ok(rdf.getModel("RDF/JSON")).header("Content-Type", "application/json;charset=UTF-8").build();
177  } else if (acceptHeader.contains("text/html")) {
178  if (pretty) {
179  JsonParser parser = new JsonParser();
180  JsonObject json = parser.parse(outArray.toString()).getAsJsonObject();
181  Gson gson = new GsonBuilder().setPrettyPrinting().create();
182  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
183  } else {
184  OUTSTRING = outArray.toString();
185  if (acceptEncoding.contains("gzip")) {
186  // set outputstream
187  final String OUTSTRING_FINAL = OUTSTRING;
188  StreamingOutput stream;
189  stream = new StreamingOutput() {
190  @Override
191  public void write(OutputStream output) throws IOException, WebApplicationException {
192  try {
193  output = GZIP(OUTSTRING_FINAL, output);
194  } catch (Exception e) {
195  System.out.println(e.toString());
196  }
197  }
198  };
199  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
200  } else {
201  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
202  }
203  }
204  } else if (acceptHeader.contains("application/xml")) {
205  return Response.ok(rdf.getModel("RDF/XML")).build();
206  } else if (acceptHeader.contains("application/rdf+xml")) {
207  return Response.ok(rdf.getModel("RDF/XML")).build();
208  } else if (acceptHeader.contains("text/turtle")) {
209  return Response.ok(rdf.getModel("Turtle")).build();
210  } else if (acceptHeader.contains("text/n3")) {
211  return Response.ok(rdf.getModel("N-Triples")).build();
212  } else if (acceptHeader.contains("application/ld+json")) {
213  return Response.ok(rdf.getModel("JSON-LD")).build();
214  } else if (pretty) {
215  JsonParser parser = new JsonParser();
216  JsonObject json = parser.parse(outArray.toString()).getAsJsonObject();
217  Gson gson = new GsonBuilder().setPrettyPrinting().create();
218  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
219  } else {
220  OUTSTRING = outArray.toString();
221  if (acceptEncoding.contains("gzip")) {
222  // set outputstream
223  final String OUTSTRING_FINAL = OUTSTRING;
224  StreamingOutput stream;
225  stream = new StreamingOutput() {
226  @Override
227  public void write(OutputStream output) throws IOException, WebApplicationException {
228  try {
229  output = GZIP(OUTSTRING_FINAL, output);
230  } catch (Exception e) {
231  System.out.println(e.toString());
232  }
233  }
234  };
235  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
236  } else {
237  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
238  }
239  }
240  } catch (Exception e) {
241  if (e.toString().contains("ResourceNotAvailableException")) {
242  JSONArray outArray = new JSONArray();
243  return Response.ok(outArray).header("Content-Type", "application/json;charset=UTF-8").build();
244  } else {
245  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
246  .header("Content-Type", "application/json;charset=UTF-8").build();
247  }
248  }
249  }

References Logging.getMessageJSON(), ConfigProperties.getPropertyParam(), and Transformer.vocabulary_GET().

◆ getVocabulary()

Response getVocabulary ( @PathParam("vocabulary") String  vocabulary,
@HeaderParam("Accept") String  acceptHeader,
@QueryParam("statistics") String  statistics,
@QueryParam("creatorInfo") String  creatorInfo,
@QueryParam("pretty") boolean  pretty,
@HeaderParam("Accept-Encoding") String  acceptEncoding 
) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
254  {
255  try {
256  String OUTSTRING = "";
257  RDF rdf = new RDF();
258  String item = "ls_voc";
259  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
260  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
261  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
262  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
263  if (result.size() < 1) {
264  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
265  }
266  for (int i = 0; i < predicates.size(); i++) {
267  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
268  }
269  if (acceptHeader.contains("application/json")) {
270  String out = Transformer.vocabulary_GET(rdf.getModel("RDF/JSON"), vocabulary, null, statistics, creatorInfo).toJSONString();
271  if (pretty) {
272  JsonParser parser = new JsonParser();
273  JsonObject json = parser.parse(out).getAsJsonObject();
274  Gson gson = new GsonBuilder().setPrettyPrinting().create();
275  return Response.ok(gson.toJson(json)).build();
276  } else {
277  OUTSTRING = out.toString();
278  if (acceptEncoding.contains("gzip")) {
279  // set outputstream
280  final String OUTSTRING_FINAL = OUTSTRING;
281  StreamingOutput stream;
282  stream = new StreamingOutput() {
283  @Override
284  public void write(OutputStream output) throws IOException, WebApplicationException {
285  try {
286  output = GZIP(OUTSTRING_FINAL, output);
287  } catch (Exception e) {
288  System.out.println(e.toString());
289  }
290  }
291  };
292  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
293  } else {
294  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
295  }
296  }
297  } else if (acceptHeader.contains("application/rdf+json")) {
298  return Response.ok(rdf.getModel("RDF/JSON")).header("Content-Type", "application/json;charset=UTF-8").build();
299  } else if (acceptHeader.contains("text/html")) {
300  String out = Transformer.vocabulary_GET(rdf.getModel("RDF/JSON"), vocabulary, null, statistics, creatorInfo).toJSONString();
301  if (pretty) {
302  JsonParser parser = new JsonParser();
303  JsonObject json = parser.parse(out).getAsJsonObject();
304  Gson gson = new GsonBuilder().setPrettyPrinting().create();
305  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
306  } else {
307  OUTSTRING = out.toString();
308  if (acceptEncoding.contains("gzip")) {
309  // set outputstream
310  final String OUTSTRING_FINAL = OUTSTRING;
311  StreamingOutput stream;
312  stream = new StreamingOutput() {
313  @Override
314  public void write(OutputStream output) throws IOException, WebApplicationException {
315  try {
316  output = GZIP(OUTSTRING_FINAL, output);
317  } catch (Exception e) {
318  System.out.println(e.toString());
319  }
320  }
321  };
322  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
323  } else {
324  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
325  }
326  }
327  } else if (acceptHeader.contains("application/xml")) {
328  return Response.ok(rdf.getModel("RDF/XML")).build();
329  } else if (acceptHeader.contains("application/rdf+xml")) {
330  return Response.ok(rdf.getModel("RDF/XML")).build();
331  } else if (acceptHeader.contains("text/turtle")) {
332  return Response.ok(rdf.getModel("Turtle")).build();
333  } else if (acceptHeader.contains("text/n3")) {
334  return Response.ok(rdf.getModel("N-Triples")).build();
335  } else if (acceptHeader.contains("application/ld+json")) {
336  return Response.ok(rdf.getModel("JSON-LD")).build();
337  } else {
338  String out = Transformer.vocabulary_GET(rdf.getModel("RDF/JSON"), vocabulary, null, statistics, creatorInfo).toJSONString();
339  if (pretty) {
340  JsonParser parser = new JsonParser();
341  JsonObject json = parser.parse(out).getAsJsonObject();
342  Gson gson = new GsonBuilder().setPrettyPrinting().create();
343  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
344  } else {
345  OUTSTRING = out.toString();
346  if (acceptEncoding.contains("gzip")) {
347  // set outputstream
348  final String OUTSTRING_FINAL = OUTSTRING;
349  StreamingOutput stream;
350  stream = new StreamingOutput() {
351  @Override
352  public void write(OutputStream output) throws IOException, WebApplicationException {
353  try {
354  output = GZIP(OUTSTRING_FINAL, output);
355  } catch (Exception e) {
356  System.out.println(e.toString());
357  }
358  }
359  };
360  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
361  } else {
362  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
363  }
364  }
365  }
366  } catch (Exception e) {
367  if (e.toString().contains("ResourceNotAvailableException")) {
368  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
369  .header("Content-Type", "application/json;charset=UTF-8").build();
370  } else {
371  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
372  .header("Content-Type", "application/json;charset=UTF-8").build();
373  }
374  }
375  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), ConfigProperties.getPropertyParam(), and Transformer.vocabulary_GET().

◆ getVocabulary_JSON()

Response getVocabulary_JSON ( @PathParam("vocabulary") String  vocabulary,
@QueryParam("pretty") boolean  pretty,
@QueryParam("statistics") String  statistics,
@QueryParam("creatorInfo") String  creatorInfo,
@HeaderParam("Accept-Encoding") String  acceptEncoding 
) throws IOException, JDOMException, TransformerException, ParserConfigurationException
380  {
381  try {
382  String OUTSTRING = "";
383  RDF rdf = new RDF();
384  String item = "ls_voc";
385  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
386  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
387  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
388  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
389  if (result.size() < 1) {
390  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
391  }
392  for (int i = 0; i < predicates.size(); i++) {
393  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
394  }
395  String out = Transformer.vocabulary_GET(rdf.getModel("RDF/JSON"), vocabulary, null, statistics, creatorInfo).toJSONString();
396  if (pretty) {
397  JsonParser parser = new JsonParser();
398  JsonObject json = parser.parse(out).getAsJsonObject();
399  Gson gson = new GsonBuilder().setPrettyPrinting().create();
400  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
401  } else {
402  OUTSTRING = out.toString();
403  if (acceptEncoding.contains("gzip")) {
404  // set outputstream
405  final String OUTSTRING_FINAL = OUTSTRING;
406  StreamingOutput stream;
407  stream = new StreamingOutput() {
408  @Override
409  public void write(OutputStream output) throws IOException, WebApplicationException {
410  try {
411  output = GZIP(OUTSTRING_FINAL, output);
412  } catch (Exception e) {
413  System.out.println(e.toString());
414  }
415  }
416  };
417  return Response.ok(stream).header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip").build();
418  } else {
419  return Response.ok(OUTSTRING).header("Content-Type", "application/json;charset=UTF-8").build();
420  }
421  }
422  } catch (Exception e) {
423  if (e.toString().contains("ResourceNotAvailableException")) {
424  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
425  .header("Content-Type", "application/json;charset=UTF-8").build();
426  } else {
427  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
428  .header("Content-Type", "application/json;charset=UTF-8").build();
429  }
430  }
431  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), ConfigProperties.getPropertyParam(), and Transformer.vocabulary_GET().

◆ getVocabulary_XML()

Response getVocabulary_XML ( @PathParam("vocabulary") String  vocabulary) throws IOException, JDOMException, TransformerException, ParserConfigurationException
436  {
437  try {
438  RDF rdf = new RDF();
439  String item = "ls_voc";
440  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
441  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
442  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
443  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
444  if (result.size() < 1) {
445  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
446  }
447  for (int i = 0; i < predicates.size(); i++) {
448  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
449  }
450  String RDFoutput = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + rdf.getModel("RDF/XML");
451  return Response.ok(RDFoutput).build();
452  } catch (Exception e) {
453  if (e.toString().contains("ResourceNotAvailableException")) {
454  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
455  .header("Content-Type", "application/json;charset=UTF-8").build();
456  } else {
457  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
458  .header("Content-Type", "application/json;charset=UTF-8").build();
459  }
460  }
461  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ getVocabularyRDF_JSONLD()

Response getVocabularyRDF_JSONLD ( @PathParam("vocabulary") String  vocabulary,
@QueryParam("pretty") boolean  pretty 
) throws IOException, JDOMException, TransformerException, ParserConfigurationException
591  {
592  try {
593  RDF rdf = new RDF();
594  String item = "ls_voc";
595  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
596  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
597  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
598  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
599  if (result.size() < 1) {
600  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
601  }
602  for (int i = 0; i < predicates.size(); i++) {
603  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
604  }
605  String out = rdf.getModel("JSON-LD");
606  if (pretty) {
607  JsonParser parser = new JsonParser();
608  JsonObject json = parser.parse(out).getAsJsonObject();
609  Gson gson = new GsonBuilder().setPrettyPrinting().create();
610  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
611  } else {
612  return Response.ok(out).header("Content-Type", "application/json;charset=UTF-8").build();
613  }
614  } catch (Exception e) {
615  if (e.toString().contains("ResourceNotAvailableException")) {
616  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
617  .header("Content-Type", "application/json;charset=UTF-8").build();
618  } else {
619  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
620  .header("Content-Type", "application/json;charset=UTF-8").build();
621  }
622  }
623  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ getVocabularyRDF_JSONRDF()

Response getVocabularyRDF_JSONRDF ( @PathParam("vocabulary") String  vocabulary,
@QueryParam("pretty") boolean  pretty 
) throws IOException, JDOMException, TransformerException, ParserConfigurationException
554  {
555  try {
556  RDF rdf = new RDF();
557  String item = "ls_voc";
558  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
559  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
560  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
561  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
562  if (result.size() < 1) {
563  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
564  }
565  for (int i = 0; i < predicates.size(); i++) {
566  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
567  }
568  String out = rdf.getModel("RDF/JSON");
569  if (pretty) {
570  JsonParser parser = new JsonParser();
571  JsonObject json = parser.parse(out).getAsJsonObject();
572  Gson gson = new GsonBuilder().setPrettyPrinting().create();
573  return Response.ok(gson.toJson(json)).header("Content-Type", "application/json;charset=UTF-8").build();
574  } else {
575  return Response.ok(out).header("Content-Type", "application/json;charset=UTF-8").build();
576  }
577  } catch (Exception e) {
578  if (e.toString().contains("ResourceNotAvailableException")) {
579  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
580  .header("Content-Type", "application/json;charset=UTF-8").build();
581  } else {
582  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
583  .header("Content-Type", "application/json;charset=UTF-8").build();
584  }
585  }
586  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ getVocabularyRDF_N3()

Response getVocabularyRDF_N3 ( @PathParam("vocabulary") String  vocabulary) throws IOException, JDOMException, TransformerException, ParserConfigurationException
525  {
526  try {
527  RDF rdf = new RDF();
528  String item = "ls_voc";
529  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
530  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
531  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
532  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
533  if (result.size() < 1) {
534  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
535  }
536  for (int i = 0; i < predicates.size(); i++) {
537  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
538  }
539  return Response.ok(rdf.getModel("N-Triples")).build();
540  } catch (Exception e) {
541  if (e.toString().contains("ResourceNotAvailableException")) {
542  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
543  .header("Content-Type", "application/json;charset=UTF-8").build();
544  } else {
545  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
546  .header("Content-Type", "application/json;charset=UTF-8").build();
547  }
548  }
549  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ getVocabularyRDF_SKOS()

Response getVocabularyRDF_SKOS ( @PathParam("vocabulary") String  vocabulary) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
628  {
629  try {
630  RDF rdf = new RDF();
631  String item = "ls_voc";
632  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
633  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
634  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
635  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
636  if (result.size() < 1) {
637  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
638  }
639  for (int i = 0; i < predicates.size(); i++) {
640  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
641  }
642  item = "ls_voc";
643  query = GeneralFunctions.getAllLabelsForVocabulary(vocabulary);
644  result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
645  List<String> labels = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "id");
646  if (result.size() < 1) {
647  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
648  }
649  for (int i = 0; i < labels.size(); i++) {
650  item = "ls_lab";
651  query = GeneralFunctions.getAllElementsForItemID(item, labels.get(i));
652  result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
653  predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
654  objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
655  if (labels.size() < 1) {
656  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
657  }
658  for (int j = 0; j < predicates.size(); j++) {
659  rdf.setModelTriple(item + ":" + labels.get(i), predicates.get(j), objects.get(j));
660  }
661  }
662  String RDFoutput = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + rdf.getModel("RDF/XML");
663  return Response.ok(RDFoutput).header("Content-Disposition", "attachment; filename=\"" + vocabulary + ".rdf\"").build();
664  } catch (Exception e) {
665  if (e.toString().contains("ResourceNotAvailableException")) {
666  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
667  .header("Content-Type", "application/json;charset=UTF-8").build();
668  } else {
669  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
670  .header("Content-Type", "application/json;charset=UTF-8").build();
671  }
672  }
673  }

References GeneralFunctions.getAllElementsForItemID(), GeneralFunctions.getAllLabelsForVocabulary(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ getVocabularyRDF_Turtle()

Response getVocabularyRDF_Turtle ( @PathParam("vocabulary") String  vocabulary) throws IOException, JDOMException, TransformerException, ParserConfigurationException
496  {
497  try {
498  RDF rdf = new RDF();
499  String item = "ls_voc";
500  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
501  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
502  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
503  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
504  if (result.size() < 1) {
505  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
506  }
507  for (int i = 0; i < predicates.size(); i++) {
508  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
509  }
510  return Response.ok(rdf.getModel("Turtle")).build();
511  } catch (Exception e) {
512  if (e.toString().contains("ResourceNotAvailableException")) {
513  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
514  .header("Content-Type", "application/json;charset=UTF-8").build();
515  } else {
516  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
517  .header("Content-Type", "application/json;charset=UTF-8").build();
518  }
519  }
520  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ getVocabularyRDF_XML()

Response getVocabularyRDF_XML ( @PathParam("vocabulary") String  vocabulary) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
466  {
467  try {
468  RDF rdf = new RDF();
469  String item = "ls_voc";
470  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
471  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
472  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
473  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
474  if (result.size() < 1) {
475  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
476  }
477  for (int i = 0; i < predicates.size(); i++) {
478  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
479  }
480  String RDFoutput = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + rdf.getModel("RDF/XML");
481  return Response.ok(RDFoutput).build();
482  } catch (Exception e) {
483  if (e.toString().contains("ResourceNotAvailableException")) {
484  return Response.status(Response.Status.NOT_FOUND).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
485  .header("Content-Type", "application/json;charset=UTF-8").build();
486  } else {
487  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
488  .header("Content-Type", "application/json;charset=UTF-8").build();
489  }
490  }
491  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), and ConfigProperties.getPropertyParam().

◆ GZIP()

static OutputStream GZIP ( String  input,
OutputStream  baos 
) throws IOException
staticprivate
862  {
863  try (GZIPOutputStream gzos = new GZIPOutputStream(baos)) {
864  gzos.write(input.getBytes("UTF-8"));
865  } catch (Exception e) {
866  System.out.println(e.toString());
867  }
868  return baos;
869  }

◆ modifySPARQLUPDATE()

static String modifySPARQLUPDATE ( String  item,
String  itemid 
) throws ConfigException, IOException, UniqueIdentifierException
staticprivate
807  {
808  RDF rdf = new RDF();
809  String prefixes = rdf.getPREFIXSPARQL();
810  Calendar calender = Calendar.getInstance();
811  Date date = calender.getTime();
812  DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
813  String dateiso = formatter.format(date);
814  String triples = prefixes + "INSERT DATA { ";
815  triples += item + ":" + itemid + " dc:modified \"" + dateiso + "\"" + " . ";
816  triples += " }";
817  return triples;
818  }

◆ postVocabulary()

Response postVocabulary ( String  json) throws IOException, JDOMException, ConfigException, ParserConfigurationException, TransformerException
678  {
679  try {
680  // get variables
681  String item = "ls_voc";
682  // validate
683  ValidateJSONObject.validateVocabulary(json);
684  // set uuid
685  String itemID = UniqueIdentifier.getHashID();
686  // parse creator
687  JSONObject jsonObject = (JSONObject) new JSONParser().parse(json);
688  String creator = (String) jsonObject.get("creator");
689  // create triples
690  json = Transformer.vocabulary_POST(json, itemID);
691  String triples = createVocabularySPARQLUPDATE(item, itemID, creator);
692  // input triples
693  RDF4J_20.inputRDFfromRDFJSONString(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), json);
694  RDF4J_20.SPARQLupdate(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), triples);
695  // trigger for create statistics
696  Transformer.writeVocabularyStatisticsToDatabase(itemID);
697  // get result als json
698  RDF rdf = new RDF();
699  String query = GeneralFunctions.getAllElementsForItemID(item, itemID);
700  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
701  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
702  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
703  if (result.size() < 1) {
704  throw new ResourceNotAvailableException("resource " + itemID + " is not available");
705  }
706  for (int i = 0; i < predicates.size(); i++) {
707  rdf.setModelTriple(item + ":" + itemID, predicates.get(i), objects.get(i));
708  }
709  String out = Transformer.vocabulary_GET(rdf.getModel("RDF/JSON"), itemID, null, "false", "false").toJSONString();
710  return Response.status(Response.Status.CREATED).entity(out).build();
711  } catch (Exception e) {
712  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
713  .header("Content-Type", "application/json;charset=UTF-8").build();
714  }
715  }

References GeneralFunctions.getAllElementsForItemID(), UniqueIdentifier.getHashID(), Logging.getMessageJSON(), ConfigProperties.getPropertyParam(), ValidateJSONObject.validateVocabulary(), Transformer.vocabulary_GET(), Transformer.vocabulary_POST(), and Transformer.writeVocabularyStatisticsToDatabase().

◆ updateVocabulary()

Response updateVocabulary ( @PathParam("vocabulary") String  vocabulary,
String  json 
) throws IOException, JDOMException, RdfException, ParserConfigurationException, TransformerException
722  {
723  try {
724  String item = "ls_voc";
725  // validate
726  ValidateJSONObject.validateVocabulary(json);
727  // check if resource exists
728  String queryExist = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
729  List<BindingSet> resultExist = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), queryExist);
730  if (resultExist.size() < 1) {
731  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
732  }
733  // insert data
734  json = Transformer.vocabulary_POST(json, vocabulary);
735  // set triples
736  RDF4J_20.SPARQLupdate(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), modifySPARQLUPDATE(item, vocabulary));
737  RDF4J_20.SPARQLupdate(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), deleteItemsSPARQLUPDATE(vocabulary));
738  RDF4J_20.inputRDFfromRDFJSONString(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), json);
739  // get result als json
740  RDF rdf = new RDF();
741  String query = GeneralFunctions.getAllElementsForItemID(item, vocabulary);
742  List<BindingSet> result = RDF4J_20.SPARQLquery(ConfigProperties.getPropertyParam("repository"), ConfigProperties.getPropertyParam("ts_server"), query);
743  List<String> predicates = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "p");
744  List<String> objects = RDF4J_20.getValuesFromBindingSet_ORDEREDLIST(result, "o");
745  if (result.size() < 1) {
746  throw new ResourceNotAvailableException("resource " + vocabulary + " is not available");
747  }
748  for (int i = 0; i < predicates.size(); i++) {
749  rdf.setModelTriple(item + ":" + vocabulary, predicates.get(i), objects.get(i));
750  }
751  String out = Transformer.vocabulary_GET(rdf.getModel("RDF/JSON"), vocabulary, null, "false", "false").toJSONString();
752  return Response.status(Response.Status.CREATED).entity(out).build();
753  } catch (Exception e) {
754  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e, "v1.rest.VocabsResource"))
755  .header("Content-Type", "application/json;charset=UTF-8").build();
756  }
757  }

References GeneralFunctions.getAllElementsForItemID(), Logging.getMessageJSON(), ConfigProperties.getPropertyParam(), ValidateJSONObject.validateVocabulary(), Transformer.vocabulary_GET(), and Transformer.vocabulary_POST().

rdf
Definition: RDF.java:1
v1.rest.VocabsResource.GZIP
static OutputStream GZIP(String input, OutputStream baos)
Definition: VocabsResource.java:862
v1.rest.VocabsResource.deleteItemsSPARQLUPDATE
static String deleteItemsSPARQLUPDATE(String id)
Definition: VocabsResource.java:820
Exception
v1.rest.VocabsResource.deleteVocabularySPARQLUPDATE
static String deleteVocabularySPARQLUPDATE(String id)
Definition: VocabsResource.java:835
v1.rest.VocabsResource.deleteLabelsSPARQLUPDATE
static String deleteLabelsSPARQLUPDATE(String vocabid)
Definition: VocabsResource.java:849
v1.rest.VocabsResource.modifySPARQLUPDATE
static String modifySPARQLUPDATE(String item, String itemid)
Definition: VocabsResource.java:807
v1.rest.VocabsResource.createVocabularySPARQLUPDATE
static String createVocabularySPARQLUPDATE(String item, String itemid, String creator)
Definition: VocabsResource.java:787