more error handling.
[mir.git] / source / mircoders / storage / DatabaseContentToMedia.java
index 1cf3708..5bfe5af 100755 (executable)
@@ -44,7 +44,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
    * get all the media-files belonging to a content entity
    *
    */
-  public EntityList getMedia(EntityContent content) {
+  public EntityList getMedia(EntityContent content)
+    throws StorageObjectException {
     EntityList returnList=null;
     if (content != null) {
       // get all to_topic from media_x_topic
@@ -56,6 +57,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
         returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,-1);
       } catch (Exception e) {
         theLog.printDebugInfo("-- get media failed " + e.toString());
+        throw new StorageObjectException("-- get media failed " + e.toString());
       }
     }
     return returnList;
@@ -65,7 +67,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
    * get all the images belonging to a content entity
    *
    */
-  public EntityList getImages(EntityContent content) {
+  public EntityList getImages(EntityContent content)
+    throws StorageObjectException {
     EntityList returnList=null;
     if (content != null) {
       // get all to_topic from media_x_topic
@@ -77,6 +80,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
         returnList = DatabaseImages.getInstance().selectByWhereClause(subselect,-1);
       } catch (Exception e) {
         theLog.printDebugInfo("-- get images failed " + e.toString());
+        throw new StorageObjectException("-- get images failed " + e.toString());
       }
     }
     return returnList;
@@ -87,7 +91,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
    * get all the uploaded Media belonging to a content entity
    *
    */
-  public EntityList getUploadedMedia(EntityContent content) {
+  public EntityList getUploadedMedia(EntityContent content)
+    throws StorageObjectException {
     EntityList returnList=null;
     if (content != null) {
       // get all to_topic from media_x_topic
@@ -99,6 +104,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
         returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,-1);
       } catch (Exception e) {
         theLog.printDebugInfo("-- get uploadedMedia failed " + e.toString());
+        throw new StorageObjectException("-- get uploadedMedia failed " + e.toString());
       }
     }
     return returnList;
@@ -124,6 +130,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       ResultSet rs = executeSql(stmt,sql);
     } catch (Exception e) {
       theLog.printDebugInfo("-- set media failed -- delete");
+      throw new StorageObjectException("-- set media failed -- delete"+e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -140,6 +147,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
         int rs = executeUpdate(stmt,sql);
       } catch (Exception e) {
         theLog.printDebugInfo("-- set topics failed -- insert");
+        throw new StorageObjectException("-- set topics failed -- insert "+e.toString());
       } finally {
         freeConnection(con,stmt);
       }
@@ -164,6 +172,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       int rs = executeUpdate(stmt,sql);
     } catch (Exception e) {
       theLog.printDebugInfo("-- add media failed -- insert");
+      throw new StorageObjectException("-- add media failed -- insert "
+        +e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -185,6 +195,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       int rs = executeUpdate(stmt,sql);
     } catch (Exception e) {
       theLog.printDebugInfo("-- set media failed -- delete");
+      throw new StorageObjectException("-- set media failed -- delete "
+        +e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -201,6 +213,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       int rs = executeUpdate(stmt,sql);
     } catch (Exception e) {
       theLog.printDebugInfo("-- set media failed -- insert");
+      throw new StorageObjectException("-- set media failed -- insert "
+        +e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -222,7 +236,9 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       stmt = con.createStatement();
       int rs = executeUpdate(stmt,sql);
     } catch (Exception e) {
-      //theLog.printDebugInfo("-- delete topics failed  ");
+      theLog.printDebugInfo("-- delete by contentId failed  ");
+      throw new StorageObjectException("-- delete by content id failed -- delete "
+        +e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -246,6 +262,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       theLog.printDebugInfo("-- delete media success ");
     } catch (Exception e) {
       theLog.printDebugInfo("-- delete media failed ");
+      throw new StorageObjectException("-- delete by media id failed -- "
+        +e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -269,6 +287,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       theLog.printDebugInfo("-- delete content_x_media success ");
     } catch (Exception e) {
       theLog.printDebugInfo("-- delete content_x_media failed ");
+      throw new StorageObjectException("-- delete content_x_media failed -- "
+        +e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -302,7 +322,11 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
             returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,-1);
         }
       }
-      catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
+      catch (Exception e) {
+        theLog.printDebugInfo("-- get content failed");
+        throw new StorageObjectException("-- get content failed -- "
+        +e.toString());
+      }
       finally { freeConnection(con,stmt);}
     }
     return returnList;
@@ -337,7 +361,11 @@ public EntityList getContent()
           returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,"webdb_lastchange desc");
       }
     }
-    catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
+    catch (Exception e) {
+        theLog.printDebugInfo("-- get content failed");
+        throw new StorageObjectException("-- get content failed -- "
+        +e.toString());
+    }
     finally { freeConnection(con,stmt);}
 
     return returnList;