Strabon

changeset 525:9fcc1b2a52e3

removed method Common.getRDFFormatforAcceptHeader() and used the provided and more robust RDFFormat.forMimeType()
author Babis Nikolaou <charnik@di.uoa.gr>
date Sat Jul 28 15:52:58 2012 +0300 (2012-07-28)
parents 79b679426d4d
children 61e60bba1cb0
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/Common.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/DescribeBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/Common.java	Sat Jul 28 15:49:30 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/Common.java	Sat Jul 28 15:52:58 2012 +0300
     1.3 @@ -69,58 +69,4 @@
     1.4  			}
     1.5  		}
     1.6  	}
     1.7 -	
     1.8 -    /**
     1.9 -     * Determines the RDF format to use. We check only for "accept"
    1.10 -     * parameter (present in the header). 
    1.11 -     * 
    1.12 -     * The use of "format" parameter is now deprecated for using any
    1.13 -     * Bean as a service. It is only used through the HTML
    1.14 -     * visual interface, provided with Strabon Endpoint.
    1.15 -     * 
    1.16 -     * @param request
    1.17 -     * @return
    1.18 -     */
    1.19 -    public static RDFFormat getRDFFormatFromAcceptHeader(String acceptHeader) {
    1.20 -        if (acceptHeader != null) {
    1.21 -            // check whether the "accept" parameter contains any 
    1.22 -            // of the mime types of any RDF format
    1.23 -            for (RDFFormat format : RDFFormat.values()) {
    1.24 -                for (String mimeType : format.getMIMETypes()) {
    1.25 -                    if (acceptHeader.contains(mimeType)) {
    1.26 -                            return format;
    1.27 -                    }
    1.28 -                }
    1.29 -            }
    1.30 -        }
    1.31 -                
    1.32 -        return null;
    1.33 -    }
    1.34 -    
    1.35 -    /**
    1.36 -     * Determines the stSPARQL query result format to use. We check only for "accept"
    1.37 -     * parameter (present in the header). 
    1.38 -     * 
    1.39 -     * The use of "format" parameter is now deprecated for using any
    1.40 -     * Bean as a service. It is only used through the HTML
    1.41 -     * visual interface, provided with Strabon Endpoint.
    1.42 -     * 
    1.43 -     * @param request
    1.44 -     * @return
    1.45 -     */
    1.46 -    public static stSPARQLQueryResultFormat getResultFormatFromAcceptHeader(String acceptHeader) {
    1.47 -    	if (acceptHeader != null) {
    1.48 -            // check whether the "accept" parameter contains any 
    1.49 -            // of the mime types of any stSPARQL query result format
    1.50 -    		for (stSPARQLQueryResultFormat format : registeredQueryResultsFormats) {
    1.51 -				for (String mimeType : format.getMIMETypes()) {
    1.52 -					if (acceptHeader.contains(mimeType)) {
    1.53 -						return format;
    1.54 -					}
    1.55 -				}
    1.56 -            }
    1.57 -        }
    1.58 -                
    1.59 -        return null;
    1.60 -    }
    1.61  }
     2.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/DescribeBean.java	Sat Jul 28 15:49:30 2012 +0300
     2.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/DescribeBean.java	Sat Jul 28 15:52:58 2012 +0300
     2.3 @@ -139,7 +139,7 @@
     2.4  		ServletOutputStream out = response.getOutputStream();
     2.5  		
     2.6  		// get the RDF format (we check only the Accept header)
     2.7 -        RDFFormat format = Common.getRDFFormatFromAcceptHeader(request.getHeader("accept"));
     2.8 +        RDFFormat format = RDFFormat.forMIMEType(request.getHeader("accept"));
     2.9          
    2.10          // get the query
    2.11  		String query = request.getParameter("query");
     3.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java	Sat Jul 28 15:49:30 2012 +0300
     3.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java	Sat Jul 28 15:52:58 2012 +0300
     3.3 @@ -148,7 +148,7 @@
     3.4  		}
     3.5      	
     3.6      	// the format of the data
     3.7 -    	RDFFormat format = Common.getRDFFormatFromAcceptHeader(request.getHeader("accept"));
     3.8 +    	RDFFormat format = RDFFormat.forMIMEType(request.getHeader("accept"));
     3.9      	
    3.10  		if (format == null) { // unknown format
    3.11  			response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);