From 2908fd5c306307e0136dc0c8a866fb87a10f39b6 Mon Sep 17 00:00:00 2001
From: Bastiaan Verhoef <verhoef@astron.nl>
Date: Mon, 2 Nov 2009 14:21:34 +0000
Subject: [PATCH] Bug1379: Add parse xml support

---
 .../mom2listener/Mom2HttpRequestHandler.java  | 27 ++++++++++---------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/Mom2HttpRequestHandler.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/Mom2HttpRequestHandler.java
index 850c2695623..cf04f45d35d 100644
--- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/Mom2HttpRequestHandler.java
+++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/Mom2HttpRequestHandler.java
@@ -66,23 +66,24 @@ public class Mom2HttpRequestHandler implements HttpRequestHandler {
 					schemas.add(this.getClass().getClassLoader().getResource("schemas/MoM2.xsd"));
 					schemas.add(this.getClass().getClassLoader().getResource("schemas/LofarMoM2.xsd"));
 					document = XMLConverter.convertXMLToDocument(inputSource,schemas);
+					LofarObservation lofarObservation = XMLParser.getLofarObservation(document);
+					try {
+						repository.store(lofarObservation);
+						response.setStatusCode(HttpStatus.SC_OK);
+						requestHandledSuccessfull = true;
+					} catch (RepositoryException e) {
+						response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+						log.fatal("Problem occurred with OTDB: " + e.getMessage(), e);
+					} catch (Exception e) {
+						response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+						log.fatal("Problem occurred : " + e.getMessage(), e);
+					}
+					response.setStatusCode(HttpStatus.SC_OK);
 				} catch (Exception e) {
 					response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
 					log.error("Problem with parsing xml content: " + e.getMessage(), e);
 				}		
-				LofarObservation lofarObservation = XMLParser.getLofarObservation(document);
-				try {
-					repository.store(lofarObservation);
-					response.setStatusCode(HttpStatus.SC_OK);
-					requestHandledSuccessfull = true;
-				} catch (RepositoryException e) {
-					response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-					log.fatal("Problem occurred with OTDB: " + e.getMessage(), e);
-				} catch (Exception e) {
-					response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-					log.fatal("Problem occurred : " + e.getMessage(), e);
-				}
-				response.setStatusCode(HttpStatus.SC_OK);
+
 			}		
 
 		} else {
-- 
GitLab