Strabon

changeset 185:91c401e50902

KML plain text option
author Michael Sioutis
date Wed May 23 13:35:07 2012 +0300 (2012-05-23)
parents 2192aa4a6418
children 975f68fc4c63
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Wed May 23 12:03:47 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Wed May 23 13:35:07 2012 +0300
     1.3 @@ -133,12 +133,19 @@
     1.4  		} else if (reqAccept.contains("text/xml")) {
     1.5  			response.setContentType("text/xml; charset=UTF-8");
     1.6  			hive.setFormat("XML");
     1.7 +		} else if (reqFormat.equalsIgnoreCase("KML file")) {
     1.8 +			response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
     1.9 +            response.setHeader("Content-Disposition","attachment;filename=pico.kml");
    1.10 +			hive.setFormat("KML");
    1.11  		} else if (reqFormat.equalsIgnoreCase("KML")) {
    1.12 -			response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
    1.13 -                        response.setHeader("Content-Disposition","attachment;filename=pico.kml");
    1.14 +			response.setContentType("text/plain; charset=UTF-8");
    1.15  			hive.setFormat("KML");
    1.16 +		} else if (reqFormat.equalsIgnoreCase("KMZ file")) {
    1.17 +			response.setContentType("application/vnd.google-earth.kmz; charset=UTF-8");
    1.18 +            response.setHeader("Content-Disposition","attachment;filename=pico.kmz");
    1.19 +			hive.setFormat("KMZ");
    1.20  		} else if (reqFormat.equalsIgnoreCase("KMZ")) {
    1.21 -			response.setContentType("application/vnd.google-earth.kmz");
    1.22 +			response.setContentType("text/plain; charset=UTF-8");
    1.23  			hive.setFormat("KMZ");
    1.24  		} else if (reqFormat.equalsIgnoreCase("SPARQLRESULTS"))  {
    1.25  			response.setContentType("application/sparql-results+xml; charset=UTF-8");
    1.26 @@ -165,11 +172,6 @@
    1.27  
    1.28  		if ((hive.getFormat().equalsIgnoreCase("KML")) || (hive.getFormat().equalsIgnoreCase("KMZ"))) {
    1.29  			StringBuilder errorMessage = new StringBuilder ();
    1.30 -			//String answer = evaluateQuery(strabonWrapper, hive.getFormat(), reqFuncionality, hive.getSPARQLQuery(), errorMessage);
    1.31 -			//hive.setErrorMessage(errorMessage.toString());
    1.32 -			//SecureRandom random = new SecureRandom();
    1.33 -			String extension = (hive.format.equalsIgnoreCase("KML") ? "kml" : "kmz");
    1.34 -			//String temp = new BigInteger(130, random).toString(32);   
    1.35  			
    1.36  			int status_code = HttpServletResponse.SC_OK;
    1.37  			String answer = "";
    1.38 @@ -199,15 +201,9 @@
    1.39  				answer = e.getMessage();
    1.40  			}
    1.41  
    1.42 -                        //response.setContentType("text/plain");
    1.43 -			//response.setCharacterEncoding("UTF-8");
    1.44 -                        response.setStatus(status_code);
    1.45 +            response.setStatus(status_code);
    1.46  			if (status_code == HttpServletResponse.SC_OK) {
    1.47 -                                //response.setContentLength(answer.length());
    1.48 -				//response.getWriter().append(answer.toString());
    1.49 -                                out.append(answer.toString());
    1.50 -                                //out.flush();
    1.51 -
    1.52 +               out.append(answer.toString());
    1.53  			} else {
    1.54  				response.getWriter().append(ResponseMessages.getXMLHeader());
    1.55  				response.getWriter().append(ResponseMessages.getXMLException(answer));
    1.56 @@ -524,7 +520,8 @@
    1.57  		selections.put("KMLMAP", "HTML with google maps (kml)");
    1.58  		selections.put("HTML", "HTML");
    1.59  		//selections.put("KMZ", "KZM file");
    1.60 -		selections.put("KML", "KML file");
    1.61 +		selections.put("KML file", "KML file");
    1.62 +		selections.put("KML", "KML plain text");
    1.63  		selections.put("XML", "XML");
    1.64  		selections.put("GEOJSON", "GeoJSON");
    1.65