X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fuwobo%2Fsrc%2Fit%2Funibo%2Fcs%2Fhelm%2Fuwobo%2FServlet.java;h=d259c3f89f68db1d8c6f48875d897a9a21ab947a;hb=2f28bfb47f5fad6b3c5a705d9ede95700416dee8;hp=3b4766250a42298964bd9612dcd00399aaf23fa4;hpb=b891e0efda6c3407d3dc861af1315a3f1309cd26;p=helm.git diff --git a/helm/uwobo/src/it/unibo/cs/helm/uwobo/Servlet.java b/helm/uwobo/src/it/unibo/cs/helm/uwobo/Servlet.java index 3b4766250..d259c3f89 100644 --- a/helm/uwobo/src/it/unibo/cs/helm/uwobo/Servlet.java +++ b/helm/uwobo/src/it/unibo/cs/helm/uwobo/Servlet.java @@ -1,3 +1,27 @@ +/* Copyright (C) 2001, HELM Team + * + * This file is part of UWOBO, developed at the Computer Science + * Department, University of Bologna, Italy. + * + * UWOBO is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * UWOBO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with UWOBO; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + * + * For details, see the UWOBO World-Wide-Web page, + * http://cs.unibo.it/helm/uwobo + */ + package it.unibo.cs.helm.uwobo; import java.io.*; @@ -7,24 +31,24 @@ import javax.servlet.http.*; import javax.xml.transform.*; import org.xml.sax.*; +// WARNING: next comment is obsolete!!!!! /* * * usage: -* http://aristotele/helm/servlet/uwobo/help -* http://aristotele/helm/servlet/uwobo/add?xsluri=&key= -* http://aristotele/helm/servlet/uwobo/remove[?key=] -* http://aristotele/helm/servlet/uwobo/list -* http://aristotele/helm/servlet/uwobo/reload[?key=] -* http://aristotele/helm/servlet/uwobo/update[?key=] -* http://aristotele/helm/servlet/uwobo/apply?xmluri=&keys=[¶m.=]* +* http://hostname/helm/servlet/uwobo/help +* http://hostname/helm/servlet/uwobo/add?bind=key,stylesheet[&bind=key,stylesheet]* +* http://hostname/helm/servlet/uwobo/remove[?keys=key_1,...,key_n] +* http://hostname/helm/servlet/uwobo/list +* http://hostname/helm/servlet/uwobo/reload[?keys=key_1,...,key_n] +* http://hostname/helm/servlet/uwobo/apply?xmluri=xmldata&keys=key_1,...,key_n[¶m.name=value]*[¶m.key.name=value]*[&prop.name=[value]]* * * example: -* http://aristotele/helm/servlet/uwobo/add?xsluri=file:///D:/Archivio/Progetti/helm/resources/xsl/foo1.xsl&key=foo1 -* http://aristotele/helm/servlet/uwobo/add?xsluri=file:///D:/Archivio/Progetti/helm/resources/xsl/foo2.xsl&key=foo2 -* http://aristotele/helm/servlet/uwobo/apply?xmluri=file:///D:/Archivio/Progetti/helm/resources/xsl/foo.xml&key=foo1&key=foo2 +* http://aristotele/helm/servlet/uwobo/add?bind=foo1,file:///D:/Archivio/Progetti/helm/resources/xsl/foo1.xsl +* http://aristotele/helm/servlet/uwobo/add?bind=foo2,file:///D:/Archivio/Progetti/helm/resources/xsl/foo2.xsl +* http://aristotele/helm/servlet/uwobo/apply?xmluri=file:///D:/Archivio/Progetti/helm/resources/xsl/foo.xml&keys=foo1,foo2 * * installation notes (Tomcat): -* replace parser.jar and jaxp.jar from /lib with xerces.jar +* replace parser.jar and jaxp.jar from /lib with xerces.jar and add xalan.jar * * add in conf/server.xml * hostname/helm/servlet/uwobo/help", - "http://hostname/helm/servlet/uwobo/add?key=key,stylesheet[&key=key,stylesheet]*", + "http://hostname/helm/servlet/uwobo/add?bind=key,stylesheet[&bind=key,stylesheet]*", "http://hostname/helm/servlet/uwobo/remove[?keys=key_1,...,key_n]", "http://hostname/helm/servlet/uwobo/list", "http://hostname/helm/servlet/uwobo/reload[?keys=key_1,...,key_n]", - "http://hostname/helm/servlet/uwobo/update[?keys=key_1,...,key_n]", "http://hostname/helm/servlet/uwobo/apply?xmluri=xmldata&keys=key_1,...,key_n[¶m.name=value]*[¶m.key.name=value]*[&prop.name=[value]]*" }; public static final String help; @@ -97,7 +118,7 @@ public class Servlet extends HttpServlet { throws IOException { resp.setContentType("text/html"); - out.println("

