- circumvented the JDBC ?-bug
authorzapata <zapata>
Sat, 14 Dec 2002 01:37:43 +0000 (01:37 +0000)
committerzapata <zapata>
Sat, 14 Dec 2002 01:37:43 +0000 (01:37 +0000)
- made a separate encodeXML function (&apos; is not valid in HTML, but
  required in XML)

14 files changed:
source/mir/misc/StringUtil.java
source/mir/storage/Database.java
source/mir/storage/DatabaseAdaptor.java
source/mir/storage/DatabaseAdaptorMySQL.java
source/mir/storage/DatabaseAdaptorPostgresql.java
source/mir/storage/DatabaseAdaptorSybase.java
source/mir/util/GeneratorHTMLFunctions.java
source/mir/util/HTMLRoutines.java
source/mir/util/JDBCStringRoutines.java [new file with mode: 0755]
source/mir/util/StringRoutines.java
source/mircoders/module/ModuleContent.java
source/mircoders/servlet/ServletModuleComment.java
source/mircoders/servlet/ServletModuleContent.java
source/mircoders/storage/DatabaseLinksImcs.java

index ac55361..85b1bc3 100755 (executable)
@@ -40,7 +40,7 @@ import  gnu.regexp.*;
 /**
  * Statische Hilfsmethoden zur Stringbehandlung
  *
- * @version $Id: StringUtil.java,v 1.29 2002/12/02 12:33:23 zapata Exp $
+ * @version $Id: StringUtil.java,v 1.30 2002/12/14 01:37:43 zapata Exp $
  * @author mir-coders group
  *
  */
@@ -322,6 +322,7 @@ public final class StringUtil {
    *
    * @return geqoteter String
    */
+/*
   public static String quote(String s)
   {
     //String s2 = quote(s, '\'');
@@ -341,7 +342,7 @@ public final class StringUtil {
     s2 = quote(s2, '\"');
     return s2;
   }
-
+*/
   /**
    * schließt <code>s</code> in <code>'</code> ein und setzt Backslashes vor
    * "gefährliche" Zeichen innerhalb des Strings
index 5dfb5b7..a40af7b 100755 (executable)
@@ -45,6 +45,7 @@ import  mir.storage.StorageObject;
 import  mir.storage.store.*;
 import  mir.entity.*;
 import  mir.misc.*;
+import  mir.util.*;
 
 
 /**
@@ -55,7 +56,7 @@ import  mir.misc.*;
  * Treiber, Host, User und Passwort, ueber den der Zugriff auf die
  * Datenbank erfolgt.
  *
- * @version $Id: Database.java,v 1.26 2002/12/13 17:57:31 zapata Exp $
+ * @version $Id: Database.java,v 1.27 2002/12/14 01:37:43 zapata Exp $
  * @author rk
  *
  */
@@ -703,8 +704,7 @@ public class Database implements StorageObject {
             }
             else {
               if (theEntity.hasValueForField(aField)) {
-                aValue = "'" + StringUtil.quote((String)theEntity.getValue(aField))
-                       + "'";
+                aValue = "'" + JDBCStringRoutines.escapeStringLiteral((String)theEntity.getValue(aField)) + "'";
               }
             }
           }
@@ -806,7 +806,9 @@ public class Database implements StorageObject {
           else {
             firstField = false;
           }
-          fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
+          fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField))).append("'");
+
+//              fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
         }
       }
     }
@@ -855,9 +857,11 @@ public class Database implements StorageObject {
         }
       }
       pstmt.executeUpdate();
