get url
[mir.git] / source / mircoders / storage / DatabaseContentToMedia.java
index 3e5db78..5a42010 100755 (executable)
@@ -39,7 +39,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     this.hasTimestamp = false;
     this.theTable="content_x_media";
   }
-  
+
   /**
    * get all the media-files belonging to a content entity
    *
@@ -62,7 +62,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     }
     return returnList;
   }
-  
+
   /**
    * get all the images belonging to a content entity
    *
@@ -92,7 +92,10 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
    *
    */
   public EntityList getUploadedMedia(EntityContent content)
-    throws StorageObjectException {
+    throws StorageObjectException
+  {
+    /** @todo this should only fetch published media / rk */
+
     EntityList returnList=null;
     if (content != null) {
       // get all to_topic from media_x_topic
@@ -103,6 +106,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       try {
         returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,"id");
       } catch (Exception e) {
+        e.printStackTrace();
         theLog.printDebugInfo("-- get uploadedMedia failed " + e.toString());
         throw new StorageObjectException("-- get uploadedMedia failed " + e.toString());
       }
@@ -121,7 +125,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     }
     //first delete all row with content_id=contentId
     String sql = "delete from "+ theTable +" where content_id=" + contentId;
-  
+
     Connection con=null;Statement stmt=null;
     try {
       con = getPooledCon();
@@ -134,7 +138,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     } finally {
       freeConnection(con,stmt);
     }
-  
+
     //now insert
     //first delete all row with content_id=contentId
     for (int i=0;i<mediaId.length;i++) {
@@ -159,10 +163,10 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     if (contentId == null && mediaId == null) {
       return;
     }
-    
+
     Connection con=null;Statement stmt=null;
     //now insert
-    
+
     String sql = "insert into "+ theTable +" (content_id,media_id) values ("
           + contentId + "," + mediaId + ")";
     try {
@@ -178,7 +182,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       freeConnection(con,stmt);
     }
   }
-  
+
   public void setMedia(String contentId, String mediaId)
     throws StorageObjectException {
     if (contentId == null && mediaId == null) {
@@ -268,7 +272,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       freeConnection(con,stmt);
     }
   }
-  
+
   public void delete(String contentId, String mediaId)
     throws StorageObjectException {
     if (mediaId == null || contentId==null) {
@@ -331,15 +335,15 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     }
     return returnList;
   }
-  
+
 /**
  * Returns a EntityList with all content-objects having a relation to a media
  */
-  
+
 public EntityList getContent()
     throws StorageObjectException {
     EntityList returnList=null;
-    
+
     String select = "select distinct content_id from " + theTable;
     // execute select statement
     Connection con=null;Statement stmt=null;