media handling fixes, gotten rid of StorageObject, set the default method for blots...
authorzapata <zapata>
Sun, 23 Jan 2005 15:36:02 +0000 (15:36 +0000)
committerzapata <zapata>
Sun, 23 Jan 2005 15:36:02 +0000 (15:36 +0000)
63 files changed:
dbscripts/create_pg.sql
source/mir/entity/AbstractEntity.java
source/mir/entity/Entity.java
source/mir/entity/EntityBrowser.java
source/mir/entity/EntityList.java
source/mir/entity/StorableObjectEntity.java
source/mir/entity/adapter/EntityAdapterEngine.java
source/mir/entity/adapter/EntityAdapterModel.java
source/mir/entity/adapter/EntityIteratorAdapter.java
source/mir/media/MediaHandler.java
source/mir/module/AbstractModule.java
source/mir/producer/EntityBatchingProducerNode.java
source/mir/producer/EntityDeletingProducerNode.java
source/mir/servlet/ServletModule.java
source/mir/storage/Database.java
source/mir/storage/StorageObject.java [deleted file]
source/mir/storage/StorageObjectFailure.java
source/mircoders/entity/EntityAudio.java
source/mircoders/entity/EntityContent.java
source/mircoders/entity/EntityImages.java
source/mircoders/entity/EntityOther.java
source/mircoders/entity/EntityUploadedMedia.java
source/mircoders/localizer/MirMediaLocalizer.java
source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java
source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java
source/mircoders/media/MediaHandlerImages.java
source/mircoders/media/MediaHelper.java
source/mircoders/module/ModuleArticleType.java
source/mircoders/module/ModuleComment.java
source/mircoders/module/ModuleCommentStatus.java
source/mircoders/module/ModuleContent.java
source/mircoders/module/ModuleLanguage.java
source/mircoders/module/ModuleMediafolder.java
source/mircoders/module/ModuleUploadedMedia.java
source/mircoders/module/ModuleUsers.java
source/mircoders/servlet/ServletModuleOpenIndy.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
source/mircoders/storage/DatabaseArticleType.java
source/mircoders/storage/DatabaseAudio.java
source/mircoders/storage/DatabaseBreaking.java
source/mircoders/storage/DatabaseComment.java
source/mircoders/storage/DatabaseCommentStatus.java
source/mircoders/storage/DatabaseCommentToMedia.java
source/mircoders/storage/DatabaseContent.java
source/mircoders/storage/DatabaseContentToMedia.java
source/mircoders/storage/DatabaseContentToTopics.java
source/mircoders/storage/DatabaseFilter.java
source/mircoders/storage/DatabaseFilterGroup.java
source/mircoders/storage/DatabaseImageColor.java
source/mircoders/storage/DatabaseImageFormat.java
source/mircoders/storage/DatabaseImageLayout.java
source/mircoders/storage/DatabaseImageType.java
source/mircoders/storage/DatabaseImages.java
source/mircoders/storage/DatabaseLanguage.java
source/mircoders/storage/DatabaseMediaType.java
source/mircoders/storage/DatabaseMediafolder.java
source/mircoders/storage/DatabaseMessages.java
source/mircoders/storage/DatabaseOther.java
source/mircoders/storage/DatabaseRights.java
source/mircoders/storage/DatabaseTopics.java
source/mircoders/storage/DatabaseUploadedMedia.java
source/mircoders/storage/DatabaseUsers.java
source/mircoders/storage/DatabaseVideo.java