-    } catch (SQLException sqe) {
+    }
+    catch (SQLException sqe) {
       throwSQLException(sqe, "update");
-    } finally {
+    }
+    finally {
       try {
         con.setAutoCommit(true);
       } catch (Exception e) {
index d97cc2f..16d42f0 100755 (executable)
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir 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.
- *
- * Mir 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 Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
-package  mir.storage;
-
-import java.util.*;
-
-
-/**
- * Interfacedefinition für Datenbank-Adpatoren. Die Adaptoren legen
- * jeweils das Verhalten und die Befehlsmächtigkeit der Datenbank
- * fest.
- *
- * @author <RK>
- *
- * @version $Id: DatabaseAdaptor.java,v 1.2 2002/09/01 22:05:52 mh Exp $
- */
-
-public interface  DatabaseAdaptor{
-
-        /* Liefert den Namen der Adaptorklasse
-        * @return Adaptorklasse als String
-        */
-       public abstract String getDriver ();
-
-
-       /**
-        * Liefert die URL für JDBC zurück, in den die Parameter user, pass und host
-        * eingefügt werden. Die URL wird aus der Konfiguration geholt.
-        *
-        * @param user user als String
-        * @param pass passwort als String
-        * @param host host als String
-        * @return url als String
-        */
-       public abstract String getURL (String user, String pass, String host);
-
-
-       /**
-        * Gibt zurück, ob das SQL der Datenbank den <code>limit</code>-Befehl beherrscht.
-        * @return true wenn ja, sonst false
-        */
-       public abstract boolean hasLimit ();
-
-
-       /**
-        * Liefert zurück, ob der <code>limit</code>-Befehl erst start und dann offset
-        * hat (true), oder umgekehrt. Nur Relevant, wenn hasLimit true zurückliefert.
-        *
-        * @return true wenn erstes, sonst false
-        */
-       public abstract boolean reverseLimit ();
-
-
-       /**
-        * Liefert ein Properties-Objekt zurueck mit user und password.
-        * @param user
-        * @param password
-        * @return Properties
-        */
-       public abstract Properties getProperties (String user, String password);
-
-
-       /**
-        * Gibt SQL-Stringfragment zurück, mit dem nach einem insert-Befehl ermittelt
-        * werden kann, wie man den primary-Key des eingefügten Datensatzes bekommt.
-        *
-        * @param theDB Database-Objekt, aus dem ggf. noetige Informationen geholt
-        * werden können, wie z.B. der Tabellenname
-        * @return SQL-Statement als String
-        */
-       public abstract String getLastInsertSQL (Database theDB);
-}
-
-
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package  mir.storage;\r
+\r
+import java.util.*;\r
+\r
+\r
+/**\r
+ * Interfacedefinition für Datenbank-Adpatoren. Die Adaptoren legen\r
+ * jeweils das Verhalten und die Befehlsmächtigkeit der Datenbank\r
+ * fest.\r
+ *\r
+ * @author <RK>\r
+ *\r
+ * @version $Id: DatabaseAdaptor.java,v 1.3 2002/12/14 01:37:43 zapata Exp $\r
+ */\r
+\r
+public interface  DatabaseAdaptor{\r
+\r
+  /* Liefert den Namen der Adaptorklasse\r
+   * @return Adaptorklasse als String\r
+   */\r
+  public abstract String getDriver();\r
+\r
+  /**\r
+   * Liefert die URL für JDBC zurück, in den die Parameter user, pass und host\r
+   * eingefügt werden. Die URL wird aus der Konfiguration geholt.\r
+   *\r
+   * @param user user als String\r
+   * @param pass passwort als String\r
+   * @param host host als String\r
+   * @return url als String\r
+   */\r
+  public abstract String getURL(String user, String pass, String host);\r
+\r
+  /**\r
+   * Gibt zurück, ob das SQL der Datenbank den <code>limit</code>-Befehl beherrscht.\r
+   * @return true wenn ja, sonst false\r
+   */\r
+  public abstract boolean hasLimit();\r
+\r
+  /**\r
+       * Liefert zurück, ob der <code>limit</code>-Befehl erst start und dann offset\r
+       * hat (true), oder umgekehrt. Nur Relevant, wenn hasLimit true zurückliefert.\r
+   *\r
+   * @return true wenn erstes, sonst false\r
+   */\r
+  public abstract boolean reverseLimit();\r
+\r
+  /**\r
+   * Liefert ein Properties-Objekt zurueck mit user und password.\r
+   * @param user\r
+   * @param password\r
+   * @return Properties\r
+   */\r
+  public abstract Properties getProperties(String user, String password);\r
+\r
+  /**\r
+   * Gibt SQL-Stringfragment zurück, mit dem nach einem insert-Befehl ermittelt\r
+   * werden kann, wie man den primary-Key des eingefügten Datensatzes bekommt.\r
+   *\r
+   * @param theDB Database-Objekt, aus dem ggf. noetige Informationen geholt\r
+   * werden können, wie z.B. der Tabellenname\r
+   * @return SQL-Statement als String\r
+   */\r
+  public abstract String getLastInsertSQL(Database theDB);\r
+}\r
+\r
index 612f8ad..a21a86d 100755 (executable)
@@ -1,71 +1,71 @@
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir 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.
- *
- * Mir 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 Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
-package mir.storage;
-
-import java.util.*;
-import mir.misc.*;
-
-/**
- * <b>Diese Klasse implementiert die abstrakte Klasse DatabaseAdaptor
- *
- * @author <RK>
- * @version 27.6.1999
- */
-
-public final class DatabaseAdaptorMySQL implements DatabaseAdaptor{
-
-    public String getDriver() {
-       return MirConfig.getProp("Adaptor.MySQL.Driver");
-    }
-
-    public String getURL(String user, String pass, String host) {
-           return MirConfig.getProp("Adaptor.MySQL.URL");
-    }
-
-    public  boolean hasLimit() {
-      return true;
-    }
-
-    public boolean reverseLimit() {
-      return false;
-    }
-
-    public Properties getProperties(String user, String password) {
-      return null;
-    }
-
-    public String getLastInsertSQL(Database theDB) {
-           return "select last_insert_id()";
-    }
-}
-
-
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.storage;\r
+\r
+import java.util.*;\r
+import mir.misc.*;\r
+\r
+/**\r
+ * <b>Diese Klasse implementiert die abstrakte Klasse DatabaseAdaptor\r
+ *\r
+ * @author <RK>\r
+ * @version 27.6.1999\r
+ */\r
+\r
+public final class DatabaseAdaptorMySQL implements DatabaseAdaptor{\r
+\r
+  public String getDriver() {\r
+    return MirConfig.getProp("Adaptor.MySQL.Driver");\r
+  }\r
+\r
+  public String getURL(String user, String pass, String host) {\r
+    return MirConfig.getProp("Adaptor.MySQL.URL");\r
+  }\r
+\r
+  public boolean hasLimit() {\r
+    return true;\r
+  }\r
+\r
+  public boolean reverseLimit() {\r
+    return false;\r
+  }\r
+\r
+  public Properties getProperties(String user, String password) {\r
+    return null;\r
+  }\r
+\r
+  public String getLastInsertSQL(Database theDB) {\r
+    return "select last_insert_id()";\r
+  }\r
+}\r
+\r
+\r
index 7072741..fb45b7d 100755 (executable)
@@ -1,71 +1,71 @@
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir 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.
- *
- * Mir 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 Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
-package mir.storage;
-
-import java.util.*;
-import mir.misc.*;
-
-/**
- * <b>Diese Klasse implementiert die abstrakte Klasse DatabaseAdaptor für Postgresql-Datenbanken
- *
- * @author <RK>
- * @version 30.12.2000
- */
-
-public final class DatabaseAdaptorPostgresql implements DatabaseAdaptor{
-
-    public String getDriver() {
-       return MirConfig.getProp("Adaptor.PostgreSQL.Driver");
-    }
-
-    public String getURL(String user, String pass, String host) {
-           return MirConfig.getProp("Adaptor.PostgreSQL.URL");
-    }
-
-    public  boolean hasLimit() {
-      return true;
-    }
-
-    public boolean reverseLimit() {
-      return true;
-    }
-
-    public Properties getProperties(String user, String password) {
-      return null;
-    }
-
-    public String getLastInsertSQL(Database theDB) {
-           return "select currval('"+theDB.getCoreTable()+"_id_seq')";
-    }
-}
-
-
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.storage;\r
+\r
+import java.util.*;\r
+import mir.misc.*;\r
+\r
+/**\r
+ * <b>Diese Klasse implementiert die abstrakte Klasse DatabaseAdaptor für Postgresql-Datenbanken\r
+ *\r
+ * @author <RK>\r
+ * @version 30.12.2000\r
+ */\r
+\r
+public final class DatabaseAdaptorPostgresql implements DatabaseAdaptor{\r
+\r
+  public String getDriver() {\r
+    return MirConfig.getProp("Adaptor.PostgreSQL.Driver");\r
+  }\r
+\r
+  public String getURL(String user, String pass, String host) {\r
+    return MirConfig.getProp("Adaptor.PostgreSQL.URL");\r
+  }\r
+\r
+  public boolean hasLimit() {\r
+    return true;\r
+  }\r
+\r
+  public boolean reverseLimit() {\r
+    return true;\r
+  }\r
+\r
+  public Properties getProperties(String user, String password) {\r
+    return null;\r
+  }\r
+\r
+  public String getLastInsertSQL(Database theDB) {\r
+    return "select currval('" + theDB.getCoreTable() + "_id_seq')";\r
+    }\r
+}\r
+\r
+\r
index 037688c..91ac1b9 100755 (executable)
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir 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.
- *
- * Mir 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 Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-/*
- * Implementiert DatabaseAdaptor Interface für Sybase.
- */
-
-
-
-package  mir.storage;
-
-import java.util.*;
-import  mir.misc.*;
-
-
-/**
- * Diese Klasse implementiert Interface DatabaseAdaptor fuer Sybase
- *
- * @author <RK>
- * @version 15.05.2000
- */
-public final class DatabaseAdaptorSybase
-               implements DatabaseAdaptor {
-
-       /**
-        * Liefert den Namen der Adaptorklasse <code>Adaptor.Sybase.Driver</code>
-        * für Sybase zurück.
-        * @return Adaptorklasse als String
-        */
-    public String getDriver() {
-           return MirConfig.getProp("Adaptor.Sybase.Driver");
-    }
-
-       /**
-        * Liefert die URL für JDBC zurück, in den die Parameter user, pass und host
-        * eingefügt werden. Die URL wird aus der Konfiguration geholt.
-        *
-        * @param user user als String
-        * @param pass passwort als String
-        * @param host host als String
-        * @return url als String
-        */
-    public String getURL(String user, String pass, String host) {
-           return MirConfig.getProp("Adaptor.Sybase.URL");
-               /** @todo  hier muesste bessererweise $HOST durch HOST ersetzt, etc. werden */
-    }
-
-       /**
-        * Gibt zurück, ob das SQL der Datenbank den <code>limit</code>-Befehl beherrscht.
-        * @return false
-        */
-       public boolean hasLimit () {
-               return  false;
-       }
-
-       /**
-        * Liefert zurück, ob der <code>limit</code>-Befehl erst start und dann offset
-        * hat (true), oder umgekehrt. Nur Relevant, wenn hasLimit true zurückliefert.
-        *
-        * @return false
-        */
-    public boolean reverseLimit() {
-      return false;
-    }
-
-       /**
-        * Liefert ein Properties-Objekt zurueck mit user und password.
-        * @param user
-        * @param password
-        * @return Properties
-        */
-    public Properties getProperties(String user, String password) {
-      Properties props = new Properties();
-      props.put("user", user);
-      props.put("password", password);
-      return props;
-    }
-
-
-
-
-
-
-
-
-    public String getLastInsertSQL(Database theDB) {
-           return "select currval('"+theDB.getCoreTable()+"_id_seq')";
-    }
-}
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+/*\r
+ * Implementiert DatabaseAdaptor Interface für Sybase.\r
+ */\r
+\r
+\r
+\r
+package  mir.storage;\r
+\r
+import java.util.*;\r
+import  mir.misc.*;\r
+\r
+\r
+/**\r
+ * Diese Klasse implementiert Interface DatabaseAdaptor fuer Sybase\r
+ *\r
+ * @author <RK>\r
+ * @version 15.05.2000\r
+ */\r
+public final class DatabaseAdaptorSybase implements DatabaseAdaptor {\r
+\r
+  /**\r
+   * Liefert den Namen der Adaptorklasse <code>Adaptor.Sybase.Driver</code>\r
+   * für Sybase zurück.\r
+   * @return Adaptorklasse als String\r
+   */\r
+  public String getDriver() {\r
+    return MirConfig.getProp("Adaptor.Sybase.Driver");\r
+  }\r
+\r
+  /**\r
+   * Liefert die URL für JDBC zurück, in den die Parameter user, pass und host\r
+   * eingefügt werden. Die URL wird aus der Konfiguration geholt.\r
+   *\r
+   * @param user user als String\r
+   * @param pass passwort als String\r
+   * @param host host als String\r
+   * @return url als String\r
+   */\r
+  public String getURL(String user, String pass, String host) {\r
+    return MirConfig.getProp("Adaptor.Sybase.URL");\r
+        /** @todo  hier muesste bessererweise $HOST durch HOST ersetzt, etc. werden */\r
+  }\r
+\r
+  /**\r
+   * Gibt zurück, ob das SQL der Datenbank den <code>limit</code>-Befehl beherrscht.\r
+   * @return false\r
+   */\r
+  public boolean hasLimit() {\r
+    return false;\r
+  }\r
+\r
+  /**\r
+   * Liefert zurück, ob der <code>limit</code>-Befehl erst start und dann offset\r
+   * hat (true), oder umgekehrt. Nur Relevant, wenn hasLimit true zurückliefert.\r
+   *\r
+   * @return false\r
+   */\r
+  public boolean reverseLimit() {\r
+    return false;\r
+  }\r
+\r
+  /**\r
+   * Liefert ein Properties-Objekt zurueck mit user und password.\r
+   * @param user\r
+   * @param password\r
+   * @return Properties\r
+   */\r
+  public Properties getProperties(String user, String password) {\r
+    Properties props = new Properties();\r
+    props.put("user", user);\r
+    props.put("password", password);\r
+    return props;\r
+  }\r
+\r
+  public String getLastInsertSQL(Database theDB) {\r
+    return "select currval('" + theDB.getCoreTable() + "_id_seq')";\r
+  }\r
+}\r
index 7d156d2..c098c27 100755 (executable)
@@ -72,4 +72,21 @@ public class GeneratorHTMLFunctions {
       }
     };
   }
