Strabon

changeset 128:fe3dcddc2aba

working on kmz workaround
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Tue May 08 10:51:26 2012 +0300 (2012-05-08)
parents 4fc7c28159aa
children 3d4a04d579aa
files endpoint/WebContent/WEB-INF/beans.xml endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/beans.xml	Fri May 04 14:08:23 2012 +0300
     1.2 +++ b/endpoint/WebContent/WEB-INF/beans.xml	Tue May 08 10:51:26 2012 +0300
     1.3 @@ -11,7 +11,7 @@
     1.4  	<bean id="strabonBean" class="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper" destroy-method="destroy">
     1.5  		<constructor-arg type="java.lang.String">
     1.6  			<!-- Database name -->
     1.7 -			<value>corine</value>
     1.8 +			<value>darmstadt-noa</value>
     1.9  		</constructor-arg>
    1.10  		<constructor-arg type="java.lang.String">
    1.11  			<!-- Username -->
    1.12 @@ -27,7 +27,7 @@
    1.13  		</constructor-arg>
    1.14  		<constructor-arg type="java.lang.String">
    1.15  			<!-- Database server -->
    1.16 -			<value>teleios4.di.uoa.gr</value>
    1.17 +			<value>localhost</value>
    1.18  		</constructor-arg>
    1.19  		<constructor-arg type="boolean">
    1.20  			<!-- Check for locks and remove them (in case of a crash) -->
     2.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Fri May 04 14:08:23 2012 +0300
     2.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Tue May 08 10:51:26 2012 +0300
     2.3 @@ -2,6 +2,8 @@
     2.4  
     2.5  import java.io.BufferedWriter;
     2.6  import java.io.File;
     2.7 +import java.io.FileInputStream;
     2.8 +import java.io.FileOutputStream;
     2.9  import java.io.FileWriter;
    2.10  import java.io.IOException;
    2.11  import java.io.PrintWriter;
    2.12 @@ -9,6 +11,8 @@
    2.13  import java.security.SecureRandom;
    2.14  import java.util.Date;
    2.15  import java.util.Iterator;
    2.16 +import java.util.zip.ZipEntry;
    2.17 +import java.util.zip.ZipOutputStream;
    2.18  
    2.19  import javax.servlet.ServletConfig;
    2.20  import javax.servlet.ServletContext;
    2.21 @@ -24,35 +28,35 @@
    2.22  import org.openrdf.repository.RepositoryException;
    2.23  import org.springframework.web.context.WebApplicationContext;
    2.24  import org.springframework.web.context.support.WebApplicationContextUtils;
    2.25 - 
    2.26 +
    2.27  
    2.28  public class QueryBean extends HttpServlet {
    2.29 -	
    2.30 +
    2.31  	private static final long serialVersionUID = -378175118289907707L;
    2.32 -	
    2.33 +
    2.34  	private ServletContext context; 
    2.35  	private StrabonBeanWrapper strabonWrapper;
    2.36 -	
    2.37 +
    2.38  	public void doGet(HttpServletRequest request, HttpServletResponse response)
    2.39 -	throws ServletException, IOException
    2.40 -	{
    2.41 +			throws ServletException, IOException
    2.42 +			{
    2.43  		doPost(request, response);
    2.44 -	}
    2.45 -	
    2.46 +			}
    2.47 +
    2.48  	public void doPost(HttpServletRequest request, HttpServletResponse response)
    2.49 -	throws ServletException, IOException
    2.50 -	{
    2.51 +			throws ServletException, IOException
    2.52 +			{
    2.53  		final class DataHive{
    2.54  			private String format;
    2.55  			private String SPARQLQuery;
    2.56  			private String errorMessage;
    2.57 -			
    2.58 +
    2.59  			DataHive(){
    2.60  				this.format = null;
    2.61  				this.SPARQLQuery = null;
    2.62  				this.errorMessage = null;				
    2.63  			}
    2.64 -			
    2.65 +
    2.66  			public String getSPARQLQuery() {
    2.67  				return SPARQLQuery;
    2.68  			}
    2.69 @@ -60,7 +64,7 @@
    2.70  			public void setSPARQLQuery(String sPARQLQuery) {
    2.71  				SPARQLQuery = sPARQLQuery;
    2.72  			}
    2.73 -			
    2.74 +
    2.75  			public String getFormat() {
    2.76  				return format;
    2.77  			}
    2.78 @@ -77,29 +81,32 @@
    2.79  				this.errorMessage = error;
    2.80  			}
    2.81  		}
    2.82 -				
    2.83 +
    2.84  		DataHive hive = new DataHive(); 
    2.85 -		
    2.86 +
    2.87  		hive.setSPARQLQuery(request.getParameter("SPARQLQuery"));
    2.88 -		
    2.89 +
    2.90  		String reqFormat = (request.getParameter("format") == null) ? "" : request.getParameter("format");
    2.91  		String reqAccept = (request.getHeader("accept") == null) ? "" : request.getHeader("accept");
    2.92  		String reqFuncionality = (request.getParameter("submit") == null) ? "" : request.getParameter("submit");
    2.93 -		
    2.94 +
    2.95  		// check whether Update submit button was fired
    2.96  		if (reqFuncionality.equals("Update")) { // only for executions from web browsers
    2.97  			response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
    2.98  			response.sendRedirect("Update?SPARQLQuery=" + hive.getSPARQLQuery());
    2.99 -			
   2.100 +
   2.101  			return;
   2.102  		}
   2.103 -		
   2.104 +
   2.105  		if ((reqFormat == "") && (reqAccept == "")) {
   2.106  			hive.setFormat("HTML");
   2.107  			response.setContentType("text/html; charset=UTF-8");			
   2.108  		} else if (reqAccept.contains("application/vnd.google-earth.kml+xml")) {
   2.109  			response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
   2.110  			hive.setFormat("KML");
   2.111 +		} else if (reqAccept.contains("application/vnd.google-earth.kmz")) {
   2.112 +			response.setContentType("application/vnd.google-earth.kmz; charset=UTF-8");
   2.113 +			hive.setFormat("KMZ");
   2.114  		} else if (reqAccept.contains("application/sparql-results+xml")) {			
   2.115  			response.setContentType("application/sparql-results+xml; charset=UTF-8");
   2.116  			hive.setFormat("XML");
   2.117 @@ -109,141 +116,283 @@
   2.118  		} else if (reqFormat.equalsIgnoreCase("KML")) {
   2.119  			response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
   2.120  			hive.setFormat("KML");
   2.121 +		} else if (reqFormat.equalsIgnoreCase("KMZ")) {
   2.122 +			response.setContentType("application/vnd.google-earth.kmz; charset=UTF-8");
   2.123 +			hive.setFormat("KMZ");
   2.124  		} else if (reqFormat.equalsIgnoreCase("SPARQLRESULTS"))  {
   2.125  			response.setContentType("application/sparql-results+xml; charset=UTF-8");
   2.126  			hive.setFormat("XML");
   2.127  		} else if (reqFormat.equalsIgnoreCase("XML"))  {
   2.128  			response.setContentType("text/xml; charset=UTF-8");
   2.129  			hive.setFormat("XML");
   2.130 +		} else if (reqFormat.equalsIgnoreCase("KMLMAP"))  {
   2.131 +			response.setContentType("text/html; charset=UTF-8");
   2.132 +			hive.setFormat("KMLMAP");
   2.133 +		} else if (reqFormat.equalsIgnoreCase("KMZMAP"))  {
   2.134 +			response.setContentType("text/html; charset=UTF-8");
   2.135 +			hive.setFormat("KMZMAP");
   2.136  		} else {
   2.137  			response.setContentType("text/html; charset=UTF-8");
   2.138  			hive.setFormat("HTML");
   2.139  		}
   2.140 -		
   2.141 +
   2.142  		PrintWriter out = response.getWriter();
   2.143 -		
   2.144 -		if ((hive.getFormat().equalsIgnoreCase("KML"))) {
   2.145 +
   2.146 +		if ((hive.getFormat().equalsIgnoreCase("KML")) || (hive.getFormat().equalsIgnoreCase("KMZ"))) {
   2.147  			StringBuilder errorMessage = new StringBuilder ();
   2.148  			String answer = evaluateQuery(strabonWrapper, hive.getFormat(), reqFuncionality, hive.getSPARQLQuery(), errorMessage);
   2.149  			hive.setErrorMessage(errorMessage.toString());
   2.150 -            SecureRandom random = new SecureRandom();
   2.151 -            String temp = new BigInteger(130, random).toString(32);        
   2.152 -            
   2.153 -            try{
   2.154 -                Date date = new Date();
   2.155 -                
   2.156 -                FileUtils.forceMkdir(new File((String) context.getRealPath("/") + "/../ROOT/tmp/"));
   2.157 -            	
   2.158 -            	Iterator it = FileUtils.iterateFiles(new File((String) context.getRealPath("/") + "/../ROOT/tmp/"), null, false);
   2.159 -                while(it.hasNext()){
   2.160 -                	File tbd = new File(((File) it.next()).getAbsolutePath());
   2.161 -                	if (FileUtils.isFileOlder( new File(tbd.getAbsolutePath()), date.getTime())){
   2.162 -                        FileUtils.forceDelete(new File(tbd.getAbsolutePath()));
   2.163 -                		}
   2.164 -                }
   2.165 -                
   2.166 -            	File file =new File((String) context.getRealPath("/") + "/../ROOT/tmp/" + temp + ".kml");
   2.167 - 
   2.168 -    	        //if file doesnt exists, then create it
   2.169 -    	        if(!file.exists()){
   2.170 -    		       file.createNewFile();
   2.171 -    	        }
   2.172 - 
   2.173 -    	        FileWriter fw = new FileWriter((String) context.getRealPath("/") + "/../ROOT/tmp/" + temp + ".kml");
   2.174 -    	        BufferedWriter bw = new BufferedWriter(fw);
   2.175 -    	        bw.write(answer);
   2.176 -    	        bw.close();
   2.177 -    	        //FileUtils.forceDeleteOnExit(new File((String) context.getRealPath("/") + "/../ROOT/tmp/" + temp + ".kml"));
   2.178 - 
   2.179 -	            //System.out.println("Done");
   2.180 - 
   2.181 -    	     } catch(IOException e) {
   2.182 -    		        e.printStackTrace();
   2.183 -    	     }
   2.184 -    	     
   2.185 - 			 response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
   2.186 - 			 response.setDateHeader("Expires", 0);
   2.187 - 			 response.setHeader("Location", request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kml");
   2.188 - 			 response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
   2.189 -			 
   2.190 -    	    String pathToKML = "";
   2.191 -    	    
   2.192 -    	    if (answer!="")
   2.193 -			   pathToKML = request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kml";
   2.194 +			SecureRandom random = new SecureRandom();
   2.195 +			String temp = new BigInteger(130, random).toString(32);   
   2.196  			
   2.197 -            appendHTML1a(out,pathToKML);
   2.198 +			String basePath = context.getRealPath("/") + "/../ROOT/tmp/";
   2.199 +
   2.200 +			try{
   2.201 +				Date date = new Date();
   2.202 +
   2.203 +				FileUtils.forceMkdir(new File(basePath));
   2.204 +
   2.205 +				Iterator it = FileUtils.iterateFiles(new File(basePath), null, false);
   2.206 +				while(it.hasNext()){
   2.207 +					File tbd = new File(((File) it.next()).getAbsolutePath());
   2.208 +					if (FileUtils.isFileOlder( new File(tbd.getAbsolutePath()), date.getTime())){
   2.209 +						FileUtils.forceDelete(new File(tbd.getAbsolutePath()));
   2.210 +					}
   2.211 +				}
   2.212 +
   2.213 +				File file =new File(basePath + temp + ".kml");
   2.214 +
   2.215 +				//if file doesnt exists, then create it
   2.216 +				if(!file.exists()){
   2.217 +					file.createNewFile();
   2.218 +				}
   2.219 +
   2.220 +				FileWriter fw = new FileWriter(basePath + temp + ".kml");
   2.221 +				BufferedWriter bw = new BufferedWriter(fw);
   2.222 +				bw.write(answer);
   2.223 +				bw.close();
   2.224 +				//FileUtils.forceDeleteOnExit(new File((String) context.getRealPath("/") + "/../ROOT/tmp/" + temp + ".kml"));
   2.225 +
   2.226 +				//System.out.println("Done");
   2.227 +
   2.228 +				if (hive.getFormat().equalsIgnoreCase("KMZ")) {
   2.229 +					//compress
   2.230 +					byte[] buf = new byte[1024];
   2.231 +					String outFilename = basePath + temp + ".kmz";
   2.232 +					ZipOutputStream kmzout = new ZipOutputStream(new FileOutputStream(outFilename));
   2.233 +
   2.234 +					// Compress the files
   2.235 +					FileInputStream in = new FileInputStream(basePath + temp + ".kml");
   2.236 +
   2.237 +					// Add ZIP entry to output stream.
   2.238 +					kmzout.putNextEntry(new ZipEntry("doc.kml"));
   2.239 +
   2.240 +					// Transfer bytes from the file to the ZIP file
   2.241 +					int len;
   2.242 +					while ((len = in.read(buf)) > 0) {
   2.243 +						kmzout.write(buf, 0, len);
   2.244 +					}
   2.245 +
   2.246 +					// Complete the entry
   2.247 +					kmzout.closeEntry();
   2.248 +					in.close();
   2.249 +
   2.250 +					// Complete the ZIP file
   2.251 +					kmzout.close();
   2.252 +				}
   2.253 +			} catch(IOException e) {
   2.254 +				e.printStackTrace();
   2.255 +			}
   2.256 +
   2.257 +			response.setDateHeader("Expires", 0);			
   2.258 +			response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
   2.259 +
   2.260 +			String pathToKML = "";
   2.261 +			if (hive.getFormat().equalsIgnoreCase("KML")) {
   2.262 +				response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
   2.263 +				response.setHeader("Location", request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kml");
   2.264 +				if (answer!="")
   2.265 +					pathToKML = request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kml";
   2.266 +			} else {
   2.267 +				response.setContentType("application/vnd.google-earth.kmz; charset=UTF-8");
   2.268 +				response.setHeader("Location", request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kmz");
   2.269 +				if (answer!="")
   2.270 +					pathToKML = request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kmz";
   2.271 +			}
   2.272  			
   2.273 +			appendHTML1a(out,pathToKML);
   2.274 +
   2.275  			appendHTMLQ(out, strabonWrapper);
   2.276 -			
   2.277 +
   2.278  			appendHTML1b(out);
   2.279 -			
   2.280 +
   2.281  			if (hive.getSPARQLQuery() != null)
   2.282  				out.write(hive.getSPARQLQuery());
   2.283 -			
   2.284 +
   2.285  			appendHTML2(out);
   2.286 -			
   2.287 +
   2.288  			out.append("</table></td></tr></table>");
   2.289 -			
   2.290 +
   2.291  			appendHTML4(out);
   2.292  			if (answer!="")
   2.293 -			   //out.append("<div id=\"map_canvas\"></div>");
   2.294 +				//out.append("<div id=\"map_canvas\"></div>");
   2.295  				out.append("");
   2.296  			appendHTML5(out);
   2.297 +
   2.298 +		} else if ((hive.getFormat().equalsIgnoreCase("KMLMAP")) || (hive.getFormat().equalsIgnoreCase("KMZMAP"))) {
   2.299 +
   2.300 +			StringBuilder errorMessage = new StringBuilder ();
   2.301 +			String answer = evaluateQuery(strabonWrapper, "KML", reqFuncionality, hive.getSPARQLQuery(), errorMessage);
   2.302 +			hive.setErrorMessage(errorMessage.toString());
   2.303 +			SecureRandom random = new SecureRandom();
   2.304 +			String temp = new BigInteger(130, random).toString(32);   
   2.305  			
   2.306 +			String basePath = context.getRealPath("/") + "/../ROOT/tmp/";
   2.307 +
   2.308 +			try{
   2.309 +				Date date = new Date();
   2.310 +
   2.311 +				FileUtils.forceMkdir(new File(basePath));
   2.312 +
   2.313 +				Iterator it = FileUtils.iterateFiles(new File(basePath), null, false);
   2.314 +				while(it.hasNext()){
   2.315 +					File tbd = new File(((File) it.next()).getAbsolutePath());
   2.316 +					if (FileUtils.isFileOlder( new File(tbd.getAbsolutePath()), date.getTime())){
   2.317 +						FileUtils.forceDelete(new File(tbd.getAbsolutePath()));
   2.318 +					}
   2.319 +				}
   2.320 +
   2.321 +				File file =new File(basePath + temp + ".kml");
   2.322 +
   2.323 +				//if file doesnt exists, then create it
   2.324 +				if(!file.exists()){
   2.325 +					file.createNewFile();
   2.326 +				}
   2.327 +
   2.328 +				FileWriter fw = new FileWriter(basePath + temp + ".kml");
   2.329 +				BufferedWriter bw = new BufferedWriter(fw);
   2.330 +				bw.write(answer);
   2.331 +				bw.close();
   2.332 +				//FileUtils.forceDeleteOnExit(new File((String) context.getRealPath("/") + "/../ROOT/tmp/" + temp + ".kml"));
   2.333 +
   2.334 +				//System.out.println("Done");
   2.335 +
   2.336 +				if (hive.getFormat().equalsIgnoreCase("KMZMAP")) {
   2.337 +					//compress
   2.338 +					byte[] buf = new byte[1024];
   2.339 +					String outFilename = basePath + temp + ".kmz";
   2.340 +					ZipOutputStream kmzout = new ZipOutputStream(new FileOutputStream(outFilename));
   2.341 +
   2.342 +					// Compress the files
   2.343 +					FileInputStream in = new FileInputStream(basePath + temp + ".kml");
   2.344 +
   2.345 +					// Add ZIP entry to output stream.
   2.346 +					kmzout.putNextEntry(new ZipEntry("doc.kml"));
   2.347 +
   2.348 +					// Transfer bytes from the file to the ZIP file
   2.349 +					int len;
   2.350 +					while ((len = in.read(buf)) > 0) {
   2.351 +						kmzout.write(buf, 0, len);
   2.352 +					}
   2.353 +
   2.354 +					// Complete the entry
   2.355 +					kmzout.closeEntry();
   2.356 +					in.close();
   2.357 +
   2.358 +					// Complete the ZIP file
   2.359 +					kmzout.close();
   2.360 +				}
   2.361 +			} catch(IOException e) {
   2.362 +				e.printStackTrace();
   2.363 +			}
   2.364 +
   2.365 +			response.setDateHeader("Expires", 0);			
   2.366 +			response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
   2.367 +
   2.368 +			String pathToKML = "";
   2.369 +			if (hive.getFormat().equalsIgnoreCase("KMLMAP")) {
   2.370 +				//response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
   2.371 +				response.setHeader("Location", request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kml");
   2.372 +				if (answer!="")
   2.373 +					pathToKML = request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kml";
   2.374 +			} else {
   2.375 +				//response.setContentType("application/vnd.google-earth.kmz; charset=UTF-8");
   2.376 +				response.setHeader("Location", request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kmz");
   2.377 +				if (answer!="")
   2.378 +					pathToKML = request.getScheme() + "://" +  request.getServerName() +":" + request.getServerPort() +"/tmp/" + temp + ".kmz";
   2.379 +			}
   2.380 +			
   2.381 +			appendHTML1a(out,pathToKML);
   2.382 +
   2.383 +			appendHTMLQ(out, strabonWrapper);
   2.384 +
   2.385 +			appendHTML1b(out);
   2.386 +
   2.387 +			if (hive.getSPARQLQuery() != null)
   2.388 +				out.write(hive.getSPARQLQuery());
   2.389 +
   2.390 +			appendHTML2(out);
   2.391 +
   2.392 +			out.append("</table></td></tr></table>");
   2.393 +
   2.394 +			appendHTML4(out);
   2.395 +			if (answer!="")
   2.396 +				out.append("<div id=\"map_canvas\"></div>");
   2.397 +			appendHTML5(out);
   2.398  		} else if ((hive.getFormat().equalsIgnoreCase("XML"))) {
   2.399  			int status_code = HttpServletResponse.SC_OK;
   2.400  			String answer = "";
   2.401 -			
   2.402 +
   2.403  			try {
   2.404  				// execute query
   2.405  				answer = (String) strabonWrapper.query(hive.getSPARQLQuery(), hive.getFormat());
   2.406 -				
   2.407 +
   2.408  			} catch (MalformedQueryException e) {
   2.409  				status_code = HttpServletResponse.SC_BAD_REQUEST;
   2.410  				answer = e.getMessage();
   2.411 -				
   2.412 +
   2.413  			} catch (RepositoryException e) {
   2.414  				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
   2.415  				answer = e.getMessage();
   2.416 -				
   2.417 +
   2.418  			} catch (QueryEvaluationException e) {
   2.419  				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
   2.420  				answer = e.getMessage();
   2.421 -				
   2.422 +
   2.423  			} catch (TupleQueryResultHandlerException e) {
   2.424  				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
   2.425  				answer = e.getMessage();
   2.426 -				
   2.427 +
   2.428  			} catch (ClassNotFoundException e) {
   2.429  				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
   2.430  				answer = e.getMessage();
   2.431  			}
   2.432 -			
   2.433 +
   2.434  			// write response to client
   2.435  			response.setContentType("text/xml; charset=UTF-8");
   2.436  			response.setStatus(status_code);
   2.437  			if (status_code == HttpServletResponse.SC_OK) {
   2.438  				response.getWriter().append(answer);
   2.439 -				
   2.440 +
   2.441  			} else {
   2.442  				response.getWriter().append(ResponseMessages.getXMLHeader());
   2.443  				response.getWriter().append(ResponseMessages.getXMLException(answer));
   2.444  				response.getWriter().append(ResponseMessages.getXMLFooter());
   2.445  			}
   2.446 -			
   2.447 +
   2.448  		} else { // HTML
   2.449 -			
   2.450 +
   2.451  			appendHTML1a(out,"");
   2.452 -			
   2.453 +
   2.454  			appendHTMLQ(out, strabonWrapper);
   2.455 -			
   2.456 +
   2.457  			appendHTML1b(out);
   2.458 -			
   2.459 +
   2.460  			if (hive.getSPARQLQuery() != null)
   2.461  				out.write(hive.getSPARQLQuery());
   2.462 -			
   2.463 +
   2.464  			appendHTML2(out);
   2.465 -			
   2.466 +
   2.467  			String answer = "";
   2.468  			if (hive.getSPARQLQuery() != null) {
   2.469  				StringBuilder errorMessage = new StringBuilder ();
   2.470 @@ -253,7 +402,7 @@
   2.471  					appendHTML3(out, hive.getErrorMessage());
   2.472  				}
   2.473  			}
   2.474 -			
   2.475 +
   2.476  			out.append("</table></td></tr></table>");
   2.477  			if (!answer.equals("")) {
   2.478  				out.println("<style type=\"text/css\">");
   2.479 @@ -269,26 +418,26 @@
   2.480  			appendHTML5(out);
   2.481  		}
   2.482  		out.flush();
   2.483 -	}
   2.484 +			}
   2.485  
   2.486  	public void init(ServletConfig servletConfig) throws ServletException {
   2.487  		super.init(servletConfig);
   2.488 -		
   2.489 +
   2.490  		// get StrabonWrapper
   2.491  		context = getServletContext();
   2.492  		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
   2.493 -		
   2.494 +
   2.495  		strabonWrapper = (StrabonBeanWrapper) applicationContext.getBean("strabonBean");
   2.496  	}
   2.497  
   2.498  	public String evaluateQuery(StrabonBeanWrapper strabonWrapper, String resultFormat, String reqFunctionality, String SPARQLQuery, StringBuilder errorMessage) {		
   2.499  		String answer = "";
   2.500 -		
   2.501 +
   2.502  		try {
   2.503  			if (SPARQLQuery == null) {
   2.504  				answer = "";
   2.505  			} else {
   2.506 -				   answer = (String) strabonWrapper.query(SPARQLQuery, resultFormat);
   2.507 +				answer = (String) strabonWrapper.query(SPARQLQuery, resultFormat);
   2.508  			}
   2.509  		} catch (MalformedQueryException e) {
   2.510  			e.printStackTrace();
   2.511 @@ -315,7 +464,7 @@
   2.512  
   2.513  		return answer;		
   2.514  	}
   2.515 -	
   2.516 +
   2.517  	protected static void appendHTML1a(PrintWriter out, String pathToKML) {
   2.518  		out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
   2.519  		out.println("<html>");
   2.520 @@ -387,24 +536,24 @@
   2.521  		out.println("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"165\" id=\"navigation\"> ");
   2.522  		out.println("<tr><td width=\"90\" class=\"style4\"><a href=\"Query\" class=\"navText\">Query</a></td></tr> ");
   2.523  	}
   2.524 -		
   2.525 +
   2.526  	protected static void appendHTML1b(PrintWriter out) {	
   2.527  		out.println("<tr><td width=\"90\" class=\"style4\"><a href=\"store.jsp\" class=\"navText\">Store</a></td></tr> ");
   2.528  		out.println("<tr><td width=\"90\" class=\"style4\"><a href=\"javascript:history.go(0)\" class=\"navText\">Clear</a></td></tr> ");
   2.529  		out.println("</table>");
   2.530  		out.println("</td>");
   2.531  		out.println("<td width=\"*\" valign=\"top\" >"); 
   2.532 -		
   2.533 +
   2.534  		out.println("<table cellspacing=\"5\">");
   2.535  		out.println("<tr>");
   2.536  		out.println("<td style=\"border: 1px dashed #bbbbbb;\">stSPARQL Query:</td>");
   2.537  		out.println("<td style=\"border: 1px dashed #bbbbbb;\"><textarea name=\"SPARQLQuery\" rows=\"15\" cols=\"100\">");
   2.538  	}
   2.539 -	
   2.540 +
   2.541  	protected static void appendHTML2(PrintWriter out) {
   2.542  		out.println("</textarea></td>");
   2.543 -//		out.println("<td style=\"border: 1px dashed #bbbbbb;\"><input type=\"radio\" name=\"format\" value=\"KML\">KML<br/>");
   2.544 -//		out.println("<input type=\"radio\" name=\"format\" value=\"HTML\">HTML</td>");
   2.545 +		//		out.println("<td style=\"border: 1px dashed #bbbbbb;\"><input type=\"radio\" name=\"format\" value=\"KML\">KML<br/>");
   2.546 +		//		out.println("<input type=\"radio\" name=\"format\" value=\"HTML\">HTML</td>");
   2.547  		out.println("<td style=\"border: 1px dashed #bbbbbb;\"><center>Output Format:<br/><select name=\"format\">");
   2.548  		out.println("	<option value=\"HTML\">HTML</option>");
   2.549  		out.println("	<option value=\"KML\">KML</option>");
   2.550 @@ -415,7 +564,7 @@
   2.551  		out.println("<td colspan=2 style=\"border: 1px dashed #bbbbbb;\"><br/><center><input type=\"submit\" value=\"Query\" name=\"submit\" style=\"width: 400px\"/><br/><input type=\"submit\" value=\"Update\" name=\"submit\" style=\"width: 400px\"/></center><br/></td>");
   2.552  		out.println("</tr>");
   2.553  	}
   2.554 -	
   2.555 +
   2.556  	protected static void appendHTML3(PrintWriter out, String errorMessage) {
   2.557  		out.println("<tr>");
   2.558  		out.println("<td style=\"border: 1px dashed #bbbbbb;\">Result: </td>");
   2.559 @@ -429,12 +578,12 @@
   2.560  		out.println("<br/><br/>");
   2.561  		out.println("</form>");
   2.562  	}
   2.563 -	
   2.564 +
   2.565  	protected static void appendHTML5(PrintWriter out) {
   2.566  		out.println("</body>");
   2.567  		out.println("</html>");
   2.568  	}
   2.569 -	
   2.570 +
   2.571  	protected static void appendHTMLQ(PrintWriter out, StrabonBeanWrapper strabonWrapper) {
   2.572  		out.println("<tr><td width=\"90\">");
   2.573  		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery1()+"\">&nbsp;&middot;&nbsp;Query 1</a></br> ");