1 40 package com.mvnforum.admin.importexport.jive; 41 42 import java.sql.Timestamp ; 43 import java.util.Vector ; 44 45 import com.mvnforum.admin.PostXML; 46 import com.mvnforum.admin.ThreadXML; 47 import net.myvietnam.mvncore.exception.*; 48 49 60 public class JiveThreadXML { 61 62 private ThreadXML threadXML=null; 63 private boolean threadCreated=false; 64 private Vector threadWatchesToAddLater=new Vector (); 65 private JiveForumXML parentForum =null; 66 67 public JiveThreadXML() { 68 super(); 69 threadXML=new ThreadXML(); 70 threadCreated=false; 71 parentForum=null; 72 } 73 74 public void setThreadID(String id) { 75 threadXML.setThreadID(id); 76 } 77 78 84 public void setThreadId(String id) { 85 setThreadID(id); 86 } 87 88 public int getThreadID() { return threadXML.getThreadID(); } 89 90 public int getParentCategoryID() { 91 return threadXML.getParentCategoryID(); 92 } 93 94 public int getParentForumID() { 95 return threadXML.getParentForumID(); 96 } 97 98 public void setParentForum(Object o) 99 throws ForeignKeyNotFoundException { 100 if (o instanceof JiveForumXML) { 101 parentForum=(JiveForumXML)o; 102 } else { 104 throw new ForeignKeyNotFoundException("Can't find parent forum."); 105 } 106 } 107 108 private String threadTopic=null; 109 public void setTopic(String value) throws CreateException { 110 if ( (value==null) || (value.equals("")) ) { 111 throw new CreateException("Cannot create a thread with an empty ThreadTopic."); 112 } else this.threadTopic=value; 113 } 114 115 private String threadBody=null; 116 public void setBody(String value) throws CreateException { 117 if ( (value==null) || (value.equals("")) ) { 118 throw new CreateException("Cannot create a thread with an empty ThreadBody."); 119 } else this.threadBody=value; 120 } 121 122 private String threadUsername=null; 123 public void setUsername(String value) throws CreateException { 124 this.threadUsername=value; 125 } 126 127 private String threadCreationDate=null; 128 public void setCreationDate(String value) throws CreateException { 129 this.threadCreationDate=value; 130 } 131 132 private String threadModifiedDate=null; 133 public void setModifiedDate(String value) throws CreateException { 134 this.threadModifiedDate=value; 135 } 136 137 public void addJiveThread() throws BadInputException, CreateException, 138 DatabaseException, ObjectNotFoundException, DuplicateKeyException, ForeignKeyNotFoundException { 139 145 if (!threadCreated) addJiveThread(threadUsername, threadTopic, threadBody); 146 } 147 148 public void addJiveThread(String firstMessageUsername, String firstMessageSubject, String firstMessageBody) 149 throws BadInputException, CreateException, 150 DatabaseException, ObjectNotFoundException, DuplicateKeyException, ForeignKeyNotFoundException { 151 156 if (threadCreated) return; 157 setUsername(firstMessageUsername); 158 setTopic(firstMessageSubject); 159 setBody(firstMessageBody); 160 161 if (parentForum!=null) { 162 parentForum.addJiveForum(); 163 threadXML.setParentForumID(parentForum.getForumID()); 164 threadXML.setParentCategoryID(parentForum.getParentCategoryID()); 165 } 166 167 ImportJive.addMessage("Adding Jive thread \""+threadTopic+"\"."); 168 threadXML.addThread(threadUsername, threadUsername, 169 threadTopic, threadBody, 170 null, null, 171 threadCreationDate, threadModifiedDate, 172 null, null, 173 null, null, 174 null, null, 175 null, null, null ); 176 threadCreated=true; 177 178 for (int i=0; i<threadWatchesToAddLater.size(); i++) { 179 String memberName= (String )threadWatchesToAddLater.elementAt(i); 180 ImportJive.addMessage("Adding thread watch for member \""+memberName+"\"."); 181 threadXML.addThreadWatch(memberName, 182 null, null, 183 null, null, 184 null, null); 185 } 186 threadWatchesToAddLater.clear(); 187 188 if (parentForum!=null) { 189 parentForum.updateAddedThread(threadXML); } 191 } 192 193 public void addJiveThreadWatch(String type, String expirable, String username) 194 throws CreateException { 195 200 threadWatchesToAddLater.add(username); 201 } 202 203 public void updateAddedPost(PostXML postXML, String postUsername, Timestamp postCreationDate) 204 throws ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException { 205 if (postXML.getParentPostID()!=0) { threadXML.increaseReplyCount(); 207 } 208 threadXML.updateLastPostMemberName(postUsername); 209 threadXML.updateLastPostDate(postCreationDate); 210 if (parentForum!=null) { 211 parentForum.updateAddedPost(postXML, postUsername, postCreationDate); 213 } 214 } 215 216 217 } 218 219 220 | Popular Tags |