Strabon

changeset 661:f840796400bf

Addresses Ticket #20: added support (not completed yet) for requesting the capabilities of Strabon Endpoint

For this a new servlet has been created and can be accessed as /Capabilities. The purpose of this servlet is
to print the capabilities of the Strabon Endpoint implemented by a class that implements the Capabilities
interface. There are two such classes (and might not exist any more): EndpointCapabilities and
AutoDiscoveryCapabilities.

- EndpointCapabilities should be used for endpoints with version >= 3.2.5 (i.e., the next release of Strabon
Endpoint).
- AutoDiscoveryCapabilities should be used for old endpoints with version <= 3.2.4. The purpose of this
implementation is to attempt to find out the capabilities of old Strabon Endpoints based on java reflection
and response messages or HTTP codes of service requests. The result might not be always accurate.
Discovery of how a service can be accessed might be done using HttpClient and catching error codes.

A new bean (like StrabonBeanWrapper) has also been created, named CapabilitiesDelegateBean, which is
instantiated with one of the Capabilities implementations, i.e., either EndpointCapabilities or
AutoDiscoveryCapabilities class. Versions <= 3.2.4 should be instantiated using the AutoDiscoveryCapabilities
implementation.

Implementation concerning this feature has been transferred in package
eu.earthobservatory.org.StrabonEndpoint.capabilities. This is to facilitate exporting this package as a jar
and then placed inside the WEB-INF/lib directory of an old endpoint in order to determine its capabilities.

The procedure is the following:
1) Extract package eu.earthobservatory.org.StrabonEndpoint.capabilities as a jar and place it inside
directory WEB-INF/lib of an old endpoint,
2) modify beans.xml so as tomcat instantiates the bean CapabilitiesDelegateBean with auto discover
functionality by adding the following lines:

<bean id="capsBean" class="eu.earthobservatory.org.StrabonEndpoint.capabilities.CapabilitiesDelegateBean" destroy-method="destroy">
<!-- specify which implementation of the Capabilities interface shall be used -->
<!-- true : AutoDiscoveryCapabilities -->
<!-- false: EndpointCapabilities -->
<constructor-arg type="boolean">
<value>true</value>
</constructor-arg>
</bean>

3) modify web.xml to define a Capabilities servlet adding the following lines:

<servlet>
<display-name>Capabilities</display-name>
<servlet-name>Capabilities</servlet-name>
<servlet-class>eu.earthobservatory.org.StrabonEndpoint.capabilities.CapabilitiesBean</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Capabilities</servlet-name>
<url-pattern>/Capabilities</url-pattern>
</servlet-mapping>

