serious memory leak in the producer subsystem fixed
[mir.git] / source / mircoders / entity / EntityContent.java
index 09fc32e..96ab2dc 100755 (executable)
 
 package mircoders.entity;
 
-import mir.entity.AbstractEntity;
-import mir.log.LoggerWrapper;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseContentToMedia;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Map;
 
+import mir.entity.AbstractEntity;
+import mir.log.LoggerWrapper;
+import mir.storage.DatabaseFailure;
+import mircoders.storage.DatabaseContentToMedia;
+
 /**
  * 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.12 2005/10/30 00:46:58 zapata Exp $
  * @author mir-coders group
  *
  */
 
 
 public class EntityContent extends AbstractEntity {
-  // constructors
-
-  public EntityContent()
-  {
-    super();
-
-    logger = new LoggerWrapper("Entity.Content");
-  }
-
   /**
    * set is_produced flag for the article
    */
-  public void setProduced(boolean yesno) throws StorageObjectFailure
+  public void setProduced(boolean yesno) throws DatabaseFailure
   {
     String value = (yesno) ? "1":"0";
     if (value.equals( getFieldValue("is_produced") )) return;
@@ -71,19 +62,19 @@ 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) {
+    catch (DatabaseFailure e) {
       throw e;
     }
     catch (SQLException e) {
-      throw new StorageObjectFailure(e);
+      throw new DatabaseFailure(e);
     }
     finally {
-      storageObject.freeConnection(con,stmt);
+      database.freeConnection(con,stmt);
     }
   }
 
@@ -92,9 +83,9 @@ public class EntityContent extends AbstractEntity {
    *
    * @param anArticleId
    * @param aMediaId
-   * @throws StorageObjectFailure
+   * @throws DatabaseFailure
    */
-  public void dettach(String anArticleId, String aMediaId) throws StorageObjectFailure
+  public void dettach(String anArticleId, String aMediaId) throws DatabaseFailure
   {
     if (aMediaId!=null){
       DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId);
@@ -107,14 +98,14 @@ public class EntityContent extends AbstractEntity {
    * Attaches media to the article
    */
 
-  public void attach(String aMediaId) throws StorageObjectFailure
+  public void attach(String aMediaId) throws DatabaseFailure
   {
     if (aMediaId!=null) {
       DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId);
       setProduced(false);
     }
     else {
-      logger.error("EntityContent: attach without mid");
+      getLogger().error("EntityContent: attach without mid");
     }
   }