Strabon
changeset 503:ae32e022c593
StoreBean: changes to conform to changeset 499:ef9c43dd2c78.
* Completed store.jsp and StoreBean
- "format" parameter is now only checked when using the HTML visual interface
- the value of Accept header is inspected when the StoreBean is used as a service
* Updated endpoint script to set the accept header with respect to the format used
QueryBean is the last one. Atsali! Leave it for tomorrow.
* Completed store.jsp and StoreBean
- "format" parameter is now only checked when using the HTML visual interface
- the value of Accept header is inspected when the StoreBean is used as a service
* Updated endpoint script to set the accept header with respect to the format used
QueryBean is the last one. Atsali! Leave it for tomorrow.
author | Babis Nikolaou <charnik@di.uoa.gr> |
---|---|
date | Wed Jul 25 01:17:59 2012 +0300 (2012-07-25) |
parents | 362b91bf1b97 |
children | b408cde6beca |
files | endpoint/WebContent/describe.jsp endpoint/WebContent/store.jsp 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 scripts/endpoint |
line diff
1.1 --- a/endpoint/WebContent/describe.jsp Tue Jul 24 23:34:55 2012 +0300 1.2 +++ b/endpoint/WebContent/describe.jsp Wed Jul 25 01:17:59 2012 +0300 1.3 @@ -1,8 +1,6 @@ 1.4 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 1.5 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 1.6 - 1.7 -<jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.StoreBean"/> 1.8 -<jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.DescribeBean"/> 1.9 +<jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.Common"/> 1.10 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 1.11 <html> 1.12 <head> 1.13 @@ -32,7 +30,7 @@ 1.14 <!-- include TELEIOS header and description --> 1.15 1.16 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Describe"> 1.17 -<input type="hidden" name="<%=DescribeBean.VIEW%>" value="<%=DescribeBean.VIEW_TYPE%>"> 1.18 +<input type="hidden" name="<%=Common.VIEW%>" value="<%=Common.VIEW_TYPE%>"> 1.19 1.20 <table border="0" width="100%"><tr> 1.21 <td width="90" valign="top" class="style4"> 1.22 @@ -50,7 +48,7 @@ 1.23 <tr> 1.24 <td id="output"><center>Output Format:<br/> 1.25 <SELECT name="format" title="select one of the following RDF graph format types"> 1.26 - <% for (String format : StoreBean.registeredFormats) {%> 1.27 + <% for (String format : Common.registeredFormats) {%> 1.28 <OPTION value="<%=format%>"><%=format%></OPTION> 1.29 <%}%> 1.30 </SELECT></center></td>
2.1 --- a/endpoint/WebContent/store.jsp Tue Jul 24 23:34:55 2012 +0300 2.2 +++ b/endpoint/WebContent/store.jsp Wed Jul 25 01:17:59 2012 +0300 2.3 @@ -1,5 +1,7 @@ 2.4 <jsp:directive.page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"/> 2.5 +<jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.Common"/> 2.6 <jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.StoreBean"/> 2.7 +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 2.8 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2.9 <html> 2.10 <head> 2.11 @@ -28,8 +30,8 @@ 2.12 <%@ include file="teleios-header.html"%> 2.13 <!-- include TELEIOS header and description --> 2.14 2.15 -<FORM method="get" action=Store> 2.16 -<INPUT type=hidden name="<%=StoreBean.SRC_REQ%>" value="browser"/> 2.17 +<FORM method=POST enctype="UTF-8" accept-charset="UTF-8" action="Store"> 2.18 +<INPUT type=hidden name="<%=Common.VIEW%>" value="<%=Common.VIEW_TYPE%>"/> 2.19 2.20 <TABLE border="0" width="100%"> 2.21 <TR> 2.22 @@ -41,39 +43,23 @@ 2.23 </TD> 2.24 <td width="*" valign="top" class="style4"> 2.25 <TABLE cellspacing="5"> 2.26 -<% 2.27 - if (request.getParameter(StoreBean.DATA_ERROR) != null) { 2.28 - %> 2.29 + 2.30 +<!-- Error Message --> 2.31 +<c:if test="${error != null}"> 2.32 + <TR><TD colspan=3> 2.33 + <CENTER><P style="color: red;">${error}</P></CENTER> 2.34 + </TD></TR> 2.35 +</c:if> 2.36 +<!-- Error Message --> 2.37 + 2.38 +<!-- Info Message --> 2.39 +<c:if test="${info != null}"> 2.40 <TR><TD colspan=3> 2.41 - <CENTER><P style="color: red;">No data provided!</P></CENTER> 2.42 + <CENTER><P>${info}</P></CENTER> 2.43 </TD></TR> 2.44 - <% 2.45 - } 2.46 - 2.47 - if (request.getParameter(StoreBean.FORMAT_ERROR) != null) { 2.48 - %> 2.49 - <TR><TD colspan=3> 2.50 - <CENTER><P style="color: red;">Unknown RDF Format!</P></CENTER> 2.51 - </TD></TR> 2.52 - <% 2.53 - } 2.54 - 2.55 - if (request.getParameter(StoreBean.STORE_ERROR) != null) { 2.56 - %> 2.57 - <TR><TD colspan=3> 2.58 - <CENTER><P style="color: red;">An error occurred while storing input data!</P></CENTER> 2.59 - </TD></TR> 2.60 - <% 2.61 - } 2.62 - 2.63 - if (request.getParameter(StoreBean.STORE_OK) != null) { 2.64 - %> 2.65 - <TR><TD colspan=3> 2.66 - <CENTER><P>Data stored successfully!</P></CENTER> 2.67 - </TD></TR> 2.68 - <% 2.69 - } 2.70 -%> 2.71 +</c:if> 2.72 +<!-- Info Message --> 2.73 + 2.74 <tr> 2.75 <!-- direct input form --> 2.76 <td id="output">Direct Input:</td> 2.77 @@ -81,8 +67,8 @@ 2.78 <textarea name="<%=StoreBean.PARAM_DATA%>" rows="15" cols="100"></textarea></td> 2.79 <td rowspan=4 id="output"> 2.80 <CENTER>RDF Format:<br/> 2.81 - <SELECT name="<%=StoreBean.PARAM_FORMAT%>"> 2.82 - <% for (String format : StoreBean.registeredFormats) {%> 2.83 + <SELECT name="format"> 2.84 + <% for (String format : Common.registeredFormats) {%> 2.85 <OPTION value="<%=format%>"><%=format%></OPTION> 2.86 <%}%> 2.87 </SELECT>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/Common.java Wed Jul 25 01:17:59 2012 +0300 3.3 @@ -0,0 +1,64 @@ 3.4 +/** 3.5 + * 3.6 + */ 3.7 +package eu.earthobservatory.org.StrabonEndpoint; 3.8 + 3.9 +import java.util.ArrayList; 3.10 + 3.11 +import org.openrdf.rio.RDFFormat; 3.12 + 3.13 +/** 3.14 + * Keeps common variables shared by beans and .jsp pages. 3.15 + * 3.16 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 3.17 + */ 3.18 +public class Common { 3.19 + 3.20 + /** 3.21 + * Parameter used in the jsp file to denote the usage 3.22 + * of the HTML interface 3.23 + */ 3.24 + public static final String VIEW = "view"; 3.25 + public static final String VIEW_TYPE = "HTML"; 3.26 + 3.27 + /** 3.28 + * Keeps the registered and available RDF formats. 3.29 + */ 3.30 + public static ArrayList<String> registeredFormats; 3.31 + 3.32 + // initialize registered and available formats 3.33 + static { 3.34 + registeredFormats = new ArrayList<String>(); 3.35 + for (RDFFormat format : RDFFormat.values()) { 3.36 + registeredFormats.add(format.getName()); 3.37 + } 3.38 + } 3.39 + 3.40 + /** 3.41 + * Determines the RDF format to use. We check only for "accept" 3.42 + * parameter (present in the header). 3.43 + * 3.44 + * The use of "format" parameter is now deprecated for using any 3.45 + * Bean as a service. It is only used through the HTML 3.46 + * visual interface, provided with Strabon Endpoint. 3.47 + * 3.48 + * @param request 3.49 + * @return 3.50 + */ 3.51 + public static RDFFormat getRDFFormatFromAcceptHeader(String acceptHeader) { 3.52 + if (acceptHeader != null) { 3.53 + // check whether the "accept" parameter contains any 3.54 + // of the mime types of any RDF format 3.55 + for (RDFFormat format : RDFFormat.values()) { 3.56 + for (String mimeType : format.getMIMETypes()) { 3.57 + if (acceptHeader.contains(mimeType)) { 3.58 + return format; 3.59 + } 3.60 + } 3.61 + } 3.62 + } 3.63 + 3.64 + return null; 3.65 + } 3.66 + 3.67 +}
4.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/DescribeBean.java Tue Jul 24 23:34:55 2012 +0300 4.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/DescribeBean.java Wed Jul 25 01:17:59 2012 +0300 4.3 @@ -18,15 +18,33 @@ 4.4 import org.springframework.web.context.WebApplicationContext; 4.5 import org.springframework.web.context.support.WebApplicationContextUtils; 4.6 4.7 +/** 4.8 + * {@link DescribeBean} implements the 4.9 + * <A href=http://www.w3.org/TR/rdf-sparql-protocol/>SPARQL Protocol for RDF</A> 4.10 + * for the DESCRIBE query form of SPARQL 1.1. The service can be accessed in two 4.11 + * ways: 4.12 + * 1) via the HTML visual interface ({@link describe.jsp}) or 4.13 + * 2) via an HTTP client (<tt>wget</tt>, <tt>curl</tt>, <tt>telnet</tt>, or any 4.14 + * other such method). 4.15 + * 4.16 + * In the second case, a single parameter is required which is the "query" 4.17 + * parameter carrying the SPARQL DESCRIBE query to execute. The client also 4.18 + * has to specify the Accept header. The value can be one of the following mime 4.19 + * types and determines the RDF format of the response: 4.20 + * "text/plain" (N-Triples), "application/rdf+xml" (RDF/XML), "text/rdf+n3" (N3), 4.21 + * "text/turtle" (Turtle), "application/x-trig" (TRIG), "application/trix" (TRIX), 4.22 + * and "application/x-binary-rdf" (BinaryRDF). 4.23 + * 4.24 + * In case of an error, an appropriate message is wrapped in an XML document 4.25 + * (see also {@link ResponseMessages}). 4.26 + * 4.27 + * 4.28 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 4.29 + * 4.30 + */ 4.31 public class DescribeBean extends HttpServlet{ 4.32 4.33 private static final long serialVersionUID = -7541662133934957148L; 4.34 - 4.35 - /** 4.36 - * Parameters used in the describe.jsp file 4.37 - */ 4.38 - public static final String VIEW = "view"; 4.39 - public static final String VIEW_TYPE = "HTML"; 4.40 4.41 /** 4.42 * Attributes carrying values to be rendered by the describe.jsp file 4.43 @@ -61,7 +79,7 @@ 4.44 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 4.45 request.setCharacterEncoding("UTF-8"); 4.46 4.47 - if (VIEW_TYPE.equals(request.getParameter(VIEW))) { 4.48 + if (Common.VIEW_TYPE.equals(request.getParameter(Common.VIEW))) { 4.49 // HTML visual interface 4.50 processVIEWRequest(request, response); 4.51 4.52 @@ -121,7 +139,7 @@ 4.53 ServletOutputStream out = response.getOutputStream(); 4.54 4.55 // get the RDF format (we check only the Accept header) 4.56 - RDFFormat format = getFormat(request.getHeader("accept")); 4.57 + RDFFormat format = Common.getRDFFormatFromAcceptHeader(request.getHeader("accept")); 4.58 4.59 // get the query 4.60 String query = request.getParameter("query"); 4.61 @@ -155,31 +173,4 @@ 4.62 4.63 out.flush(); 4.64 } 4.65 - 4.66 - /** 4.67 - * Determines the RDF format to use. We check only for "accept" 4.68 - * parameter (present in the header). 4.69 - * 4.70 - * The use of "format" parameter is now deprecated for using the 4.71 - * DescribeBean as a service. It is only used through the HTML 4.72 - * visual interface, provided with Strabon Endpoint. 4.73 - * 4.74 - * @param request 4.75 - * @return 4.76 - */ 4.77 - private RDFFormat getFormat(String reqAccept) { 4.78 - if (reqAccept != null) { 4.79 - // check whether the "accept" parameter contains any 4.80 - // of the mime types of any RDF format 4.81 - for (RDFFormat format : RDFFormat.values()) { 4.82 - for (String mimeType : format.getMIMETypes()) { 4.83 - if (reqAccept.contains(mimeType)) { 4.84 - return format; 4.85 - } 4.86 - } 4.87 - } 4.88 - } 4.89 - 4.90 - return null; 4.91 - } 4.92 }
5.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java Tue Jul 24 23:34:55 2012 +0300 5.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java Wed Jul 25 01:17:59 2012 +0300 5.3 @@ -5,8 +5,8 @@ 5.4 5.5 import java.io.IOException; 5.6 import java.net.MalformedURLException; 5.7 -import java.util.ArrayList; 5.8 5.9 +import javax.servlet.RequestDispatcher; 5.10 import javax.servlet.ServletConfig; 5.11 import javax.servlet.ServletContext; 5.12 import javax.servlet.ServletException; 5.13 @@ -38,31 +38,26 @@ 5.14 public static final String PARAM_DATA = "data"; 5.15 public static final String PARAM_FORMAT = "format"; 5.16 public static final String PARAM_DATA_URL = "url"; 5.17 - public static final String SRC_REQ = "source_request"; 5.18 5.19 /** 5.20 - * Error parameters used in the store.jsp file 5.21 + * Error/Info parameters used in the store.jsp file 5.22 */ 5.23 - public static final String DATA_ERROR = "edata"; 5.24 - public static final String FORMAT_ERROR = "eformat"; 5.25 - public static final String STORE_ERROR = "estore"; 5.26 + public static final String ERROR = "error"; 5.27 + public static final String INFO = "info"; 5.28 + 5.29 + /** 5.30 + * Error/Info messages 5.31 + */ 5.32 + private static final String STORE_ERROR = "An error occurred while storing input data!"; 5.33 + private static final String PARAM_ERROR = "RDF format or input data are not set or are invalid!"; 5.34 + private static final String STORE_OK = "Data stored successfully!"; 5.35 5.36 /** 5.37 * Submit buttons 5.38 */ 5.39 public static final String SUBMIT_INPUT = "dsubmit"; 5.40 public static final String SUBMIT_URL = "fromurl"; 5.41 - 5.42 - /** 5.43 - * Parameter for successful store used in the store.jsp file 5.44 - */ 5.45 - public static final String STORE_OK = "storeOK"; 5.46 - 5.47 - /** 5.48 - * Keeps the registered and available RDF formats. 5.49 - */ 5.50 - public static ArrayList<String> registeredFormats; 5.51 - 5.52 + 5.53 /** 5.54 * Strabon wrapper 5.55 */ 5.56 @@ -76,12 +71,6 @@ 5.57 ServletContext context = getServletContext(); 5.58 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context); 5.59 strabon = (StrabonBeanWrapper) applicationContext.getBean("strabonBean"); 5.60 - 5.61 - // initialize registered and available formats 5.62 - registeredFormats = new ArrayList<String>(); 5.63 - for (RDFFormat format : RDFFormat.values()) { 5.64 - registeredFormats.add(format.getName()); 5.65 - } 5.66 } 5.67 5.68 @Override 5.69 @@ -89,74 +78,110 @@ 5.70 doPost(request, response); 5.71 } 5.72 5.73 - @Override 5.74 - public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 5.75 + private String getData(HttpServletRequest request) { 5.76 // check whether we read from INPUT or URL 5.77 boolean input = (request.getParameter(SUBMIT_URL) != null) ? false:true; 5.78 5.79 - // check if the request was from store.jsp 5.80 - boolean browser = (request.getParameter(SRC_REQ) != null) ? true:false; 5.81 + // return "data" value accordingly 5.82 + return input ? request.getParameter(PARAM_DATA):request.getParameter(PARAM_DATA_URL); 5.83 + } 5.84 + 5.85 + @Override 5.86 + public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 5.87 5.88 - // RDF data to store 5.89 - String data = null; 5.90 + // check whether the request was from store.jsp 5.91 + if (Common.VIEW_TYPE.equals(request.getParameter(Common.VIEW))) { 5.92 + processVIEWRequest(request, response); 5.93 + 5.94 + } else { 5.95 + processRequest(request, response); 5.96 + } 5.97 + } 5.98 + 5.99 + /** 5.100 + * Processes the request made from the HTML visual interface of Strabon Endpoint. 5.101 + * 5.102 + * @param request 5.103 + * @param response 5.104 + * @throws ServletException 5.105 + * @throws IOException 5.106 + */ 5.107 + private void processVIEWRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 5.108 + // check whether we read from INPUT or URL 5.109 + boolean input = (request.getParameter(SUBMIT_URL) != null) ? false:true; 5.110 5.111 - // the format of the data 5.112 - String format = null; 5.113 + // get the dispatcher for forwarding the rendering of the response 5.114 + RequestDispatcher dispatcher = request.getRequestDispatcher("store.jsp"); 5.115 + 5.116 + // RDF data to store 5.117 + String data = getData(request); 5.118 + 5.119 + // the format of the data 5.120 + RDFFormat format = (request.getParameter(PARAM_FORMAT) != null) ? RDFFormat.valueOf(request.getParameter(PARAM_FORMAT)):null; 5.121 + 5.122 + if (data == null || format == null) { 5.123 + request.setAttribute(ERROR, PARAM_ERROR); 5.124 + 5.125 + } else { 5.126 + 5.127 + // store data 5.128 + try { 5.129 + strabon.store(data, format, !input); 5.130 + 5.131 + // store was successful, return the respective message 5.132 + request.setAttribute(INFO, STORE_OK); 5.133 + 5.134 + } catch (Exception e) { 5.135 + request.setAttribute(ERROR, STORE_ERROR + " " + e.getMessage()); 5.136 + } 5.137 + } 5.138 + 5.139 + dispatcher.forward(request, response); 5.140 + } 5.141 + 5.142 + /** 5.143 + * Processes the request made by a client of the endpoint that uses it as a service. 5.144 + * 5.145 + * @param request 5.146 + * @param response 5.147 + * @throws IOException 5.148 + */ 5.149 + private void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { 5.150 + // check whether we read from INPUT or URL 5.151 + boolean input = (request.getParameter(SUBMIT_URL) != null) ? false:true; 5.152 5.153 - format = request.getParameter(PARAM_FORMAT); 5.154 - data = input ? request.getParameter(PARAM_DATA):request.getParameter(PARAM_DATA_URL); 5.155 - 5.156 - if (data == null) { 5.157 - if (browser) { 5.158 - redirect(response, DATA_ERROR); 5.159 - 5.160 - } else { 5.161 - response.sendError(HttpServletResponse.SC_NO_CONTENT); 5.162 - } 5.163 + // RDF data to store 5.164 + String data = getData(request); 5.165 + 5.166 + if (data == null) { 5.167 + response.sendError(HttpServletResponse.SC_NO_CONTENT); 5.168 + return; 5.169 + } 5.170 + 5.171 + // the format of the data 5.172 + RDFFormat format = Common.getRDFFormatFromAcceptHeader(request.getHeader("accept")); 5.173 + 5.174 + if (format == null) { // unknown format 5.175 + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); 5.176 return ; 5.177 } 5.178 5.179 - // get input format 5.180 - RDFFormat rdfFormat = RDFFormat.valueOf(format); 5.181 - 5.182 - if (rdfFormat == null) { // unknown format 5.183 - if (browser) { 5.184 - redirect(response, FORMAT_ERROR); 5.185 + // store data 5.186 + try { 5.187 + strabon.store(data, format, !input); 5.188 + 5.189 + // store was successful, return the respective message 5.190 + response.sendError(HttpServletResponse.SC_OK); 5.191 + } catch (Exception e) { 5.192 + if (e instanceof RDFParseException || 5.193 + e instanceof IllegalArgumentException || e instanceof MalformedURLException) { 5.194 + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); 5.195 5.196 } else { 5.197 - response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); 5.198 + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 5.199 } 5.200 5.201 - return ; 5.202 - } 5.203 - 5.204 - // store data 5.205 - try { 5.206 - strabon.store(data, rdfFormat, !input); 5.207 - 5.208 - // store was successful, return the respective message 5.209 - if (browser) { 5.210 - redirect(response, STORE_OK); 5.211 - 5.212 - } else { 5.213 - response.sendError(HttpServletResponse.SC_OK); 5.214 - } 5.215 - } catch (Exception e) { 5.216 - if (browser) { 5.217 - redirect(response, STORE_ERROR); 5.218 - } else { 5.219 - if (e instanceof RDFParseException || e instanceof IllegalArgumentException || e instanceof MalformedURLException) { 5.220 - response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); 5.221 - } else { 5.222 - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 5.223 - } 5.224 - } 5.225 logger.error("[StrabonEndpoint.StoreBean] " + e.getMessage()); 5.226 } 5.227 - } 5.228 - 5.229 - private void redirect(HttpServletResponse response, String error) { 5.230 - response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); 5.231 - response.setHeader("Location", "store.jsp?" + error + "="); 5.232 - } 5.233 + } 5.234 }
6.1 --- a/scripts/endpoint Tue Jul 24 23:34:55 2012 +0300 6.2 +++ b/scripts/endpoint Wed Jul 25 01:17:59 2012 +0300 6.3 @@ -224,14 +224,45 @@ 6.4 fi 6.5 URL="${1}/Store" 6.6 FORMAT="${2}" 6.7 + MIME_TYPE= 6.8 + case "${FORMAT}" in 6.9 + N-Triples) 6.10 + MIME_TYPE="text/plain" 6.11 + ;; 6.12 + RDF/XML) 6.13 + MIME_TYPE="application/rdf+xml" 6.14 + ;; 6.15 + N3) 6.16 + MIME_TYPE="text/rdf+n3" 6.17 + ;; 6.18 + TURTLE) 6.19 + MIME_TYPE="text/turtle" 6.20 + ;; 6.21 + TRIG) 6.22 + MIME_TYPE="application/x-trig" 6.23 + ;; 6.24 + TRIX) 6.25 + MIME_TYPE="application/trix" 6.26 + ;; 6.27 + BinaryRDF) 6.28 + MIME_TYPE="application/x-binary-rdf" 6.29 + ;; 6.30 + *) 6.31 + echo "${CMD}: unknown format \"${FORMAT}\"." 6.32 + echo "${CMD}: possible values are \`N-Triples' (default), \`RDM/XML', \`N3', \`TURTLE', \`TRIG', \`TRIX', and \`BinaryRDF'" 6.33 + exit 2 6.34 + ;; 6.35 + esac 6.36 + 6.37 case "${3}" in 6.38 -t) 6.39 TRIPLES="${4}" 6.40 - EXEC="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode data='${TRIPLES}' ${URL}" 6.41 + EXEC="curl -w '\nHTTP_CODE=%{http_code}\n' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode data='${TRIPLES}' ${URL}" 6.42 ;; 6.43 -u) 6.44 + 6.45 URL_TRIPLES="${4}" 6.46 - EXEC="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode url='${URL_TRIPLES}' -d fromurl='' ${URL}" 6.47 + EXEC="curl -w '\nHTTP_CODE=%{http_code}\n' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode url='${URL_TRIPLES}' -d fromurl='' ${URL}" 6.48 ;; 6.49 *) 6.50 help_store