Changeset 671:24a6e7d423eb


Ignore:
Timestamp:
10/30/12 22:38:05 (5 years ago)
Author:
Babis Nikolaou <charnik@…>
Branch:
default
Message:

added interface (EndpointResult?) for the return type of the answer of an endpoint. Added a prototypical implementation for StrabonEndpoint?

Location:
endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/client
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/client/SpatialEndpoint.java

    r670 r671  
    2525public interface SpatialEndpoint { 
    2626 
    27         public String query(String sparqlQuery, stSPARQLQueryResultFormat format) throws IOException; 
     27        public EndpointResult query(String sparqlQuery, stSPARQLQueryResultFormat format) throws IOException; 
    2828         
    2929        public boolean store(String data, RDFFormat format); 
     
    3333        public boolean update(String sparqlUpdate); 
    3434         
    35         public boolean describe(String sparqlDescribe); 
     35        public EndpointResult describe(String sparqlDescribe); 
    3636         
    37         public boolean construct(String sparqlConstruct); 
     37        public EndpointResult construct(String sparqlConstruct); 
    3838} 
  • endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/client/StrabonEndpoint.java

    r670 r671  
    1414 
    1515import org.apache.commons.httpclient.HttpMethod; 
    16 import org.apache.commons.httpclient.HttpStatus; 
    1716import org.apache.commons.httpclient.methods.PostMethod; 
    1817import org.openrdf.query.resultio.stSPARQLQueryResultFormat; 
     
    3231 
    3332        @Override 
    34         public String query(String sparqlQuery, stSPARQLQueryResultFormat format) throws IOException { 
     33        public EndpointResult query(String sparqlQuery, stSPARQLQueryResultFormat format) throws IOException { 
    3534                // create a post method to execute 
    3635                HttpMethod method = new PostMethod(getConnectionURL()); 
     
    4645                        int statusCode = hc.executeMethod(method); 
    4746 
    48                         // check the status code 
    49                         if (statusCode != HttpStatus.SC_OK) { 
    50                                 System.err.println("Method failed: " + method.getStatusLine()); 
    51                         } 
    52  
    5347                        // Read the response body. 
    5448                        byte[] responseBody = method.getResponseBody(); 
     
    5751                        // Use caution: ensure correct character encoding and is not binary 
    5852                        // data 
    59                         return new String(responseBody); 
     53                        String response = new String(responseBody); 
     54                         
     55                        return new StrabonEndpointResult(statusCode, method.getStatusText(), response); 
    6056 
    6157                } catch (IOException e) { 
     
    8480 
    8581        @Override 
    86         public boolean describe(String sparqlDescribe) { 
    87                 return false; 
     82        public EndpointResult describe(String sparqlDescribe) { 
     83                return null; 
    8884        } 
    8985 
    9086        @Override 
    91         public boolean construct(String sparqlConstruct) { 
    92                 return false; 
     87        public EndpointResult construct(String sparqlConstruct) { 
     88                return null; 
    9389        } 
    9490 
Note: See TracChangeset for help on using the changeset viewer.