+
+  public static class encodeXMLGeneratorFunction implements Generator.GeneratorFunction {
+    public Object perform(List aParameters) throws GeneratorExc {
+      try {
+        if (aParameters.size()!=1)
+          throw new GeneratorExc("encodeHTMLGeneratorFunction: only 1 parameter expected");
+
+        return HTMLRoutines.encodeXML(StringRoutines.interpretAsString(aParameters.get(0)));
+      }
+      catch (GeneratorExc e) {
+        throw e;
+      }
+      catch (Throwable t) {
+        throw new GeneratorFailure("encodeHTMLGeneratorFunction: " + t.getMessage(), t);
+      }
+    };
+  }
 }
index 076f4ce..53bced3 100755 (executable)
@@ -40,34 +40,16 @@ public class HTMLRoutines {
   }
 
   public static String encodeHTML(String aText) {
-    final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"', '\'' };
-    final String[] ESCAPE_CODES = { "&amp;", "&lt;", "&gt;", "&quot;", "&apos;" };
-
-    int position, nextPosition;
-    int i;
-    StringBuffer result = new StringBuffer();
-
-    position=0;
-
-    do {
-      nextPosition = StringRoutines.indexOfCharacters(aText, CHARACTERS_TO_ESCAPE, position);
+    final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"' };
+    final String[] ESCAPE_CODES = { "&amp;", "&lt;", "&gt;", "&quot;" };
 
-      if (nextPosition<0)
-        nextPosition = aText.length();
-
-      result.append(aText.substring(position, nextPosition));
+    return StringRoutines.replaceStringCharacters(aText, CHARACTERS_TO_ESCAPE, ESCAPE_CODES);
+  }
 
-      if (nextPosition<aText.length())
-        for (i=0; i<CHARACTERS_TO_ESCAPE.length; i++) {
-          if (CHARACTERS_TO_ESCAPE[i] == aText.charAt(nextPosition)) {
-            result.append(ESCAPE_CODES[i]);
-            break;
-          }
-        }
-      position=nextPosition+1;
-    }
-    while (nextPosition<aText.length()) ;
+  public static String encodeXML(String aText) {
+    final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"', '\'' };
+    final String[] ESCAPE_CODES = { "&amp;", "&lt;", "&gt;", "&quot;", "&apos;" };
 
-    return result.toString();
+    return StringRoutines.replaceStringCharacters(aText, CHARACTERS_TO_ESCAPE, ESCAPE_CODES);
   }
 }
