KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > admin > ThreadXML


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/ThreadXML.java,v 1.11 2006/04/14 17:36:29 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.11 $
5  * $Date: 2006/04/14 17:36:29 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Igor Manic
39  */

40 package com.mvnforum.admin;
41
42 import java.io.IOException JavaDoc;
43 import java.sql.Timestamp JavaDoc;
44 import java.util.*;
45
46 import com.mvnforum.admin.importexport.XMLUtil;
47 import com.mvnforum.admin.importexport.XMLWriter;
48 import com.mvnforum.db.*;
49 import net.myvietnam.mvncore.exception.*;
50 import net.myvietnam.mvncore.filter.DisableHtmlTagFilter;
51 import net.myvietnam.mvncore.filter.EnableHtmlTagFilter;
52
53 /**
54  * @author Igor Manic
55  * @version $Revision: 1.11 $, $Date: 2006/04/14 17:36:29 $
56  * <br/>
57  * <code>ThreadXML</code> todo Igor: enter description
58  *
59  */

60 public class ThreadXML {
61
62     private int threadID;
63     /** Returns <code>ThreadID</code> of this thread or
64       * <code>-1</code> if thread is not created yet. */

65     public int getThreadID() { return threadID; }
66
67     private int parentForumID;
68     /** Returns <code>ForumID</code> of this thread's parent forum or
69       * <code>-1</code> if this thread is not created yet. */

70     public int getParentForumID() { return parentForumID; }
71
72     private int parentCategoryID;
73     /** Returns <code>CategoryID</code> of this thread's parent category or
74       * <code>-1</code> if this thread is not created yet. */

75     public int getParentCategoryID() { return parentCategoryID; }
76
77     public ThreadXML() {
78         super();
79         threadID=-1;
80         parentForumID=-1;
81         parentCategoryID=-1;
82     }
83
84     public void setThreadID(String JavaDoc id) {
85         threadID=XMLUtil.stringToIntDef(id, -1);
86     }
87
88     public void setParentForum(Object JavaDoc o)
89     throws ForeignKeyNotFoundException {
90         if (o instanceof ForumXML) {
91             parentForumID=((ForumXML)o).getForumID();
92         } else {
93             throw new ForeignKeyNotFoundException("Can't find parent forum's ID");
94         }
95     }
96
97     public void setParentForumID(int value) {
98         if (value<0) parentForumID=-1;
99         else parentForumID=value;
100     }
101
102     public void setParentCategory(Object JavaDoc o)
103     throws ForeignKeyNotFoundException {
104         if (o instanceof ForumXML) {
105             parentCategoryID=((ForumXML)o).getParentCategoryID();
106         } else {
107             throw new ForeignKeyNotFoundException("Can't find parent category's ID");
108         }
109     }
110
111     public void setParentCategoryID(int value) {
112         if (value<0) parentCategoryID=-1;
113         else parentCategoryID=value;
114     }
115
116     /**
117      * Creates a thread. All argument values (<code>int</code>s, <code>Timestamp</code>s, ...)
118      * are represented as <code>String</code>s, because of more convenient using
119      * of this method for XML parsing.
120      *
121      * @param memberName Member that created the thread. Can be null.
122      * @param lastPostMemberName Can be null.
123      * @param threadTopic Thread topic.
124      * @param threadBody Thread body (description).
125      * @param threadVoteCount Can be null.
126      * @param threadVoteTotalStars Can be null.
127      * @param threadCreationDate Can be null.
128      * @param threadLastPostDate Can be null.
129      * @param threadType Can be null.
130      * @param threadOption Can be null.
131      * @param threadStatus Can be null.
132      * @param threadHasPoll Can be null.
133      * @param threadViewCount Can be null.
134      * @param threadReplyCount Can be null.
135      * @param threadIcon Can be null.
136      * @param threadDuration Can be null.
137      *
138      * @throws CreateException
139      * @throws DuplicateKeyException
140      * @throws ObjectNotFoundException
141      * @throws DatabaseException
142      * @throws ForeignKeyNotFoundException
143      */

144     public void addThread(String JavaDoc memberName, String JavaDoc lastPostMemberName,
145                           String JavaDoc threadTopic, String JavaDoc threadBody,
146                           String JavaDoc threadVoteCount, String JavaDoc threadVoteTotalStars,
147                           String JavaDoc threadCreationDate, String JavaDoc threadLastPostDate,
148                           String JavaDoc threadType, String JavaDoc threadOption,
149                           String JavaDoc threadStatus, String JavaDoc threadHasPoll,
150                           String JavaDoc threadViewCount, String JavaDoc threadReplyCount,
151                           String JavaDoc threadIcon, String JavaDoc threadDuration, String JavaDoc threadAttachCount)
152         throws CreateException, ObjectNotFoundException,
153         DatabaseException, ForeignKeyNotFoundException {
154
155         if (parentForumID<0) {
156             throw new CreateException("Can't create a thread, because no parent forum assigned yet.");
157         } else if (parentCategoryID<0) {
158             throw new CreateException("Can't create a thread, because no parent category assigned yet.");
159         } else if ((threadTopic==null) || (threadBody==null)) {
160             throw new CreateException("Can't create a thread with empty ThreadTopic or empty ThreadBody.");
161         } else {
162             int threadVoteCount1;
163             int threadVoteTotalStars1;
164             java.sql.Timestamp JavaDoc threadCreationDate1;
165             java.sql.Timestamp JavaDoc threadLastPostDate1;
166             int threadType1;
167             int threadOption1;
168             int threadStatus1;
169             int threadHasPoll1;
170             int threadViewCount1;
171             int threadReplyCount1;
172             int threadDuration1;
173             int threadAttachCount1;
174
175             try {
176                 if (memberName==null) memberName="";
177                 if (lastPostMemberName==null) lastPostMemberName="";
178                 threadVoteCount1= XMLUtil.stringToIntDef(threadVoteCount, 0);
179                 threadVoteTotalStars1= XMLUtil.stringToIntDef(threadVoteTotalStars, 0);
180                 threadCreationDate1= XMLUtil.stringToSqlTimestampDefNow(threadCreationDate);
181                 threadLastPostDate1= XMLUtil.stringToSqlTimestampDefNull(threadLastPostDate);
182                 threadType1 = XMLUtil.stringToIntDef(threadType, 0);
183                 threadOption1 = XMLUtil.stringToIntDef(threadOption, 0);
184                 threadStatus1 = XMLUtil.stringToIntDef(threadStatus, 0);
185                 threadHasPoll1 = XMLUtil.stringToIntDef(threadHasPoll, 0);
186                 threadViewCount1 = XMLUtil.stringToIntDef(threadViewCount, 0);
187                 threadReplyCount1 = XMLUtil.stringToIntDef(threadReplyCount, 0);
188                 threadAttachCount1 = XMLUtil.stringToIntDef(threadAttachCount, 0);
189                 if (threadIcon==null) threadIcon="";
190                 threadDuration1 = XMLUtil.stringToIntDef(threadDuration, 0);
191             } catch (NumberFormatException JavaDoc e) {
192                 throw new CreateException("Invalid data for a thread. Expected a number.");
193             }
194
195             threadTopic=EnableHtmlTagFilter.filter(threadTopic);
196             threadBody=EnableHtmlTagFilter.filter(threadBody);
197             threadIcon=EnableHtmlTagFilter.filter(threadIcon);
198             this.threadID = DAOFactory.getThreadDAO().createThread(parentForumID,
199                                 memberName, lastPostMemberName,
200                                 threadTopic, threadBody,
201                                 threadVoteCount1, threadVoteTotalStars1,
202                                 threadCreationDate1, threadLastPostDate1,
203                                 threadType1, threadOption1, threadStatus1,
204                                 threadHasPoll1, threadViewCount1, threadReplyCount1,
205                                 threadIcon, threadDuration1, threadAttachCount1);
206         }
207     }
208
209     /**
210      * Creates a thread watch for this thread. In order to know which thread we are
211      * reffering to, this method is supposed to be called after {@link #setThreadID(String)},
212      * {@link #addThread(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
213      * have been called. Otherwise, this watch will be simply ignored.
214      *
215      * @param memberName
216      * @param watchType Can be null.
217      * @param watchOption Can be null.
218      * @param watchStatus Can be null.
219      * @param watchCreationDate Can be null.
220      * @param watchLastSentDate Can be null.
221      * @param watchEndDate Can be null.
222      *
223      * @throws BadInputException
224      * @throws CreateException
225      * @throws DatabaseException
226      * @throws ObjectNotFoundException
227      * @throws DuplicateKeyException
228      * @throws ForeignKeyNotFoundException
229      */

230     public void addThreadWatch(String JavaDoc memberName,
231                 String JavaDoc watchType, String JavaDoc watchOption,
232                 String JavaDoc watchStatus, String JavaDoc watchCreationDate,
233                 String JavaDoc watchLastSentDate, String JavaDoc watchEndDate)
234         throws CreateException, DatabaseException, ObjectNotFoundException,
235         DuplicateKeyException, ForeignKeyNotFoundException {
236
237         if (threadID<0) {
238             throw new CreateException("Found thread watch that is not assigned to any known thread.");
239         }
240
241         int watchType1;
242         int watchOption1;
243         int watchStatus1;
244         java.sql.Timestamp JavaDoc watchCreationDate1;
245         java.sql.Timestamp JavaDoc watchLastSentDate1;
246         java.sql.Timestamp JavaDoc watchEndDate1;
247
248         try {
249             if (memberName==null) memberName="";
250             watchType1= XMLUtil.stringToIntDef(watchType, 0);
251             watchOption1= XMLUtil.stringToIntDef(watchOption, 0);
252             watchStatus1= XMLUtil.stringToIntDef(watchStatus, 0);
253             watchCreationDate1= XMLUtil.stringToSqlTimestampDefNow(watchCreationDate);
254             watchLastSentDate1= XMLUtil.stringToSqlTimestampDefNull(watchLastSentDate);
255             watchEndDate1= XMLUtil.stringToSqlTimestampDefNull(watchEndDate);
256         } catch (NumberFormatException JavaDoc e) {
257             throw new CreateException("Invalid data for a thread watch. Expected a number.");
258         }
259
260         //todo Igor: Shoud I allow memberID==0 here?
261
int memberID=0;
262         if (!memberName.equals("")) {
263             memberID=DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName);
264         }
265         DAOFactory.getWatchDAO().create(
266              memberID, 0/*categoryID*/, threadID, 0/*forumID*/,
267              watchType1, watchOption1, watchStatus1,
268              watchCreationDate1, watchLastSentDate1, watchEndDate1);
269     }
270
271     public void addFavoriteThread(String JavaDoc memberName,
272                 String JavaDoc favoriteCreationDate, String JavaDoc favoriteType,
273                 String JavaDoc favoriteOption, String JavaDoc favoriteStatus)
274         throws CreateException, DatabaseException, ObjectNotFoundException,
275         DuplicateKeyException, ForeignKeyNotFoundException {
276
277         if (threadID<0) {
278             throw new CreateException("Found favorite-thread record that is not assigned to any known thread.");
279         } else if (parentForumID<0) {
280             throw new CreateException("Can't create a favorite-thread, because no parent forum assigned yet.");
281         }
282
283         java.sql.Timestamp JavaDoc favoriteCreationDate1;
284         int favoriteType1;
285         int favoriteOption1;
286         int favoriteStatus1;
287
288         try {
289             if (memberName==null) memberName="";
290             favoriteCreationDate1= XMLUtil.stringToSqlTimestampDefNow(favoriteCreationDate);
291             favoriteType1= XMLUtil.stringToIntDef(favoriteType, 0);
292             favoriteOption1= XMLUtil.stringToIntDef(favoriteOption, 0);
293             favoriteStatus1= XMLUtil.stringToIntDef(favoriteStatus, 0);
294         } catch (NumberFormatException JavaDoc e) {
295             throw new CreateException("Invalid data for a favorite-thread. Expected a number.");
296         }
297
298         //todo Igor: Shoud I allow memberID==0 here?
299
int memberID=0;
300         if (!memberName.equals("")) {
301             memberID=DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName);
302         }
303         DAOFactory.getFavoriteThreadDAO().create(
304              memberID, threadID, parentForumID,
305              favoriteCreationDate1, favoriteType1, favoriteOption1, favoriteStatus1);
306     }
307
308     public void increaseReplyCount()
309         throws ObjectNotFoundException, DatabaseException {
310
311         if (threadID<0) {
312             throw new ObjectNotFoundException("Can't update ThreadReplyCount on thread that is not created yet.");
313         }
314         DAOFactory.getThreadDAO().increaseReplyCount(threadID);
315     }
316
317     public void updateLastPostMemberName(String JavaDoc value)
318         throws ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException {
319         if (threadID<0) {
320             throw new ObjectNotFoundException("Can't update LastPostMemberName on thread that is not created yet.");
321         }
322         DAOFactory.getThreadDAO().updateLastPostMemberName(threadID, value);
323     }
324
325     public void updateLastPostDate(Timestamp JavaDoc value)
326     throws ObjectNotFoundException, DatabaseException {
327         if (threadID<0) {
328             throw new ObjectNotFoundException("Can't update ThreadLastPostDate on thread that is not created yet.");
329         }
330         DAOFactory.getThreadDAO().updateLastPostDate(threadID, value);
331     }
332
333
334 // ===============================================================
335
// ==================== STATIC EXPORT METHODS ====================
336
// ===============================================================
337
public static void exportThreadWatchesForThread(XMLWriter xmlWriter, int threadID)
338     throws IOException JavaDoc, ExportException, NumberFormatException JavaDoc, ObjectNotFoundException,
339     DatabaseException {
340         Collection threadWatches=ExportWebHelper.execSqlQuery(
341                    "SELECT MemberID, WatchType, WatchOption, WatchStatus, WatchCreationDate, WatchLastSentDate, WatchEndDate"+
342                    " FROM "+WatchDAO.TABLE_NAME+
343                    " WHERE ThreadID="+Integer.toString(threadID));//AND ForumID=0 AND CategoryID=0
344
Iterator iter=threadWatches.iterator();
345         String JavaDoc[] threadWatch=null;
346         //try {
347
xmlWriter.startElement("ThreadWatchList");
348             try {
349                 while ( (threadWatch=(String JavaDoc[])iter.next()) !=null) {
350                     if (threadWatch.length!=7) {
351                         throw new ExportException("Error while retrieving data about thread watch for threadID=="+threadID);
352                     }
353                     String JavaDoc memberName=DAOFactory.getMemberDAO().getMember_forPublic(Integer.parseInt(threadWatch[0])).getMemberName();
354                     xmlWriter.startElement("ThreadWatch");
355                     xmlWriter.startElement("MemberName");
356                     xmlWriter.writeData(memberName);
357                     xmlWriter.endElement("MemberName");
358                     xmlWriter.startElement("WatchType");
359                     xmlWriter.writeData(threadWatch[1]);
360                     xmlWriter.endElement("WatchType");
361                     xmlWriter.startElement("WatchOption");
362                     xmlWriter.writeData(threadWatch[2]);
363                     xmlWriter.endElement("WatchOption");
364                     xmlWriter.startElement("WatchStatus");
365                     xmlWriter.writeData(threadWatch[3]);
366                     xmlWriter.endElement("WatchStatus");
367                     xmlWriter.startElement("WatchCreationDate");
368                     xmlWriter.writeData(threadWatch[4]);
369                     xmlWriter.endElement("WatchCreationDate");
370                     xmlWriter.startElement("WatchLastSentDate");
371                     xmlWriter.writeData(threadWatch[5]);
372                     xmlWriter.endElement("WatchLastSentDate");
373                     xmlWriter.startElement("WatchEndDate");
374                     xmlWriter.writeData(threadWatch[6]);
375                     xmlWriter.endElement("WatchEndDate");
376                     xmlWriter.endElement("ThreadWatch");
377                 }
378             } catch (NoSuchElementException e) {
379                 //no more database records
380
}
381             xmlWriter.endElement("ThreadWatchList");
382          //} catch throw exportexception
383
}
384
385     public static void exportFavoriteThreadsForThread(XMLWriter xmlWriter, int threadID)
386     throws IOException JavaDoc, ExportException, NumberFormatException JavaDoc, ObjectNotFoundException,
387     DatabaseException {
388         Collection favoriteThreads=ExportWebHelper.execSqlQuery(
389                    "SELECT MemberID, FavoriteCreationDate,"+
390                    " FavoriteType, FavoriteOption, FavoriteStatus"+
391                    " FROM "+FavoriteThreadDAO.TABLE_NAME+
392                    " WHERE ThreadID="+Integer.toString(threadID));
393         Iterator iter=favoriteThreads.iterator();
394         String JavaDoc[] favoriteThread=null;
395         //try {
396
xmlWriter.startElement("FavoriteThreadList");
397             try {
398                 while ( (favoriteThread=(String JavaDoc[])iter.next()) !=null) {
399                     if (favoriteThread.length!=5) {
400                         throw new ExportException("Error while retrieving data about favorite-thread records for threadID=="+threadID);
401                     }
402                     String JavaDoc memberName=DAOFactory.getMemberDAO().getMember_forPublic(Integer.parseInt(favoriteThread[0])).getMemberName();
403                     xmlWriter.startElement("FavoriteThread");
404                     xmlWriter.startElement("MemberName");
405                     xmlWriter.writeData(memberName);
406                     xmlWriter.endElement("MemberName");
407                     xmlWriter.startElement("FavoriteCreationDate");
408                     xmlWriter.writeData(favoriteThread[1]);
409                     xmlWriter.endElement("FavoriteCreationDate");
410                     xmlWriter.startElement("FavoriteType");
411                     xmlWriter.writeData(favoriteThread[2]);
412                     xmlWriter.endElement("FavoriteType");
413                     xmlWriter.startElement("FavoriteOption");
414                     xmlWriter.writeData(favoriteThread[3]);
415                     xmlWriter.endElement("FavoriteOption");
416                     xmlWriter.startElement("FavoriteStatus");
417                     xmlWriter.writeData(favoriteThread[4]);
418                     xmlWriter.endElement("FavoriteStatus");
419                     xmlWriter.endElement("FavoriteThread");
420                 }
421             } catch (NoSuchElementException e) {
422                 //no more database records
423
}
424             xmlWriter.endElement("FavoriteThreadList");
425          //} catch throw exportexception
426
}
427
428     public static void exportThread(XMLWriter xmlWriter, int threadID)
429     throws NumberFormatException JavaDoc, IOException JavaDoc, ExportException, ObjectNotFoundException,
430     DatabaseException {
431         Collection thread1=ExportWebHelper.execSqlQuery(
432                    "SELECT MemberName, LastPostMemberName,"+
433                    " ThreadTopic, ThreadBody, ThreadVoteCount, ThreadVoteTotalStars,"+
434                    " ThreadCreationDate, ThreadLastPostDate, ThreadType, ThreadOption,"+
435                    " ThreadStatus, ThreadHasPoll, ThreadViewCount, ThreadReplyCount,"+
436                    " ThreadIcon, ThreadDuration, ThreadAttachCount"+
437                    " FROM "+ThreadDAO.TABLE_NAME+
438                    " WHERE ThreadID="+Integer.toString(threadID));
439         Iterator iter=thread1.iterator();
440         String JavaDoc[] thread=null;
441         //try {
442
try {
443                 if ( (thread=(String JavaDoc[])iter.next()) ==null) {
444                     throw new ExportException("Can't find data for threadID=="+threadID);
445                 }
446                 if (thread.length!=17) {
447                     throw new ExportException("Error while retrieving data about thread with threadID=="+threadID);
448                 }
449             } catch (NoSuchElementException e) {
450                 throw new ExportException("Can't find data for threadID=="+threadID);
451             }
452
453             //if I am here, that means I now have correct object thread
454
xmlWriter.startElement("Thread");
455
456             xmlWriter.startElement("MemberName");
457             xmlWriter.writeData(thread[0]);
458             xmlWriter.endElement("MemberName");
459             xmlWriter.startElement("ThreadLastPostMemberName");
460             xmlWriter.writeData(thread[1]);
461             xmlWriter.endElement("ThreadLastPostMemberName");
462             xmlWriter.startElement("ThreadTopic");
463             xmlWriter.writeData(DisableHtmlTagFilter.filter(thread[2]));
464             xmlWriter.endElement("ThreadTopic");
465             xmlWriter.startElement("ThreadBody");
466             xmlWriter.writeData(DisableHtmlTagFilter.filter(thread[3]));
467             xmlWriter.endElement("ThreadBody");
468             xmlWriter.startElement("ThreadVoteCount");
469             xmlWriter.writeData(thread[4]);
470             xmlWriter.endElement("ThreadVoteCount");
471
472             xmlWriter.startElement("ThreadVoteTotalStars");
473             xmlWriter.writeData(thread[5]);
474             xmlWriter.endElement("ThreadVoteTotalStars");
475             xmlWriter.startElement("ThreadCreationDate");
476             xmlWriter.writeData(thread[6]);
477             xmlWriter.endElement("ThreadCreationDate");
478             xmlWriter.startElement("ThreadLastPostDate");
479             xmlWriter.writeData(thread[7]);
480             xmlWriter.endElement("ThreadLastPostDate");
481             xmlWriter.startElement("ThreadType");
482             xmlWriter.writeData(thread[8]);
483             xmlWriter.endElement("ThreadType");
484             xmlWriter.startElement("ThreadOption");
485             xmlWriter.writeData(thread[9]);
486             xmlWriter.endElement("ThreadOption");
487
488             xmlWriter.startElement("ThreadStatus");
489             xmlWriter.writeData(thread[10]);
490             xmlWriter.endElement("ThreadStatus");
491             xmlWriter.startElement("ThreadHasPoll");
492             xmlWriter.writeData(thread[11]);
493             xmlWriter.endElement("ThreadHasPoll");
494             xmlWriter.startElement("ThreadViewCount");
495             xmlWriter.writeData(thread[12]);
496             xmlWriter.endElement("ThreadViewCount");
497             xmlWriter.startElement("ThreadReplyCount");
498             xmlWriter.writeData(thread[13]);
499             xmlWriter.endElement("ThreadReplyCount");
500             xmlWriter.startElement("ThreadIcon");
501             xmlWriter.writeData(DisableHtmlTagFilter.filter(thread[14]));
502             xmlWriter.endElement("ThreadIcon");
503
504             xmlWriter.startElement("ThreadDuration");
505             xmlWriter.writeData(thread[15]);
506             xmlWriter.endElement("ThreadDuration");
507
508             xmlWriter.startElement("ThreadAttachCount");
509             xmlWriter.writeData(thread[16]);
510             xmlWriter.endElement("ThreadAttachCount");
511             exportThreadWatchesForThread(xmlWriter, threadID);
512             exportFavoriteThreadsForThread(xmlWriter, threadID);
513             PostXML.exportPostList(xmlWriter, threadID);
514
515             xmlWriter.endElement("Thread");
516          //} catch throw exportexception
517
}
518
519     //todo Igor important: merge exportThreadList and exportThread so I use only one SQL query
520
//same for category(list), ...
521
public static void exportThreadList(XMLWriter xmlWriter, int parentForumID)
522     throws IOException JavaDoc, ExportException, ObjectNotFoundException, DatabaseException {
523         Collection threadIDs=ExportWebHelper.execSqlQuery(
524                    "SELECT ThreadID"+
525                    " FROM "+ThreadDAO.TABLE_NAME+
526                    " WHERE ForumID="+Integer.toString(parentForumID));
527         Iterator iter=threadIDs.iterator();
528         String JavaDoc[] threadID=null;
529         //try {
530
xmlWriter.startElement("ThreadList");
531             try {
532                 while ( (threadID=(String JavaDoc[])iter.next()) !=null) {
533                     if (threadID.length!=1) {
534                         throw new ExportException("Error while retrieving list of threads.");
535                     }
536                     try {
537                         int i=Integer.parseInt(threadID[0]);
538                         exportThread(xmlWriter, i);
539                     } catch (NumberFormatException JavaDoc e) {
540                         throw new ExportException("Error while retrieving list of threads.");
541                     }
542                 }
543             } catch (NoSuchElementException e) {
544                 //no more database records
545
}
546             xmlWriter.endElement("ThreadList");
547          //} catch throw exportexception
548
}
549
550
551 }
552
553
Popular Tags