KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > admin > importexport > jive > ImportJive


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/importexport/jive/ImportJive.java,v 1.8 2006/04/14 17:36:29 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.8 $
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.importexport.jive;
41
42 import java.io.File JavaDoc;
43 import java.io.IOException JavaDoc;
44 import java.util.Calendar JavaDoc;
45 import java.util.Vector JavaDoc;
46 import javax.servlet.http.HttpServletRequest JavaDoc;
47 import javax.servlet.http.HttpServletResponse JavaDoc;
48
49 import org.apache.commons.digester.Digester;
50 import org.apache.commons.logging.Log;
51 import org.apache.commons.logging.LogFactory;
52 import org.xml.sax.SAXException JavaDoc;
53 import com.mvnforum.MVNForumConfig;
54 import com.mvnforum.admin.CategoryXML;
55 import com.mvnforum.admin.ImportWebHelper;
56 import com.mvnforum.admin.importexport.SetParentRule;
57 import net.myvietnam.mvncore.exception.*;
58
59 /**
60  * @author Igor Manic
61  * @version $Revision: 1.8 $, $Date: 2006/04/14 17:36:29 $
62  * <br/>
63  * <code>ImportJive</code> class encapsulates processing
64  * of Jive's XMLs, and imports all the data into MVN Forum database.
65  * For details see {@link #importXml(File, HttpServletRequest, HttpServletResponse, int, String, Calendar, String, boolean, Vector, int)}
66  * <br/>
67  * This class cannot be instantiated.
68  */