For future development of services in Strabon, notice that when a new service (XXXBean) is created, a corresponding class
XXXCapabilities should also be created in package eu.earthobservatory.org.StrabonEndpoint.capabilities.
author Babis Nikolaou <charnik@di.uoa.gr>
date Thu Oct 25 18:39:53 2012 +0300 (2012-10-25)
parents b7cc27a40787
children 4b2117a1b743
files endpoint/WebContent/WEB-INF/beans.xml endpoint/WebContent/WEB-INF/web.xml endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/BrowseBeanCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesDelegateBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/ConnectionBeanCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/QueryBeanCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/RequestCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/StoreBeanCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/UpdateBeanCapabilities.java
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/beans.xml	Wed Oct 24 19:08:26 2012 +0300
     1.2 +++ b/endpoint/WebContent/WEB-INF/beans.xml	Thu Oct 25 18:39:53 2012 +0300
     1.3 @@ -14,6 +14,15 @@
     1.4  		</property>
     1.5  	</bean>
     1.6    
     1.7 +	<bean id="capsBean" class="eu.earthobservatory.org.StrabonEndpoint.capabilities.CapabilitiesDelegateBean" destroy-method="destroy">
     1.8 +		<!-- specify which implementation of the Capabilities interface shall be used -->
     1.9 +		<!-- true : AutoDiscoveryCapabilities -->
    1.10 +		<!-- false: EndpointCapabilities -->
    1.11 +		<constructor-arg type="boolean">
    1.12 +            <value>true</value>
    1.13 +        </constructor-arg>
    1.14 +	</bean>
    1.15 +	
    1.16      <bean
    1.17          id="strabonBean"
    1.18          class="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper"
     2.1 --- a/endpoint/WebContent/WEB-INF/web.xml	Wed Oct 24 19:08:26 2012 +0300
     2.2 +++ b/endpoint/WebContent/WEB-INF/web.xml	Thu Oct 25 18:39:53 2012 +0300
     2.3 @@ -92,6 +92,17 @@
     2.4  	</servlet-mapping>
     2.5  	
     2.6  	<servlet>
     2.7 +		<display-name>Capabilities</display-name>
     2.8 +		<servlet-name>Capabilities</servlet-name>
     2.9 +		<servlet-class>eu.earthobservatory.org.StrabonEndpoint.capabilities.CapabilitiesBean</servlet-class>
    2.10 +		<load-on-startup>1</load-on-startup>
    2.11 +	</servlet>
    2.12 +	<servlet-mapping>
    2.13 +		<servlet-name>Capabilities</servlet-name>
    2.14 +		<url-pattern>/Capabilities</url-pattern>
    2.15 +	</servlet-mapping>
    2.16 +	
    2.17 +	<servlet>
    2.18  		<servlet-name>query.jsp</servlet-name>
    2.19  		<jsp-file>/query.jsp</jsp-file>
    2.20  	</servlet>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
     3.3 @@ -0,0 +1,141 @@
     3.4 +/**
     3.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     3.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     3.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     3.8 + * 
     3.9 + * Copyright (C) 2012, Pyravlos Team
    3.10 + * 
    3.11 + * http://www.strabon.di.uoa.gr/
    3.12 + */
    3.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    3.14 +
    3.15 +import org.slf4j.Logger;
    3.16 +import org.slf4j.LoggerFactory;
    3.17 +
    3.18 +/**
    3.19 + * This class implements the {@link Capabilities} interface and
    3.20 + * shall be used only for versions of Strabon Endpoint prior to
    3.21 + * version 3.2.5.
    3.22 + * 
    3.23 + * The purpose of this implementation is to attempt to find out the
    3.24 + * capabilities of old Strabon Endpoints based on two simple heuristics:
    3.25 + * 
    3.26 + * 1) what has been changed in the code (addition of methods/classes adding
    3.27 + *    specific functionality)
    3.28 + * 2) response messages or HTTP codes that old Strabon Endpoints give on wrong
    3.29 + *    parameters.    
    3.30 + * 
    3.31 + * The result may not be accurate in every case.
    3.32 + * 
    3.33 + * 
    3.34 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    3.35 + */
    3.36 +public class AutoDiscoveryCapabilities implements Capabilities {
    3.37 +
    3.38 +	private static Logger logger = LoggerFactory.getLogger(eu.earthobservatory.org.StrabonEndpoint.capabilities.AutoDiscoveryCapabilities.class);
    3.39 +	
    3.40 +	@Override
    3.41 +	public boolean supportsLimit() {
    3.42 +		@SuppressWarnings("rawtypes")
    3.43 +		Class strabonWrapper;
    3.44 +		try {
    3.45 +			strabonWrapper = Class.forName("eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper");
    3.46 +
    3.47 +			strabonWrapper.getDeclaredField("maxLimit");
    3.48 +			
    3.49 +			return true;
    3.50 +				
    3.51 +		} catch (ClassNotFoundException e1) {
    3.52 +			// No StrabonBeanWrapper? How come?
    3.53 +			logger.warn("[StrabonEndpoint.AutoDiscoveryCapabilities] Didn't find StrabonEndpoint class!!! How come?");
    3.54 +			
    3.55 +		} catch (SecurityException e) {
    3.56 +			logger.info("[StrabonEndpoint.AutoDiscoveryCapabilities] Could not determine limit support due to security exception. ", e);
    3.57 +			
    3.58 +		} catch (NoSuchFieldException e) {
    3.59 +			// this exception is OK. Strabon Endpoint does not support limit of results
    3.60 +		}
    3.61 +		
    3.62 +		return false;
    3.63 +	}
    3.64 +
    3.65 +	@Override
    3.66 +	public boolean supportsAuthentication() {
    3.67 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.Authenticate");
    3.68 +	}
    3.69 +
    3.70 +	@Override
    3.71 +	public boolean supportsConnectionModification() {
    3.72 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.ChangeConnectionBean");
    3.73 +	}
    3.74 +
    3.75 +	@Override
    3.76 +	public String getVersion() {
    3.77 +		return "<= 3.2.4";
    3.78 +	}
    3.79 +
    3.80 +	@Override
    3.81 +	public RequestCapabilities getQueryCapabilities() {
    3.82 +		// TODO Auto-generated method stub
    3.83 +		return null;
    3.84 +	}
    3.85 +
    3.86 +	@Override
    3.87 +	public RequestCapabilities getUpdateCapabilities() {
    3.88 +		// TODO Auto-generated method stub
    3.89 +		return null;
    3.90 +	}
    3.91 +
    3.92 +	@Override
    3.93 +	public RequestCapabilities getStoreCapabilities() {
    3.94 +		// TODO Auto-generated method stub
    3.95 +		return null;
    3.96 +	}
    3.97 +
    3.98 +	@Override
    3.99 +	public RequestCapabilities getBrowseCapabilities() {
   3.100 +		// TODO Auto-generated method stub
   3.101 +		return null;
   3.102 +	}
   3.103 +
   3.104 +	@Override
   3.105 +	public RequestCapabilities getConnectionCapabilities() {
   3.106 +		// TODO Auto-generated method stub
   3.107 +		return null;
   3.108 +	}
   3.109 +
   3.110 +	@Override
   3.111 +	public boolean supportsQuerying() {
   3.112 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.QueryBean");
   3.113 +	}
   3.114 +
   3.115 +	@Override
   3.116 +	public boolean supportsUpdating() {
   3.117 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.UpdateBean");
   3.118 +	}
   3.119 +
   3.120 +	@Override
   3.121 +	public boolean supportsStoring() {
   3.122 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.StoreBean");
   3.123 +	}
   3.124 +
   3.125 +	@Override
   3.126 +	public boolean supportsDescribing() {
   3.127 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.DescribeBean");
   3.128 +	}
   3.129 +
   3.130 +	@Override
   3.131 +	public boolean supportsBrowsing() {
   3.132 +		return canBeLoaded("eu.earthobservatory.org.StrabonEndpoint.BrowseBean");
   3.133 +	}
   3.134 +	
   3.135 +	private boolean canBeLoaded(String className) {
   3.136 +		try {
   3.137 +			Class.forName(className);
   3.138 +			return true;
   3.139 +			
   3.140 +		} catch (ClassNotFoundException e1) {
   3.141 +			return false;
   3.142 +		}
   3.143 +	}
   3.144 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/BrowseBeanCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
     4.3 @@ -0,0 +1,53 @@
     4.4 +/**
     4.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     4.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     4.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     4.8 + * 
     4.9 + * Copyright (C) 2012, Pyravlos Team
    4.10 + * 
    4.11 + * http://www.strabon.di.uoa.gr/
    4.12 + */
    4.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    4.14 +
    4.15 +import java.util.List;
    4.16 +
    4.17 +
    4.18 +/**
    4.19 + * 
    4.20 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    4.21 + */
    4.22 +public class BrowseBeanCapabilities implements RequestCapabilities {
    4.23 +
    4.24 +	private static BrowseBeanCapabilities caps;
    4.25 +	
    4.26 +	protected BrowseBeanCapabilities() {
    4.27 +		
    4.28 +	}
    4.29 +	
    4.30 +	public static synchronized BrowseBeanCapabilities getInstance() {
    4.31 +		if (caps == null) {
    4.32 +			caps = new BrowseBeanCapabilities();
    4.33 +		}
    4.34 +		
    4.35 +		return caps;
    4.36 +	}
    4.37 +	
    4.38 +	@Override
    4.39 +	public List<String> getParameters() {
    4.40 +		// TODO Auto-generated method stub
    4.41 +		return null;
    4.42 +	}
    4.43 +
    4.44 +	@Override
    4.45 +	public List<String> getAcceptedValues(String param) {
    4.46 +		// TODO Auto-generated method stub
    4.47 +		return null;
    4.48 +	}
    4.49 +
    4.50 +	@Override
    4.51 +	public boolean isOptional(String param) {
    4.52 +		// TODO Auto-generated method stub
    4.53 +		return false;
    4.54 +	}
    4.55 +
    4.56 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java	Thu Oct 25 18:39:53 2012 +0300
     5.3 @@ -0,0 +1,133 @@
     5.4 +/**
     5.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     5.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     5.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5.8 + * 
     5.9 + * Copyright (C) 2012, Pyravlos Team
    5.10 + * 
    5.11 + * http://www.strabon.di.uoa.gr/
    5.12 + */
    5.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    5.14 +
    5.15 +
    5.16 +/**
    5.17 + * Interface that exposes the capabilities of a Strabon Endpoint.
    5.18 + * 
    5.19 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    5.20 + */
    5.21 +public interface Capabilities {
    5.22 +
    5.23 +	/**
    5.24 +	 * Return the version of Stabon Endpoint.
    5.25 +	 * 
    5.26 +	 * @return
    5.27 +	 */
    5.28 +	public String getVersion();
    5.29 +	
    5.30 +	/**
    5.31 +	 * True when the endpoint supports limiting of results.
    5.32 +	 * 
    5.33 +	 * @return
    5.34 +	 */
    5.35 +	public boolean supportsLimit();
    5.36 +	
    5.37 +	/**
    5.38 +	 * True when the endpoint supports authentication for
    5.39 +	 * update operations (Store/Delete/Update/Insert).
    5.40 +	 * 
    5.41 +	 * @return
    5.42 +	 */
    5.43 +	public boolean supportsAuthentication();
    5.44 +
    5.45 +	/**
    5.46 +	 * True when the endpoint supports querying using
    5.47 +	 * SPARQL.
    5.48 +	 * 
    5.49 +	 * @return
    5.50 +	 */
    5.51 +	public boolean supportsQuerying();
    5.52 +	
    5.53 +	/**
    5.54 +	 * True when the endpoint supports update queries using
    5.55 +	 * SPARQL.
    5.56 +	 * 
    5.57 +	 * @return
    5.58 +	 */
    5.59 +	public boolean supportsUpdating();
    5.60 +	
    5.61 +	/**
    5.62 +	 * True when the endpoint supports storing of RDF triples.
    5.63 +	 * 
    5.64 +	 * @return
    5.65 +	 */
    5.66 +	public boolean supportsStoring();
    5.67 +	
    5.68 +	/**
    5.69 +	 * True when the endpoint supports describe queries using
    5.70 +	 * SPARQL.
    5.71 +	 * 
    5.72 +	 * @return
    5.73 +	 */
    5.74 +	public boolean supportsDescribing();
    5.75 +	
    5.76 +	/**
    5.77 +	 * True when the endpoint supports browsing of RDF
    5.78 +	 * resources.
    5.79 +	 * 
    5.80 +	 * @return
    5.81 +	 */
    5.82 +	public boolean supportsBrowsing();
    5.83 +	
    5.84 +	/**
    5.85 +	 * True when the endpoint supports modification of the
    5.86 +	 * connection details used for the database connection.
    5.87 +	 * 
    5.88 +	 * @return
    5.89 +	 */
    5.90 +	public boolean supportsConnectionModification();
    5.91 +	
    5.92 +	/**
    5.93 +	 * Returns a {@link RequestCapabilities} instance containing
    5.94 +	 * the details for how one can query the Query service of the
    5.95 +	 * endpoint.
    5.96 +	 * 
    5.97 +	 * @return
    5.98 +	 */
    5.99 +	public RequestCapabilities getQueryCapabilities();
   5.100 +	
   5.101 +	/**
   5.102 +	 * Returns a {@link RequestCapabilities} instance containing
   5.103 +	 * the details for how one can query the Update service of the
   5.104 +	 * endpoint.
   5.105 +	 * 
   5.106 +	 * @return
   5.107 +	 */
   5.108 +	public RequestCapabilities getUpdateCapabilities();
   5.109 +	
   5.110 +	/**
   5.111 +	 * Returns a {@link RequestCapabilities} instance containing
   5.112 +	 * the details for how one can query the Store service of the
   5.113 +	 * endpoint.
   5.114 +	 * 
   5.115 +	 * @return
   5.116 +	 */
   5.117 +	public RequestCapabilities getStoreCapabilities();
   5.118 +	
   5.119 +	/**
   5.120 +	 * Returns a {@link RequestCapabilities} instance containing
   5.121 +	 * the details for how one can query the Browse service of the
   5.122 +	 * endpoint.
   5.123 +	 * 
   5.124 +	 * @return
   5.125 +	 */
   5.126 +	public RequestCapabilities getBrowseCapabilities();
   5.127 +	
   5.128 +	/**
   5.129 +	 * Returns a {@link RequestCapabilities} instance containing
   5.130 +	 * the details for how one can query the Connection service of
   5.131 +	 * the endpoint.
   5.132 +	 * 
   5.133 +	 * @return
   5.134 +	 */
   5.135 +	public RequestCapabilities getConnectionCapabilities();
   5.136 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java	Thu Oct 25 18:39:53 2012 +0300
     6.3 @@ -0,0 +1,114 @@
     6.4 +/**
     6.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     6.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     6.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6.8 + * 
     6.9 + * Copyright (C) 2012, Pyravlos Team
    6.10 + * 
    6.11 + * http://www.strabon.di.uoa.gr/
    6.12 + */
    6.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    6.14 +
    6.15 +import java.io.IOException;
    6.16 +
    6.17 +import javax.servlet.ServletConfig;
    6.18 +import javax.servlet.ServletContext;
    6.19 +import javax.servlet.ServletException;
    6.20 +import javax.servlet.ServletOutputStream;
    6.21 +import javax.servlet.http.HttpServlet;
    6.22 +import javax.servlet.http.HttpServletRequest;
    6.23 +import javax.servlet.http.HttpServletResponse;
    6.24 +
    6.25 +import org.springframework.web.context.WebApplicationContext;
    6.26 +import org.springframework.web.context.support.WebApplicationContextUtils;
    6.27 +
    6.28 +import eu.earthobservatory.org.StrabonEndpoint.Common;
    6.29 +
    6.30 +/**
    6.31 + * 
    6.32 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    6.33 + */
    6.34 +public class CapabilitiesBean extends HttpServlet {
    6.35 +	
    6.36 +	private static final long serialVersionUID = -8941754144139158506L;
    6.37 +	
    6.38 +	/**
    6.39 +	 * The context of the servlet
    6.40 +	 */
    6.41 +	private ServletContext context;
    6.42 +	
    6.43 +	/**
    6.44 +	 * The capabilities of the endpoint
    6.45 +	 */
    6.46 +	private Capabilities caps;
    6.47 +	
    6.48 +	public void init(ServletConfig servletConfig) throws ServletException {
    6.49 +		super.init(servletConfig);
    6.50 +		
    6.51 +		// get the context of the servlet
    6.52 +		context = getServletContext();
    6.53 +		
    6.54 +		// get the context of the application
    6.55 +		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    6.56 +
    6.57 +		// the the strabon wrapper
    6.58 +		CapabilitiesDelegateBean capsBean = (CapabilitiesDelegateBean) applicationContext.getBean("capsBean");
    6.59 +		
    6.60 +		// get capabilities
    6.61 +		caps = capsBean.getEndpointCapabilities();
    6.62 +	}
    6.63 +
    6.64 +	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    6.65 +		doPost(request, response);
    6.66 +	}
    6.67 +
    6.68 +	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    6.69 +		request.setCharacterEncoding("UTF-8");
    6.70 +		
    6.71 +		if (Common.VIEW_TYPE.equals(request.getParameter(Common.VIEW))) {
    6.72 +			// HTML visual interface
    6.73 +			processVIEWRequest(request, response);
    6.74 +
    6.75 +		} else {// invoked as a service
    6.76 +			processRequest(request, response);
    6.77 +	    }
    6.78 +	}
    6.79 +	
    6.80 +	/**
    6.81 +     * Processes the request made from the HTML visual interface of Strabon Endpoint.
    6.82 +     * 
    6.83 +     * @param request
    6.84 +     * @param response
    6.85 +     * @throws ServletException
    6.86 +     * @throws IOException
    6.87 +     */
    6.88 +	private void processVIEWRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    6.89 +		//RequestDispatcher dispatcher;
    6.90 +	}
    6.91 +	
    6.92 +	/**
    6.93 +     * Processes the request made by a client of the endpoint that uses it as a service. 
    6.94 +     * 
    6.95 +     * @param request
    6.96 +     * @param response
    6.97 +     * @throws IOException 
    6.98 +     */
    6.99 +	private void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
   6.100 +		ServletOutputStream out = response.getOutputStream();
   6.101 +		
   6.102 +		out.println("Version						: " + caps.getVersion());
   6.103 +		out.println("Supports limit					: " + getYesNo(caps.supportsLimit()));
   6.104 +		out.println("Supports authentication				: " + getYesNo(caps.supportsAuthentication()));
   6.105 +		out.println("Supports modification of database connection	: " + getYesNo(caps.supportsConnectionModification()));
   6.106 +		out.println("Supports SPARQL					: " + getYesNo(caps.supportsQuerying()));
   6.107 +		out.println("Supports SPARQL Update				: " + getYesNo(caps.supportsUpdating()));
   6.108 +		out.println("Supports storing				: " + getYesNo(caps.supportsStoring()));
   6.109 +		out.println("Supports DESCRIBE				: " + getYesNo(caps.supportsDescribing()));
   6.110 +		out.println("Supports CONSTRUCT				: " + getYesNo(caps.supportsDescribing()));
   6.111 +		out.println("Supports browsing				: "	+ getYesNo(caps.supportsBrowsing()));
   6.112 +	}
   6.113 +	
   6.114 +	private String getYesNo(boolean val) {
   6.115 +		return val ? "yes":"no";
   6.116 +	}
   6.117 +}
   6.118 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesDelegateBean.java	Thu Oct 25 18:39:53 2012 +0300
     7.3 @@ -0,0 +1,38 @@
     7.4 +/**
     7.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     7.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     7.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7.8 + * 
     7.9 + * Copyright (C) 2012, Pyravlos Team
    7.10 + * 
    7.11 + * http://www.strabon.di.uoa.gr/
    7.12 + */
    7.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    7.14 +
    7.15 +
    7.16 +/**
    7.17 + * 
    7.18 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    7.19 + */
    7.20 +public class CapabilitiesDelegateBean implements org.springframework.beans.factory.DisposableBean {
    7.21 +
    7.22 +	private static Capabilities caps;
    7.23 +	
    7.24 +	public CapabilitiesDelegateBean(boolean autoDiscoverCapabilities) {
    7.25 +		if (autoDiscoverCapabilities) {
    7.26 +			caps = new AutoDiscoveryCapabilities();
    7.27 +			
    7.28 +		} else {
    7.29 +			caps = new EndpointCapabilities();
    7.30 +		}
    7.31 +	}
    7.32 +	
    7.33 +	@Override
    7.34 +	public void destroy() throws Exception {
    7.35 +		// nothing to destroy
    7.36 +	}
    7.37 +	
    7.38 +	public Capabilities getEndpointCapabilities() {
    7.39 +		return caps;
    7.40 +	}
    7.41 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/ConnectionBeanCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
     8.3 @@ -0,0 +1,53 @@
     8.4 +/**
     8.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     8.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     8.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     8.8 + * 
     8.9 + * Copyright (C) 2012, Pyravlos Team
    8.10 + * 
    8.11 + * http://www.strabon.di.uoa.gr/
    8.12 + */
    8.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    8.14 +
    8.15 +import java.util.List;
    8.16 +
    8.17 +
    8.18 +/**
    8.19 + * 
    8.20 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    8.21 + */
    8.22 +public class ConnectionBeanCapabilities implements RequestCapabilities {
    8.23 +
    8.24 +	private static ConnectionBeanCapabilities caps;
    8.25 +	
    8.26 +	protected ConnectionBeanCapabilities() {
    8.27 +		
    8.28 +	}
    8.29 +	
    8.30 +	public static synchronized ConnectionBeanCapabilities getInstance() {
    8.31 +		if (caps == null) {
    8.32 +			caps = new ConnectionBeanCapabilities();
    8.33 +		}
    8.34 +		
    8.35 +		return caps;
    8.36 +	}
    8.37 +	
    8.38 +	@Override
    8.39 +	public List<String> getParameters() {
    8.40 +		// TODO Auto-generated method stub
    8.41 +		return null;
    8.42 +	}
    8.43 +
    8.44 +	@Override
    8.45 +	public List<String> getAcceptedValues(String param) {
    8.46 +		// TODO Auto-generated method stub
    8.47 +		return null;
    8.48 +	}
    8.49 +
    8.50 +	@Override
    8.51 +	public boolean isOptional(String param) {
    8.52 +		// TODO Auto-generated method stub
    8.53 +		return false;
    8.54 +	}
    8.55 +
    8.56 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
     9.3 @@ -0,0 +1,91 @@
     9.4 +/**
     9.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     9.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     9.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     9.8 + * 
     9.9 + * Copyright (C) 2012, Pyravlos Team
    9.10 + * 
    9.11 + * http://www.strabon.di.uoa.gr/
    9.12 + */
    9.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
    9.14 +
    9.15 +
    9.16 +/**
    9.17 + * This class implements the {@link Capabilities} interface and
    9.18 + * shall be used only for versions of Strabon Endpoint newer than
    9.19 + * version 3.2.4.
    9.20 + * 
    9.21 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    9.22 + */
    9.23 +public class EndpointCapabilities implements Capabilities {
    9.24 +
    9.25 +	@Override
    9.26 +	public String getVersion() {
    9.27 +		return "3.2.4-SNAPSHOT";
    9.28 +	}
    9.29 +	
    9.30 +	@Override
    9.31 +	public boolean supportsLimit() {
    9.32 +		return true;
    9.33 +	}
    9.34 +
    9.35 +	@Override
    9.36 +	public boolean supportsAuthentication() {
    9.37 +		return true;
    9.38 +	}
    9.39 +
    9.40 +	@Override
    9.41 +	public boolean supportsConnectionModification() {
    9.42 +		return true;
    9.43 +	}
    9.44 +	
    9.45 +	@Override
    9.46 +	public boolean supportsQuerying() {
    9.47 +		return true;
    9.48 +	}
    9.49 +
    9.50 +	@Override
    9.51 +	public boolean supportsUpdating() {
    9.52 +		return true;
    9.53 +	}
    9.54 +
    9.55 +	@Override
    9.56 +	public boolean supportsStoring() {
    9.57 +		return true;
    9.58 +	}
    9.59 +
    9.60 +	@Override
    9.61 +	public boolean supportsDescribing() {
    9.62 +		return true;
    9.63 +	}
    9.64 +
    9.65 +	@Override
    9.66 +	public boolean supportsBrowsing() {
    9.67 +		return true;
    9.68 +	}
    9.69 +
    9.70 +	@Override
    9.71 +	public RequestCapabilities getQueryCapabilities() {
    9.72 +		return QueryBeanCapabilities.getInstance();
    9.73 +	}
    9.74 +
    9.75 +	@Override
    9.76 +	public RequestCapabilities getUpdateCapabilities() {
    9.77 +		return UpdateBeanCapabilities.getInstance();
    9.78 +	}
    9.79 +
    9.80 +	@Override
    9.81 +	public RequestCapabilities getStoreCapabilities() {
    9.82 +		return StoreBeanCapabilities.getInstance();
    9.83 +	}
    9.84 +
    9.85 +	@Override
    9.86 +	public RequestCapabilities getBrowseCapabilities() {
    9.87 +		return BrowseBeanCapabilities.getInstance();
    9.88 +	}
    9.89 +
    9.90 +	@Override
    9.91 +	public RequestCapabilities getConnectionCapabilities() {
    9.92 +		return ConnectionBeanCapabilities.getInstance();
    9.93 +	}
    9.94 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/QueryBeanCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
    10.3 @@ -0,0 +1,53 @@
    10.4 +/**
    10.5 + * This Source Code Form is subject to the terms of the Mozilla Public
    10.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    10.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    10.8 + * 
    10.9 + * Copyright (C) 2012, Pyravlos Team
   10.10 + * 
   10.11 + * http://www.strabon.di.uoa.gr/
   10.12 + */
   10.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
   10.14 +
   10.15 +import java.util.List;
   10.16 +
   10.17 +
   10.18 +/**
   10.19 + * 
   10.20 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
   10.21 + */
   10.22 +public class QueryBeanCapabilities implements RequestCapabilities {
   10.23 +
   10.24 +	private static QueryBeanCapabilities caps;
   10.25 +	
   10.26 +	protected QueryBeanCapabilities() {
   10.27 +		
   10.28 +	}
   10.29 +	
   10.30 +	public static synchronized QueryBeanCapabilities getInstance() {
   10.31 +		if (caps == null) {
   10.32 +			caps = new QueryBeanCapabilities();
   10.33 +		}
   10.34 +		
   10.35 +		return caps;
   10.36 +	}
   10.37 +	
   10.38 +	@Override
   10.39 +	public List<String> getParameters() {
   10.40 +		// TODO Auto-generated method stub
   10.41 +		return null;
   10.42 +	}
   10.43 +
   10.44 +	@Override
   10.45 +	public List<String> getAcceptedValues(String param) {
   10.46 +		// TODO Auto-generated method stub
   10.47 +		return null;
   10.48 +	}
   10.49 +
   10.50 +	@Override
   10.51 +	public boolean isOptional(String param) {
   10.52 +		// TODO Auto-generated method stub
   10.53 +		return false;
   10.54 +	}
   10.55 +
   10.56 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/RequestCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
    11.3 @@ -0,0 +1,47 @@
    11.4 +/**
    11.5 + * This Source Code Form is subject to the terms of the Mozilla Public
    11.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    11.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    11.8 + * 
    11.9 + * Copyright (C) 2012, Pyravlos Team
   11.10 + * 
   11.11 + * http://www.strabon.di.uoa.gr/
   11.12 + */
   11.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
   11.14 +
   11.15 +import java.util.List;
   11.16 +
   11.17 +/**
   11.18 + * Interface that exposes the kind of requests that clients
   11.19 + * of Strabon Endpoint can access its services, i.e.,
   11.20 + * Query, Store, Update, Browse, etc.   
   11.21 + * 
   11.22 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
   11.23 + */
   11.24 +public interface RequestCapabilities {
   11.25 +	
   11.26 +	/**
   11.27 +	 * Get the accepted parameters of a service request
   11.28 +	 * as a list.
   11.29 +	 * 
   11.30 +	 * @return
   11.31 +	 */
   11.32 +	public List<String> getParameters();
   11.33 +	
   11.34 +	/**
   11.35 +	 * Get the accepted values of a service parameter.
   11.36 +	 * 
   11.37 +	 * @param param
   11.38 +	 * @return
   11.39 +	 */
   11.40 +	public List<String> getAcceptedValues(String param);
   11.41 +	
   11.42 +	/**
   11.43 +	 * Determine wether the given parameter is optional
   11.44 +	 * and thus can be omitted.
   11.45 +	 * 
   11.46 +	 * @param param
   11.47 +	 * @return
   11.48 +	 */
   11.49 +	public boolean isOptional(String param);
   11.50 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/StoreBeanCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
    12.3 @@ -0,0 +1,53 @@
    12.4 +/**
    12.5 + * This Source Code Form is subject to the terms of the Mozilla Public
    12.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    12.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    12.8 + * 
    12.9 + * Copyright (C) 2012, Pyravlos Team
   12.10 + * 
   12.11 + * http://www.strabon.di.uoa.gr/
   12.12 + */
   12.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
   12.14 +
   12.15 +import java.util.List;
   12.16 +
   12.17 +
   12.18 +/**
   12.19 + * 
   12.20 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
   12.21 + */
   12.22 +public class StoreBeanCapabilities implements RequestCapabilities {
   12.23 +
   12.24 +	private static StoreBeanCapabilities caps;
   12.25 +	
   12.26 +	protected StoreBeanCapabilities() {
   12.27 +		
   12.28 +	}
   12.29 +	
   12.30 +	public static synchronized StoreBeanCapabilities getInstance() {
   12.31 +		if (caps == null) {
   12.32 +			caps = new StoreBeanCapabilities();
   12.33 +		}
   12.34 +		
   12.35 +		return caps;
   12.36 +	}
   12.37 +	
   12.38 +	@Override
   12.39 +	public List<String> getParameters() {
   12.40 +		// TODO Auto-generated method stub
   12.41 +		return null;
   12.42 +	}
   12.43 +
   12.44 +	@Override
   12.45 +	public List<String> getAcceptedValues(String param) {
   12.46 +		// TODO Auto-generated method stub
   12.47 +		return null;
   12.48 +	}
   12.49 +
   12.50 +	@Override
   12.51 +	public boolean isOptional(String param) {
   12.52 +		// TODO Auto-generated method stub
   12.53 +		return false;
   12.54 +	}
   12.55 +
   12.56 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/UpdateBeanCapabilities.java	Thu Oct 25 18:39:53 2012 +0300
    13.3 @@ -0,0 +1,52 @@
    13.4 +/**
    13.5 + * This Source Code Form is subject to the terms of the Mozilla Public
    13.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    13.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    13.8 + * 
    13.9 + * Copyright (C) 2012, Pyravlos Team
   13.10 + * 
   13.11 + * http://www.strabon.di.uoa.gr/
   13.12 + */
   13.13 +package eu.earthobservatory.org.StrabonEndpoint.capabilities;
   13.14 +
   13.15 +import java.util.List;
   13.16 +
   13.17 +
   13.18 +/**
   13.19 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
   13.20 + *
   13.21 + */
   13.22 +public class UpdateBeanCapabilities implements RequestCapabilities {
   13.23 +
   13.24 +	private static UpdateBeanCapabilities caps;
   13.25 +	
   13.26 +	protected UpdateBeanCapabilities() {
   13.27 +		
   13.28 +	}
   13.29 +	
   13.30 +	public static synchronized UpdateBeanCapabilities getInstance() {
   13.31 +		if (caps == null) {
   13.32 +			caps = new UpdateBeanCapabilities();
   13.33 +		}
   13.34 +		
   13.35 +		return caps;
   13.36 +	}
   13.37 +	
   13.38 +	@Override
   13.39 +	public List<String> getParameters() {
   13.40 +		// TODO Auto-generated method stub
   13.41 +		return null;
   13.42 +	}
   13.43 +
   13.44 +	@Override
   13.45 +	public List<String> getAcceptedValues(String param) {
   13.46 +		// TODO Auto-generated method stub
   13.47 +		return null;
   13.48 +	}
   13.49 +
   13.50 +	@Override
   13.51 +	public boolean isOptional(String param) {
   13.52 +		// TODO Auto-generated method stub
   13.53 +		return false;
   13.54 +	}
   13.55 +}