first cut of merge of STABLE-pre1_0 into HEAD. I won't even guarantee that it
[mir.git] / source / mircoders / storage / DatabaseContentToTopics.java
index d00fa86..1eb4137 100755 (executable)
@@ -65,7 +65,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
    * Returns a ArrayList of Integer-Objects from a content-id.
    * @returns ArrayList
    */
-  public ArrayList getTopicsOfContent(String contentId) {
+  public ArrayList getTopicsOfContent(String contentId)
+    throws StorageObjectException {
     ArrayList returnList = new ArrayList();
     if (contentId != null) {
       String sql = "select topic_id from " + theTable + " where content_id=" + contentId;
@@ -93,7 +94,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
   /**
    * Set new topics
    */
-  public void setTopics(String contentId, String[] topicId) {
+  public void setTopics(String contentId, String[] topicId)
+    throws StorageObjectException {
     if (contentId == null){
       return;
     }
@@ -101,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.
@@ -142,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
@@ -188,7 +192,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
     }
   }
 
-  public void deleteByContentId(String contentId) {
+  public void deleteByContentId(String contentId)
+    throws StorageObjectException {
     if (contentId == null) {
       //theLog.printDebugInfo("-- delete topics failed -- no content id");
       return;
@@ -209,7 +214,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
     }
   }
 
-  public void deleteByTopicId(String topicId) {
+  public void deleteByTopicId(String topicId)
+    throws StorageObjectException {
     if (topicId == null) {
       //theLog.printDebugInfo("-- delete topics failed -- no topic id");
       return;
@@ -231,7 +237,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
   }
 
 
-  public EntityList getContent(EntityTopics topic) {
+  public EntityList getContent(EntityTopics topic)
+    throws StorageObjectException {
     EntityList returnList=null;
     if (topic != null) {
       String id = topic.getId();