fixing scaling images -> nullpointer, patch by yossarian
[mir.git] / source / mircoders / storage / DatabaseCommentToMedia.java
index aa6267e..8d6f0a1 100755 (executable)
 package mircoders.storage;
 
 import java.sql.Connection;
-import java.sql.ResultSet;
 import java.sql.Statement;
 import java.util.ArrayList;
 
 import mir.entity.EntityList;
 import mir.log.LoggerWrapper;
 import mir.storage.Database;
-import mir.storage.Database;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityComment;
+import mir.storage.DatabaseFailure;
 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.9 2005/01/23 15:36:05 zapata Exp $
- *
- */
-
 public class DatabaseCommentToMedia extends Database {
 
   private static DatabaseCommentToMedia instance;
@@ -72,7 +60,7 @@ public class DatabaseCommentToMedia extends Database {
   }
 
   public void addMedia(String commentId, String mediaId) throws
-      StorageObjectFailure {
+      DatabaseFailure {
     if (commentId == null && mediaId == null) {
       return;
     }
@@ -91,7 +79,7 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- add media failed -- insert");
-      throw new StorageObjectFailure("-- add media failed -- insert ", e);
+      throw new DatabaseFailure("-- add media failed -- insert ", e);
     }
     finally {
       freeConnection(con, stmt);
@@ -99,7 +87,7 @@ public class DatabaseCommentToMedia extends Database {
   }
 
   public void setMedia(String commentId, String mediaId) throws
-      StorageObjectFailure {
+      DatabaseFailure {
     if (commentId == null && mediaId == null) {
       return;
     }
@@ -116,7 +104,7 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- set media failed -- delete");
-      throw new StorageObjectFailure("-- set media failed -- delete ", e);
+      throw new DatabaseFailure("-- set media failed -- delete ", e);
     }
     finally {
       freeConnection(con, stmt);
@@ -135,14 +123,14 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- set media failed -- insert");
-      throw new StorageObjectFailure("-- set media failed -- insert ", e);
+      throw new DatabaseFailure("-- set media failed -- insert ", e);
     }
     finally {
       freeConnection(con, stmt);
     }
   }
 
-  public void deleteByCommentId(String commentId) throws StorageObjectFailure {
+  public void deleteByCommentId(String commentId) throws DatabaseFailure {
     if (commentId == null) {
       //theLog.printDebugInfo("-- delete topics failed -- no comment id");
       return;
@@ -160,7 +148,7 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- delete by commentId failed  ");
-      throw new StorageObjectFailure(
+      throw new DatabaseFailure(
           "-- delete by comment id failed -- delete ", e);
     }
     finally {
@@ -168,7 +156,7 @@ public class DatabaseCommentToMedia extends Database {
     }
   }
 
-  public void deleteByMediaId(String mediaId) throws StorageObjectFailure {
+  public void deleteByMediaId(String mediaId) throws DatabaseFailure {
     if (mediaId == null) {
       //theLog.printDebugInfo("-- delete topics failed -- no topic id");
       return;
@@ -187,7 +175,7 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- delete media failed ");
-      throw new StorageObjectFailure("-- delete by media id failed -- ", e);
+      throw new DatabaseFailure("-- delete by media id failed -- ", e);
     }
     finally {
       freeConnection(con, stmt);
@@ -195,7 +183,7 @@ public class DatabaseCommentToMedia extends Database {
   }
 
   public void delete(String commentId, String mediaId) throws
-      StorageObjectFailure {
+      DatabaseFailure {
     if (mediaId == null || commentId == null) {
       logger.debug("-- delete media failed -- missing parameter");
       return;
@@ -215,7 +203,7 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- delete comment_x_media failed ");
-      throw new StorageObjectFailure("-- delete comment_x_media failed -- ", e);
+      throw new DatabaseFailure("-- delete comment_x_media failed -- ", e);
     }
     finally {
       freeConnection(con, stmt);
@@ -223,7 +211,7 @@ public class DatabaseCommentToMedia extends Database {
   }
 
   public EntityList getComment(EntityUploadedMedia media) throws
-      StorageObjectFailure {
+      DatabaseFailure {
 
     EntityList returnList = null;
     if (media != null) {
@@ -240,7 +228,7 @@ public class DatabaseCommentToMedia extends Database {
       }
       catch (Exception e) {
         logger.error("-- get comment failed");
-        throw new StorageObjectFailure("-- get comment failed -- ", e);
+        throw new DatabaseFailure("-- get comment failed -- ", e);
       }
     }
     return returnList;
@@ -251,7 +239,7 @@ public class DatabaseCommentToMedia extends Database {
    *  a relation to a media
    */
 
-  public EntityList getComment() throws StorageObjectFailure {
+  public EntityList getComment() throws DatabaseFailure {
     EntityList returnList = null;
 
     ArrayList extraTables = new ArrayList();
@@ -265,7 +253,7 @@ public class DatabaseCommentToMedia extends Database {
     }
     catch (Exception e) {
       logger.error("-- get comment failed");
-      throw new StorageObjectFailure("-- get comment failed -- ", e);
+      throw new DatabaseFailure("-- get comment failed -- ", e);
     }
     return returnList;