bugfix: no classcast-exception at topics to article anymore
authoridfx <idfx>
Sat, 2 Feb 2002 13:07:16 +0000 (13:07 +0000)
committeridfx <idfx>
Sat, 2 Feb 2002 13:07:16 +0000 (13:07 +0000)
build.sh-dist
source/mir/misc/MirConfig.java
source/mircoders/storage/DatabaseContentToTopics.java

index 350c146..aaef003 100755 (executable)
@@ -10,7 +10,7 @@ LOCALCLASSPATH=`echo /usr/share/java/*.jar | tr ' ' ':'`
 LIB_HOME=lib
 TOMCAT_HOME=/usr/share/tomcat
 
-CP=$LIB_HOME/servlet.jar
+CP=$LIB_HOME/servlet-2.2.jar
 CP=$CP:$ANT_HOME/ant.jar:$ANT_HOME/xerces.jar
 CP=$CP:$LOCALCLASSPATH
 CP=$CP:$TOMCAT_HOME/lib/tomcat.jar
index 4eb5b8f..0cf4859 100755 (executable)
@@ -6,6 +6,7 @@ import  java.io.*;
 import  java.util.*;
 import  java.lang.*;
 import  com.javaexchange.dbConnectionBroker.*;
+import         mir.storage.StorageObjectException;
 
 /**
  * Title:        Mir
@@ -79,7 +80,7 @@ public class MirConfig extends Configuration {
            (String)configHash.get(propName);
   }
 
-  public static void addBroker(String driver, String URL) throws Exception {
+  public static void addBroker(String driver, String URL) throws StorageObjectException {
 
     String username,passwd,min,max,log,reset;
 
@@ -102,13 +103,11 @@ public class MirConfig extends Configuration {
         if (br!=null){
           instances++;
           brokerHash.put("Pool.broker",br);
-        } else {
-            throw new Exception();
         }
-      } catch(Exception e){
+      } catch(IOException e){
         System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace();
-        throw new Exception(e.toString());
-      }
+        throw new StorageObjectException(e.toString());
+           }
     } // end if
   }
 
index c9bb9ea..1eb4137 100755 (executable)
@@ -45,8 +45,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
    * @param EntityContent content
    * @returns EntityList
    */
-  public EntityList getTopics(EntityContent content)
-    throws StorageObjectException {
+  public EntityList getTopics(EntityContent content) {
     EntityList returnList=null;
     if (content != null) {
       // get all to_topic from content_x_topic
@@ -57,7 +56,6 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
         returnList = DatabaseTopics.getInstance().selectByWhereClause(subselect,-1);
       } catch (Exception e) {
         theLog.printDebugInfo("-- get topics failed " + e.toString());
-        throw new StorageObjectException("-- get topics failed " + e.toString());
       }
     }
     return returnList;
@@ -86,7 +84,6 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
       } catch (Exception e) {
         theLog.printError(e.toString());
         theLog.printError("-- get topicsofcontent failed");
-        throw new StorageObjectException("-- get topicsofcontent failed" + e.toString());
       } finally {
         freeConnection(con,stmt);
       }
@@ -106,9 +103,9 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
       return;
     }
     //first check which topics this article has
-    ArrayList hasTopics = getTopicsOfContent(contentId);
-    ArrayList toSet = new ArrayList();
-    ArrayList toDelete = new ArrayList();
+    Collection hasTopics = getTopicsOfContent(contentId);
+    Collection toSet = new ArrayList();
+    Collection toDelete = new ArrayList();
     
     if(hasTopics!=null && hasTopics.size()>0){
       //now we check if there are new topics and copy them to an array.
@@ -147,7 +144,9 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
       }
     } else {
       //all the topics has to be set, so we copy all to the array
-      toSet=(ArrayList)Arrays.asList(topicId);
+                       for (int i = 0; i < topicId.length; i++){
+                               toSet.add(topicId[i]);
+                       }
     }
     
     //first delete all row with content_id=contentId
@@ -171,7 +170,6 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
       int rs = executeUpdate(stmt,sql);
     } catch (Exception e) {
       theLog.printDebugInfo("-- deleting topics failed");
-      throw new StorageObjectException("-- deleting topics failed" + e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -188,7 +186,6 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
         int rs = executeUpdate(stmt,sql);
       } catch (Exception e) {
         theLog.printDebugInfo("-- set topics failed -- insert laenge topicId" + topicId.length);
-        throw new StorageObjectException("-- set topics failed" + e.toString());
       } finally {
         freeConnection(con,stmt);
       }
@@ -211,8 +208,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
       stmt = con.createStatement();
       ResultSet rs = executeSql(stmt,sql);
     } catch (Exception e) {
-      theLog.printDebugInfo("-- delete topics by contentId failed  ");
-      throw new StorageObjectException("-- delete topics by contentId failed" + e.toString());
+      //theLog.printDebugInfo("-- delete topics failed  ");
     } finally {
       freeConnection(con,stmt);
     }
@@ -235,7 +231,6 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
       ResultSet rs = executeSql(stmt,sql);
     } catch (Exception e) {
       theLog.printDebugInfo("-- delete topics failed ");
-      throw new StorageObjectException("-- delete topics by topicId failed" + e.toString());
     } finally {
       freeConnection(con,stmt);
     }
@@ -269,10 +264,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
             returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1);
         }
       }
-      catch (Exception e) {
-        theLog.printDebugInfo("-- get content failed");
-        throw new StorageObjectException("-- get content failed" + e.toString());
-      } finally { freeConnection(con,stmt);}
+      catch (Exception e) {theLog.printDebugInfo("-- get contetn failed");}
+      finally { freeConnection(con,stmt);}
     }
     return returnList;
   }