From ec5dfc2301dafa4e84ab43c521c9c5a6910e3a48 Mon Sep 17 00:00:00 2001 From: idfx Date: Sat, 2 Feb 2002 13:07:16 +0000 Subject: [PATCH] bugfix: no classcast-exception at topics to article anymore --- build.sh-dist | 2 +- source/mir/misc/MirConfig.java | 11 ++++----- .../mircoders/storage/DatabaseContentToTopics.java | 27 ++++++++-------------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/build.sh-dist b/build.sh-dist index 350c1467..aaef0033 100755 --- a/build.sh-dist +++ b/build.sh-dist @@ -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 diff --git a/source/mir/misc/MirConfig.java b/source/mir/misc/MirConfig.java index 4eb5b8fe..0cf48591 100755 --- a/source/mir/misc/MirConfig.java +++ b/source/mir/misc/MirConfig.java @@ -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 } diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java index c9bb9ead..1eb41374 100755 --- a/source/mircoders/storage/DatabaseContentToTopics.java +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -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; } -- 2.11.0