\ No newline at end of file
diff --git a/source/mir/util/JDBCStringRoutines.java b/source/mir/util/JDBCStringRoutines.java
new file mode 100755 (executable)
index 0000000..0e273f2
--- /dev/null
@@ -0,0 +1,23 @@
+package mir.util;
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2002</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class JDBCStringRoutines {
+  private JDBCStringRoutines() {
+  }
+
+  public static String escapeStringLiteral(String aText) {
+    final char[] CHARACTERS_TO_ESCAPE = { '\'', '\\', '%', '_', '?' };
+    final String[] ESCAPE_CODES = { "\'\'", "\\\\", "\\%", "\\_", "\\?" };
+
+    return StringRoutines.replaceStringCharacters(aText, CHARACTERS_TO_ESCAPE, ESCAPE_CODES);
+  }
+
+}
\ No newline at end of file
index e25df14..ddb6ccb 100755 (executable)
@@ -55,6 +55,36 @@ public class StringRoutines {
     return result;
   }
 
+  static String replaceStringCharacters(String aText, char[] aCharactersToReplace, String[] aStringsToSubstitute) {
+    int position, nextPosition;
+    int i;
+    StringBuffer result = new StringBuffer();
+
+    position=0;
+
+    do {
+      nextPosition = StringRoutines.indexOfCharacters(aText, aCharactersToReplace, position);
+
+      if (nextPosition<0)
+        nextPosition = aText.length();
+
+      result.append(aText.substring(position, nextPosition));
+
+      if (nextPosition<aText.length())
+        for (i=0; i<aCharactersToReplace.length; i++) {
+          if (aCharactersToReplace[i] == aText.charAt(nextPosition)) {
+            result.append(aStringsToSubstitute[i]);
+            break;
+          }
+        }
+      position=nextPosition+1;
+    }
+    while (nextPosition<aText.length()) ;
+
+    return result.toString();
+  }
+
+
   public static String interpretAsString(Object aValue) throws Exception {
     if (aValue instanceof String)
       return (String) aValue;
index 6a44b55..3c92930 100755 (executable)
@@ -42,6 +42,7 @@ import mir.servlet.*;
 import mir.module.*;
 import mir.entity.*;
 import mir.misc.*;
+import mir.util.*;
 import mir.storage.*;
 import mir.log.*;
 
@@ -51,7 +52,7 @@ import mircoders.storage.*;
 /*
  *  ContentObjekt -
  *
- * @version $Id: ModuleContent.java,v 1.12 2002/11/30 19:45:56 zapata Exp $
+ * @version $Id: ModuleContent.java,v 1.13 2002/12/14 01:37:43 zapata Exp $
  *
  * @author RK, mir-coders
  *
@@ -156,7 +157,7 @@ public class ModuleContent extends AbstractModule
   public EntityList getContentByField(String aField, String aValue, String orderBy, int offset,
                                       EntityUsers user) throws ModuleException
   {
-    String whereClause = "lower("+aField + ") like lower('%" + StringUtil.quote(aValue) + "%')";
+    String whereClause = "lower("+aField + ") like lower('%" + JDBCStringRoutines.escapeStringLiteral(aValue) + "%')";
     return getContent(whereClause, orderBy, offset, user);
   }
 
index c2040c2..81aac14 100755 (executable)
@@ -166,8 +166,7 @@ public class ServletModuleComment extends ServletModule
         if (!whereClause.equals(""))
           whereClause = whereClause + " and ";
 
-        // ML: searchText must be properly escaped!
-        whereClause = whereClause + "lower(" + queryField + ") like '%" + searchText.toLowerCase() + "%'";
+        whereClause = whereClause + "lower(" + queryField + ") like '%" + JDBCStringRoutines.escapeStringLiteral(searchText.toLowerCase()) + "%'";
       }
     }
 
index fda22ad..c926156 100755 (executable)
@@ -62,7 +62,7 @@ import mircoders.localizer.*;
  *  ServletModuleContent -
  *  deliver html for the article admin form.
  *
- * @version $Id: ServletModuleContent.java,v 1.28 2002/12/13 20:59:42 zapata Exp $
+ * @version $Id: ServletModuleContent.java,v 1.29 2002/12/14 01:37:44 zapata Exp $
  * @author rk, mir-coders
  *
  */
@@ -156,7 +156,7 @@ public class ServletModuleContent extends ServletModule
       String        orderParam = req.getParameter("order");
 
       theList = ((ModuleContent)mainModule).getContentByField(fieldParam, fieldValueParam, orderParam, 0, user);
-      returnArticleList(req, res, "lower("+ fieldParam + ") like lower('%" + StringUtil.quote(fieldValueParam) + "%')", orderParam, 0);
+      returnArticleList(req, res, "lower("+ fieldParam + ") like lower('%" + JDBCStringRoutines.escapeStringLiteral(fieldValueParam) + "%')", orderParam, 0);
     } catch (ModuleException e) {
       throw new ServletModuleException(e.toString());
     }
