diff --git a/html/rest.html b/html/rest.html index 8c724a42a53dcf5dd60cc1fc5ea9a58a7fb9b350..4aef223953dce8f5d45ef9028414611b27228297 100644 --- a/html/rest.html +++ b/html/rest.html @@ -23,7 +23,7 @@ The result of these requests are provided in XML. In the sequel, we describe the various request types. They can be obtained by: <div class="terminal"> -$ curl -H "Content-Type: text/xml" <URL> +$ curl -H "Content-Type: text/xml" '<URL>' </div> </p> <p> @@ -31,6 +31,11 @@ The <tt>msgid</tt> and <tt>in-reply-to</tt> elements are not compulsory and may not be present in messages. </p> +<p style="background-color: yellow;"> +Beware: URIs within the <URL> above should be URLEncoded. +This is particularly true of '#' that do not pass through Java URL decoding. +</p> + <h3>listalignments<a name="listalignments"></a></h3> <p>Gets the list of the alignments available on the server.</p> diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 8fb8d8873952104db3d4301720e9a2ffdeb5a797..24412863215471647b0755827c4d8869444ccdd0 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -362,9 +362,12 @@ public class AServProtocolManager { String msg = ""; boolean strict = (params.getProperty("strict")!=null); try { - for ( Cell c : al.getAlignCells1( uri ) ) { - if ( !strict || c.getRelation() instanceof EquivRelation ) { - msg += c.getObject2AsURI( al )+" "; + Set<Cell> cells = al.getAlignCells1( uri ); + if ( cells != null ) { + for ( Cell c : cells ) { + if ( !strict || c.getRelation() instanceof EquivRelation ) { + msg += c.getObject2AsURI( al )+" "; + } } } } catch ( AlignmentException alex ) { // should never happen diff --git a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java index 680082c1eeafd8702eeeaa6ff33fc6f484dc3449..6e918450fe5b3e93698aeebe4b042dbd961dce87 100644 --- a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java @@ -152,8 +152,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { // The handler deals with the request // most of its work is to deal with large content sent in specific ways Handler handler = new AbstractHandler(){ - public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) - throws IOException, ServletException { + public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch ) throws IOException, ServletException { String method = request.getMethod(); //uri = URLDecoder.decode( request.getURI(), "iso-8859-1" ); // Should be decoded? @@ -165,7 +164,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { // See below how it is done. Properties header = new Properties(); Enumeration headerNames = request.getHeaderNames(); - while(headerNames.hasMoreElements()) { + while( headerNames.hasMoreElements() ) { String headerName = (String)headerNames.nextElement(); header.setProperty( headerName, request.getHeader(headerName) ); } @@ -199,13 +198,17 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( mimetype != null && mimetype.startsWith("text/xml") ) { // Most likely Web service request (REST through POST) int length = request.getContentLength(); - char [] mess = new char[length+1]; - try { - new BufferedReader(new InputStreamReader(request.getInputStream())).read( mess, 0, length); - } catch (Exception e) { - e.printStackTrace(); // To clean up + if ( length > 0 ) { + char [] mess = new char[length+1]; + try { + System.err.println("!!!!!"+length); + new BufferedReader(new InputStreamReader(request.getInputStream())).read( mess, 0, length); + System.err.println("?????"); + } catch (Exception e) { + e.printStackTrace(); // To clean up + } + params.setProperty( "content", new String( mess ) ); } - params.setProperty( "content", new String( mess ) ); // File attached to SOAP messages } else if ( mimetype != null && mimetype.startsWith("application/octet-stream") ) { File alignFile = new File(File.separator + "tmp" + File.separator + newId() +"XXX.rdf"); @@ -292,16 +295,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { Enumeration en = header.propertyNames(); while ( en.hasMoreElements()) { String value = (String)en.nextElement(); - //System.err.println( " HDR: '" + value + "' = '" + - // header.getProperty( value ) + "'" ); - } - /* - e = parms.propertyNames(); - while ( e.hasMoreElements()) { - String value = (String)e.nextElement(); - //System.err.println( " PRM: '" + value + "' = '" +parms.getProperty( value ) + "'" ); } - */ // Convert parms to parameters Properties params = new Properties(); @@ -902,6 +896,7 @@ result += "<td><form action=\"metadata\"><input type=\"hidden\" name=\"id\" valu if ( sep >= 0 ){ try { p.put( URLDecoder.decode( next.substring( 0, sep ), "iso-8859-1" ).trim(), + // JE: URLDecoder allows for : and / but not # URLDecoder.decode( next.substring( sep+1 ), "iso-8859-1" )); } catch (Exception e) {}; //never thrown } diff --git a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java index c4defc18fbe2f45538219cb82a3e1b133c4f3713..26fb853d05dccac3c511af39ae5ab24003a8e2c0 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java @@ -338,7 +338,7 @@ public class WSAServProfile implements AlignmentServiceProfile { } else { answer = manager.findCorrespondences( new Message(newId(),(Message)null,myId,serverURL,"", newparameters) ); } - msg += " <correspResponse"+svcNS+">\n"+answer.SOAPString()+"</correspResponse>\n"; + msg += " <correspResponse"+svcNS+">\n"+answer.SOAPString()+" </correspResponse>\n"; } else if ( method.equals("findRequest") || method.equals("find") ) { // URI * URI -> List of URI if ( newparameters.getProperty( "onto1" ) == null && newparameters.getProperty( "onto2" ) == null ) { answer = new NonConformParameters(0,(Message)null,myId,"",message,(Properties)null);