index 2726939..a37a74f 100755 (executable)
@@ -222,8 +222,8 @@ CREATE UNIQUE INDEX "idx_uploaded_media_is_published" on "uploaded_media" using
 --
 
 CREATE TABLE "images" (
-       "image_data" oid,
-       "icon_data" oid,
+       "image_data" bytea,
+       "icon_data" bytea,
        "year" character varying(40),
        "img_width" smallint,
        "img_height" smallint,
index 5cfd829..72e98ec 100755 (executable)
@@ -36,22 +36,22 @@ import java.util.Map;
 
 import mir.config.MirPropertiesConfiguration;
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectExc;
 import mir.storage.StorageObjectFailure;
+import mir.storage.Database;
 
 /**
  * Base class the entities are derived from. Provides base functionality of
  * an entity.
  *
- * @version $Id: AbstractEntity.java,v 1.8.2.4 2005/01/09 20:37:07 zapata Exp $
+ * @version $Id: AbstractEntity.java,v 1.8.2.5 2005/01/23 15:36:02 zapata Exp $
  */
 
 public class AbstractEntity implements Entity {
   protected static MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();
 
   protected Map values;
-  protected StorageObject storageObject;
+  protected Database database;
   protected LoggerWrapper logger;
 
   public AbstractEntity() {
@@ -60,8 +60,8 @@ public class AbstractEntity implements Entity {
     values = new HashMap();
   }
 
-  public void setStorage(StorageObject aStorageObject) {
-    storageObject = aStorageObject;
+  public void setStorage(Database aDatabase) {
+    database = aDatabase;
   }
 
   /** {@inheritDoc} */
@@ -80,28 +80,28 @@ public class AbstractEntity implements Entity {
 
   /** {@inheritDoc} */
   public String getId() {
-    return getFieldValue(storageObject.getIdName());
+    return getFieldValue(database.getIdFieldName());
   }
 
   /** {@inheritDoc} */
   public void setId(String id) {
-    setFieldValue(storageObject.getIdName(), id);
+    setFieldValue(database.getIdFieldName(), id);
   }
 
   /** {@inheritDoc} */
   public String insert() throws StorageObjectExc {
     logger.debug("Entity: trying to insert ...");
 
-    if (storageObject != null) {
-      return storageObject.insert(this);
+    if (database != null) {
+      return database.insert(this);
     }
     else
-      throw new StorageObjectExc("storageObject == null!");
+      throw new StorageObjectExc("database == null!");
   }
 
   /** {@inheritDoc} */
   public void update() throws StorageObjectFailure {
-    storageObject.update(this);
+    database.update(this);
   }
 
   /** {@inheritDoc} */
@@ -138,7 +138,7 @@ public class AbstractEntity implements Entity {
    * Returns the field names of the Entity
    */
   public List getFieldNames() throws StorageObjectFailure {
-    return storageObject.getFieldNames();
+    return database.getFieldNames();
   }
 
   /** Returns whether fieldName is a valid field name of this Entity.
index 7aa6574..cac1e44 100755 (executable)
@@ -39,7 +39,7 @@ import java.util.Map;
  * An <code>Entity</code> represents a persistent data object, typically
  *   stored in a database.<p>
  *
- * @version $Id: Entity.java,v 1.21.2.9 2005/01/09 20:37:07 zapata Exp $
+ * @version $Id: Entity.java,v 1.21.2.10 2005/01/23 15:36:02 zapata Exp $
  */
 
 public interface Entity {
@@ -58,13 +58,13 @@ public interface Entity {
   public String getId();
 
   /**
-   * Defines the primary key of the Entity (only to be set by the StorageObject)
+   * Defines the primary key of the Entity (only to be set by the Database)
    * @param id
    */
   public void setId(String id);
 
   /**
-   * Insers Entity into the database via StorageObject
+   * Insers Entity into the database via Database
    * @return Primary Key of the Entity
    * @exception StorageObjectExc
    */
index d42dc90..c51d9c9 100755 (executable)
 
 package mir.entity;
 
-import java.util.List;
-
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 import mir.util.RewindableIterator;
 
+import java.util.List;
+
+import multex.Failure;
+
 public class EntityBrowser implements RewindableIterator {
 
-  private StorageObject storage;
+  private Database database;
   private String mainTablePrefix;
   private List extraTables;
   private String whereClause;
@@ -52,11 +54,11 @@ public class EntityBrowser implements RewindableIterator {
   private int batchPosition;
   private int positionInBatch;
 
-  public EntityBrowser(StorageObject aStorage, String aMainTablePrefix, List someExtraTables,
+  public EntityBrowser(Database aDatabase, String aMainTablePrefix, List someExtraTables,
      String aWhereClause, String anOrderByClause,
      int aBatchSize, int aLimit, int aSkip) throws StorageObjectFailure {
 
-    storage=aStorage;
+    database=aDatabase;
     mainTablePrefix=aMainTablePrefix;
     extraTables=someExtraTables;
     whereClause=aWhereClause;
@@ -68,19 +70,19 @@ public class EntityBrowser implements RewindableIterator {
     rewind();
   }
 
-  public EntityBrowser(StorageObject aStorage, String aWhereClause, String anOrderByClause,
+  public EntityBrowser(Database aDatabase, String aWhereClause, String anOrderByClause,
                        int aBatchSize, int aLimit, int aSkip) throws StorageObjectFailure {
-    this(aStorage, "", null, aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip);
+    this(aDatabase, "", null, aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip);
   }
 
-  public EntityBrowser(StorageObject aStorage,
+  public EntityBrowser(Database aDatabase,
           String aWhereClause, String anOrderByClause,
           int aBatchSize) throws StorageObjectFailure {
-    this(aStorage, aWhereClause, anOrderByClause, aBatchSize, -1, 0);
+    this(aDatabase, aWhereClause, anOrderByClause, aBatchSize, -1, 0);
   }
 
   public void readCurrentBatch(int aSkip) throws StorageObjectFailure {
-    currentBatch = storage.selectByWhereClause(mainTablePrefix, extraTables,
+    currentBatch = database.selectByWhereClause(mainTablePrefix, extraTables,
         whereClause, orderByClause, aSkip, batchSize);
     batchPosition = aSkip;
     positionInBatch = 0;
@@ -91,7 +93,7 @@ public class EntityBrowser implements RewindableIterator {
       readCurrentBatch(skip);
     }
     catch (Throwable t) {
-      throw new RuntimeException(t.getMessage());
+      throw new Failure("Error while rewinging", t);
     }
   }
 
index d3b1fed..7e3cc85 100755 (executable)
  */
 package mir.entity;
 
-import java.util.ArrayList;
-import java.util.Set;
-
 import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.store.StorableObject;
 import mir.storage.store.StoreContainerType;
 import mir.storage.store.StoreIdentifier;
 import mir.storage.store.StoreUtil;
 
+import java.util.ArrayList;
+import java.util.Set;
+
 /**
  *
  * Container class for lists of Entities.
- * Now implements @see mir.storage.store.StorableObject.
+ * Now implements @see mir.database.store.StorableObject.
  *
  * @author <RK>
  * first version       27.6.1999
@@ -56,21 +55,20 @@ public class EntityList implements StorableObject {
   protected LoggerWrapper logger;
   private ArrayList           theEntityArrayList = new ArrayList();
   private String              whereClause, orderClause;
-  private StorageObject       storage;
+  private Database            storage;
   private int                 offset, limit;
   private int                 nextOffset = -1;
-  private int                 previousOffset = -1;
 
   public EntityList(){
     logger = new LoggerWrapper("Entity.List");
   }
 
 /* get/set EntityClass of Objects stored in EntityList */
-  public void setStorage(StorageObject aStorage) {
+  public void setStorage(Database aStorage) {
     storage=aStorage;
   }
 
-  public StorageObject getStorage() {
+  public Database getStorage() {
     return storage;
   }
 
@@ -160,15 +158,6 @@ public class EntityList implements StorableObject {
   }
 
   /**
-   * Sets the offset of the previous batch.
-   *
-   * @param i the previous offset
-   */
-  public void setPrevBatch(int i) {
-    previousOffset = i;
-  }
-
-  /**
    * Inserts an Entity into the EntityList.
    *
    * @param anEntity The entity to be inserted.
index b955d68..8749bc2 100755 (executable)
@@ -59,8 +59,8 @@ public class StorableObjectEntity extends AbstractEntity
    */
   public StoreIdentifier getStoreIdentifier() {
     String id = getId();
-    if ( id!=null && storageObject!= null )
-     return new StoreIdentifier(this, id+"@"+storageObject.getTableName());
+    if ( id!=null && database!= null )
+     return new StoreIdentifier(this, id+"@"+database.getTableName());
     return null;
   }
 
@@ -76,7 +76,7 @@ public class StorableObjectEntity extends AbstractEntity
   public static final StoreIdentifier getStoreIdentifier(Database theStorage,
      Class theEntityClass, ResultSet rs) throws SQLException {
 
-        String idcol = theStorage.getIdName();
+        String idcol = theStorage.getIdFieldName();
         String idval = rs.getObject(idcol).toString();
 
         if (idval != null) {
index f1ba030..6031288 100755 (executable)
@@ -60,7 +60,7 @@ public class EntityAdapterEngine {
    */
   static public List retrieveAdapterList(EntityAdapterModel aModel, String aDefinition, String aQualifier, String anOrder, int aLimit, int anOffset) {
     try {
-      EntityBrowser browser = new EntityBrowser(aModel.getMappingForName(aDefinition).getStorage(), aQualifier, anOrder, 30, aLimit, anOffset);
+      EntityBrowser browser = new EntityBrowser(aModel.getMappingForName(aDefinition).getDatabase(), aQualifier, anOrder, 30, aLimit, anOffset);
 
       return new EntityListAdapter(aModel, aDefinition, browser, aLimit);
     }
index 598596b..0c0a094 100755 (executable)
  */
 package mir.entity.adapter;
 
+import mir.entity.Entity;
+import mir.storage.Database;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import mir.entity.Entity;
-import mir.storage.StorageObject;
-
 public class EntityAdapterModel {
   private Map entityAdapterMappings;
 
@@ -51,7 +51,7 @@ public class EntityAdapterModel {
   public EntityAdapter createNewEntity( String aName ) throws EntityAdapterExc {
     try {
       Mapping mapping = getMappingForName(aName);
-      Entity entity = mapping.storage.createNewEntity();
+      Entity entity = mapping.database.createNewEntity();
 
       return mapping.getDefinition().makeEntityAdapter(entity, this);
     }
@@ -60,8 +60,8 @@ public class EntityAdapterModel {
     }
   }
 
-  public void addMapping( String aName, StorageObject aStorage, EntityAdapterDefinition aDefinition ) {
-    entityAdapterMappings.put( aName, new Mapping( aStorage, aDefinition ) );
+  public void addMapping(String aName, Database aDatabase, EntityAdapterDefinition aDefinition ) {
+    entityAdapterMappings.put(aName, new Mapping(aDatabase, aDefinition));
   }
 
   public Mapping getMappingForName( String aName ) {
@@ -72,16 +72,16 @@ public class EntityAdapterModel {
   }
 
   public class Mapping {
-    private StorageObject storage;
+    private Database database;
     private EntityAdapterDefinition definition;
 
-    public Mapping( StorageObject aStorage, EntityAdapterDefinition aDefinition ) {
-      storage = aStorage;
+    public Mapping(Database aDatabase, EntityAdapterDefinition aDefinition ) {
+      database = aDatabase;
       definition = aDefinition;
     }
 
-    public StorageObject getStorage() {
-      return storage;
+    public Database getDatabase() {
+      return database;
     }
 
     public EntityAdapterDefinition getDefinition() {
index bdcb42d..fbc6a01 100755 (executable)
@@ -50,20 +50,20 @@ public class EntityIteratorAdapter implements RewindableIterator {
   public EntityIteratorAdapter(String aWhereClause, String anOrderByClause,
           int aBatchSize, EntityAdapterModel aModel, String aDefinitionName )
           throws StorageObjectFailure {
-    this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize), aModel, aDefinitionName);
+    this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getDatabase(), aWhereClause, anOrderByClause, aBatchSize), aModel, aDefinitionName);
   }
 
   public EntityIteratorAdapter(String aWhereClause, String anOrderByClause,
           int aBatchSize, EntityAdapterModel aModel, String aDefinitionName,
           int aLimit, int aSkip) throws StorageObjectFailure {
-    this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
+    this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getDatabase(), aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
   }
 
   public EntityIteratorAdapter(String aMainTablePrefix, List someExtraTables,
           String aWhereClause, String anOrderByClause,
           int aBatchSize, EntityAdapterModel aModel, String aDefinitionName,
           int aLimit, int aSkip) throws StorageObjectFailure {
-    this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aMainTablePrefix, someExtraTables, aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
+    this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getDatabase(), aMainTablePrefix, someExtraTables, aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
   }
 
 
index 36d9fa1..cc1ea37 100755 (executable)
@@ -63,15 +63,15 @@ import mir.session.UploadedFile;
  * content-type map for this....).
  * <p>
  * The "mime_type" field is the most important as it does maps the type to Java
- * classes (the storage and media_handler name). We call those classes using
+ * classes (the database and media_handler name). We call those classes using
  * reflection. This way, once a Handler for a specific media type is implemented
  * and entered into the media_type table, no other Mir code needs to be modified.
  * <p>
  * The "classname" field is the name of the media handler (e.g MediaHandlerAudio)
  * we use it to call the MediaHandler methods via reflection.
  * <p>
- * The "tablename" is the name of the database storage classes (e.g DatabaseImages
- * and EntityImages). We use this to fetch/storage the media (meta)data in the db.
+ * The "tablename" is the name of the database database classes (e.g DatabaseImages
+ * and EntityImages). We use this to fetch/database the media (meta)data in the db.
  * <p?
  * The "dcname" field is as of yet unused. Do search for "Dublin Core" on google
  * to learn more.
@@ -80,7 +80,7 @@ import mir.session.UploadedFile;
  * ) and just override the things that need to be specific. see MediaHandlerAudio
  *
  * @author <mh@nadir.org>, the Mir-coders group
- * @version $Id: MediaHandler.java,v 1.1.2.4 2005/01/09 20:37:08 zapata Exp $
+ * @version $Id: MediaHandler.java,v 1.1.2.5 2005/01/23 15:36:03 zapata Exp $
  */
 
 public interface MediaHandler {
@@ -105,7 +105,7 @@ public interface MediaHandler {
   public void produce(Entity aMedia, Entity aMediaType ) throws MediaExc, MediaFailure;
 
   /**
-   * Get's the media data from storage and returns it as an InputStream
+   * Get's the media data from database and returns it as an InputStream
    * Not very useful for most media types as they are stored in a file,
    * but very usefull for ones stored in the DB as it is necessary to get
    * it first before making a file out of it (in Producer*).
index 94fbffb..490a50d 100755 (executable)
@@ -34,7 +34,7 @@ import java.sql.SQLException;
 
 import mir.entity.Entity;
 import mir.entity.EntityList;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 
 /**
@@ -50,24 +50,24 @@ import mir.storage.StorageObject;
  */
 
 public class AbstractModule {
-  protected StorageObject storage;
+  protected Database database;
 
-  public AbstractModule(StorageObject aStorageObject) {
-    storage = aStorageObject;
+  public AbstractModule(Database aDatabase) {
+    database = aDatabase;
   }
 
   /**
-   * Returns the storage object associated with this module
+   * Returns the database object associated with this module
    */
-  public StorageObject getStorageObject () {
-    return storage;
+  public Database getStorageObject () {
+    return database;
   }
 
   public Entity getById (String id) throws ModuleExc, ModuleFailure {
     try {
-      if (storage == null)
-        throw  new ModuleExc("AbstractModule.getById: No StorageObject set!");
-      Entity entity = storage.selectById(id);
+      if (database == null)
+        throw  new ModuleExc("AbstractModule.getById: No Database set!");
+      Entity entity = database.selectById(id);
 
       if (entity == null)
         throw new ModuleExc("AbstractModule.getById: No object for id = " + id);
@@ -81,10 +81,10 @@ public class AbstractModule {
 
   public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure {
     try {
-      if (storage == null)
-        throw  new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!");
+      if (database == null)
+        throw  new ModuleExc("AbstractModule.getByWhereClause: No Database set!");
 
-      return storage.selectByWhereClause(whereClause, offset);
+      return database.selectByWhereClause(whereClause, offset);
     }
     catch (Throwable e) {
       throw new ModuleFailure(e);
@@ -92,7 +92,7 @@ public class AbstractModule {
   }
 
   /**
-   *    * Standardfunktion, um einen Datensatz via StorageObject einzuf?gen
+   *    * Standardfunktion, um einen Datensatz via Database einzuf?gen
    * @param theValues Hash mit Spalte/Wert-Paaren
    * @return Id des eingef?gten Objekts
    * @exception ModuleExc
@@ -100,7 +100,7 @@ public class AbstractModule {
    */
   public String add(Map theValues) throws ModuleExc, ModuleFailure {
     try {
-      Entity entity = storage.createNewEntity();
+      Entity entity = database.createNewEntity();
       entity.setFieldValues(theValues);
 
       return entity.insert();
@@ -111,7 +111,7 @@ public class AbstractModule {
   }
 
   /**
-   * Standardfunktion, um einen Datensatz via StorageObject zu aktualisieren
+   * Standardfunktion, um einen Datensatz via Database zu aktualisieren
    * @param theValues Hash mit Spalte/Wert-Paaren
    * @return Id des eingef?gten Objekts
    * @exception ModuleExc
@@ -119,7 +119,7 @@ public class AbstractModule {
    */
   public String set (Map theValues) throws ModuleExc, ModuleFailure {
     try {
-      Entity theEntity = storage.selectById((String) theValues.get("id"));
+      Entity theEntity = database.selectById((String) theValues.get("id"));
       if (theEntity == null)
         throw new ModuleExc("No object found with id " + theValues.get("id"));
       theEntity.setFieldValues(theValues);
@@ -139,7 +139,7 @@ public class AbstractModule {
    */
   public void deleteById (String idParam) throws ModuleExc, ModuleFailure {
     try {
-      storage.delete(idParam);
+      database.delete(idParam);
     }
     catch (Throwable e) {
       throw new ModuleFailure(e);
@@ -151,7 +151,7 @@ public class AbstractModule {
    */
   public int getSize(String where) throws ModuleExc, ModuleFailure {
     try {
-      return storage.getSize(where);
+      return database.getSize(where);
     }
     catch (SQLException e) {
       throw new ModuleFailure("Can't retrieve number of entities: " + e.toString(), e);
index aa0bf41..cbf1e9a 100755 (executable)
@@ -144,7 +144,7 @@ public class EntityBatchingProducerNode implements ProducerNode {
       batchesData = new ArrayList();
       batchLocations = new ArrayList();
 
-      nrEntities = model.getMappingForName(definition).getStorage().getSize(
+      nrEntities = model.getMappingForName(definition).getDatabase().getSize(
           mainTablePrefix, extraTableList, expandedWhereClause)-nrEntitiesToSkip;
       nrEntitiesInFirstBatch = nrEntities % nrEntitiesPerBatch;
       while (nrEntitiesInFirstBatch<minNrEntitiesInFirstBatch && nrEntities-nrEntitiesInFirstBatch>=nrEntitiesPerBatch)
index 0a09c02..630c70b 100755 (executable)
@@ -51,7 +51,7 @@ public class EntityDeletingProducerNode implements ProducerNode {
     try {
       EntityAdapterModel.Mapping mapping = model.getMappingForName(definition);
 
-      mapping.getStorage().deleteByWhereClause(ParameterExpander.expandExpression( aValueMap, whereClause ));
+      mapping.getDatabase().deleteByWhereClause(ParameterExpander.expandExpression( aValueMap, whereClause ));
     }
     catch (Throwable t) {
       aLogger.error("Error while deleting entities: " + t.toString());
index 02d4761..b3a2d6c 100755 (executable)
@@ -41,7 +41,7 @@ import mir.entity.adapter.EntityAdapterModel;
 import mir.log.LoggerWrapper;
 import mir.module.AbstractModule;
 import mir.module.ModuleExc;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.util.HTTPRequestParser;
 import mir.util.URLBuilder;
 import mircoders.global.MirGlobal;
@@ -432,11 +432,11 @@ public abstract class ServletModule {
 
   /**
    * Gets the fields from a httprequest and matches them with the metadata from
-   * the storage object. Returns the keys that match, with their values.
+   * the database object. Returns the keys that match, with their values.
    *
    * @return Map with the values
    */
-  public Map getIntersectingValues(HttpServletRequest aRequest, StorageObject theStorage)
+  public Map getIntersectingValues(HttpServletRequest aRequest, Database theStorage)
       throws ServletModuleExc, ServletModuleFailure {
 
     HTTPRequestParser parser;
index 452dd98..ea6d987 100755 (executable)
@@ -40,23 +40,25 @@ import mir.storage.store.*;
 import mir.util.JDBCStringRoutines;
 import mircoders.global.MirGlobal;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
 import java.sql.*;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+import org.apache.commons.dbcp.DelegatingConnection;
+import org.postgresql.PGConnection;
+import org.postgresql.largeobject.LargeObjectManager;
+import org.postgresql.largeobject.LargeObject;
+
 /**
  * Implements database access.
  *
- * @version $Id: Database.java,v 1.44.2.25 2005/01/09 22:07:45 zapata Exp $
+ * @version $Id: Database.java,v 1.44.2.26 2005/01/23 15:36:03 zapata Exp $
  * @author rk
  *
  */
-public class Database implements StorageObject {
+public class Database {
   private static Class GENERIC_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;
   protected static final ObjectStore o_store = ObjectStore.getInstance();
   private static final int _millisPerHour = 60 * 60 * 1000;
@@ -70,6 +72,7 @@ public class Database implements StorageObject {
 
   protected List fieldNames;
   protected int[] fieldTypes;
+  protected Map fieldNameToType;
 
   protected Class entityClass;
   private int defaultLimit;
@@ -108,13 +111,6 @@ public class Database implements StorageObject {
     }
   }
 
-  /**
-   * Liefert die Entity-Klasse zur?ck, in der eine Datenbankzeile gewrappt
-   * wird. Wird die Entity-Klasse durch die erbende Klasse nicht ?berschrieben,
-   * wird eine mir.entity.GenericEntity erzeugt.
-   *
-   * @return Class-Objekt der Entity
-   */
   public java.lang.Class getEntityClass() {
     return entityClass;
   }
@@ -141,12 +137,7 @@ public class Database implements StorageObject {
     return defaultLimit;
   }
 
-  /**
-   * Liefert den Namen des Primary-Keys zur?ck. Wird die Variable nicht von
-   * der erbenden Klasse ?berschrieben, so ist der Wert <code>PKEY</code>
-   * @return Name des Primary-Keys
-   */
-  public String getIdName() {
+  public String getIdFieldName() {
     return primaryKeyField;
   }
 
@@ -174,11 +165,11 @@ public class Database implements StorageObject {
   }
 
   /**
-   * {@inheritDoc}
+   * Returns a list of field names for this <code>Database</code>
    */
   public List getFieldNames() throws StorageObjectFailure {
     if (fieldNames == null) {
-      retrieveMetaData();
+      acquireMetaData();
     }
 
     return fieldNames;
@@ -593,10 +584,6 @@ public class Database implements StorageObject {
         theReturnList.setStorage(this);
         theReturnList.setLimit(aLimit);
 
-        if (anOffset >= aLimit) {
-          theReturnList.setPrevBatch(anOffset - aLimit);
-        }
-
         if (hasMore) {
           theReturnList.setNextBatch(anOffset + aLimit);
         }
@@ -951,10 +938,6 @@ public class Database implements StorageObject {
 
   /**
    * Deletes entities based on a where clause
-   *
-   * @param aWhereClause
-   * @return
-   * @throws StorageObjectFailure
    */
   public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure {
     invalidateStore();
@@ -1027,6 +1010,10 @@ public class Database implements StorageObject {
     }
   }
 
+  /**
+   * Executes 1 sql statement and returns the results as a <code>List</code> of
+   * <code>Map</code>s
+   */
   public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc {
     Connection connection = null;
     Statement statement = null;
@@ -1056,6 +1043,10 @@ public class Database implements StorageObject {
     }
   };
 
+  /**
+   * Executes 1 sql statement and returns the first result row as a <code>Map</code>s
+   * (<code>null</code> if there wasn't any row)
+   */
   public Map executeFreeSingleRowSql(String anSqlStatement) throws StorageObjectFailure, StorageObjectExc {
     try {
       List resultList = executeFreeSql(anSqlStatement, 1);
@@ -1073,6 +1064,10 @@ public class Database implements StorageObject {
     }
   };
 
+  /**
+   * Executes 1 sql statement and returns the first column of the first result row as a <code>String</code>s
+   * (<code>null</code> if there wasn't any row)
+   */
   public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc {
     Map row = executeFreeSingleRowSql(sql);
 
@@ -1189,6 +1184,7 @@ public class Database implements StorageObject {
    */
   private void processMetaData(ResultSetMetaData aMetaData) throws StorageObjectFailure {
     fieldNames = new ArrayList();
+    fieldNameToType = new HashMap();
 
     try {
       int numFields = aMetaData.getColumnCount();
@@ -1197,6 +1193,7 @@ public class Database implements StorageObject {
       for (int i = 1; i <= numFields; i++) {
         fieldNames.add(aMetaData.getColumnName(i));
         fieldTypes[i - 1] = aMetaData.getColumnType(i);
+        fieldNameToType.put(aMetaData.getColumnName(i), new Integer(aMetaData.getColumnType(i)));
       }
     }
     catch (SQLException e) {
@@ -1207,7 +1204,7 @@ public class Database implements StorageObject {
   /**
    * Retrieves metadata from the table this Database object represents
    */
-  private void retrieveMetaData() throws StorageObjectFailure {
+  private void acquireMetaData() throws StorageObjectFailure {
     Connection connection = null;
     PreparedStatement statement = null;
     String sql = "select * from " + mainTable + " where 0=1";
@@ -1226,7 +1223,7 @@ public class Database implements StorageObject {
       }
     }
     catch (SQLException e) {
-      throwSQLException(e, "retrieveMetaData");
+      throwSQLException(e, "acquireMetaData");
     }
     finally {
       freeConnection(connection, statement);
@@ -1336,8 +1333,14 @@ public class Database implements StorageObject {
 
         if(resultSet!=null) {
           if (resultSet.next()) {
-            inputStream = resultSet.getBlob(1).getBinaryStream();
-            imageInputStream = new BinaryFieldInputStream(inputStream, connection, statement);
+            if (resultSet.getMetaData().getColumnType(1) == java.sql.Types.BINARY) {
+              byte[] data = resultSet.getBytes(1);
+              imageInputStream = new ByteArrayInputStream(data);
+            }
+            else {
+              inputStream = resultSet.getBlob(1).getBinaryStream();
+              imageInputStream = new BinaryFieldInputStream(inputStream, connection, statement);
+            }
           }
           resultSet.close();
         }
@@ -1371,21 +1374,37 @@ public class Database implements StorageObject {
   }
 
   /**
-   * Sets a binary value. The query is supposed to contain 1 ? denoting where the
-   * binary value should be inserted.
-   *
-   * e.g. <code>update images set image_data = ? where id= 22</code>
+   * Sets a binary value for a particular field in a record specified by its identifier
    */
-  public void setBinaryField(String aQuery, byte aData[]) throws StorageObjectFailure, SQLException {
+  public void setBinaryField(String aFieldName, String anObjectId, byte aData[]) throws StorageObjectFailure, SQLException {
     PreparedStatement statement = null;
     Connection connection = obtainConnection();
+
     try {
       connection.setAutoCommit(false);
       try {
-        statement = connection.prepareStatement(aQuery);
-        statement.setBinaryStream(1, new ByteArrayInputStream(aData), aData.length);
-        statement.execute();
-        connection.commit();
+        // are we using bytea ?
+        if (getFieldType(aFieldName) == java.sql.Types.BINARY) {
+          statement = connection.prepareStatement(
+                "update " + mainTable + " set " + aFieldName + " = ? where " + getIdFieldName() + "=" + Integer.parseInt(anObjectId));
+          statement.setBytes(1, aData);
+          statement.execute();
+          connection.commit();
+        }
+        // or the old oid's
+        else {
+          PGConnection postgresqlConnection = (org.postgresql.PGConnection) ((DelegatingConnection) connection).getDelegate();
+          LargeObjectManager lobManager = postgresqlConnection.getLargeObjectAPI();
+          int oid = lobManager.create(LargeObjectManager.READ | LargeObjectManager.WRITE);
+          LargeObject obj = lobManager.open(oid, LargeObjectManager.WRITE);  // Now open the file File file =
+          obj.write(aData);
+          obj.close();
+          statement = connection.prepareStatement(
+                "update " + mainTable + " set " + aFieldName + " = ? where " + getIdFieldName() + "=" + Integer.parseInt(anObjectId));
+          statement.setInt(1, oid);
+          statement.execute();
+          connection.commit();
+        }
       }
       finally {
         connection.setAutoCommit(true);
@@ -1409,6 +1428,15 @@ public class Database implements StorageObject {
     logger.error("QUERY " + aQuery + " took " + aTime + "ms, but threw exception " + anException.toString());
   }
 
+  private int getFieldType(String aFieldName) {
+    if (fieldNameToType == null) {
+      acquireMetaData();
+    }
+
+    return ((Integer) fieldNameToType.get(aFieldName)).intValue();
+  }
+
+
   /**
    * a small wrapper class that allows us to store the DB connection resources
    * that the BlobInputStream is using and free them upon closing of the stream
diff --git a/source/mir/storage/StorageObject.java b/source/mir/storage/StorageObject.java
deleted file mode 100755 (executable)
index 483fde5..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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  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.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-import java.util.Map;
-import java.io.InputStream;
-
-import mir.entity.Entity;
-import mir.entity.EntityList;
-
-/**
- * Interface for low-level database actions.
- */
-
-public interface StorageObject {
-  public Entity selectById(String id) throws StorageObjectExc;
-
-  public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure;
-
-  public EntityList selectByWhereClause(String whereClause) throws StorageObjectFailure;
-
-  public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure;
-
-  public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure;
-
-  public EntityList selectByWhereClause(String whereClause, String orderBy, int offset, int limit) throws StorageObjectFailure;
-
-  public EntityList selectByWhereClause(String mainTablePrefix, List extraTables, String aWhereClause, String anOrderByClause, int offset, int limit) throws StorageObjectFailure;
-
-  public boolean delete(String id) throws StorageObjectFailure;
-
-  /**
-   * Deletes entities based on a where clause
-   */
-  public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure;
-
-  /**
-   * Returns a list of field names for this <code>StorageObject</code>
-   */
-  public List getFieldNames() throws StorageObjectFailure;
-
-  public void update(Entity a) throws StorageObjectFailure;
-
-  public String insert(Entity a) throws StorageObjectFailure;
-
-  public Class getEntityClass();
-
-  public Entity createNewEntity() throws StorageObjectFailure; 
-
-  public String getIdName();
-
-  public String getTableName();
-
-  public Connection obtainConnection() throws StorageObjectFailure;
-
-  public ResultSet executeSql(Statement a, String sql) throws StorageObjectFailure, SQLException;
-
-  /**
-   * Executes 1 sql statement and returns the results as a <code>List</code> of
-   * <code>Map</code>s
-   */
-  public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc;
-
-  /**
-   * Executes 1 sql statement and returns the first result row as a <<code>Map</code>s
-   * (<code>null</code> if there wasn't any row)
-   */
-  public Map executeFreeSingleRowSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
-
-  /**
-   * Executes 1 sql statement and returns the first column of the first result row as a <<code>String</code>s
-   * (<code>null</code> if there wasn't any row)
-   */
-  public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
-
-  public void freeConnection(Connection con, Statement stmt) throws StorageObjectFailure;
-
-  public int executeUpdate(Statement a, String sql) throws StorageObjectFailure, SQLException;
-
-  public int executeUpdate(String sql) throws StorageObjectFailure, SQLException;
-
-  public int getSize(String where) throws SQLException, StorageObjectFailure;
-
-  public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure;
-
-  public InputStream getBinaryField(String aQuery) throws SQLException, StorageObjectFailure;
-
-  public void setBinaryField(String aQuery, byte aData[]) throws StorageObjectFailure, SQLException;
-}
index 40765af..c1b7aca 100755 (executable)
@@ -33,7 +33,7 @@ import multex.Failure;
 
 
 /**
- * Exception for all occuring failures in the storage-layer
+ * Exception for all occuring failures in the database-layer
  * @author idefix
  */
 public class StorageObjectFailure extends Failure {
index f06443b..fd26137 100755 (executable)
@@ -33,10 +33,10 @@ package mircoders.entity;
 import java.util.Map;
 
 /**
- * This class handles storage of audio data and meta data
+ * This class handles database of audio data and meta data
  *
  * @author mh
- * @version $Id: EntityAudio.java,v 1.11.2.2 2005/01/09 20:37:10 zapata Exp $
+ * @version $Id: EntityAudio.java,v 1.11.2.3 2005/01/23 15:36:04 zapata Exp $
  */
 
 
index 09fc32e..2b208dd 100755 (executable)
@@ -44,7 +44,7 @@ import java.util.Map;
  * this class implements mapping of one line of the database table content
  * to a java object
  *
- * @version $Id: EntityContent.java,v 1.19.2.8 2005/01/09 20:37:10 zapata Exp $
+ * @version $Id: EntityContent.java,v 1.19.2.9 2005/01/23 15:36:04 zapata Exp $
  * @author mir-coders group
  *
  */
@@ -71,10 +71,10 @@ public class EntityContent extends AbstractEntity {
     Connection con=null;Statement stmt=null;
     String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'";
     try {
-      con = storageObject.obtainConnection();
+      con = database.obtainConnection();
       /** todo should be preparedStatement: faster!! */
       stmt = con.createStatement();
-      storageObject.executeUpdate(stmt,sql);
+      database.executeUpdate(stmt,sql);
     }
     catch (StorageObjectFailure e) {
       throw e;
@@ -83,7 +83,7 @@ public class EntityContent extends AbstractEntity {
       throw new StorageObjectFailure(e);
     }
     finally {
-      storageObject.freeConnection(con,stmt);
+      database.freeConnection(con,stmt);
     }
   }
 
index 8abaf44..7221e9b 100755 (executable)
@@ -42,7 +42,7 @@ import java.sql.SQLException;
 /**
  *
  * @author RK, mh, mir-coders
- * @version $Id: EntityImages.java,v 1.21.2.6 2005/01/09 20:37:10 zapata Exp $
+ * @version $Id: EntityImages.java,v 1.21.2.7 2005/01/23 15:36:04 zapata Exp $
  */
 
 
@@ -66,7 +66,7 @@ public class EntityImages extends EntityUploadedMedia
    */
   public InputStream getImage() throws StorageObjectFailure {
     try {
-      return storageObject.getBinaryField("select image_data from images where id="+getId());
+      return database.getBinaryField("select image_data from images where id="+getId());
     }
     catch (SQLException e) {
       throw new StorageObjectFailure(e);
@@ -77,8 +77,6 @@ public class EntityImages extends EntityUploadedMedia
    * Processes and saves image data
    */
   public void setImage(InputStream anInputStream, String type) throws StorageObjectFailure {
-    // todo: failures should be treated anInputStream a better way: exception -> rollback instead
-    //  of commit
     if (anInputStream != null) {
       try {
         ByteArrayOutputStream inputData = new ByteArrayOutputStream();
@@ -89,7 +87,7 @@ public class EntityImages extends EntityUploadedMedia
 
         ByteArrayOutputStream imageData = new ByteArrayOutputStream();
         processor.writeScaledData(imageData, type);
-        storageObject.setBinaryField("update images set image_data = ? where id = "+getId(), imageData.toByteArray());
+        database.setBinaryField("image_data", getId(), imageData.toByteArray());
 
         setFieldValue("img_height", new Integer(processor.getScaledHeight()).toString());
         setFieldValue("img_width", new Integer(processor.getScaledWidth()).toString());
@@ -97,7 +95,7 @@ public class EntityImages extends EntityUploadedMedia
         imageData.reset();
         processor.descaleImage(maxIconSize, minDescaleRatio, minDescaleReduction);
         processor.writeScaledData(imageData, type);
-        storageObject.setBinaryField("update images set icon_data = ? where id = "+getId(), imageData.toByteArray());
+        database.setBinaryField("icon_data", getId(), imageData.toByteArray());
 
         setFieldValue("icon_height", new Integer(processor.getScaledHeight()).toString());
         setFieldValue("icon_width", new Integer(processor.getScaledWidth()).toString());
@@ -118,7 +116,7 @@ public class EntityImages extends EntityUploadedMedia
    */
   public InputStream getIcon() throws StorageObjectFailure {
     try {
-      return storageObject.getBinaryField("select icon_data from images where id="+getId());
+      return database.getBinaryField("select icon_data from images where id="+getId());
     }
     catch (SQLException e) {
       throw new StorageObjectFailure(e);
index 53be655..ba4d468 100755 (executable)
@@ -33,7 +33,7 @@ package mircoders.entity;
 import java.util.Map;
 
 /**
- * This class handles storage of other data and meta data
+ * This class handles database of other data and meta data
  *
  * @author mh
  * @version 11.11.2000
index a6a1fcb..6147337 100755 (executable)
@@ -41,7 +41,7 @@ import java.util.Map;
 /**
  *
  * @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.9 2005/01/09 20:37:10 zapata Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.10 2005/01/23 15:36:04 zapata Exp $
  */
 
 public class EntityUploadedMedia extends AbstractEntity {
@@ -55,7 +55,7 @@ public class EntityUploadedMedia extends AbstractEntity {
     super.update();
 
     try {
-      storageObject.executeUpdate(
+      database.executeUpdate(
           "update content " +
           "set is_produced='0' " +
           "from content_x_media cxm " +
@@ -63,7 +63,7 @@ public class EntityUploadedMedia extends AbstractEntity {
           "   cxm.content_id=content.id and cxm.media_id=" + getId()
       );
 
-      storageObject.executeUpdate(
+      database.executeUpdate(
           "update content " +
           "set is_produced='0' " +
           "from comment_x_media cxm, comment c "+
index f4b7e5e..9217ae5 100755 (executable)
@@ -34,7 +34,7 @@ import mir.media.MediaHandler;
 
 /**
  * Interface to allow for customization of the way Mir handles media publication,
- *    manipulation and storage
+ *    manipulation and database
  */
 
 public interface MirMediaLocalizer {
index 4839f72..75e7978 100755 (executable)
@@ -52,7 +52,7 @@ import mir.session.SessionFailure;
 import mir.session.SessionHandler;
 import mir.session.UploadedFile;
 import mir.session.ValidationError;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.util.ExceptionFunctions;
 import mir.util.FileFunctions;
 import mircoders.global.MirGlobal;
@@ -460,9 +460,9 @@ public abstract class MirBasicPostingSessionHandler implements SessionHandler {
 
   /**
    * Method to filter the attributes and their values of a request
-   * based on the fields of a storage object.
+   * based on the fields of a database object.
    */
-  protected static final Map getIntersectingValues(Request aRequest, StorageObject aStorage) throws SessionFailure {
+  protected static final Map getIntersectingValues(Request aRequest, Database aStorage) throws SessionFailure {
     Map result = new HashMap();
 
     Iterator i = aStorage.getFieldNames().iterator();
index 8b96748..d774733 100755 (executable)
@@ -125,7 +125,8 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
     }
     catch (Throwable t) {
       logger.error("initializeGenerationValueSet: Exception while collecting comment statuses" + t.getMessage());
-      throw new RuntimeException(t.getMessage());
+
+      throw new MirLocalizerFailure(t);
     }
 
   };
index d563200..4bf2f8f 100755 (executable)
@@ -60,7 +60,7 @@ import mircoders.entity.EntityImages;
  *
  * @see mir.media.MediaHandler
  * @author mh
- * @version $Id: MediaHandlerImages.java,v 1.23.2.6 2005/01/09 20:37:12 zapata Exp $
+ * @version $Id: MediaHandlerImages.java,v 1.23.2.7 2005/01/23 15:36:04 zapata Exp $
  */
 
 
@@ -81,7 +81,7 @@ public abstract class MediaHandlerImages extends AbstractMediaHandler implements
     InputStream inputStream;
 
     try {
-      inputStream = ((EntityImages)ent).getImage();
+      inputStream = ((EntityImages) ent).getImage();
     }
     catch (Throwable e) {
       logger.error("MediaHandlerImages.getImage: " + e.toString());
@@ -106,10 +106,9 @@ public abstract class MediaHandlerImages extends AbstractMediaHandler implements
       ((EntityImages) ent).setImage(in, getType());
     }
     catch (Throwable e) {
-      logger.error("MediaHandlerImages.store: "+e.toString());
-      e.printStackTrace(logger.asPrintWriter(LoggerWrapper.ERROR_MESSAGE));
+      logger.error("MediaHandlerImages.store", e);
 
-      throw new MediaExc("A problem has occurred processing the media file: " + e.toString());
+      throw new MediaFailure("A problem has occurred processing the media file", e);
     }
   }
 
index bad3d16..db32939 100755 (executable)
@@ -77,7 +77,7 @@ public final class MediaHelper {
     if (aTable.equals("Other"))
       return DatabaseOther.getInstance();
 
-    throw new MediaExc("Unknown storage specification: " + aTable);
+    throw new MediaExc("Unknown database specification: " + aTable);
   }
 }
 
index 953a732..20d847d 100755 (executable)
@@ -45,7 +45,7 @@ public class ModuleArticleType extends AbstractModule {
 
   public String articleTypeIdForName(String aName) throws ModuleExc, ModuleFailure {
     try {
-      return storage.executeFreeSingleValueSql("select id from article_type where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+      return database.executeFreeSingleValueSql("select id from article_type where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
     }
     catch (Throwable t) {
       throw new ModuleFailure(t);
index a66d4cc..d850cfa 100755 (executable)
@@ -57,7 +57,7 @@ public class ModuleComment extends AbstractModule
 
   public void deleteById (String anId) throws ModuleExc, ModuleFailure {
     try {
-      Entity theEntity = storage.selectById((String)anId);
+      Entity theEntity = database.selectById((String)anId);
       if (theEntity != null)
         DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media"));
 
@@ -78,7 +78,7 @@ public class ModuleComment extends AbstractModule
 
   public String set(Map theValues) throws ModuleExc, ModuleFailure {
     try {
-      Entity theEntity = storage.selectById((String)theValues.get("id"));
+      Entity theEntity = database.selectById((String)theValues.get("id"));
       if (theEntity == null)
          throw new ModuleExc("No Object in the database with id " + theValues.get("id"));
       DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media"));
index 8a9417d..8329f53 100755 (executable)
@@ -45,7 +45,7 @@ public class ModuleCommentStatus extends AbstractModule {
 
   public String commentStatusIdForName(String aName) throws ModuleExc, ModuleFailure {
     try {
-      return storage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+      return database.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
     }
     catch (Throwable t) {
       throw new ModuleFailure(t);
index d3877d5..847dc58 100755 (executable)
@@ -78,7 +78,7 @@ public class ModuleContent extends AbstractModule
       if (!aForce)
         query = query + " and to_locking_user is null";
 
-      return storage.executeUpdate(query) > 0;
+      return database.executeUpdate(query) > 0;
     }
     catch (Throwable t) {
       return false;
@@ -103,7 +103,7 @@ public class ModuleContent extends AbstractModule
       if (!aForce)
         query = query + " and to_locking_user = "+JDBCStringRoutines.escapeStringLiteral(aUserId);
 
-      return storage.executeUpdate(query) > 0;
+      return database.executeUpdate(query) > 0;
     }
     catch (Throwable t) {
       return false;
@@ -118,7 +118,7 @@ public class ModuleContent extends AbstractModule
    */
   public String queryArticleLock(String anId)  {
     try {
-      String result = storage.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId));
+      String result = database.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId));
 
       if (result!=null && !MirGlobal.isUserLoggedIn(result)) {
         expireArticleLock(anId, result);
index 069dc99..2001c77 100755 (executable)
@@ -56,7 +56,7 @@ public class ModuleLanguage extends AbstractModule {
 
   public String languageIdForCode(String aCode) throws ModuleExc, ModuleFailure {
     try {
-      return storage.executeFreeSingleValueSql("select id from language where code = '" + JDBCStringRoutines.escapeStringLiteral(aCode) + "'");
+      return database.executeFreeSingleValueSql("select id from language where code = '" + JDBCStringRoutines.escapeStringLiteral(aCode) + "'");
     }
     catch (Throwable t) {
       throw new ModuleFailure(t);
@@ -65,7 +65,7 @@ public class ModuleLanguage extends AbstractModule {
 
   public Entity languageForCode(String aCode) throws ModuleExc, ModuleFailure {
     try {
-      EntityList list = storage.selectByFieldValue("code", aCode);
+      EntityList list = database.selectByFieldValue("code", aCode);
       
       if (list.size()>0) {
         return list.elementAt(0);
index aedb191..d98e17d 100755 (executable)
@@ -54,7 +54,7 @@ public class ModuleMediafolder extends AbstractModule {
 
   public String mediaFolderIdForName(String aName) throws ModuleExc, ModuleFailure {
     try {
-      return storage.executeFreeSingleValueSql("select id from media_folder where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+      return database.executeFreeSingleValueSql("select id from media_folder where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
     }
     catch (Throwable t) {
       throw new ModuleFailure(t);
index 49cc431..59c1063 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.module;
 
 import mir.log.LoggerWrapper;
 import mir.module.AbstractModule;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 /**
  *
@@ -48,7 +48,7 @@ public class ModuleUploadedMedia extends AbstractModule
 {
   static LoggerWrapper logger = new LoggerWrapper("Module.UploadedMedia");
 
-  public ModuleUploadedMedia(StorageObject aStorage) {
+  public ModuleUploadedMedia(Database aStorage) {
     super(aStorage);
   }
 }
\ No newline at end of file
index 27efcda..bf03447 100755 (executable)
@@ -160,7 +160,7 @@ public class ModuleUsers extends AbstractModule
     try {
       String sql = "update webdb_users set lastlogin=now() where id = " + aUser.getId();
 
-      storage.executeUpdate(sql);
+      database.executeUpdate(sql);
     }
     catch (Throwable t) {
 //      no propagation of this error for now, to allow mir to still function
index 2e37241..6de49f4 100755 (executable)
@@ -121,7 +121,7 @@ import org.apache.lucene.search.Searcher;
  *    open-postings to the newswire
  *
  * @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.13 2005/01/09 20:37:14 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.14 2005/01/23 15:36:05 zapata Exp $
  *
  */
 
@@ -881,7 +881,7 @@ public class ServletModuleOpenIndy extends ServletModule
                 throw new ServletModuleExc("Please let me sort by something!(missing search_sort)");
               }
 
-              // here is where the documents will go for storage across sessions
+              // here is where the documents will go for database across sessions
               ArrayList theDocumentsSorted = new ArrayList();
 
               if (sortBy.equals("score")) {
index b924244..a1729e2 100755 (executable)
@@ -441,7 +441,7 @@ public abstract class ServletModuleUploadedMedia extends ServletModule {
 
     if (idParam!=null && !idParam.equals("")) {
       try {
-        EntityUploadedMedia entity = (EntityUploadedMedia)mainModule.getById(idParam);
+        EntityUploadedMedia entity = (EntityUploadedMedia) mainModule.getById(idParam);
         Entity mediaType = entity.getMediaType();
         MediaHandler mediaHandler;
 
index 7d14141..9921ee3 100755 (executable)
@@ -41,10 +41,10 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
-public class DatabaseArticleType extends Database implements StorageObject{
+public class DatabaseArticleType extends Database {
 
   private static DatabaseArticleType instance;
 
index 6b8126c..9ab4a68 100755 (executable)
  */
 package mircoders.storage;
 
-import java.util.GregorianCalendar;
-
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.storage.Database;
-import mir.storage.StorageObject;
 import mir.storage.StorageObjectFailure;
 
-public class DatabaseAudio extends Database implements StorageObject{
+import java.util.GregorianCalendar;
+
+public class DatabaseAudio extends Database {
 
   private static DatabaseAudio instance;
 
index fe12761..a4b07df 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -41,7 +41,7 @@ import mir.storage.StorageObjectFailure;
  *
  */
 
-public class DatabaseBreaking extends Database implements StorageObject{
+public class DatabaseBreaking extends Database {
   private static DatabaseBreaking instance;
 
   public synchronized static DatabaseBreaking getInstance() throws StorageObjectFailure {
index edbe653..ab545b6 100755 (executable)
@@ -36,7 +36,7 @@ import java.sql.Statement;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -46,7 +46,7 @@ import mir.storage.StorageObjectFailure;
  *
  */
 
-public class DatabaseComment extends Database implements StorageObject{
+public class DatabaseComment extends Database {
 
   private static DatabaseComment instance;
 
index 46dd251..337d92b 100755 (executable)
@@ -32,10 +32,10 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
-public class DatabaseCommentStatus extends Database implements StorageObject{
+public class DatabaseCommentStatus extends Database {
 
   private static DatabaseCommentStatus instance;
 
index 1105a7d..aa6267e 100755 (executable)
@@ -38,7 +38,7 @@ import java.util.ArrayList;
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectExc;
 import mir.storage.StorageObjectFailure;
 import mircoders.entity.EntityComment;
@@ -48,11 +48,11 @@ import mircoders.entity.EntityUploadedMedia;
  * <b>implements abstract DB connection to the comment_x_media SQL table
  *
  * @author RK, mir-coders group
- * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.8 2005/01/09 20:37:15 zapata Exp $
+ * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.9 2005/01/23 15:36:05 zapata Exp $
  *
  */
 
-public class DatabaseCommentToMedia extends Database implements StorageObject{
+public class DatabaseCommentToMedia extends Database {
 
   private static DatabaseCommentToMedia instance;
 
index dbe4e01..c5283a5 100755 (executable)
@@ -35,7 +35,7 @@ import java.sql.Statement;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -44,7 +44,7 @@ import mir.storage.StorageObjectFailure;
  *
  */
 
-public class DatabaseContent extends Database implements StorageObject {
+public class DatabaseContent extends Database  {
 
   private static DatabaseContent      instance;
 
index 6dd5098..8188465 100755 (executable)
@@ -38,7 +38,7 @@ import java.util.ArrayList;
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectExc;
 import mir.storage.StorageObjectFailure;
 import mircoders.entity.EntityContent;
@@ -48,11 +48,11 @@ import mircoders.entity.EntityUploadedMedia;
  * <b>implements abstract DB connection to the content_x_media SQL table
  *
  * @author RK, mir-coders group
- * @version $Id: DatabaseContentToMedia.java,v 1.19.2.7 2005/01/09 20:37:15 zapata Exp $
+ * @version $Id: DatabaseContentToMedia.java,v 1.19.2.8 2005/01/23 15:36:05 zapata Exp $
  *
  */
 
-public class DatabaseContentToMedia extends Database implements StorageObject{
+public class DatabaseContentToMedia extends Database {
 
   private static DatabaseContentToMedia instance;
 
index cddbe9e..18ae652 100755 (executable)
@@ -33,7 +33,7 @@ package mircoders.storage;
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 import mircoders.entity.EntityContent;
 import mircoders.entity.EntityTopics;
@@ -52,7 +52,7 @@ import java.util.List;
  *
  */
 
-public class DatabaseContentToTopics extends Database implements StorageObject{
+public class DatabaseContentToTopics extends Database {
 
   private static DatabaseContentToTopics instance;
 
index 2c86e5e..6c34f7c 100755 (executable)
@@ -36,9 +36,9 @@ package mircoders.storage;
 \r
 import mir.log.LoggerWrapper;\r
 import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import mir.storage.Database;\r
 \r
-public class DatabaseFilter extends Database implements StorageObject{\r
+public class DatabaseFilter extends Database {\r
   private static DatabaseFilter instance;\r
 \r
   public synchronized static DatabaseFilter getInstance() {\r
index de15925..e6c1696 100755 (executable)
@@ -36,9 +36,9 @@ package mircoders.storage;
 \r
 import mir.log.LoggerWrapper;\r
 import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import mir.storage.Database;\r
 \r
-public class DatabaseFilterGroup extends Database implements StorageObject {\r
+public class DatabaseFilterGroup extends Database {\r
   private static DatabaseFilterGroup instance;\r
 \r
   public synchronized static DatabaseFilterGroup getInstance() {\r
index ab66401..545f0db 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 /**
  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
@@ -40,7 +40,7 @@ import mir.storage.StorageObject;
  *
  */
 
-public class DatabaseImageColor extends Database implements StorageObject{
+public class DatabaseImageColor extends Database {
 
   private static DatabaseImageColor instance;
 
index cd02567..e25ee77 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 /**
  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
@@ -40,7 +40,7 @@ import mir.storage.StorageObject;
  *
  */
 
-public class DatabaseImageFormat extends Database implements StorageObject{
+public class DatabaseImageFormat extends Database {
 
   private static DatabaseImageFormat instance;
 
index ec10643..2a3c882 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 /**
  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
@@ -40,7 +40,7 @@ import mir.storage.StorageObject;
  *
  */
 
-public class DatabaseImageLayout extends Database implements StorageObject{
+public class DatabaseImageLayout extends Database {
 
   private static DatabaseImageLayout instance;
 
index 1ae36c5..377767f 100755 (executable)
@@ -31,7 +31,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 /**
  *
@@ -43,7 +43,7 @@ import mir.storage.StorageObject;
  * @version 1.0
  */
 
-public class DatabaseImageType extends Database implements StorageObject{
+public class DatabaseImageType extends Database {
   private static DatabaseImageType instance;
 
   public synchronized static DatabaseImageType getInstance() {
index 69a24bf..8b9a70b 100755 (executable)
@@ -36,7 +36,7 @@ import mir.entity.Entity;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -45,7 +45,7 @@ import mir.storage.StorageObjectFailure;
  *
  */
 
-public class DatabaseImages extends Database implements StorageObject{
+public class DatabaseImages extends Database {
 
   private static DatabaseImages instance;
 
index 9439f47..f9ba4a2 100755 (executable)
@@ -45,11 +45,11 @@ import mir.entity.Entity;
 import mir.entity.EntityBrowser;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 
-public class DatabaseLanguage extends Database implements StorageObject{
+public class DatabaseLanguage extends Database {
   private static DatabaseLanguage instance;
 
   // the following *has* to be sychronized cause this static method
index da70771..0b1ed4c 100755 (executable)
@@ -31,7 +31,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -41,7 +41,7 @@ import mir.storage.StorageObjectFailure;
  *
  */
 
-public class DatabaseMediaType extends Database implements StorageObject{
+public class DatabaseMediaType extends Database {
   private static DatabaseMediaType instance;
 
   public synchronized static DatabaseMediaType getInstance() {
index 9204112..bbf4ecb 100755 (executable)
@@ -36,9 +36,9 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
-public class DatabaseMediafolder extends Database implements StorageObject{
+public class DatabaseMediafolder extends Database {
   private static DatabaseMediafolder instance;
 
   public synchronized static DatabaseMediafolder getInstance() {
index efac2e7..aeb8a16 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 
 
 /**
@@ -45,7 +45,7 @@ import mir.storage.StorageObject;
  */
 
 
-public class DatabaseMessages extends Database implements StorageObject{
+public class DatabaseMessages extends Database {
   private static DatabaseMessages instance;
 
   public synchronized static DatabaseMessages getInstance() {
index a7df77b..2931809 100755 (executable)
@@ -36,7 +36,7 @@ import mir.entity.Entity;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -49,7 +49,7 @@ import mir.storage.StorageObjectFailure;
  * @version 1.0
  */
 
-public class DatabaseOther extends Database implements StorageObject{
+public class DatabaseOther extends Database {
   private static DatabaseOther instance;
 
   // the following *has* to be sychronized cause this static method
index e6adf8d..2f38d94 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -45,7 +45,7 @@ import mir.storage.StorageObjectFailure;
  * @version 1.0
  */
 
-public class DatabaseRights extends Database implements StorageObject{
+public class DatabaseRights extends Database {
   private static DatabaseRights instance;
 
   public synchronized static DatabaseRights getInstance() {
index cc2d4b3..49c84d1 100755 (executable)
@@ -36,7 +36,7 @@ import mir.entity.Entity;
 import mir.entity.EntityBrowser;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -49,7 +49,7 @@ import mir.storage.StorageObjectFailure;
  * @version 1.0
  */
 
-public class DatabaseTopics extends Database implements StorageObject{
+public class DatabaseTopics extends Database {
   private static DatabaseTopics instance;
 
   public synchronized static DatabaseTopics getInstance() {
index fc3849d..72bf3b5 100755 (executable)
@@ -36,10 +36,10 @@ import mir.entity.Entity;
 import mir.entity.EntityBrowser;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
-public class DatabaseUploadedMedia extends Database implements StorageObject {
+public class DatabaseUploadedMedia extends Database  {
   private static DatabaseUploadedMedia  instance;
 
   public synchronized static DatabaseUploadedMedia getInstance() {
index cd1ad60..02bc85e 100755 (executable)
@@ -32,7 +32,7 @@ package mircoders.storage;
 
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -45,7 +45,7 @@ import mir.storage.StorageObjectFailure;
  * @version 1.0
  */
 
-public class DatabaseUsers extends Database implements StorageObject{
+public class DatabaseUsers extends Database {
 
   private static DatabaseUsers instance;
 
index e2c1c9c..6e253a2 100755 (executable)
@@ -36,7 +36,7 @@ import mir.entity.Entity;
 import mir.log.LoggerWrapper;
 import mir.misc.StringUtil;
 import mir.storage.Database;
-import mir.storage.StorageObject;
+import mir.storage.Database;
 import mir.storage.StorageObjectFailure;
 
 /**
@@ -49,7 +49,7 @@ import mir.storage.StorageObjectFailure;
  * @version 1.0
  */
 
-public class DatabaseVideo extends Database implements StorageObject{
+public class DatabaseVideo extends Database {
 
   private static DatabaseVideo instance;