index 7290782..e2d55f5 100755 (executable)
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir 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.
- *
- * Mir 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 Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
-package  mircoders.storage;
-
-import  java.lang.*;
-import  java.sql.*;
-import  java.io.*;
-import  java.util.*;
-import  freemarker.template.*;
-import  mir.storage.*;
-import  mir.entity.*;
-import  mir.misc.*;
-
-
-/**
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
- *
- *
- */
-public class DatabaseLinksImcs extends Database
-               implements StorageObject {
-       private static DatabaseLinksImcs instance;
-
-       /**
-        * put your documentation comment here
-        * @return
-        * @exception StorageObjectException
-        */
-       // the following *has* to be sychronized cause this static method
-       // could get preemted and we could end up with 2 instances of DatabaseFoo..
-       // see the "Singletons with needles and thread" article at JavaWorld -mh
-       public synchronized static DatabaseLinksImcs getInstance () 
-         throws StorageObjectException {
-               if (instance == null) {
-                       instance = new DatabaseLinksImcs();
-                       instance.myselfDatabase = instance;
-               }
-               return  instance;
-       }
-
-       /**
-        * put your documentation comment here
-        */
-       private DatabaseLinksImcs () throws StorageObjectException
-       {
-               super();
-               ////this.cache = new HashMap();
-               this.hasTimestamp = false;
-               this.theTable = "links_imcs";
-               try {
-                       this.theEntityClass = Class.forName("mircoders.entity.EntityLinksImcs");
-               } catch (Exception e) {
-                       throw  new StorageObjectException(e.toString());
-               }
-       }
-
-       /** @todo toooo much copy/paste in this class //rk  */
-
-       public String insert (Entity theEntity) throws StorageObjectException {
-               String returnId = "0";
-               Connection con = null;
-               PreparedStatement pstmt = null;
-               //cache
-               invalidatePopupCache();
-               try {
-                       HashMap theEntityValues = theEntity.getValues();
-                       ArrayList streamedInput = theEntity.streamedInput();
-                       StringBuffer f = new StringBuffer();
-                       StringBuffer v = new StringBuffer();
-                       String aField, aValue;
-                       boolean firstField = true;
-                       // make sql-string
-                       for (int i = 0; i < getFields().size(); i++) {
-                               aField = (String)getFields().get(i);
-                               if (!aField.equals(thePKeyName)) {
-                                       aValue = null;
-                                       // sonderfaelle
-                                       if (aField.equals("webdb_create")) {
-                                               aValue = "NOW()";
-                                       }
-                                       else {
-                                               if (streamedInput != null && streamedInput.contains(aField)) {
-                                                       aValue = "?";
-                                               }
-                                               else {
-                                                       if (theEntityValues.containsKey(aField)) {
-                                                               if (aField.equals("to_parent_id")) {
-                                                                       aValue = StringUtil.quote((String)theEntityValues.get(aField));
-                                                               } else {
-                                                                       aValue = "'" + StringUtil.quote((String)theEntityValues.get(aField)) + "'";
-                                                               }
-                                                       }
-                                               }
-                                       }
-                                       // wenn Wert gegeben, dann einbauen
-                                       if (aValue != null) {
-                                               if (firstField == false) {
-                                                       f.append(",");
-                                                       v.append(",");
-                                               }
-                                               else {
-                                                       firstField = false;
-                                               }
-                                               f.append(aField);
-                                               v.append(aValue);
-                                       }
-                               }
-                       }         // end for
-                       // insert into db
-                       StringBuffer sqlBuf = new StringBuffer("insert into ").append(theTable).append("(").append(f).append(") values (").append(v).append(")");
-                       String sql = sqlBuf.toString();
-                       theLog.printInfo("INSERT: " + sql);
-                       con = getPooledCon();
-                       con.setAutoCommit(false);
-                       pstmt = con.prepareStatement(sql);
-                       if (streamedInput != null) {
-                               for (int i = 0; i < streamedInput.size(); i++) {
-                                       String inputString = (String)theEntityValues.get(streamedInput.get(i));
-                                       pstmt.setBytes(i + 1, inputString.getBytes());
-                               }
-                       }
-                       pstmt.execute();
-                       pstmt = con.prepareStatement(theAdaptor.getLastInsertSQL((Database)myselfDatabase));
-                       ResultSet rs = pstmt.executeQuery();
-                       rs.next();
-                       returnId = rs.getString(1);
-                       theEntity.setId(returnId);
-               } catch (SQLException sqe) {
-                       throwSQLException(sqe, "insert");
-               } finally {
-                       try {
-                               con.setAutoCommit(true);
-                       } catch (Exception e) {
-                               ;
-                       }
-                       freeConnection(con, pstmt);
-               }
-               return  returnId;
-       }
-
-       public void update (Entity theEntity) throws StorageObjectException {
-               Connection con = null;
-               PreparedStatement pstmt = null;
-               ArrayList streamedInput = theEntity.streamedInput();
-               HashMap theEntityValues = theEntity.getValues();
-               String id = theEntity.getId();
-               String aField;
-               StringBuffer fv = new StringBuffer();
-               boolean firstField = true;
-               //cache
-               invalidatePopupCache();
-               // build sql statement
-               for (int i = 0; i < getFields().size(); i++) {
-                       aField = (String)metadataFields.get(i);
-                       // only normal cases
-                       if (!(aField.equals(thePKeyName) || aField.equals("webdb_create") ||
-                                       aField.equals("webdb_lastchange") || (streamedInput != null && streamedInput.contains(aField)))) {
-                               if (theEntityValues.containsKey(aField)) {
-                                       if (firstField == false) {
-                                               fv.append(", ");
-                                       }
-                                       else {
-                                               firstField = false;
-                                       }
-                                       if (aField.equals("to_parent_id")) {
-                                               fv.append(aField).append("=").append(StringUtil.quote((String)theEntityValues.get(aField)));
-                                       } else {
-                                               fv.append(aField).append("='").append(StringUtil.quote((String)theEntityValues.get(aField))).append("'");
-                                       }
-                               }
-                       }
-               }
-               StringBuffer sql = new StringBuffer("update ").append(theTable).append(" set ").append(fv);
-               // exceptions
-               if (metadataFields.contains("webdb_lastchange")) {
-                       sql.append(",webdb_lastchange=NOW()");
-               }
-               if (streamedInput != null) {
-                       for (int i = 0; i < streamedInput.size(); i++) {
-                               sql.append(",").append(streamedInput.get(i)).append("=?");
-                       }
-               }
-               sql.append(" where id=").append(id);
-               theLog.printInfo("UPDATE: " + sql);
-               // execute sql
-               try {
-                       con = getPooledCon();
-                       con.setAutoCommit(false);
-                       pstmt = con.prepareStatement(sql.toString());
-                       if (streamedInput != null) {
-                               for (int i = 0; i < streamedInput.size(); i++) {
-                                       String inputString = (String)theEntityValues.get(streamedInput.get(i));
-                                       pstmt.setBytes(i + 1, inputString.getBytes());
-                               }
-                       }
-                       pstmt.executeUpdate();
-               } catch (SQLException sqe) {
-                       throwSQLException(sqe, "update");
-               } finally {
-                       try {
-                               con.setAutoCommit(true);
-                       } catch (Exception e) {
-                               ;
-                       }
-                       freeConnection(con, pstmt);
-               }
-       }
-
-}
-
-
-
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package  mircoders.storage;\r
+\r
+import  java.lang.*;\r
+import  java.sql.*;\r
+import  java.io.*;\r
+import  java.util.*;\r
+import  freemarker.template.*;\r
+import  mir.storage.*;\r
+import  mir.entity.*;\r
+import  mir.misc.*;\r
+import  mir.util.*;\r
+\r
+\r
+/**\r
+ * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle\r
+ *\r
+ *\r
+ */\r
+public class DatabaseLinksImcs extends Database\r
+    implements StorageObject {\r
+  private static DatabaseLinksImcs instance;\r
+\r
+  /**\r
+   * put your documentation comment here\r
+   * @return\r
+   * @exception StorageObjectException\r
+   */\r
+  // the following *has* to be sychronized cause this static method\r
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
+  // see the "Singletons with needles and thread" article at JavaWorld -mh\r
+  public synchronized static DatabaseLinksImcs getInstance() throws\r
+      StorageObjectException {\r
+    if (instance == null) {\r
+      instance = new DatabaseLinksImcs();\r
+      instance.myselfDatabase = instance;\r
+    }\r
+    return instance;\r
+  }\r
+\r
+  /**\r
+   * put your documentation comment here\r
+   */\r
+  private DatabaseLinksImcs() throws StorageObjectException {\r
+    super();\r
+    ////this.cache = new HashMap();\r
+    this.hasTimestamp = false;\r
+    this.theTable = "links_imcs";\r
+    try {\r
+      this.theEntityClass = Class.forName("mircoders.entity.EntityLinksImcs");\r
+    }\r
+    catch (Exception e) {\r
+      throw new StorageObjectException(e.toString());\r
+    }\r
+  }\r
+\r
+  /** @todo toooo much copy/paste in this class //rk  */\r
+\r
+  public String insert(Entity theEntity) throws StorageObjectException {\r
+    String returnId = "0";\r
+    Connection con = null;\r
+    PreparedStatement pstmt = null;\r
+    //cache\r
+    invalidatePopupCache();\r
+    try {\r
+      HashMap theEntityValues = theEntity.getValues();\r
+      ArrayList streamedInput = theEntity.streamedInput();\r
+      StringBuffer f = new StringBuffer();\r
+      StringBuffer v = new StringBuffer();\r
+      String aField, aValue;\r
+      boolean firstField = true;\r
+      // make sql-string\r
+      for (int i = 0; i < getFields().size(); i++) {\r
+        aField = (String) getFields().get(i);\r
+        if (!aField.equals(thePKeyName)) {\r
+          aValue = null;\r
+          // sonderfaelle\r
+          if (aField.equals("webdb_create")) {\r
+            aValue = "NOW()";\r
+          }\r
+          else {\r
+            if (streamedInput != null && streamedInput.contains(aField)) {\r
+              aValue = "?";\r
+            }\r
+            else {\r
+              if (theEntityValues.containsKey(aField)) {\r
+                if (aField.equals("to_parent_id")) {\r
+                  aValue = JDBCStringRoutines.escapeStringLiteral((String) theEntityValues.get(aField));\r
+                }\r
+                else {\r
+                  aValue = "'" + JDBCStringRoutines.escapeStringLiteral((String) theEntityValues.get(aField)) +  "'";\r
+                }\r
+              }\r
+            }\r
+          }\r
+          // wenn Wert gegeben, dann einbauen\r
+          if (aValue != null) {\r
+            if (firstField == false) {\r
+              f.append(",");\r
+              v.append(",");\r
+            }\r
+            else {\r
+              firstField = false;\r
+            }\r
+            f.append(aField);\r
+            v.append(aValue);\r
+          }\r
+        }\r
+      } // end for\r
+      // insert into db\r
+      StringBuffer sqlBuf = new StringBuffer("insert into ").append(theTable).\r
+          append("(").append(f).append(") values (").append(v).append(")");\r
+      String sql = sqlBuf.toString();\r
+      theLog.printInfo("INSERT: " + sql);\r
+      con = getPooledCon();\r
+      con.setAutoCommit(false);\r
+      pstmt = con.prepareStatement(sql);\r
+      if (streamedInput != null) {\r
+        for (int i = 0; i < streamedInput.size(); i++) {\r
+          String inputString = (String) theEntityValues.get(streamedInput.get(i));\r
+          pstmt.setBytes(i + 1, inputString.getBytes());\r
+        }\r
+      }\r
+      pstmt.execute();\r
+      pstmt = con.prepareStatement(theAdaptor.getLastInsertSQL( (Database)\r
+          myselfDatabase));\r
+      ResultSet rs = pstmt.executeQuery();\r
+      rs.next();\r
+      returnId = rs.getString(1);\r
+      theEntity.setId(returnId);\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "insert");\r
+    }\r
+    finally {\r
+      try {\r
+        con.setAutoCommit(true);\r
+      }\r
+      catch (Exception e) {\r
+        ;\r
+      }\r
+      freeConnection(con, pstmt);\r
+    }\r
+    return returnId;\r
+  }\r
+\r
+  public void update(Entity theEntity) throws StorageObjectException {\r
+    Connection con = null;\r
+    PreparedStatement pstmt = null;\r
+    ArrayList streamedInput = theEntity.streamedInput();\r
+    HashMap theEntityValues = theEntity.getValues();\r
+    String id = theEntity.getId();\r
+    String aField;\r
+    StringBuffer fv = new StringBuffer();\r
+    boolean firstField = true;\r
+    //cache\r
+    invalidatePopupCache();\r
+    // build sql statement\r
+    for (int i = 0; i < getFields().size(); i++) {\r
+      aField = (String) metadataFields.get(i);\r
+      // only normal cases\r
+      if (! (aField.equals(thePKeyName) || aField.equals("webdb_create") ||\r
+             aField.equals("webdb_lastchange") ||\r
+             (streamedInput != null && streamedInput.contains(aField)))) {\r
+        if (theEntityValues.containsKey(aField)) {\r
+          if (firstField == false) {\r
+            fv.append(", ");\r
+          }\r
+          else {\r
+            firstField = false;\r
+          }\r
+          if (aField.equals("to_parent_id")) {\r
+            fv.append(aField).append("=").append(JDBCStringRoutines.escapeStringLiteral((String)theEntityValues.get(aField)));\r
+          }\r
+          else {\r
+            fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral((String)theEntityValues.get(aField))).append("'");\r
+          }\r
+        }\r
+      }\r
+    }\r
+    StringBuffer sql = new StringBuffer("update ").append(theTable).append(\r
+        " set ").append(fv);\r
+    // exceptions\r
+    if (metadataFields.contains("webdb_lastchange")) {\r
+      sql.append(",webdb_lastchange=NOW()");\r
+    }\r
+    if (streamedInput != null) {\r
+      for (int i = 0; i < streamedInput.size(); i++) {\r
+        sql.append(",").append(streamedInput.get(i)).append("=?");\r
+      }\r
+    }\r
+    sql.append(" where id=").append(id);\r
+    theLog.printInfo("UPDATE: " + sql);\r
+    // execute sql\r
+    try {\r
+      con = getPooledCon();\r
+      con.setAutoCommit(false);\r
+      pstmt = con.prepareStatement(sql.toString());\r
+      if (streamedInput != null) {\r
+        for (int i = 0; i < streamedInput.size(); i++) {\r
+          String inputString = (String) theEntityValues.get(streamedInput.get(i));\r
+          pstmt.setBytes(i + 1, inputString.getBytes());\r
+        }\r
+      }\r
+      pstmt.executeUpdate();\r
+    }\r
+    catch (SQLException sqe) {\r
+      throwSQLException(sqe, "update");\r
+    }\r
+    finally {\r
+      try {\r
+        con.setAutoCommit(true);\r
+      }\r
+      catch (Exception e) {\r
+        ;\r
+      }\r
+      freeConnection(con, pstmt);\r
+    }\r
+  }\r
+\r
+}
\ No newline at end of file