69 public class ImportJive extends ImportWebHelper {
70
71     /** Message log. */
72     private static Log log = LogFactory.getLog(ImportJive.class);
73
74     /** Cannot instantiate. */
75     private ImportJive() {
76     }
77
78
79 // =================================================================
80
// ===================== MAIN PUBLIC METHODS =======================
81
// =================================================================
82
/**
83      * This method performs processing of Jive's XML backup file <code>importFile</code>
84      * and imports the data into the MVN Forum system. It clears the database
85      * and files, does neccessary setup (including startup of message output),
86      * and calls {@link #processXml(File, Calendar)} to do actual processing.<br/>
87      *
88      * @param importFile Jive XML file to be imported.
89      * @param request Current session's <code>HttpServletRequest</code> object.
90      * @param response Current session's <code>HttpServletResponse</code> object.
91      * @param logonMemberID MemberID of user who is logged in, and who initiated import process.
92      * @param logonMemberName MemberName of user who is logged in, and who initiated import process.
93      * @param importTime The moment when import process was started.
94      * @param importIP From this IP address admin requested import.
95      * @param clearIfError Should it clear/reset the database in case of error.
96      * @param otherFieldValues Vector of name/value pairs of other form fields (like
97      * <code>RootCategory</code>, <code>ForumPasswords</code>)
98      * @param messageLevel What messages should be written to output during the process.
99      * For details see {@link com.mvnforum.MVNForumConstant#MESSAGE_LEVEL_ALL_MESSAGES},
100      * {@link com.mvnforum.MVNForumConfig#MESSAGE_LEVEL_IMPORTANT_MESSAGES} and
101      * {@link com.mvnforum.MVNForumConfig#MESSAGE_LEVEL_ONLY_ERRORS}.
102      *
103      * @exception ImportException If there is an error during the process. See {@link net.myvietnam.mvncore.exception.ImportException}.
104      *
105      */

106     public static void importXml(File JavaDoc importFile,
107           HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response,
108           int logonMemberID, String JavaDoc logonMemberName,
109           Calendar JavaDoc importTime, String JavaDoc importIP, boolean clearIfError,
110           Vector JavaDoc otherFieldValues, int messageLevel)
111     throws ImportException {
112         for (int i=0; i<otherFieldValues.size()-1; i+=2) {
113             String JavaDoc name=(String JavaDoc)otherFieldValues.get(i);
114             String JavaDoc value=(String JavaDoc)otherFieldValues.get(i+1);
115             if (name!=null) {
116                 if (name.equals("ForumPasswords")) JiveXML.allForumsPassword=value;
117                 else if (name.equals("RootCategory")) JiveXML.rootCategoryName=value;
118                 else if (name.equals("RootCategoryDesc")) JiveXML.rootCategoryDesc=value;
119                 else if (name.equals("JiveGuest")) JiveXML.guestName=value;
120                 else if (name.equals("JiveAdmin")) JiveXML.adminName=value;
121                 //else ignore
122
}
123         }
124
125         try {
126             response.setContentType("text/html; charset=utf-8");
127             setOutputHtmlWriter(response.getWriter());
128             setMessageOutputLevel(messageLevel);
129             startHtml(request);
130             clearDatabase();
131             clearFiles(request.getSession().getServletContext());
132         } catch (DatabaseException e) {
133             handleFatalError("Database error while clearing previous contents.",
134                              e, clearIfError, request);
135         } catch (IOException JavaDoc e) {
136             handleFatalError("I/O error while clearing previous contents.",
137                              e, clearIfError, request);
138         }
139
140         try {
141             processXml(importFile, importTime);
142             handleSuccess(request);
143         } catch (ImportException e) {
144             handleFatalError(e.getMessage(), e.getException(),
145                              clearIfError, request);
146         } catch (IOException JavaDoc e) {
147             handleFatalError("I/O error while reading XML file.",
148                              e, clearIfError, request);
149         } catch (SAXException JavaDoc e) {
150             if (e.getException()==null) {
151                 handleFatalError("Error while parsing uploaded XML file.",
152                                  e, clearIfError, request);
153             } else {
154                 handleFatalError("Error while parsing uploaded XML file.",
155                                  e.getException(), clearIfError, request);
156             }
157         } finally {
158            /* Don't delete this XML since this method was maybe started from the
159             * command-line, which means this file is not temporary (uploaded)
160             * //if ((importFile!=null) && (importFile.exists())) importFile.delete();
161             * Anyway, if neccessary, this XML will be deleted in the caller (WebHandler)
162             */

163         }
164     }
165
166
167 // =================================================================
168
// ================== MAIN PROCESSING XML METHOD ===================
169
// =================================================================
170
/**
171      * This method performs actual processing of Jive's XML file <code>inputFile</code>
172      * and imports the data into the MVN Forum system.<br/>
173      * Don't use this method directly. Instead, you should use
174      * {@link #importXml(File, HttpServletRequest, HttpServletResponse, int, String, Calendar, String, boolean, Vector, int)}.
175      *
176      * @param inputFile Jive XML file to be imported.
177      * @param importTime The moment when import process was started.
178      *
179      * @exception IOException If there is an I/O error while processing XML file.
180      * @exception SAXException If there is an error while parsing XML file.
181      * @exception ImportException If there is an error while adding some default values to database.
182      *
183      */

184     protected static void processXml(File JavaDoc inputFile, Calendar JavaDoc importTime)
185     throws IOException JavaDoc, SAXException JavaDoc, ImportException {
186         addImportantMessage("Starting migration of data...");
187
188         //SAXParserFactory factory=SAXParserFactory.newInstance();
189
Digester digester=new Digester();
190         //should try new Digester(SAXParser), or Digester(XMLReader)
191
digester.setValidating(true);
192         digester.setNamespaceAware(true);
193
194
195         /* =================================================================
196          * This is the main part of file - XML processing rules for Digester
197          * =================================================================
198          *
199          * note: since SetTopRule is firing the desired method at the end of
200          * the XML element matching the pattern, I had to implement my own
201          * SetParentRule which does exactly the same thing (calls desired
202          * child's method with a parent object as an argument). The difference
203          * is that it is firing the "setParent" method at the beginning of the
204          * corresponding XML element, thus leaving me the chance to, for example,
205          * create messages as they arrive from the XML parser, not waiting the
206          * end of the whole document (!!!), because I can't add a message, unless
207          * I already added it's parent messages, thread, forum and category.
208          */

209
210         /* First, I'll create root object of class JiveXML.
211          * It's constructor will create default contents of the database, including
212          * admin member (with MemberID=1, MemberName=JiveXML.adminName, MemberPassword="admin").
213          * Later, if I find Jive's admin, I'll just rewrite this default's admin data.
214          * JiveXML constructor will also create a root category,
215          * to which I am going to put all forums from Jive.
216          */

217         digester.addObjectCreate("Jive", JiveXML.class);
218         digester.addSetProperties("Jive", "xmlversion", "jiveXmlVersion");
219         digester.addSetProperties("Jive", "exportDate", "jiveExportDate");
220
221
222         /* For each Jive user, create MVN Forum member. */
223         digester.addObjectCreate("Jive/UserList/User", JiveUserXML.class);
224         //todo Igor: check what this is about: digester.addSetProperties("Jive/UserList/User", "id", "userId");
225
digester.addCallMethod("Jive/UserList/User", "addJiveUser", 9);
226         digester.addCallParam("Jive/UserList/User/Username", 0);
227         digester.addCallParam("Jive/UserList/User/Password", 1);
228         digester.addCallParam("Jive/UserList/User/Email", 2);
229         digester.addCallParam("Jive/UserList/User/Email", 3, "visible");
230         digester.addCallParam("Jive/UserList/User/Name", 4);
231         digester.addCallParam("Jive/UserList/User/Name", 5, "visible");
232         digester.addCallParam("Jive/UserList/User/CreationDate", 6);
233         digester.addCallParam("Jive/UserList/User/ModifiedDate", 7);
234         digester.addCallParam("Jive/UserList/User/RewardPoints", 8);
235         ImportJive.addMessage("All Jive/UserList/User/PropertyList/Property will be ignored.");
236
237
238         /* For each Jive group, create MVN Forum group.
239          * -> Jive/GroupList/Group/PropertyList/Property is not imported
240          * -> Jive/GroupList/Group/AdministratorList/Username - only the
241          * first one will be imported (as GroupOwner)
242          */

243         digester.addObjectCreate("Jive/GroupList/Group", JiveGroupXML.class);
244         /* addJiveGroup will be fired at the end of the <Group> XML element. */
245         digester.addCallMethod("Jive/GroupList/Group", "addJiveGroup");
246         //todo Igor: check what this is about: digester.addSetProperties("Jive/GroupList/Group", "id", "groupId");
247
digester.addCallMethod("Jive/GroupList/Group/Name", "setGroupName", 0);
248         digester.addCallMethod("Jive/GroupList/Group/Description", "setGroupDescription", 0);
249         digester.addCallMethod("Jive/GroupList/Group/CreationDate", "setGroupCreationDate", 0);
250         digester.addCallMethod("Jive/GroupList/Group/ModifiedDate", "setGroupModifiedDate", 0);
251         digester.addCallMethod("Jive/GroupList/Group/AdministratorList/Username", "setGroupOwnerName", 0);
252         ImportJive.addMessage("All Jive/GroupList/Group/PropertyList/Property will be ignored.");
253         ImportJive.addMessage("All Jive/GroupList/Group/AdministratorList/Username will be ignored, except for the first one (to become GroupOwner).");
254
255         /* addJiveGroupMember must first call addJiveGroup to create this group,
256          * since it's not yet created (didn't get to the end of the <Group> XML element).
257          */

258         digester.addCallMethod("Jive/GroupList/Group/MemberList/Username", "addJiveGroupMember", 0);
259
260
261         /* For each Jive forum, create MVN Forum forum.
262          * -> Jive/ForumList/Forum/FilterList/Filter is not imported
263          * -> Jive/ForumList/Forum/PropertyList/Property is not imported
264          */

265         digester.addObjectCreate("Jive/ForumList/Forum", JiveForumXML.class);
266         /* addJiveForum will be fired at the end of the <Forum> XML element. */
267         digester.addCallMethod("Jive/ForumList/Forum", "addJiveForum");
268         //todo Igor: check what this is about: digester.addSetProperties("Jive/ForumList/Forum", "id", "forumId");
269
digester.addCallMethod("Jive/ForumList/Forum/Name", "setForumName", 0);
270         digester.addCallMethod("Jive/ForumList/Forum/Description", "setForumDescription", 0);
271         digester.addCallMethod("Jive/ForumList/Forum/CreationDate", "setForumCreationDate", 0);
272         digester.addCallMethod("Jive/ForumList/Forum/ModifiedDate", "setForumModifiedDate", 0);
273         ImportJive.addMessage("All Jive/ForumList/Forum/FilterList/Filter will be ignored.");
274         ImportJive.addMessage("All Jive/ForumList/Forum/PropertyList/Property will be ignored.");
275
276         /* addJiveForumUser must first call addJiveForum to create this forum,
277          * since it's not yet created (didn't get to the end of the <Forum> XML element).
278          */

279         digester.addCallMethod("Jive/ForumList/Forum/PermissionList/UserPermissionList/UserPermission", "addJiveForumUser", 3);
280         digester.addCallParam("Jive/ForumList/Forum/PermissionList/UserPermissionList/UserPermission", 0, "usertype");
281         digester.addCallParam("Jive/ForumList/Forum/PermissionList/UserPermissionList/UserPermission", 1, "username");
282         digester.addCallParam("Jive/ForumList/Forum/PermissionList/UserPermissionList/UserPermission", 2, "permission");
283
284         /* addJiveForumGroup must first call addJiveForum to create this forum,
285          * since it's not yet created (didn't get to the end of the <Forum> XML element).
286          */

287         digester.addCallMethod("Jive/ForumList/Forum/PermissionList/GroupPermissionList/GroupPermission", "addJiveForumGroup", 2);
288         digester.addCallParam("Jive/ForumList/Forum/PermissionList/GroupPermissionList/GroupPermission", 0, "groupname");
289         digester.addCallParam("Jive/ForumList/Forum/PermissionList/GroupPermissionList/GroupPermission", 1, "permission");
290
291
292         /* For each Jive thread, create MVN Forum thread.
293          * -> Jive/ForumList/Forum/ThreadList/Thread/PropertyList/Property is not imported
294          */

295         digester.addObjectCreate("Jive/ForumList/Forum/ThreadList/Thread", JiveThreadXML.class);
296         //digester.addSetTop("Jive/ForumList/Forum/ThreadList/Thread", "setParentForum");
297
SetParentRule threadParentRule = new SetParentRule("setParentForum");
298         digester.addRule("Jive/ForumList/Forum/ThreadList/Thread", threadParentRule);
299         /* addJiveThread will be fired at the end of the <Thread> XML element. */
300         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread", "addJiveThread");
301         //todo Igor: check what this is about: digester.addSetProperties("Jive/ForumList/Forum/ThreadList/Thread", "id", "threadId");
302
/* this doesn't work here since it will be fired only after we start processing first message:
303         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread/Message/Username", "setUsername", 0);
304         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread/Message/Subject", "setTopic", 0);
305         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread/Message/Body", "setBody", 0); */

306
307         /* We consider the thread is created by the author of the first message. But, when
308          * we come to <Message> element, we'll already have JiveMessageXML on top of Digester
309          * stack. Thus, here we'll handle thread parameters we know now, and other parameters
310          * will be known and given to JiveThreadXML object when we come to processing the
311          * first Message of the thread (which always exists).
312          * This applies to rules matching Message/Username, Message/Subject and Message/Body.
313          * They will not only set corresponding JiveMessageXML fields, but also parent
314          * JiveThreadXML fields if it is the first message in a thread.
315          * One more problem is about thread watches - these Watch elements are parsed before
316          * the first message. But, to enter thread watch into the database, we need to have
317          * already created thread. And that's not possible before we process the first message.
318          * So, all thread watches will be remembered in JiveThreadXML, and when we process the
319          * first message, we'll then setup all the fields of JiveThreadXML, create the thread,
320          * and then add all thread watches we remembered.
321          */

322         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread/CreationDate", "setCreationDate", 0);
323         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread/ModifiedDate", "setModifiedDate", 0);
324         ImportJive.addMessage("All Jive/ForumList/Forum/ThreadList/Thread/PropertyList/Property will be ignored.");
325
326         digester.addCallMethod("Jive/ForumList/Forum/ThreadList/Thread/WatchList/Watch", "addJiveThreadWatch", 3);
327         digester.addCallParam("Jive/ForumList/Forum/ThreadList/Thread/WatchList/Watch", 0, "type");
328         digester.addCallParam("Jive/ForumList/Forum/ThreadList/Thread/WatchList/Watch", 1, "expirable");
329         digester.addCallParam("Jive/ForumList/Forum/ThreadList/Thread/WatchList/Watch/Username", 2);
330
331
332         /* For each Jive message, create MVN Forum post.
333          * -> * /Message/PropertyList/Property is not imported
334          */

335         digester.addObjectCreate("*/Message", JiveMessageXML.class);
336         //digester.addSetTop("*/Message", "setParentThreadOrPost");
337
SetParentRule messageParentRule = new SetParentRule("setParentThreadOrPost");
338         digester.addRule("*/Message", messageParentRule);
339         /* addJiveMessage will be fired at the end of the <Message> XML element. */
340         digester.addCallMethod("*/Message", "addJiveMessage");
341         //todo Igor: check what this is about: digester.addSetProperties("*/Message", "id", "postId");
342
digester.addCallMethod("*/Message/Subject", "setPostSubject", 0);
343         digester.addCallMethod("*/Message/Body", "setPostBody", 0);
344         digester.addCallMethod("*/Message/Username", "setPostUsername", 0);
345         digester.addCallMethod("*/Message/CreationDate", "setPostCreationDate", 0);
346         digester.addCallMethod("*/Message/ModifiedDate", "setPostModifiedDate", 0);
347         ImportJive.addMessage("All */Message/PropertyList/Property will be ignored.");
348
349
350         /* At this point, on top of stack we have only the root JiveXML object */
351
352         digester.addCallMethod("Jive/UserPermissionList/UserPermission", "addJiveUserPermission", 3);
353         digester.addCallParam("Jive/UserPermissionList/UserPermission", 0, "usertype");
354         digester.addCallParam("Jive/UserPermissionList/UserPermission", 1, "username");
355         digester.addCallParam("Jive/UserPermissionList/UserPermission", 2, "permission");
356
357         /* addJiveForumGroup must first call addJiveForum to create this forum,
358          * since it's not yet created (didn't get to the end of the <Forum> XML element).
359          */

360         digester.addCallMethod("Jive/GroupPermissionList/GroupPermission", "addJiveGroupPermission", 2);
361         digester.addCallParam("Jive/GroupPermissionList/GroupPermission", 0, "groupname");
362         digester.addCallParam("Jive/GroupPermissionList/GroupPermission", 1, "permission");
363
364         /* ==================================================================
365          * This was the main part of file - XML processing rules for Digester
366          * ==================================================================
367          */

368
369         digester.parse(inputFile);
370
371         //now add some default permissions for guests and registered members (if they don't exist yet)
372
try {
373             for (int j=0; j<JiveXML.addDefaultPermissionsToGuests.length; j++) {
374                 try {
375                     JiveXML.addGuestMemberPermission(Integer.toString(JiveXML.addDefaultPermissionsToGuests[j]));
376                 } catch (DuplicateKeyException e) {
377                     /* Ignore if we doubled some permissions.
378                      * Because we convert each Jive permission into the list of
379                      * MVN Forum permissions (can be more than one), some permissions
380                      * could be generated twice, or more times.
381                      */

382                 }
383             }
384
385             for (int j=0; j<JiveXML.addDefaultPermissionsToMembers.length; j++) {
386                 try {
387                     JiveXML.addRegisteredMembersGroupPermission(Integer.toString(JiveXML.addDefaultPermissionsToMembers[j]));
388                 } catch (DuplicateKeyException e) {
389                     /* Ignore if we doubled some permissions.
390                      * Because we convert each Jive permission into the list of
391                      * MVN Forum permissions (can be more than one), some permissions
392                      * could be generated twice, or more times.
393                      */

394                 }
395             }
396         } catch (DatabaseException e) {
397             log.error("Database error while adding default permissions.", e);
398             throw new ImportException("Error while adding default permissions to guests and registered members.", e);
399         } catch (CreateException e) {
400             log.error("Create data error while adding default permissions.", e);
401             throw new ImportException("Error while adding default permissions to guests and registered members.", e);
402         } catch (ForeignKeyNotFoundException e) {
403             log.error("Foreign key not found error while adding default permissions.", e);
404             throw new ImportException("Error while adding default permissions to guests and registered members.", e);
405         }
406
407         if (JiveXML.foundAdminUser) {
408             ImportJive.addImportantMessage("IMPORTANT: Jive user \""+JiveXML.adminName+
409                           "\" kept all his data (including password), and has SYSTEM_ADMIN "+
410                           "permissions - even if he didn't have them in Jive!!!");
411         } else {
412             ImportJive.addImportantMessage("SYSTEM_ADMIN user with a name \""+
413                           JiveXML.adminName+"\" and password \"admin\" was created. "+
414                           "For your security, you should first change that password.");
415         }
416     }
417
418     /**
419      * Adds <code>message</code> to the output stream that was setup in
420      * {@link #importXml(File, HttpServletRequest, HttpServletResponse, int, String, Calendar, String, boolean, Vector, int)}.
421      * <br/>This method was made public to be available to Jive XML processing classes.
422      *
423      * @param message Message to be written to output.
424      * @see com.mvnforum.admin.ImportWebHelper#addMessage(java.lang.String)
425      *
426      */

427     public static void addMessage(String JavaDoc message) {
428         ImportWebHelper.addMessage(message);
429     }
430
431     /**
432      * Adds important (bold) <code>message</code> to the output stream that was setup in
433      * {@link #importXml(File, HttpServletRequest, HttpServletResponse, int, String, Calendar, String, boolean, Vector, int)}.
434      * <br/>This method was made public to be available to Jive XML processing classes.
435      *
436      * @param message Message to be written to output.
437      * @see com.mvnforum.admin.ImportWebHelper#addImportantMessage(java.lang.String)
438      *
439      */

440     public static void addImportantMessage(String JavaDoc message) {
441         ImportWebHelper.addImportantMessage(message);
442     }
443
444     public static void createDefaultGuestMember() throws DuplicateKeyException,
445     ObjectNotFoundException, CreateException, DatabaseException, ForeignKeyNotFoundException {
446         if ((JiveXML.guestName==null) || (JiveXML.guestName.length()<=0)) {
447             JiveXML.guestName=MVNForumConfig.getDefaultGuestName();
448         }
449         //addImportantMessage("Adding \""+JiveXML.guestName+"\" virtual guest member.");
450
ImportWebHelper.createDefaultGuestMember(JiveXML.guestName);
451     }
452
453     public static void createDefaultAdminMember() throws ObjectNotFoundException,
454     CreateException, DatabaseException, DuplicateKeyException, ForeignKeyNotFoundException {
455         if ((JiveXML.adminName==null) || (JiveXML.adminName.length()<=0)) {
456             JiveXML.adminName="Admin";
457         }
458         //addImportantMessage("Adding \""+JiveXML.adminName+"\" member with SYSTEM_ADMIN permissions.");
459
ImportWebHelper.createDefaultAdminMember(JiveXML.adminName);
460     }
461
462     public static void createDefaultRegisteredMembersGroup() throws CreateException,
463     DuplicateKeyException, ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException {
464         //addMessage("Adding default group of \"Registered Members\".");
465
ImportWebHelper.createDefaultRegisteredMembersGroup(JiveXML.adminName);
466     }
467
468     public static void createDefaultRanks() throws CreateException,
469     DuplicateKeyException, ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException {
470         //addMessage("Adding default rank titles.");
471
ImportWebHelper.createDefaultRanks();
472     }
473
474     public static void createRootCategory() throws CreateException,
475     DuplicateKeyException, ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException {
476         /* Each MVN category can have any number of it's own forums.
477          * Also, MVN supports (sub)categories in each category.
478          * Jive's forums are the same as MVN's forums, but Jive doesn't have categories at all.
479          * That means that all Jive's forums will be translated into MVN's forums that
480          * have to be put down into the one and only MVN category I must create here.
481          */

482         addMessage("Adding category \""+JiveXML.rootCategoryName+"\" where all Jive forums will be stored in.");
483         CategoryXML categoryXML=new CategoryXML();
484         categoryXML.addCategory(JiveXML.rootCategoryName, JiveXML.rootCategoryDesc,
485                     null /*categoryCreationDate*/, null /*categoryModifiedDate*/,
486                     null /*categoryOrder*/, null /*categoryOption*/, null /*categoryStatus*/);
487         JiveXML.rootCategoryID=categoryXML.getCategoryID();
488         addImportantMessage("All ForumPasswords will be set to \""+JiveXML.allForumsPassword+"\".");
489     }
490
491     private static void handleSuccess(HttpServletRequest JavaDoc request) {
492         addSuccessMessage();
493         endHtml();
494     }
495
496     //it's possible I called this method with e==null
497
private static void handleFatalError(String JavaDoc message, Exception JavaDoc e,
498              boolean clearIfError, HttpServletRequest JavaDoc request)
499     throws ImportException {
500         if (e==null) log.error(message);
501         else log.error(message, e);
502         if ((e==null) || (e.getMessage()==null)) addErrorMessage(message);
503         else addErrorMessage(message+"<br/>Cause: "+e.getMessage());
504         //try to clear the database and rollback to valid empty state with admin member
505
ImportWebHelper.addFinalErrorHandling(request, clearIfError);
506         endHtml();
507         if (e==null) throw new ImportException(message);
508         else throw new ImportException(message, e);
509     }
510
511
512 }
513
514
Popular Tags