1 package com.ontotext.ordi.wsmo4rdf.remote.client;
2
3 import static com.ontotext.ordi.wsmo4rdf.remote.Constants.SRX_NAMESPACE;
4
5 import java.io.ByteArrayInputStream;
6 import java.io.IOException;
7 import java.io.UnsupportedEncodingException;
8 import java.math.BigDecimal;
9 import java.util.LinkedList;
10 import java.util.List;
11 import java.util.Set;
12
13 import javanet.staxutils.SimpleNamespaceContext;
14
15 import javax.xml.parsers.DocumentBuilderFactory;
16 import javax.xml.parsers.ParserConfigurationException;
17 import javax.xml.xpath.XPath;
18 import javax.xml.xpath.XPathConstants;
19 import javax.xml.xpath.XPathExpression;
20 import javax.xml.xpath.XPathExpressionException;
21 import javax.xml.xpath.XPathFactory;
22
23 import org.apache.commons.lang.SerializationException;
24 import org.apache.log4j.Logger;
25 import org.omwg.ontology.Ontology;
26 import org.openrdf.query.MalformedQueryException;
27 import org.w3c.dom.Attr;
28 import org.w3c.dom.Document;
29 import org.w3c.dom.Element;
30 import org.w3c.dom.NodeList;
31 import org.wsmo.common.Entity;
32 import org.wsmo.common.IRI;
33 import org.wsmo.common.Identifier;
34 import org.wsmo.common.exception.SynchronisationException;
35 import org.wsmo.factory.DataFactory;
36 import org.wsmo.factory.Factory;
37 import org.wsmo.factory.LogicalExpressionFactory;
38 import org.wsmo.factory.WsmoFactory;
39 import org.wsmo.mediator.Mediator;
40 import org.wsmo.service.Goal;
41 import org.wsmo.service.WebService;
42 import org.xml.sax.SAXException;
43
44 import com.ontotext.ordi.DataSource;
45 import com.ontotext.ordi.IsolationLevel;
46 import com.ontotext.ordi.exception.ORDIException;
47 import com.ontotext.ordi.exception.ORDIWarning;
48 import com.ontotext.ordi.wsmo4rdf.QueryResultListener;
49 import com.ontotext.ordi.wsmo4rdf.WsmoConnection;
50 import com.ontotext.ordi.wsmo4rdf.remote.DOMUtil;
51 import com.ontotext.ordi.wsmo4rdf.remote.Marshaller;
52 import com.ontotext.ordi.wsmo4rdf.remote.client.conn.MalformedQueryException_Exception;
53 import com.ontotext.ordi.wsmo4rdf.remote.client.conn.NonExistingEntryException_Exception;
54 import com.ontotext.ordi.wsmo4rdf.remote.client.conn.ORDIException_Exception;
55 import com.ontotext.ordi.wsmo4rdf.remote.client.conn.OrdiConfigurationException_Exception;
56 import com.ontotext.ordi.wsmo4rdf.remote.client.conn.SynchronisationException_Exception;
57 import com.ontotext.ordi.wsmo4rdf.remote.client.conn.UnmarshalException_Exception;
58 import com.ontotext.ordi.wsmo4rdf.remote.exception.UnmarshalException;
59
60 public class RemoteWsmoConnection implements WsmoConnection {
61
62 private final static Logger logger = Logger
63 .getLogger(RemoteWsmoConnection.class);
64
65 private final int id;
66 private final RemoteWsmo4rdfGate gate;
67 private final WsmoFactory wsmoFactory;
68 private final LogicalExpressionFactory leFactory;
69 private final DataFactory dtFactory;
70
71 public RemoteWsmoConnection(int conId, RemoteWsmo4rdfGate gate) {
72 this.id = conId;
73 this.gate = gate;
74
75 this.wsmoFactory = Factory.createWsmoFactory(null);
76 this.leFactory = Factory.createLogicalExpressionFactory(null);
77 this.dtFactory = Factory.createDataFactory(null);
78 }
79
80 @Override
81 public void finalize() {
82 try {
83 logger.debug("GarbageCollector requested closing this(ID="
84 + this.id + ") connection.");
85 close();
86 } catch (ORDIException e) {
87 logger.warn("Trying to close "
88 + RemoteWsmoConnection.class.getName() + "with ID="
89 + this.id + " failed.");
90 e.printStackTrace();
91 }
92 }
93
94 int getId() {
95 return this.id;
96 }
97
98 public void evaluate(String query, QueryResultListener listener)
99 throws MalformedQueryException {
100 String sxr = null;
101 try {
102 sxr = this.gate.getConnectionService().evaluate(this.id, query);
103 } catch (NonExistingEntryException_Exception e) {
104 logException(e, "evaluate");
105 e.printStackTrace();
106 return;
107 } catch (OrdiConfigurationException_Exception e) {
108 logger
109 .error("Invalid ORDI configuration on the server. Aborting query evaluation.");
110 e.printStackTrace();
111 return;
112 } catch (MalformedQueryException_Exception e) {
113
114 throw new MalformedQueryException(e);
115 }
116
117 Document resp = parseXmlFromResponseString(sxr);
118 if (resp == null) {
119 logger
120 .error("Cannot parse SPARQL XML Response. Aborting SPARQL query evaluation.");
121 return;
122 }
123
124 System.out.println(DOMUtil.convert(resp).toString());
125
126 XPathFactory factory = XPathFactory.newInstance();
127 XPath xpath = factory.newXPath();
128
129 SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
130 nsContext.setPrefix("xsr", SRX_NAMESPACE);
131
132 xpath.setNamespaceContext(nsContext);
133
134 XPathExpression expr = null;
135 NodeList xpathResult = null;
136 try {
137 expr = xpath.compile("//xsr:sparql/xsr:results/xsr:result");
138 xpathResult = (NodeList) expr
139 .evaluate(resp, XPathConstants.NODESET);
140 } catch (XPathExpressionException e) {
141 assert (false);
142 }
143 assert (expr != null);
144 assert (xpathResult != null);
145
146 for (int i = 0; i < xpathResult.getLength(); i++) {
147 Element resultElement = (Element) xpathResult.item(i);
148 Element bindingElement = (Element) resultElement
149 .getElementsByTagNameNS(SRX_NAMESPACE, "binding").item(0);
150
151 String variableName = bindingElement.getAttribute("name");
152
153 NodeList dataElementsList = bindingElement.getChildNodes();
154 Element dataElement = null;
155 int j;
156 for (j = 0; j < dataElementsList.getLength()
157 && !(dataElementsList.item(j) instanceof Element); j++) {
158 }
159 dataElement = (Element) dataElementsList.item(j);
160 assert (dataElement != null);
161
162
163
164 String dataElementName = dataElement.getLocalName();
165 if (dataElementName.equalsIgnoreCase("uri")) {
166 listener.nextBinding(variableName, this.wsmoFactory
167 .createIRI(dataElement.getTextContent()));
168 } else if (dataElementName.equalsIgnoreCase("bnode")) {
169 listener.nextBinding(variableName, this.wsmoFactory
170 .createAnonymousID());
171 } else if (dataElementName.equalsIgnoreCase("literal")) {
172 Attr datatypeAttribute = dataElement.getAttributeNodeNS(
173 SRX_NAMESPACE, "datatype");
174 if (datatypeAttribute != null) {
175
176 String dtContent = datatypeAttribute.getValue();
177 if (dtContent
178 .equals("http://www.wsmo.org/wsml/wsml-syntax#variable")) {
179 listener.nextBinding(variableName, this.leFactory
180 .createVariable(dataElement.getTextContent()));
181 }
182
183 } else {
184 String value = dataElement.getTextContent();
185 try {
186 double pValue = Double.valueOf(value);
187 BigDecimal objValue = BigDecimal.valueOf(pValue);
188 listener.nextBinding(variableName, this.dtFactory
189 .createWsmlDecimal(objValue));
190 } catch (NumberFormatException nfe1) {
191 try {
192 @SuppressWarnings("unused")
193 Integer objValue = Integer.valueOf(value);
194 listener.nextBinding(variableName, this.dtFactory
195 .createWsmlInteger(value));
196 } catch (NumberFormatException nfe2) {
197 listener.nextBinding(variableName, this.dtFactory
198 .createWsmlString(value));
199 }
200 }
201
202 }
203
204 }
205
206 }
207 }
208
209 public String getDescription() {
210 String result = null;
211 try {
212 result = this.gate.getConnectionService().getDescription(this.id);
213 } catch (NonExistingEntryException_Exception e) {
214 logException(e, "getDescription");
215 e.printStackTrace();
216 }
217 return result;
218 }
219
220 public void setDescription(String desc) {
221 try {
222 this.gate.getConnectionService().setDescription(this.id, desc);
223 } catch (NonExistingEntryException_Exception e) {
224 logException(e, "setDescription");
225 e.printStackTrace();
226 return;
227 }
228 }
229
230 public String getVersion() throws SynchronisationException {
231 String version = null;
232 try {
233 version = this.gate.getConnectionService().getVersion(this.id);
234 } catch (NonExistingEntryException_Exception e) {
235 logException(e, "getVersion");
236 e.printStackTrace();
237 } catch (SynchronisationException_Exception e) {
238 throw new SynchronisationException(e);
239 }
240 return version;
241 }
242
243 public void addOntology(Ontology ont) throws SynchronisationException {
244 try {
245 this.gate.getConnectionService().addOntology(this.id,
246 Marshaller.marshal(ont));
247 } catch (NonExistingEntryException_Exception e) {
248 logException(e, "addOntology");
249 e.printStackTrace();
250 return;
251 } catch (SynchronisationException_Exception e) {
252 throw new SynchronisationException(e);
253 } catch (UnmarshalException_Exception e) {
254 logException(e, "addOntology");
255 e.printStackTrace();
256 return;
257 }
258 }
259
260 public void deleteOntology(IRI id) throws SynchronisationException {
261 try {
262 this.gate.getConnectionService().deleteOntology(this.id,
263 id.toString());
264 } catch (NonExistingEntryException_Exception e) {
265 logException(e, "deleteOntology");
266 e.printStackTrace();
267 return;
268 } catch (SynchronisationException_Exception e) {
269 throw new SynchronisationException(e);
270 }
271 }
272
273 public Ontology getOntology(IRI id) throws SynchronisationException {
274 Ontology ontology = null;
275 String ontoString = null;
276 try {
277 ontoString = this.gate.getConnectionService().getOntology(this.id,
278 id.toString());
279 ontology = Marshaller.unmarshalOntology(ontoString);
280 } catch (NonExistingEntryException_Exception e) {
281 logException(e, "getOntology");
282 e.printStackTrace();
283 return null;
284 } catch (SynchronisationException_Exception e) {
285 throw new SynchronisationException(e);
286 } catch (UnmarshalException e) {
287 logException(e, "getOntology");
288 e.printStackTrace();
289 return null;
290 }
291 return ontology;
292 }
293
294 public void saveOntology(Ontology ont) throws SynchronisationException {
295 try {
296 this.gate.getConnectionService().saveOntology(this.id,
297 Marshaller.marshal(ont));
298 } catch (NonExistingEntryException_Exception e) {
299 logException(e, "saveOntology");
300 e.printStackTrace();
301 return;
302 } catch (SynchronisationException_Exception e) {
303 throw new SynchronisationException(e);
304 } catch (UnmarshalException_Exception e) {
305 logException(e, "saveOntology");
306 e.printStackTrace();
307 return;
308 }
309 }
310
311 public List<IRI> listOntologies() throws SynchronisationException {
312 List<String> ontoIriStringList = null;
313 try {
314 ontoIriStringList = this.gate.getConnectionService()
315 .listOntologies(this.id);
316 } catch (NonExistingEntryException_Exception e) {
317 logException(e, "listOntologies");
318 e.printStackTrace();
319 return null;
320 } catch (SynchronisationException_Exception e) {
321 throw new SynchronisationException(e);
322 }
323 assert (ontoIriStringList != null);
324 List<IRI> result = new LinkedList<IRI>();
325 for (String iriString : ontoIriStringList) {
326 result.add(Marshaller.newIRI(iriString));
327 }
328 return result;
329 }
330
331 public void addGoal(Goal goal) throws SynchronisationException {
332
333 try {
334 this.gate.getConnectionService().addGoal(this.id,
335 Marshaller.marshal(goal));
336 } catch (NonExistingEntryException_Exception e) {
337 logException(e, "addGoal");
338 } catch (UnmarshalException_Exception e) {
339 logException(e, "addGoal");
340 e.printStackTrace();
341 } catch (SynchronisationException_Exception e) {
342 throw new SynchronisationException(e);
343 }
344 }
345
346 public void saveGoal(Goal goal) throws SynchronisationException {
347 try {
348 this.gate.getConnectionService().saveGoal(this.id,
349 Marshaller.marshal(goal));
350 } catch (NonExistingEntryException_Exception e) {
351 logException(e, "saveGoal");
352 } catch (UnmarshalException_Exception e) {
353 logException(e, "saveGoal");
354 } catch (SynchronisationException_Exception e) {
355 throw new SerializationException(e);
356 }
357
358 }
359
360 public Goal getGoal(IRI id) throws SynchronisationException {
361 String goalAsString = null;
362 try {
363 goalAsString = this.gate.getConnectionService().getGoal(this.id,
364 id.toString());
365 } catch (NonExistingEntryException_Exception e) {
366 logException(e, "getGoal");
367 } catch (SynchronisationException_Exception e) {
368 throw new SynchronisationException(e);
369 }
370 Goal goal = null;
371 try {
372 goal = Marshaller.unmarshalGoal(goalAsString);
373 } catch (UnmarshalException e) {
374 logException(e, "getGoal");
375 e.printStackTrace();
376 return null;
377 }
378 return goal;
379 }
380
381 public void deleteGoal(IRI id) throws SynchronisationException {
382 try {
383 this.gate.getConnectionService().deleteGoal(this.id, id.toString());
384 } catch (NonExistingEntryException_Exception e) {
385 logException(e, "deleteGoal");
386 } catch (SynchronisationException_Exception e) {
387 throw new SynchronisationException(e);
388 }
389 }
390
391 public List<IRI> listGoals() throws SynchronisationException {
392 List<String> goalIriStringList = null;
393 try {
394 goalIriStringList = this.gate.getConnectionService().listGoals(
395 this.id);
396 } catch (NonExistingEntryException_Exception e) {
397 logException(e, "listGoals");
398 e.printStackTrace();
399 return null;
400 } catch (SynchronisationException_Exception e) {
401 throw new SynchronisationException(e);
402 }
403 assert (goalIriStringList != null);
404 List<IRI> result = new LinkedList<IRI>();
405 for (String iriString : goalIriStringList) {
406 result.add(Marshaller.newIRI(iriString));
407 }
408 return result;
409 }
410
411 public void addMediator(Mediator med) throws SynchronisationException {
412 try {
413 this.gate.getConnectionService().addMediator(this.id,
414 Marshaller.marshal(med));
415 } catch (NonExistingEntryException_Exception e) {
416 logException(e, "addMediator");
417 } catch (UnmarshalException_Exception e) {
418 logException(e, "addMediator");
419 e.printStackTrace();
420 } catch (SynchronisationException_Exception e) {
421 throw new SynchronisationException(e);
422 }
423 }
424
425 public void addWebService(WebService ws) throws SynchronisationException {
426 try {
427 this.gate.getConnectionService().addWebService(this.id,
428 Marshaller.marshal(ws));
429 } catch (NonExistingEntryException_Exception e) {
430 logException(e, "addWebService");
431 } catch (UnmarshalException_Exception e) {
432 logException(e, "addWebService");
433 e.printStackTrace();
434 } catch (SynchronisationException_Exception e) {
435 throw new SynchronisationException(e);
436 }
437 }
438
439 public void deleteMediator(IRI id) throws SynchronisationException {
440 try {
441 this.gate.getConnectionService().deleteMediator(this.id,
442 id.toString());
443 } catch (NonExistingEntryException_Exception e) {
444 logException(e, "deleteMediator");
445 e.printStackTrace();
446 return;
447 } catch (SynchronisationException_Exception e) {
448 throw new SynchronisationException(e);
449 }
450 }
451
452 public void deleteWebService(IRI id) throws SynchronisationException {
453 try {
454 this.gate.getConnectionService().deleteWebService(this.id,
455 id.toString());
456 } catch (NonExistingEntryException_Exception e) {
457 logException(e, "deleteWebService");
458 e.printStackTrace();
459 return;
460 } catch (SynchronisationException_Exception e) {
461 throw new SynchronisationException(e);
462 }
463 }
464
465 public Mediator getMediator(IRI id) throws SynchronisationException {
466 String mediatorAsString = null;
467 try {
468 mediatorAsString = this.gate.getConnectionService().getMediator(this.id,
469 id.toString());
470 } catch (NonExistingEntryException_Exception e) {
471 logException(e, "getMediator");
472 } catch (SynchronisationException_Exception e) {
473 throw new SynchronisationException(e);
474 }
475 Mediator mediator = null;
476 try {
477 mediator = Marshaller.unmarshalMediatior(mediatorAsString);
478 } catch (UnmarshalException e) {
479 logException(e, "getMediator");
480 e.printStackTrace();
481 return null;
482 }
483 return mediator;
484 }
485
486 public WebService getWebService(IRI id) throws SynchronisationException {
487 String serviceAsString = null;
488 try {
489 serviceAsString = this.gate.getConnectionService().getWebService(this.id,
490 id.toString());
491 } catch (NonExistingEntryException_Exception e) {
492 logException(e, "getWebService");
493 } catch (SynchronisationException_Exception e) {
494 throw new SynchronisationException(e);
495 }
496 WebService webService = null;
497 try {
498 webService = Marshaller.unmarshalWebService(serviceAsString);
499 } catch (UnmarshalException e) {
500 logException(e, "getWebService");
501 e.printStackTrace();
502 return null;
503 }
504 return webService;
505 }
506
507 public List<IRI> listMediators() throws SynchronisationException {
508 List<String> mediatorIriStringList = null;
509 try {
510 mediatorIriStringList = this.gate.getConnectionService().listMediators(
511 this.id);
512 } catch (NonExistingEntryException_Exception e) {
513 logException(e, "listMediators");
514 e.printStackTrace();
515 return null;
516 } catch (SynchronisationException_Exception e) {
517 throw new SynchronisationException(e);
518 }
519 assert (mediatorIriStringList != null);
520 List<IRI> result = new LinkedList<IRI>();
521 for (String iriString : mediatorIriStringList) {
522 result.add(Marshaller.newIRI(iriString));
523 }
524 return result;
525 }
526
527 public List<IRI> listWebServices() throws SynchronisationException {
528 List<String> serviceIriStringList = null;
529 try {
530 serviceIriStringList = this.gate.getConnectionService().listWebServices(this.id);
531 } catch (NonExistingEntryException_Exception e) {
532 logException(e, "listWebServices");
533 e.printStackTrace();
534 return null;
535 } catch (SynchronisationException_Exception e) {
536 throw new SynchronisationException(e);
537 }
538 assert (serviceIriStringList != null);
539 List<IRI> result = new LinkedList<IRI>();
540 for (String iriString : serviceIriStringList) {
541 result.add(Marshaller.newIRI(iriString));
542 }
543 return result;
544 }
545
546 public void saveMediator(Mediator med) throws SynchronisationException {
547 try {
548 this.gate.getConnectionService().saveMediator(this.id,
549 Marshaller.marshal(med));
550 } catch (NonExistingEntryException_Exception e) {
551 logException(e, "saveMediator");
552 e.printStackTrace();
553 return;
554 } catch (SynchronisationException_Exception e) {
555 throw new SynchronisationException(e);
556 } catch (UnmarshalException_Exception e) {
557 logException(e, "saveMediator");
558 e.printStackTrace();
559 return;
560 }
561 }
562
563 public void saveWebService(WebService ws) throws SynchronisationException {
564 try {
565 this.gate.getConnectionService().saveWebService(this.id,
566 Marshaller.marshal(ws));
567 } catch (NonExistingEntryException_Exception e) {
568 logException(e, "saveWebService");
569 e.printStackTrace();
570 return;
571 } catch (SynchronisationException_Exception e) {
572 throw new SynchronisationException(e);
573 } catch (UnmarshalException_Exception e) {
574 logException(e, "saveWebService");
575 e.printStackTrace();
576 return;
577 }
578 }
579
580 public Set<Entity> load(Identifier id) {
581 throw new UnsupportedOperationException();
582 }
583
584 @SuppressWarnings("unchecked")
585 public Entity load(Identifier id, Class clazz) {
586 throw new UnsupportedOperationException();
587 }
588
589 public void remove(Identifier id) {
590 throw new UnsupportedOperationException();
591 }
592
593 @SuppressWarnings("unchecked")
594 public void remove(Identifier id, Class clazz) {
595 throw new UnsupportedOperationException();
596 }
597
598 public void save(Entity item) {
599 throw new UnsupportedOperationException();
600 }
601
602 public void close() throws ORDIException {
603 try {
604 this.gate.getConnectionService().close(this.id);
605 } catch (NonExistingEntryException_Exception nee) {
606 logException(nee, "close");
607 return;
608 } catch (ORDIException_Exception e) {
609 throw new ORDIException(e);
610 }
611 }
612
613 public void commit() throws ORDIException {
614 try {
615 this.gate.getConnectionService().commit(this.id);
616 } catch (NonExistingEntryException_Exception e) {
617 logException(e, "commit");
618 return;
619 } catch (ORDIException_Exception e) {
620 throw new ORDIException(e);
621 }
622 }
623
624 public DataSource getDataSource() {
625 throw new UnsupportedOperationException();
626 }
627
628 public IsolationLevel getTransactionIsolationLevel() {
629 throw new UnsupportedOperationException();
630 }
631
632 public boolean isAutoCommit() {
633 try {
634 boolean result = this.gate.getConnectionService().isAutoCommit(
635 this.id);
636 return result;
637 } catch (NonExistingEntryException_Exception e) {
638 logException(e, "isAutoCommit");
639 e.printStackTrace();
640 return false;
641 }
642 }
643
644 public boolean isOpen() {
645 try {
646 this.gate.getConnectionService().isOpen(this.id);
647 } catch (NonExistingEntryException_Exception e) {
648 logException(e, "isOpen");
649 e.printStackTrace();
650 return false;
651 }
652 return false;
653 }
654
655 public boolean isReadOnly() {
656 try {
657 boolean result = this.gate.getConnectionService().isReadOnly(
658 this.id);
659 return result;
660 } catch (NonExistingEntryException_Exception e) {
661 logException(e, "isReadOnly");
662 e.printStackTrace();
663 return true;
664
665 }
666 }
667
668 public void rollback() throws ORDIException {
669 try {
670 this.gate.getConnectionService().rollback(this.id);
671 } catch (NonExistingEntryException_Exception e) {
672 logException(e, "rollback");
673 return;
674 } catch (ORDIException_Exception e) {
675 throw new ORDIException(e);
676 }
677 }
678
679 public void setAutoCommit(boolean mode) throws ORDIException {
680 try {
681 this.gate.getConnectionService().setAutoCommit(this.id, mode);
682 } catch (NonExistingEntryException_Exception e) {
683 logException(e, "setAutoCommit");
684 return;
685 } catch (ORDIException_Exception e) {
686 throw new ORDIException(e);
687 }
688 }
689
690 public void setTransactionIsolationLevel(IsolationLevel isolationLevel)
691 throws ORDIException {
692 throw new UnsupportedOperationException();
693 }
694
695 public boolean isWrapperFor(Class<?> iface) throws ORDIException {
696 throw new UnsupportedOperationException();
697 }
698
699 public <T> T unwrap(Class<T> iface) throws ORDIException {
700 throw new UnsupportedOperationException();
701 }
702
703 public void clearWarnings() {
704 try {
705 this.gate.getConnectionService().clearWarnings(this.id);
706 } catch (NonExistingEntryException_Exception e) {
707 logException(e, "clearWarnings");
708 e.printStackTrace();
709 return;
710 }
711 }
712
713
714 public ORDIWarning getWarning() {
715 throw new UnsupportedOperationException();
716 }
717
718 private Document parseXmlFromResponseString(String sxr) {
719 Document resp = null;
720
721 DocumentBuilderFactory docBuldFactory = DocumentBuilderFactory
722 .newInstance();
723 docBuldFactory.setNamespaceAware(true);
724 try {
725 resp = docBuldFactory.newDocumentBuilder().parse(
726 new ByteArrayInputStream(sxr.getBytes("UTF-8")));
727 } catch (UnsupportedEncodingException e) {
728 logger
729 .error("Response string is not encoeded in UTF-8. Aborting parsing.");
730 e.printStackTrace();
731 return null;
732 } catch (SAXException e) {
733 logger
734 .error("SAXException while trying to parse SPARQL XML Response. Aborting parsing.");
735 e.printStackTrace();
736 return null;
737 } catch (IOException e) {
738 logger
739 .error("IOException thrown while trying to parse the SPARQL XML Result. Aborting parsing.");
740 e.printStackTrace();
741 return null;
742 } catch (ParserConfigurationException e) {
743 logger
744 .error("ParserConfigurationException while trying to parse SPARQL XML Response. Aborting parsing.");
745 e.printStackTrace();
746 return null;
747 }
748 return resp;
749 }
750
751
752
753
754
755 private void logException(Exception e, String operation) {
756 logger.error(e.getClass().getName() + " thrown in " + operation
757 + ". Aborting method execution.");
758 }
759 }