Uwobo servlet

"); + out.println("

" + server.PACKAGE + " servlet

"); } private void html_close(ServletOutputStream out) @@ -109,7 +130,7 @@ public class Servlet extends HttpServlet { private String msg_out(String message) { - return message+"
"; + return message+"
"; } private String exc_out(String message, Exception e) @@ -121,13 +142,14 @@ public class Servlet extends HttpServlet { } String local = e.getLocalizedMessage(); local = local.substring(local.lastIndexOf(':')+1); - return ""+message+": "+local+"
"; + return ""+message+": "+local+"
"; } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletOutputStream out = response.getOutputStream(); + String log = ""; response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); @@ -140,18 +162,20 @@ public class Servlet extends HttpServlet { sendError(response, out, "unknown command", help); return; } if (cmd.equals("/add")) { - final String[] xslkey = request.getParameterValues("key"); + final String[] xslkey = request.getParameterValues("bind"); if (xslkey == null) { sendError(response, out, "bad parameters", usage[1]); return; } html_open(response, out); for (int i = 0; i < xslkey.length; i++) { final String data[] = split2(xslkey[i], ","); - out.println(msg_out("adding key "+data[0]+" ("+data[1]+")")); + out.println(msg_out("adding stylesheet "+data[0]+" ("+data[1]+")")); try { - server.add(data[1], data[0]); + log = server.add(data[1], data[0]); + if(!log.equals("")) + out.println(msg_out(log)); } catch (TransformerConfigurationException tce) { - out.println(exc_out("stylesheet error", tce)); + out.println(exc_out("Stylesheet Error", tce)); } catch (Exception e) { out.println(exc_out(null, e)); } @@ -236,10 +260,14 @@ public class Servlet extends HttpServlet { for (int i = 0; i < data.length; i++) { if (data[i] == null) { out.println(msg_out("removing all keys")); - server.removeAll(); + ArrayList res; + res = server.removeAll(); + Iterator j = res.iterator(); + while (j.hasNext()) + out.println(msg_out((String)j.next())); } else { out.println(msg_out("removing key "+data[i])); - server.remove(data[i]); + out.println(msg_out(server.remove(data[i]))); } } html_close(out); return; @@ -261,34 +289,17 @@ public class Servlet extends HttpServlet { try { if (data[i] == null) { out.println(msg_out("reloading all keys")); - server.reloadAll(); + ArrayList res; + res = server.reloadAll(); + Iterator j = res.iterator(); + while(j.hasNext()) + out.println(msg_out((String)j.next())); } else { out.println(msg_out("reloading key "+data[i])); - server.reload(data[i]); - } - } catch (TransformerConfigurationException tce) { - out.println(exc_out("stylesheet error", tce)); - } catch (Exception e) { - out.println(exc_out(null, e)); - } - } - html_close(out); return; - } - if (cmd.equals("/update")) { - final String key = request.getParameter("keys"); - final String [] data = split(key, ","); - html_open(response, out); - for (int i = 0; i < data.length; i++) { - try { - if (data[i] == null) { - out.println(msg_out("updating all keys")); - server.updateAll(); - } else { - out.println(msg_out("updating key "+data[i])); - server.update(data[i]); + out.println(msg_out(server.reload(data[i]))); } } catch (TransformerConfigurationException tce) { - out.println(exc_out("stylesheet error", tce)); + out.println(exc_out("Stylesheet Error", tce)); } catch (Exception e) { out.println(exc_out(null, e)); } @@ -297,14 +308,21 @@ public class Servlet extends HttpServlet { } if (cmd.equals("/help")) { html_open(response, out); - out.println("

"+server.PACKAGE+" servlet - version "+server.VERSION+"

"); + out.println("

Version "+server.VERSION+"

"); out.println("compiled "+server.DATE+" at "+server.TIME.substring(0,2)+":"+server.TIME.substring(2)+""); + if(Server.SERIALIZATION_DIR.equals("")) { + out.println("

Stylesheet serialization is off."); + out.println("(To turn it on, choose a non-empty value for the " + + "SERIALIZATION_DIR property.)

"); + } else + out.println("

Serialized stylesheed are stored in "" + + Server.SERIALIZATION_DIR + "".

"); out.println("

usage:

"+help+""); html_close(out); return; } sendError(response, out, "unknown command", help); return; } catch (Exception e) { - sendError(response, out, exc_out(null, e),""); // FG: non dovrebbe servire mai + sendError(response, out, exc_out(null, e),""); return; } }