more flexibility in the to comments field
[mir.git] / source / mircoders / entity / EntityContent.java
index 87f6397..5eb2bf5 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002  The Mir-coders group
+ * Copyright (C) 2001, 2002 The Mir-coders group
  *
  * This file is part of Mir.
  *
  * 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.
+ * 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 mircoders.entity;
@@ -35,26 +34,26 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.HashMap;
+import java.util.Map;
 
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-
-import mir.log.LoggerWrapper;
 import mir.entity.Entity;
 import mir.entity.EntityList;
+import mir.log.LoggerWrapper;
 import mir.storage.StorageObject;
 import mir.storage.StorageObjectExc;
 import mir.storage.StorageObjectFailure;
 import mircoders.storage.DatabaseContent;
 import mircoders.storage.DatabaseContentToMedia;
 import mircoders.storage.DatabaseContentToTopics;
+import freemarker.template.SimpleScalar;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
 
 /**
  * this class implements mapping of one line of the database table content
  * to a java object
  *
- * @version $Id: EntityContent.java,v 1.15 2003/02/23 05:00:13 zapata Exp $
+ * @version $Id: EntityContent.java,v 1.19 2003/04/21 12:42:54 idfx Exp $
  * @author mir-coders group
  *
  */
@@ -71,7 +70,7 @@ public class EntityContent extends Entity
   //this should always be transient i.e it can never be stored in the db
   //or ObjectStore. (so the ObjectStore should only be caching what comes
   //directly out of the DB. @todo confirm this with rk. -mh
-  HashMap _entCache = new HashMap();
+  Map _entCache = new HashMap();
   Boolean _hasMedia = null;
 
   // constructors
@@ -85,6 +84,7 @@ public class EntityContent extends Entity
 
   public EntityContent(StorageObject theStorage) {
     this();
+
     setStorage(theStorage);
   }
 
@@ -119,56 +119,43 @@ public class EntityContent extends Entity
     }
   }
 
-
   /**
-   * make openposting to newswire
-   */
-
-  public void newswire() throws StorageObjectFailure
-  {
-    String sql = "update content set to_article_type='1', is_produced='0' where id='" + getId()+"'";
-    try {
-      theStorageObject.executeUpdate(sql);
-    } catch (StorageObjectFailure e) {
-      throwStorageObjectFailure(e, "\n -- newswire failed");
-    } catch (SQLException e) {
-      throwStorageObjectFailure(e, "\n -- newswire failed");
-    }
-  }
-
-
-  /**
-   * dettach from media
+   * Deattaches media from an article
+   *
+   * @param anArticleId
+   * @param aMediaId
+   * @throws StorageObjectFailure
    */
-  public void dettach(String cid,String mid) throws StorageObjectFailure
+  public void dettach(String anArticleId, String aMediaId) throws StorageObjectFailure
   {
-    if (mid!=null){
+    if (aMediaId!=null){
       try{
-        DatabaseContentToMedia.getInstance().delete(cid,mid);
+        DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId);
       }
       catch (Exception e){
         throwStorageObjectFailure(e, "\n -- failed to get instance");
       }
 
-      //set Content to unproduced
       setProduced(false);
     }
   }
 
   /**
-   * attach to media
+   * Attaches media to an article
+   *
+   * @param mid
+   * @throws StorageObjectFailure
    */
 
-  public void attach(String mid) throws StorageObjectFailure
+  public void attach(String aMediaId) throws StorageObjectFailure
   {
-    if (mid!=null) {
-      //write media-id mid and content-id in table content_x_media
+    if (aMediaId!=null) {
       try{
-        DatabaseContentToMedia.getInstance().addMedia(getId(),mid);
-      } catch(StorageObjectFailure e){
+        DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId);
+      }
+      catch(StorageObjectFailure e){
         throwStorageObjectFailure(e, "attach: could not get the instance");
       }
-      //set Content to unproduced
       setProduced(false);
     }
     else {
@@ -260,7 +247,7 @@ public class EntityContent extends Entity
   /**
    * overridden method setValues to patch creator_main_url
    */
-  public void setValues(HashMap theStringValues) {
+  public void setValues(Map theStringValues) {
     if (theStringValues != null) {
       if (theStringValues.containsKey("creator_main_url")){
         if (((String)theStringValues.get("creator_main_url")).equalsIgnoreCase("http://")){