Strabon

changeset 135:de305c240be4

Escape SPARQLQuery parameter when redirecting request to update bean
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Tue May 08 20:29:23 2012 +0300 (2012-05-08)
parents ddaa14997077
children 2e6a4b6d6450 9088d826b017
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	Tue May 08 18:35:48 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Tue May 08 20:29:23 2012 +0300
     1.3 @@ -82,6 +82,12 @@
     1.4  			public void setErrorMessage(String error) {
     1.5  				this.errorMessage = error;
     1.6  			}
     1.7 +			
     1.8 +			public String toString() {
     1.9 +				return "Format: " + (this.format != null ? this.format : " NULL") + 
    1.10 +						", SPARQLQuery: " + (this.SPARQLQuery != null ? this.SPARQLQuery : " NULL") + 
    1.11 +						", errormessage: " + (this.errorMessage != null ? this.errorMessage : " NULL") + ".";
    1.12 + 			}
    1.13  		}
    1.14  
    1.15  		DataHive hive = new DataHive(); 
    1.16 @@ -91,11 +97,17 @@
    1.17  		String reqFormat = (request.getParameter("format") == null) ? "" : request.getParameter("format");
    1.18  		String reqAccept = (request.getHeader("accept") == null) ? "" : request.getHeader("accept");
    1.19  		String reqFuncionality = (request.getParameter("submit") == null) ? "" : request.getParameter("submit");
    1.20 +		
    1.21 +		//System.out.println("request format: " + reqFormat);
    1.22 +		//System.out.println("request accept: " + reqAccept);
    1.23 +		//System.out.println("request functionality: " + reqFuncionality);
    1.24  
    1.25  		// check whether Update submit button was fired
    1.26  		if (reqFuncionality.equals("Update")) { // only for executions from web browsers
    1.27 +			//System.out.println("Running update");
    1.28 +			//System.out.println("Datahive: " + hive.toString());
    1.29  			response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
    1.30 -			response.sendRedirect("Update?SPARQLQuery=" + hive.getSPARQLQuery());
    1.31 +			response.sendRedirect("Update?SPARQLQuery=" +URLEncoder.encode(hive.getSPARQLQuery(), "UTF-8"));
    1.32  
    1.33  			return;
    1.34  		}