0001: package com.mvnforum.jaxb;
0002:
0003: import java.io.FileNotFoundException;
0004: import java.io.FileOutputStream;
0005: import java.sql.Date;
0006: import java.sql.Timestamp;
0007: import java.text.ParseException;
0008: import java.util.ArrayList;
0009: import java.util.Collection;
0010: import java.util.Iterator;
0011: import java.util.List;
0012:
0013: import javax.xml.bind.JAXBException;
0014: import javax.xml.bind.Marshaller;
0015:
0016: import net.myvietnam.mvncore.exception.CreateException;
0017: import net.myvietnam.mvncore.exception.DatabaseException;
0018: import net.myvietnam.mvncore.exception.DuplicateKeyException;
0019: import net.myvietnam.mvncore.exception.ForeignKeyNotFoundException;
0020: import net.myvietnam.mvncore.exception.ObjectNotFoundException;
0021:
0022: import org.mvnforum.phpbb2mvnforum.db.MemberDAO;
0023: import org.mvnforum.phpbb2mvnforum.db.MessageDAO;
0024: import org.mvnforum.phpbb2mvnforum.db.PhpbbAuthAccess;
0025: import org.mvnforum.phpbb2mvnforum.db.PhpbbAuthAccessDAO;
0026: import org.mvnforum.phpbb2mvnforum.db.PhpbbCategories;
0027: import org.mvnforum.phpbb2mvnforum.db.PhpbbCategoriesDAO;
0028: import org.mvnforum.phpbb2mvnforum.db.PhpbbForum;
0029: import org.mvnforum.phpbb2mvnforum.db.PhpbbForumDAO;
0030: import org.mvnforum.phpbb2mvnforum.db.PhpbbGroup;
0031: import org.mvnforum.phpbb2mvnforum.db.PhpbbGroupDAO;
0032: import org.mvnforum.phpbb2mvnforum.db.PhpbbPost;
0033: import org.mvnforum.phpbb2mvnforum.db.PhpbbPostDAO;
0034: import org.mvnforum.phpbb2mvnforum.db.PhpbbPostText;
0035: import org.mvnforum.phpbb2mvnforum.db.PhpbbPostTextDAO;
0036: import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgs;
0037: import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgsDAO;
0038: import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgsTextDAO;
0039: import org.mvnforum.phpbb2mvnforum.db.PhpbbRanks;
0040: import org.mvnforum.phpbb2mvnforum.db.PhpbbRanksDAO;
0041: import org.mvnforum.phpbb2mvnforum.db.PhpbbTopics;
0042: import org.mvnforum.phpbb2mvnforum.db.PhpbbTopicsDAO;
0043: import org.mvnforum.phpbb2mvnforum.db.PhpbbTopicsWatch;
0044: import org.mvnforum.phpbb2mvnforum.db.PhpbbTopicsWatchDAO;
0045: import org.mvnforum.phpbb2mvnforum.db.PhpbbUserDAO;
0046: import org.mvnforum.phpbb2mvnforum.db.PhpbbUserGroup;
0047: import org.mvnforum.phpbb2mvnforum.db.PhpbbUserGroupDAO;
0048: import org.mvnforum.phpbb2mvnforum.db.PhpbbUsers;
0049: import org.mvnforum.phpbb2mvnforum.db.jdbc.DAOFactory;
0050: import org.mvnforum.util.MD5;
0051: import org.mvnforum.util.Utils;
0052:
0053: import com.mvnforum.db.GroupPermissionDAO;
0054: import com.mvnforum.db.GroupsDAO;
0055: import com.mvnforum.db.MemberPermissionDAO;
0056: import com.mvnforum.db.MessageFolderDAO;
0057: import com.mvnforum.db.RankDAO;
0058: import com.mvnforum.db.WatchDAO;
0059: import com.mvnforum.jaxb.dao.CategoryListDAO;
0060: import com.mvnforum.jaxb.dao.GroupListDAO;
0061: import com.mvnforum.jaxb.dao.MemberListDAO;
0062: import com.mvnforum.jaxb.dao.RankListDAO;
0063: import com.mvnforum.jaxb.db.AttachmentList;
0064: import com.mvnforum.jaxb.db.CategoryListType;
0065: import com.mvnforum.jaxb.db.CategoryType;
0066: import com.mvnforum.jaxb.db.CategoryWatchList;
0067: import com.mvnforum.jaxb.db.FavoriteThreadList;
0068: import com.mvnforum.jaxb.db.ForumList;
0069: import com.mvnforum.jaxb.db.ForumType;
0070: import com.mvnforum.jaxb.db.ForumWatchList;
0071: import com.mvnforum.jaxb.db.GlobalPermissionList;
0072: import com.mvnforum.jaxb.db.GlobalWatchList;
0073: import com.mvnforum.jaxb.db.GlobalWatchType;
0074: import com.mvnforum.jaxb.db.GroupForumPermissionList;
0075: import com.mvnforum.jaxb.db.GroupForumPermissionType;
0076: import com.mvnforum.jaxb.db.GroupMemberList;
0077: import com.mvnforum.jaxb.db.GroupMemberType;
0078: import com.mvnforum.jaxb.db.GroupType;
0079: import com.mvnforum.jaxb.db.MemberForumPermissionList;
0080: import com.mvnforum.jaxb.db.MemberType;
0081: import com.mvnforum.jaxb.db.MessageFolderList;
0082: import com.mvnforum.jaxb.db.MessageFolderType;
0083: import com.mvnforum.jaxb.db.MessageList;
0084: import com.mvnforum.jaxb.db.MessageType;
0085: import com.mvnforum.jaxb.db.Mvnforum;
0086: import com.mvnforum.jaxb.db.ObjectFactory;
0087: import com.mvnforum.jaxb.db.PostList;
0088: import com.mvnforum.jaxb.db.PostType;
0089: import com.mvnforum.jaxb.db.RankType;
0090: import com.mvnforum.jaxb.db.ThreadList;
0091: import com.mvnforum.jaxb.db.ThreadType;
0092: import com.mvnforum.jaxb.db.ThreadWatchList;
0093: import com.mvnforum.jaxb.db.ThreadWatchType;
0094: import com.mvnforum.jaxb.db.MvnforumType.GroupListType;
0095: import com.mvnforum.jaxb.db.MvnforumType.MemberListType;
0096: import com.mvnforum.jaxb.db.MvnforumType.RankListType;
0097: import com.mvnforum.jaxb.util.ImportExportUtil;
0098: import com.mvnforum.jaxb.util.XMLUtil;
0099:
0100: public class ImportExportXML {
0101:
0102: private Mvnforum mvnforum = null;
0103:
0104: private static DAOFactory factory = new DAOFactory();
0105:
0106: private static int GROUP_ADMIN_PERMISSION = 100;
0107:
0108: private static int GROUP_GUEST_PERMISSION = 109;
0109:
0110: private static int ADMIN_ID = 1;
0111:
0112: private static int GUEST_ID = 2;
0113:
0114: public ImportExportXML() throws JAXBException {
0115: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
0116: mvnforum = objectFactory.createMvnforum();
0117: }
0118:
0119: public void exportGroupList() throws JAXBException,
0120: DatabaseException, ObjectNotFoundException {
0121: GroupListDAO groupListDAO = new GroupListDAO();
0122: PhpbbGroupDAO phpbbGroupDAO = factory.getPhpbbGroupDAO();
0123: PhpbbUserGroupDAO phpbbUserGroupDAO = factory
0124: .getPhpbbUserGroupDAO();
0125: PhpbbUserDAO phpbbUserDAO = factory.getPhpUserDAO();
0126:
0127: Collection beans = phpbbGroupDAO.getBeans();
0128: Collection groupTypes = new ArrayList();
0129:
0130: for (Iterator groupIter = beans.iterator(); groupIter.hasNext();) {
0131: PhpbbGroup phpbbGroup = (PhpbbGroup) groupIter.next();
0132: int groupID = phpbbGroup.getgroup_id();
0133: String groupName = phpbbGroup.getgroup_name();
0134: String groupOwnerName = "";
0135: if (!(groupName.equalsIgnoreCase("Anonymous") || groupName
0136: .equalsIgnoreCase("Admin"))) {
0137: int groupOwnerID = phpbbGroup.getgroup_moderator();
0138: if (groupOwnerID == 0)
0139: continue;
0140: groupOwnerName = phpbbUserDAO
0141: .getUserNameFromUserID(groupOwnerID);
0142: }
0143: int groupOption = 0;
0144: String groupDesc = phpbbGroup.getgroup_description();
0145:
0146: Collection userGroupBeans = phpbbUserGroupDAO
0147: .getBeansByGroupID(groupID);
0148:
0149: Collection groupMemberTypes = new ArrayList();
0150: for (Iterator userGroupIter = userGroupBeans.iterator(); userGroupIter
0151: .hasNext();) {
0152: PhpbbUserGroup phpbbUserGroup = (PhpbbUserGroup) userGroupIter
0153: .next();
0154: int memberID = phpbbUserGroup.getuser_id();
0155: String memberName = phpbbUserDAO
0156: .getUserNameFromUserID(memberID);
0157:
0158: int privilege = 0;
0159: String creationDate = ImportExportUtil
0160: .dateTimeFormat(new Timestamp(0));
0161: String modifiedDate = creationDate;
0162: GroupMemberType groupMemberType = groupListDAO
0163: .getGroupMemberType(memberName, privilege,
0164: creationDate, modifiedDate);
0165: groupMemberTypes.add(groupMemberType);
0166: }
0167: GroupMemberList groupMemberList = groupListDAO
0168: .getGroupMemberList(groupMemberTypes);
0169:
0170: //phpbb doesn't has globalPermission for Group, so I'll set permission only for Admin's group and
0171: //Guest's group
0172: Collection globalPermissionList = new ArrayList();
0173: if (groupName.equalsIgnoreCase("Anonymous")) {
0174: globalPermissionList.add(new Integer(
0175: GROUP_GUEST_PERMISSION));
0176: }
0177: if (groupName.equalsIgnoreCase("Admin")) {
0178: globalPermissionList.add(new Integer(
0179: GROUP_ADMIN_PERMISSION));
0180: }
0181: GlobalPermissionList globalPermissionLists = groupListDAO
0182: .getGlobalPermissionList(globalPermissionList);
0183: //////////////////////////////////
0184: String groupCreationDate = ImportExportUtil
0185: .dateTimeFormat(new Timestamp(0));
0186: String groupModifiedDate = ImportExportUtil
0187: .dateTimeFormat(new Timestamp(0));
0188: GroupType groupType = groupListDAO.getGroupType(groupName,
0189: groupDesc, groupOption, groupOwnerName,
0190: groupCreationDate, groupModifiedDate,
0191: globalPermissionLists, groupMemberList);
0192: groupTypes.add(groupType);
0193: }
0194:
0195: GroupListType groupListType = groupListDAO
0196: .getGroupListType(groupTypes);
0197: mvnforum.setGroupList(groupListType);
0198: }
0199:
0200: /*
0201: * TODO because rank in phpbb differ with rank in mvnforumRank, so i don't export rank.
0202: * I'll use default rank in mvnforum, so that admin must config rank.
0203: */
0204: public void exportRankList() throws JAXBException,
0205: DatabaseException {
0206: RankListDAO rankListDAO = new RankListDAO();
0207: PhpbbRanksDAO phpbbRanksDAO = factory.getPhpbbRanksDAO();
0208:
0209: Collection phpbbRanks = phpbbRanksDAO.getBeans();
0210: Collection rankTypes = new ArrayList();
0211:
0212: for (Iterator phpbbrankIter = phpbbRanks.iterator(); phpbbrankIter
0213: .hasNext();) {
0214: PhpbbRanks phpbbRank = (PhpbbRanks) phpbbrankIter.next();
0215:
0216: int rankMinposts = phpbbRank.getrank_min();
0217: int rankLevel = 0;
0218: String rankTitle = phpbbRank.getrank_title();
0219: String rankImage = phpbbRank.getrank_image();
0220: int rankType1 = 0;
0221: int rankOption = 0;
0222:
0223: RankType rankType = rankListDAO.getRankType(rankMinposts,
0224: rankLevel, rankTitle, rankImage, rankType1,
0225: rankOption);
0226: rankTypes.add(rankType);
0227: }
0228: RankListType rankListType = rankListDAO
0229: .getRankListType(rankTypes);
0230: mvnforum.setRankList(rankListType);
0231: }
0232:
0233: public void exportCategoryList() throws JAXBException,
0234: DatabaseException, ObjectNotFoundException {
0235: PhpbbCategoriesDAO phpbbCategoriesDAO = factory
0236: .getPhpbbCategoriesDAO();
0237: PhpbbForumDAO phpbbForumDAO = factory.getPhpbbForumDAO();
0238: PhpbbPostDAO phpbbPostDAO = factory.getPhpbbPostDAO();
0239: PhpbbUserDAO phpbbUserDAO = factory.getPhpUserDAO();
0240: PhpbbTopicsDAO phpbbTopicsDAO = factory.getPhpbbTopicsDAO();
0241: PhpbbPostTextDAO phpbbPostTextDAO = factory
0242: .getPhpbbPostTextDAO();
0243: PhpbbTopicsWatchDAO phpbbTopicsWatchDAO = factory
0244: .getPhpbbTopicsWatchDAO();
0245: PhpbbAuthAccessDAO phpbbAuthAccessDAO = factory
0246: .getPhpbbAuthAccessDAO();
0247: PhpbbGroupDAO phpbbGroupDAO = factory.getPhpbbGroupDAO();
0248:
0249: CategoryListDAO categoryListDAO = new CategoryListDAO();
0250: Collection phpbbCategoriesBeans = phpbbCategoriesDAO.getBeans();
0251: Collection categoryTypes = new ArrayList();
0252:
0253: for (Iterator iter = phpbbCategoriesBeans.iterator(); iter
0254: .hasNext();) {
0255: PhpbbCategories phpbbCategories = (PhpbbCategories) iter
0256: .next();
0257: int catID = phpbbCategories.getCatId();
0258:
0259: Collection forumTypes = new ArrayList();
0260: Collection phpbbForumBeans = phpbbForumDAO
0261: .getBeansByCategoryID(catID);
0262: for (Iterator forumIter = phpbbForumBeans.iterator(); forumIter
0263: .hasNext();) {
0264: PhpbbForum phpbbForum = (PhpbbForum) forumIter.next();
0265: int forumID = phpbbForum.getforum_id();
0266:
0267: Collection threadTypes = new ArrayList();
0268: Collection phpbbTopicBeans = phpbbTopicsDAO
0269: .getBeansByForumID(forumID);
0270: for (Iterator threadIter = phpbbTopicBeans.iterator(); threadIter
0271: .hasNext();) {
0272: PhpbbTopics bean = (PhpbbTopics) threadIter.next();
0273: int threadID = bean.gettopic_id();
0274:
0275: Collection postLists = new ArrayList();
0276: Collection phpbbPostBeans = phpbbPostDAO
0277: .getBeansByThreadID(threadID);
0278: for (Iterator postIter = phpbbPostBeans.iterator(); postIter
0279: .hasNext();) {
0280: PhpbbPost phpbbPost = (PhpbbPost) postIter
0281: .next();
0282: int postID = phpbbPost.getpost_id();
0283:
0284: //no information about Attach in phpbb
0285: Collection attachmentTypes = new ArrayList();
0286: //attachmentTypes.add(attachmentType);
0287: AttachmentList attachmentList = categoryListDAO
0288: .getAttachmentList(attachmentTypes);
0289:
0290: int memberID = phpbbPost.getposter_id();
0291: Collection ppidrs = phpbbPostDAO
0292: .getPostIDsFromTopicID(threadID);
0293: int ppid = 0;
0294: for (Iterator ppidrsIter = ppidrs.iterator(); ppidrsIter
0295: .hasNext();) {
0296: PhpbbPost phpbbPost_Top = (PhpbbPost) ppidrsIter
0297: .next();
0298: int ppidtmp = phpbbPost_Top.getpost_id();
0299: if (ppidtmp == postID)
0300: break;
0301: else
0302: ppid = ppidtmp;
0303: }
0304:
0305: String memberName = phpbbUserDAO
0306: .getUserNameFromUserID(memberID);
0307:
0308: String lastEditMemberName = memberName;
0309: PhpbbPostText phpbbPostText = phpbbPostTextDAO
0310: .getBean(postID);
0311: String postTopic = ImportExportUtil
0312: .wrapit(phpbbPostText.getpost_subject());
0313: String postBody = ImportExportUtil
0314: .wrapit(phpbbPostText.getpost_text());
0315:
0316: String postCreationDate = ImportExportUtil
0317: .dateTimeFormat((long) phpbbPost
0318: .getpost_time());
0319: String postLastEditDate = postCreationDate;
0320: String postCreationIP = ImportExportUtil
0321: .wrapit(ImportExportUtil
0322: .HexIPtoString(phpbbPost
0323: .getposter_ip()));
0324: String postLastEditIP = postCreationIP;
0325: int postEditCount = phpbbPost
0326: .getpost_edit_count();
0327: int postFormatOption = 0;
0328: int postOption = 0;
0329: int postStatus = 0;
0330: String postIcon = "";
0331: int postAttachCount = 0;
0332:
0333: PostType postType = categoryListDAO
0334: .getPostType(memberName,
0335: lastEditMemberName, postTopic,
0336: postBody, postCreationDate,
0337: postLastEditDate,
0338: postCreationIP, postLastEditIP,
0339: postEditCount,
0340: postFormatOption, postOption,
0341: postStatus, postIcon,
0342: postAttachCount,
0343: attachmentList, categoryListDAO
0344: .getPortList());
0345: postLists.add(postType);
0346: }
0347: PostList postList = categoryListDAO
0348: .getPostList(postLists);
0349: ///////////////////////////
0350:
0351: //no information about favoriteThreadTypes in phpbb
0352: Collection favoriteThreadTypes = new ArrayList();
0353: FavoriteThreadList favoriteThreadList = categoryListDAO
0354: .getFavoriteThreadList(favoriteThreadTypes);
0355: //////////////////////////
0356:
0357: //phpbb contains only thread_watch, category_watch and forum_watch can find out by thread_id
0358: Collection threadWatchTypes = new ArrayList();
0359: Collection phpbbTopicWatchs = phpbbTopicsWatchDAO
0360: .getBeansByTopicID(threadID);
0361: for (Iterator topicWatchIter = phpbbTopicWatchs
0362: .iterator(); topicWatchIter.hasNext();) {
0363: PhpbbTopicsWatch phpbbTopicsWatch = (PhpbbTopicsWatch) topicWatchIter
0364: .next();
0365: int memberID = phpbbTopicsWatch.getuser_id();
0366: String memberName = phpbbUserDAO
0367: .getUserNameFromUserID(memberID);
0368: int watchType = 0;
0369: int watchOption = 0;
0370: int watchStatus = 0;
0371: String watchCreationDate = ImportExportUtil
0372: .dateTimeFormat(new Timestamp(0));
0373: String watchLastSentDate = watchCreationDate;
0374: String watchEndDate = watchCreationDate;
0375:
0376: ThreadWatchType threadWatchType = categoryListDAO
0377: .getThreadWatchType(memberName,
0378: watchType, watchOption,
0379: watchStatus, watchCreationDate,
0380: watchLastSentDate, watchEndDate);
0381: threadWatchTypes.add(threadWatchType);
0382: }
0383: ThreadWatchList threadWatchList = categoryListDAO
0384: .getThreadWatchList(threadWatchTypes);
0385:
0386: int memberID = bean.gettopic_poster();
0387: String memberName = memberName = phpbbUserDAO
0388: .getUserNameFromUserID(memberID);
0389:
0390: String lastPostMemberName = lastPostMemberName = phpbbUserDAO
0391: .getUserNameFromUserID(memberID);
0392: String threadTopic = bean.gettopic_title();
0393:
0394: String threadBody = "";
0395: int first_post_id = bean.gettopic_first_post_id();
0396: try {
0397: threadBody = phpbbPostTextDAO
0398: .getPostTextFromPostID(first_post_id);
0399: } catch (ObjectNotFoundException oe) {
0400: }
0401: threadBody = ImportExportUtil
0402: .wrapit(ImportExportUtil
0403: .stripPHPBBQuotes(threadBody));
0404:
0405: int threadVoteCount = 0;
0406: int threadVoteTotalStars = 0;
0407: String threadCreationDate = ImportExportUtil
0408: .dateTimeFormat((int) bean.gettopic_time());
0409:
0410: String threadLastPostDate = ImportExportUtil
0411: .dateTimeFormat(new Timestamp(0));
0412: int last_post_id = bean.gettopic_last_post_id();
0413: try {
0414: threadLastPostDate = ImportExportUtil
0415: .dateTimeFormat(phpbbPostDAO
0416: .getPostTimeFromPostID(last_post_id));
0417: } catch (ObjectNotFoundException oe) {
0418: }
0419:
0420: int threadType1 = 0;
0421: int threadOption = 0;
0422: int threadStatus = bean.gettopic_status();
0423: int threadHasPoll = bean.gettopic_vote();
0424: int threadViewCount = bean.gettopic_views();
0425: int threadReplyCount = bean.gettopic_replies();
0426: String threadIcon = "";
0427: int threadDuration = 0;
0428: //int threadAttachCount = 0;
0429: ThreadType threadType = categoryListDAO
0430: .getThreadType(memberName,
0431: lastPostMemberName, threadTopic,
0432: threadBody, threadVoteCount,
0433: threadVoteTotalStars,
0434: threadCreationDate,
0435: threadLastPostDate, threadType1,
0436: threadOption, threadStatus,
0437: threadHasPoll, threadViewCount,
0438: threadReplyCount, threadIcon,
0439: threadDuration, threadWatchList,
0440: favoriteThreadList, postList);
0441: threadTypes.add(threadType);
0442: }
0443: ThreadList threadList = categoryListDAO
0444: .getThreadList(threadTypes);
0445: /////////////////////////////
0446: //phpbb contains only threadWatch.
0447: Collection forumWatchLists = new ArrayList();
0448: ForumWatchList forumWatchList = categoryListDAO
0449: .getForumWatchList(forumWatchLists);
0450: /////////////////////////////
0451:
0452: Collection groupForumPermissionTypes = new ArrayList();
0453: Collection phpbbAuthAccesses = phpbbAuthAccessDAO
0454: .getBeansByForumID(forumID);
0455: for (Iterator authIter = phpbbAuthAccesses.iterator(); authIter
0456: .hasNext();) {
0457: PhpbbAuthAccess phpbbAuthAccess = (PhpbbAuthAccess) authIter
0458: .next();
0459:
0460: int groupID = phpbbAuthAccess.getgroup_id();
0461: PhpbbGroup phpbbGroup = phpbbGroupDAO
0462: .getTruthGroup(groupID);
0463: if (phpbbGroup == null)
0464: continue;
0465: String groupName = phpbbGroup.getgroup_name();
0466:
0467: if (phpbbAuthAccess.getauth_mod() == 1) {
0468: GroupForumPermissionType groupForumPermissionType = categoryListDAO
0469: .getGroupForumPermissionType(groupName,
0470: 106);
0471: groupForumPermissionTypes
0472: .add(groupForumPermissionType);
0473: }
0474:
0475: if (phpbbAuthAccess.getauth_edit() == 1) {
0476: GroupForumPermissionType groupForumPermissionType = categoryListDAO
0477: .getGroupForumPermissionType(groupName,
0478: 2000);
0479: GroupForumPermissionType groupForumPermissionType1 = categoryListDAO
0480: .getGroupForumPermissionType(groupName,
0481: 2103);
0482: groupForumPermissionTypes
0483: .add(groupForumPermissionType);
0484: groupForumPermissionTypes
0485: .add(groupForumPermissionType1);
0486: }
0487:
0488: if (phpbbAuthAccess.getauth_delete() == 1) {
0489: GroupForumPermissionType groupForumPermissionType = categoryListDAO
0490: .getGroupForumPermissionType(groupName,
0491: 2001);
0492: GroupForumPermissionType groupForumPermissionType1 = categoryListDAO
0493: .getGroupForumPermissionType(groupName,
0494: 2104);
0495: groupForumPermissionTypes
0496: .add(groupForumPermissionType);
0497: groupForumPermissionTypes
0498: .add(groupForumPermissionType1);
0499: }
0500:
0501: if (phpbbAuthAccess.getauth_pollcreate() == 1) {
0502: GroupForumPermissionType groupForumPermissionType = categoryListDAO
0503: .getGroupForumPermissionType(groupName,
0504: 2105);
0505: GroupForumPermissionType groupForumPermissionType1 = categoryListDAO
0506: .getGroupForumPermissionType(groupName,
0507: 2106);
0508: GroupForumPermissionType groupForumPermissionType2 = categoryListDAO
0509: .getGroupForumPermissionType(groupName,
0510: 2107);
0511: groupForumPermissionTypes
0512: .add(groupForumPermissionType);
0513: groupForumPermissionTypes
0514: .add(groupForumPermissionType1);
0515: groupForumPermissionTypes
0516: .add(groupForumPermissionType2);
0517: }
0518:
0519: if (phpbbAuthAccess.getauth_attachments() == 1) {
0520: GroupForumPermissionType groupForumPermissionType = categoryListDAO
0521: .getGroupForumPermissionType(groupName,
0522: 2109);
0523: GroupForumPermissionType groupForumPermissionType1 = categoryListDAO
0524: .getGroupForumPermissionType(groupName,
0525: 2108);
0526: groupForumPermissionTypes
0527: .add(groupForumPermissionType);
0528: groupForumPermissionTypes
0529: .add(groupForumPermissionType1);
0530: }
0531:
0532: /*GroupForumPermissionType groupForumPermissionType = categoryListDAO.getGroupForumPermissionType("Administrator", 12);
0533: groupForumPermissionTypes.add(groupForumPermissionType);*/
0534: }
0535:
0536: GroupForumPermissionList groupForumPermissionList = categoryListDAO
0537: .getGroupForumPermissionList(groupForumPermissionTypes);
0538: /////////////////////////////
0539: Collection memberForumPermissionTypes = new ArrayList();
0540: /*MemberForumPermissionType memberForumPermissionType = categoryListDAO.getMemberForumPermissionType("admin", 12);
0541: memberForumPermissionTypes.add(memberForumPermissionType);*/
0542: MemberForumPermissionList memberForumPermissionList = categoryListDAO
0543: .getMemberForumPermissionList(memberForumPermissionTypes);
0544: /////////////////////////////
0545: //int categoryID = phpbbForum.getcat_id();
0546: int last_post_id = phpbbForum.getforum_last_post_id();
0547: if (last_post_id == 0) {
0548: continue;
0549: }
0550: String lastPostMemberName = phpbbUserDAO
0551: .getUserNameFromUserID(phpbbPostDAO
0552: .getPosterIDFromPostID(last_post_id));
0553: /*if (last_post_id == PHPBB_ADMIN_ID) {
0554: lastPostMemberName = "Admin";
0555: } else {
0556: if (last_post_id == PHPBB_GUEST_ID) {
0557: lastPostMemberName = "Guest";
0558: } else {
0559: lastPostMemberName = phpbbUserDAO.getUserNameFromUserID(phpbbPostDAO
0560: .getPosterIDFromPostID(last_post_id));
0561: }
0562: }*/
0563: String forumName = phpbbForum.getforum_name();
0564: String forumDesc = phpbbForum.getforum_desc();
0565: String forumCreationDate = ImportExportUtil
0566: .dateTimeFormat(new Timestamp(0));
0567: String forumModifiedDate = forumCreationDate;
0568: String forumLastPostDate = forumCreationDate;
0569: int forumOrder = phpbbForum.getforum_order();
0570: //int forumType1 = 0;
0571: int forumFormatOption = 0;
0572: int forumOption = 0;
0573: int forumStatus = phpbbForum.getforum_status();
0574: int forumModerationMode = 0;
0575: String forumPassword = "";
0576: int forumThreadCount = phpbbForum.getforum_topics();
0577: int forumPostCount = phpbbForum.getforum_posts();
0578:
0579: ForumType forumType = categoryListDAO.getForumType(
0580: lastPostMemberName, forumName, forumDesc,
0581: forumCreationDate, forumModifiedDate,
0582: forumLastPostDate, forumOrder,
0583: forumFormatOption, forumOption, forumStatus,
0584: forumModerationMode, forumPassword,
0585: forumThreadCount, forumPostCount,
0586: memberForumPermissionList,
0587: groupForumPermissionList, forumWatchList,
0588: threadList);
0589: forumTypes.add(forumType);
0590:
0591: }
0592:
0593: ForumList forumList = categoryListDAO
0594: .getForumList(forumTypes);
0595: ///////////////////////////////////////////
0596: Collection categoryWatchs = new ArrayList();
0597: //categoryWatchs.add("CategoryWatchList");
0598: CategoryWatchList categoryWatchList = categoryListDAO
0599: .getCategoryWatchList(categoryWatchs);
0600: ///////////////////////////////////////////
0601: //int parentCategoryID = 0;
0602: String categoryName = phpbbCategories.getCatTitle();
0603: String categoryDesc = "";
0604: String categoryCreationDate = ImportExportUtil
0605: .dateTimeFormat(new Timestamp(0));
0606: String categoryModifiedDate = categoryCreationDate;
0607: int categoryOrder = phpbbCategories.getCatOrder();
0608: int categoryOption = 0;
0609: int categoryStatus = 0;
0610:
0611: CategoryType categoryType = categoryListDAO
0612: .getCategoryType(categoryName, categoryDesc,
0613: categoryCreationDate, categoryModifiedDate,
0614: categoryOrder, categoryOption,
0615: categoryStatus, categoryWatchList,
0616: forumList, categoryListDAO
0617: .getCategoryListType());
0618: categoryTypes.add(categoryType);
0619: }
0620: CategoryListType categoryListType = categoryListDAO
0621: .getCategoryListType(categoryTypes);
0622:
0623: mvnforum.setCategoryList(categoryListType);
0624: }
0625:
0626: public void exportMemberList() throws DatabaseException,
0627: JAXBException, ObjectNotFoundException {
0628: PhpbbUserDAO phpbbUserDAO = factory.getPhpUserDAO();
0629: PhpbbPrivmMsgsDAO phpbbPrivmMsgsDAO = factory
0630: .getPhpbbPrivmMsgsDAO();
0631: PhpbbTopicsWatchDAO phpbbTopicsWatchDAO = factory
0632: .getPhpbbTopicsWatchDAO();
0633: PhpbbPrivmMsgsTextDAO phpbbPrivmMsgsTextDAO = factory
0634: .getPhpbbPrivmMsgsTextDAO();
0635:
0636: MemberListDAO memberDAO = new MemberListDAO();
0637:
0638: Collection phpbbUserBeans = phpbbUserDAO.getBeans();
0639: Collection memberTypes = new ArrayList();
0640:
0641: for (Iterator iter = phpbbUserBeans.iterator(); iter.hasNext();) {
0642: PhpbbUsers bean = (PhpbbUsers) iter.next();
0643: int memberID = bean.getUserId();
0644: String memberName = bean.getUsername();
0645: ////////////////////////////////
0646: Collection globalWatchLists = new ArrayList();
0647: Collection phpbbTopicWatchs = phpbbTopicsWatchDAO.getBeans(
0648: memberID, 0);
0649: for (Iterator topicWatchIter = phpbbTopicWatchs.iterator(); topicWatchIter
0650: .hasNext();) {
0651: int watchType = 0;
0652: int watchOption = 0;
0653: int watchStatus = 0;
0654: String watchCreationDate = ImportExportUtil
0655: .dateTimeFormat(new Timestamp(0));
0656: String watchLastSentDate = watchCreationDate;
0657: String watchEndDate = watchCreationDate;
0658:
0659: GlobalWatchType globalWatchType = memberDAO
0660: .getGlobalWatchType(watchType, watchOption,
0661: watchStatus, watchCreationDate,
0662: watchLastSentDate, watchEndDate);
0663: globalWatchLists.add(globalWatchType);
0664: }
0665: GlobalWatchList globalWatchList = memberDAO
0666: .getGlobalWatchList(globalWatchLists);
0667: ////////////////////////////////
0668: Collection messageFolders = new ArrayList();
0669: //phpbb don't allow user create new message folder, so every user has 4 message folder Inbox, Sent, Out,
0670: //Save
0671:
0672: //Inbox contains message receive, don't save
0673: String folderCreationDate = ImportExportUtil
0674: .dateTimeFormat(new Timestamp(0));
0675: String folderModifiedDate = folderCreationDate;
0676:
0677: Collection messageTypesInSaveBox = new ArrayList();
0678: Collection saveBoxMessages = phpbbPrivmMsgsDAO
0679: .getBeansByType(3, memberID);
0680: for (Iterator receiveIter = saveBoxMessages.iterator(); receiveIter
0681: .hasNext();) {
0682: PhpbbPrivmMsgs phpbbPrivmMsgs = (PhpbbPrivmMsgs) receiveIter
0683: .next();
0684: int messageID = phpbbPrivmMsgs.getprivmsgs_id();
0685: int receiverID = phpbbPrivmMsgs
0686: .getprivmsgs_from_userid();
0687: String messageSenderName = phpbbUserDAO
0688: .getUserNameFromUserID(receiverID);
0689: String messageToList = memberName;
0690: String folderName = "SaveBox";
0691: String messageCcList = "";
0692: String messageBccList = "";
0693: String messageTopic = Utils.wrapIt(phpbbPrivmMsgs
0694: .getprivmsgs_subject());
0695: String messageBody = Utils.wrapIt(phpbbPrivmMsgsTextDAO
0696: .getBean(messageID).getprivmsgs_text());
0697: int messageType = 0;
0698: int messageOption = 0;
0699: int messageStatus = 0;
0700: int messageReadStatus = 1;
0701: int messageNotify = 0;
0702: String messageIcon = "";
0703: int messageAttachCount = 0;
0704: String messageIP = Utils
0705: .wrapIt(Utils.HexIPtoString(phpbbPrivmMsgs
0706: .getprivmsgs_ip()));
0707: String messageCreationDate = ImportExportUtil
0708: .dateTimeFormat(phpbbPrivmMsgs
0709: .getprivmsgs_date());
0710:
0711: MessageType messageType2 = memberDAO.getMessageType(
0712: folderName, messageSenderName, messageToList,
0713: messageCcList, messageBccList, messageTopic,
0714: messageBody, messageType, messageOption,
0715: messageStatus, messageReadStatus,
0716: messageNotify, messageIcon, messageAttachCount,
0717: messageIP, messageCreationDate);
0718: messageTypesInSaveBox.add(messageType2);
0719: }
0720: MessageList messageListInSaveBox = memberDAO
0721: .getMessageList(messageTypesInSaveBox);
0722:
0723: MessageFolderType inboxFolder = memberDAO
0724: .getMessageFolderType("SaveBox", 0,
0725: folderCreationDate, folderModifiedDate,
0726: messageListInSaveBox);
0727: messageFolders.add(inboxFolder);
0728:
0729: //SentBox contains all of messages has type = 2. Sent box contains messages you sent to your contact and he
0730: //has read it
0731: Collection messageTypesInSentBox = new ArrayList();
0732: Collection sentBoxMessages = phpbbPrivmMsgsDAO
0733: .getBeansByTypeAndReceiveUser(2, memberID);
0734: for (Iterator receiveIter = sentBoxMessages.iterator(); receiveIter
0735: .hasNext();) {
0736: PhpbbPrivmMsgs phpbbPrivmMsgs = (PhpbbPrivmMsgs) receiveIter
0737: .next();
0738: int messageID = phpbbPrivmMsgs.getprivmsgs_id();
0739: String folderName = "SentBox";
0740: String messageSenderName = memberName;
0741: int receiverID = phpbbPrivmMsgs
0742: .getprivmsgs_from_userid();
0743: String messageToList = phpbbUserDAO
0744: .getUserNameFromUserID(receiverID);
0745: String messageCcList = "";
0746: String messageBccList = "";
0747: String messageTopic = Utils.wrapIt(phpbbPrivmMsgs
0748: .getprivmsgs_subject());
0749: String messageBody = Utils.wrapIt(phpbbPrivmMsgsTextDAO
0750: .getBean(messageID).getprivmsgs_text());
0751: int messageType = 0;
0752: int messageOption = 0;
0753: int messageStatus = 0;
0754: int messageReadStatus = 1;
0755: int messageNotify = 0;
0756: String messageIcon = "";
0757: int messageAttachCount = 0;
0758: String messageIP = Utils
0759: .wrapIt(Utils.HexIPtoString(phpbbPrivmMsgs
0760: .getprivmsgs_ip()));
0761: String messageCreationDate = ImportExportUtil
0762: .dateTimeFormat(phpbbPrivmMsgs
0763: .getprivmsgs_date());
0764:
0765: MessageType messageType2 = memberDAO.getMessageType(
0766: folderName, messageSenderName, messageToList,
0767: messageCcList, messageBccList, messageTopic,
0768: messageBody, messageType, messageOption,
0769: messageStatus, messageReadStatus,
0770: messageNotify, messageIcon, messageAttachCount,
0771: messageIP, messageCreationDate);
0772: messageTypesInSentBox.add(messageType2);
0773: }
0774: MessageList messageListInSentBox = memberDAO
0775: .getMessageList(messageTypesInSentBox);
0776: //SentBox contains message you sent and your contact has read it.
0777: MessageFolderType sendFolder = memberDAO
0778: .getMessageFolderType("SentBox", 1,
0779: folderCreationDate, folderModifiedDate,
0780: messageListInSentBox);
0781: messageFolders.add(sendFolder);
0782:
0783: Collection messageTypesInOutBox = new ArrayList();
0784: //OutBox contains all of messages has type = 1 or 5. OutBox contains messages you sent to your contact, and
0785: //your contact hasn't read it.
0786: Collection outBoxMessage = phpbbPrivmMsgsDAO
0787: .getBeansByTypeAndReceiveUser(1, memberID);
0788: Collection outBoxMessage1 = phpbbPrivmMsgsDAO
0789: .getBeansByTypeAndReceiveUser(5, memberID);
0790:
0791: for (Iterator iter1 = outBoxMessage1.iterator(); iter1
0792: .hasNext();) {
0793: outBoxMessage.add(iter1.next());
0794: }
0795:
0796: for (Iterator receiveIter = outBoxMessage.iterator(); receiveIter
0797: .hasNext();) {
0798: PhpbbPrivmMsgs phpbbPrivmMsgs = (PhpbbPrivmMsgs) receiveIter
0799: .next();
0800: int messageID = phpbbPrivmMsgs.getprivmsgs_id();
0801: String folderName = "OutBox";
0802: String messageSenderName = memberName;
0803: int receiverID = phpbbPrivmMsgs
0804: .getprivmsgs_from_userid();
0805: String messageToList = phpbbUserDAO
0806: .getUserNameFromUserID(receiverID);
0807: String messageCcList = "";
0808: String messageBccList = "";
0809: String messageTopic = Utils.wrapIt(phpbbPrivmMsgs
0810: .getprivmsgs_subject());
0811: String messageBody = Utils.wrapIt(phpbbPrivmMsgsTextDAO
0812: .getBean(messageID).getprivmsgs_text());
0813: int messageType = 0;
0814: int messageOption = 0;
0815: int messageStatus = 0;
0816: int messageReadStatus = 0;
0817: int messageNotify = 0;
0818: String messageIcon = "";
0819: int messageAttachCount = 0;
0820: String messageIP = Utils
0821: .wrapIt(Utils.HexIPtoString(phpbbPrivmMsgs
0822: .getprivmsgs_ip()));
0823: String messageCreationDate = ImportExportUtil
0824: .dateTimeFormat(phpbbPrivmMsgs
0825: .getprivmsgs_date());
0826:
0827: MessageType messageType2 = memberDAO.getMessageType(
0828: folderName, messageSenderName, messageToList,
0829: messageCcList, messageBccList, messageTopic,
0830: messageBody, messageType, messageOption,
0831: messageStatus, messageReadStatus,
0832: messageNotify, messageIcon, messageAttachCount,
0833: messageIP, messageCreationDate);
0834: messageTypesInOutBox.add(messageType2);
0835: }
0836: MessageList messageListInOutBox = memberDAO
0837: .getMessageList(messageTypesInOutBox);
0838: //Out box contains message sent so outBox Order must be 2
0839: MessageFolderType draftFolder = memberDAO
0840: .getMessageFolderType("OutBox", 2,
0841: folderCreationDate, folderModifiedDate,
0842: messageListInOutBox);
0843: messageFolders.add(draftFolder);
0844:
0845: Collection messageTypesInInBox = new ArrayList();
0846: //InBox contains all of messages has type = 1 or 5 or 0
0847: Collection inBoxMessage = phpbbPrivmMsgsDAO.getBeansByType(
0848: 1, memberID);
0849: Collection inboxMessage1 = phpbbPrivmMsgsDAO
0850: .getBeansByType(5, memberID);
0851: Collection inboxMessage2 = phpbbPrivmMsgsDAO
0852: .getBeansByType(0, memberID);
0853:
0854: for (Iterator iter1 = inboxMessage1.iterator(); iter1
0855: .hasNext();) {
0856: inBoxMessage.add(iter1.next());
0857: }
0858:
0859: for (Iterator iter1 = inboxMessage2.iterator(); iter1
0860: .hasNext();) {
0861: inBoxMessage.add(iter1.next());
0862: }
0863:
0864: outBoxMessage.add(phpbbPrivmMsgsDAO.getBeansByType(5,
0865: memberID));
0866: outBoxMessage.add(phpbbPrivmMsgsDAO.getBeansByType(0,
0867: memberID));
0868: for (Iterator receiveIter = inBoxMessage.iterator(); receiveIter
0869: .hasNext();) {
0870: PhpbbPrivmMsgs phpbbPrivmMsgs = (PhpbbPrivmMsgs) receiveIter
0871: .next();
0872: int messageID = phpbbPrivmMsgs.getprivmsgs_id();
0873: String folderName = "InBox";
0874: int receiverID = phpbbPrivmMsgs
0875: .getprivmsgs_from_userid();
0876: String messageSenderName = phpbbUserDAO
0877: .getUserNameFromUserID(receiverID);
0878: String messageToList = memberName;
0879: String messageCcList = "";
0880: String messageBccList = "";
0881: String messageTopic = Utils.wrapIt(phpbbPrivmMsgs
0882: .getprivmsgs_subject());
0883: String messageBody = Utils.wrapIt(phpbbPrivmMsgsTextDAO
0884: .getBean(messageID).getprivmsgs_text());
0885: int messageType = 0;
0886: int messageOption = 0;
0887: int messageStatus = 0;
0888: int messageRead = phpbbPrivmMsgs.getprivmsgs_type();
0889: int messageReadStatus = (messageRead == 5)
0890: || (messageRead == 1) ? 0 : 1;
0891: int messageNotify = 0;
0892: String messageIcon = "";
0893: int messageAttachCount = 0;
0894: String messageIP = Utils
0895: .wrapIt(Utils.HexIPtoString(phpbbPrivmMsgs
0896: .getprivmsgs_ip()));
0897: String messageCreationDate = ImportExportUtil
0898: .dateTimeFormat(phpbbPrivmMsgs
0899: .getprivmsgs_date());
0900:
0901: MessageType messageType2 = memberDAO.getMessageType(
0902: folderName, messageSenderName, messageToList,
0903: messageCcList, messageBccList, messageTopic,
0904: messageBody, messageType, messageOption,
0905: messageStatus, messageReadStatus,
0906: messageNotify, messageIcon, messageAttachCount,
0907: messageIP, messageCreationDate);
0908: messageTypesInInBox.add(messageType2);
0909: }
0910: MessageList messageListInInBox = memberDAO
0911: .getMessageList(messageTypesInInBox);
0912: //SaveBox contains message save
0913: MessageFolderType trashFolder = memberDAO
0914: .getMessageFolderType("InBox", 3,
0915: folderCreationDate, folderModifiedDate,
0916: messageListInInBox);
0917: messageFolders.add(trashFolder);
0918:
0919: MessageFolderList messageFolderList = memberDAO
0920: .getMessageFolderList(messageFolders);
0921: ////////////////////////////////
0922: Collection globalPermissionLists = new ArrayList();
0923: int userLevel = bean.getUserLevel();
0924: //if user is admin user
0925: if (userLevel == 1) {
0926: globalPermissionLists.add(new Integer(100));
0927: }
0928: if (userLevel == 2) {
0929: globalPermissionLists.add(new Integer(106));
0930: }
0931: GlobalPermissionList globalPermissionList = memberDAO
0932: .getGlobalPermissionList(globalPermissionLists);
0933: ////////////////////////////////
0934:
0935: String memberPassword = bean.getUserPassword();
0936: if (!memberPassword.equals("")) {
0937: memberPassword = ImportExportUtil.wrapit(MD5
0938: .getMD5_Base64(memberPassword));
0939: }
0940: String memberFirstEmail = ImportExportUtil.wrapit(bean
0941: .getUserEmail());
0942: String memberEmail = memberFirstEmail;
0943:
0944: int memberEmailVisible = bean.getUserViewemail();
0945: // Keep name invisible (no equivalent in phpbb)
0946: int memberNameVisible = 0;
0947: String memberFirstIP = "0.0.0.0";
0948: String memberLastIP = "0.0.0.0";
0949: int memberViewCount = 0;
0950: int memberPostCount = bean.getUserPosts();
0951: String memberCreationDate = ImportExportUtil
0952: .dateTimeFormat(bean.getUserRegdate());
0953: String memberModifiedDate = memberCreationDate;
0954: String memberExpireDate = memberCreationDate;
0955: String memberLastLogon = ImportExportUtil
0956: .dateTimeFormat(bean.getUserLastvisit());
0957: int memberOption = 0;
0958: int memberStatus = 0;
0959: String memberActivateCode = "";
0960: String memberTempPassword = "";
0961: int memberMessageCount = 0;
0962: int memberMessageOption = 0;
0963: int memberPostsPerPage = 10; //Default by mvnForum.
0964: int memberWarnCount = 0;
0965: int memberVoteCount = 0;
0966: int memberVoteTotalStars = 0;
0967: int memberRewardPoints = 0;
0968: String memberTitle = "";
0969:
0970: double tzone = bean.getUserTimezone().doubleValue();
0971:
0972: String memberSignature = ImportExportUtil.wrapit(bean
0973: .getUserSig());
0974: String memberAvatar = ImportExportUtil.wrapit(bean
0975: .getUserAvatar());
0976: String memberSkin = "";
0977: //replace default language
0978:
0979: //String memberLanguage = bean.getUserLang();
0980: String memberLanguage = "en";
0981:
0982: //PHPBB does not store names
0983: String memberFirstname = memberName;
0984: //because mvnforum doesn't allow empty name
0985: String memberLastname = "";
0986:
0987: //PHPBB does not store gender. This can be an issue. Everyone will be made a female
0988: int memberGender = 0;
0989: String memberBirthday = ImportExportUtil
0990: .dateTimeFormat(new Timestamp(0));
0991: String memberAddress = bean.getUserFrom();
0992: String memberCity = "";
0993: String memberState = "";
0994: String memberCountry = "";
0995: String memberPhone = "";
0996: String memberMobile = "";
0997: String memberFax = "";
0998: String memberCareer = ImportExportUtil.wrapit(bean
0999: .getUserOcc());
1000: String memberHomepage = ImportExportUtil.wrapit(bean
1001: .getUserWebsite());
1002: String memberYahoo = ImportExportUtil.wrapit(bean
1003: .getUserYim());
1004: String memberAol = ImportExportUtil.wrapit(bean
1005: .getUserAim());
1006: String memberIcq = "";
1007: String memberMsn = ImportExportUtil.wrapit(bean
1008: .getUserMsnm());
1009: // No interests collumn in MvnForum. We will just put the interests in CoolLink1 so that
1010: // no data is lost.
1011: String memberCoolLink1 = ImportExportUtil.wrapit(bean
1012: .getUserInterests());
1013: String memberCoolLink2 = "";
1014:
1015: MemberType memberType = memberDAO.getMemberList(memberName,
1016: memberPassword, memberFirstEmail, memberEmail,
1017: memberEmailVisible, memberNameVisible,
1018: memberFirstIP, memberLastIP, memberViewCount,
1019: memberPostCount, memberCreationDate,
1020: memberModifiedDate, memberExpireDate,
1021: memberLastLogon, memberOption, memberStatus,
1022: memberActivateCode, memberTempPassword,
1023: memberMessageCount, memberMessageOption,
1024: memberPostsPerPage, memberWarnCount,
1025: memberVoteCount, memberVoteTotalStars,
1026: memberRewardPoints, memberTitle, tzone,
1027: memberSignature, memberAvatar, memberSkin,
1028: memberLanguage, memberFirstname, memberLastname,
1029: memberGender, memberBirthday, memberAddress,
1030: memberCity, memberState, memberCountry,
1031: memberPhone, memberMobile, memberFax, memberCareer,
1032: memberHomepage, memberYahoo, memberAol, memberIcq,
1033: memberMsn, memberCoolLink1, memberCoolLink2,
1034: globalPermissionList, messageFolderList,
1035: globalWatchList);
1036:
1037: memberTypes.add(memberType);
1038: }
1039: MemberListType memberListType = memberDAO
1040: .getMemberListType(memberTypes);
1041: mvnforum.setMemberList(memberListType);
1042: }
1043:
1044: public void importRank() throws JAXBException, CreateException,
1045: DatabaseException, DuplicateKeyException {
1046: RankListDAO rankListDAO = new RankListDAO();
1047: RankDAO rankDAO = factory.getRankDAO();
1048: List rankTypes = rankListDAO.importRankType();
1049: for (int i = 0; i < rankTypes.size(); i++) {
1050: RankType rankType = (RankType) rankTypes.get(i);
1051:
1052: int rankMinPosts = rankType.getRankMinPosts();
1053: int rankLevel = rankType.getRankLevel();
1054: String rankTitle = rankType.getRankTitle();
1055: String rankImage = rankType.getRankImage();
1056: int rankType1 = rankType.getRankType();
1057: int rankOption = rankType.getRankOption();
1058:
1059: rankDAO.create(rankMinPosts, rankLevel, rankTitle,
1060: rankImage, rankType1, rankOption);
1061: }
1062: }
1063:
1064: public void importGroup() throws JAXBException, CreateException,
1065: DatabaseException, DuplicateKeyException,
1066: ForeignKeyNotFoundException, ParseException,
1067: ObjectNotFoundException {
1068: GroupListDAO groupListDAO = new GroupListDAO();
1069: GroupsDAO groupsDAO = factory.getGroupsDAO();
1070: GroupPermissionDAO groupPermissionDAO = factory
1071: .getGroupPermissionDAO();
1072: List groupTypes = groupListDAO.importGroupTypes();
1073:
1074: for (int i = 0; i < groupTypes.size(); i++) {
1075: GroupType groupType = (GroupType) groupTypes.get(i);
1076:
1077: String groupName = groupType.getGroupName();
1078: String groupDesc = groupType.getGroupDesc();
1079: int groupOption = groupType.getGroupOption();
1080: String groupOwnerName = groupType.getGroupOwnerName();
1081: Timestamp groupCreationDate = ImportExportUtil
1082: .string2TimeStamp(groupType.getGroupCreationDate());
1083: Timestamp groupModifiedDate = ImportExportUtil
1084: .string2TimeStamp(groupType.getGroupModifiedDate());
1085:
1086: if (groupName.equalsIgnoreCase("Anonymous")) {
1087: groupsDAO.update(1, groupName, groupDesc,
1088: groupModifiedDate);
1089: groupsDAO.updateOwner(1, groupOwnerName,
1090: groupModifiedDate);
1091: } else if (groupName.equalsIgnoreCase("Admin")) {
1092: groupsDAO.update(2, groupName, groupDesc,
1093: groupModifiedDate);
1094: groupsDAO.updateOwner(2, groupOwnerName,
1095: groupModifiedDate);
1096: } else {
1097: groupsDAO.create(groupOwnerName, groupName, groupDesc,
1098: groupOption, groupCreationDate,
1099: groupModifiedDate);
1100: }
1101: int groupID = groupsDAO.getGroupIDFromGroupName(groupName);
1102: //import to global permission:
1103: GlobalPermissionList globalPermissionList = groupType
1104: .getGlobalPermissionList();
1105: List globalPermissionLists = globalPermissionList
1106: .getGlobalPermission();
1107: for (int j = 0; j < globalPermissionLists.size(); j++) {
1108: groupPermissionDAO.create(groupID,
1109: ((Integer) globalPermissionLists.get(j))
1110: .intValue());
1111: }
1112: }
1113: }
1114:
1115: public void importMember() throws JAXBException, ParseException,
1116: CreateException, DatabaseException, DuplicateKeyException,
1117: ObjectNotFoundException, ForeignKeyNotFoundException {
1118: MemberListDAO memberListDAO = new MemberListDAO();
1119: MemberDAO memberDAO = factory.getMemberDAO();
1120: MessageFolderDAO messageFolderDAO = factory
1121: .getMessageFolderDAO();
1122: MemberPermissionDAO memberPermissionDAO = factory
1123: .getMemberPermissionDAO();
1124: MessageDAO messageDAO = factory.getMessageDAO();
1125: WatchDAO watchDAO = factory.getWatchDAO();
1126:
1127: List memeberTypes = memberListDAO.importMemberList();
1128:
1129: for (int i = 0; i < memeberTypes.size(); i++) {
1130: MemberType memberType = (MemberType) memeberTypes.get(i);
1131:
1132: String memberName = memberType.getMemberName();
1133: System.out.println("memberName " + memberName);
1134: String memberPassword = memberType.getMemberPassword()
1135: .trim();
1136: /*System.out.println("memberpassword " + memberPassword);
1137: if (!memberPassword.equals(""))
1138: memberPassword = Utils.wrapIt(MD5.getBase64FromMD5(memberPassword));*/
1139: String memberFirstEmail = memberType.getMemberFirstEmail();
1140: String memberEmail = memberType.getMemberEmail();
1141:
1142: int memberEmailVisible = memberType.getMemberEmailVisible();
1143: int memberNameVisible = memberType.getMemberNameVisible();
1144: String memberFirstIP = memberType.getMemberFirstIP();
1145: String memberLastIP = memberType.getMemberLastIP();
1146: int memberViewCount = memberType.getMemberViewCount();
1147: int memberPostCount = memberType.getMemberPostCount();
1148: Timestamp memberCreationDate = ImportExportUtil
1149: .string2TimeStamp(memberType
1150: .getMemberCreationDate());
1151: Timestamp memberModifiedDate = ImportExportUtil
1152: .string2TimeStamp(memberType
1153: .getMemberModifiedDate());
1154: Timestamp memberExpireDate = ImportExportUtil
1155: .string2TimeStamp(memberType.getMemberExpireDate());
1156: Timestamp memberLastLogon = ImportExportUtil
1157: .string2TimeStamp(memberType.getMemberLastLogon());
1158: int memberOption = memberType.getMemberOption();
1159: int memberStatus = memberType.getMemberStatus();
1160: String memberActivateCode = memberType
1161: .getMemberActivateCode();
1162: String memberTempPassword = memberType
1163: .getMemberTempPassword();
1164: int memberMessageCount = memberType.getMemberMessageCount();
1165: int memberMessageOption = memberType
1166: .getMemberMessageOption();
1167: int memberPostsPerPage = memberType.getMemberPostsPerPage();
1168: int memberWarnCount = memberType.getMemberWarnCount();
1169: int memberVoteCount = memberType.getMemberVoteCount();
1170: int memberVoteTotalStars = memberType
1171: .getMemberVoteTotalStars();
1172: int memberRewardPoints = memberType.getMemberRewardPoints();
1173: String memberTitle = memberType.getMemberTitle();
1174:
1175: double tzone = memberType.getMemberTimeZone();
1176:
1177: String memberSignature = memberType.getMemberSignature();
1178: String memberAvatar = memberType.getMemberAvatar();
1179: String memberSkin = memberType.getMemberSkin();
1180: String memberLanguage = memberType.getMemberLanguage();
1181: String memberFirstname = memberType.getMemberFirstname();
1182: String memberLastname = memberType.getMemberLastname();
1183:
1184: int memberGender = memberType.getMemberGender();
1185: Date memberBirthday = ImportExportUtil
1186: .string2Date(memberType.getMemberBirthday());
1187: String memberAddress = memberType.getMemberAddress();
1188: String memberCity = memberType.getMemberCity();
1189: String memberState = memberType.getMemberState();
1190: String memberCountry = memberType.getMemberCountry();
1191: String memberPhone = memberType.getMemberPhone();
1192: String memberMobile = memberType.getMemberMobile();
1193: String memberFax = memberType.getMemberFax();
1194: String memberCareer = memberType.getMemberCareer();
1195: String memberHomepage = memberType.getMemberHomepage();
1196: String memberYahoo = memberType.getMemberYahoo();
1197: String memberAol = memberType.getMemberAol();
1198: String memberIcq = memberType.getMemberIcq();
1199: String memberMsn = memberType.getMemberMsn();
1200: String memberCoolLink1 = memberType.getMemberCoolLink1();
1201: String memberCoolLink2 = memberType.getMemberCoolLink2();
1202:
1203: if (memberName.equalsIgnoreCase("admin")) {
1204: memberDAO.update(ADMIN_ID, memberName, memberPassword,
1205: memberFirstEmail, memberEmail,
1206: memberEmailVisible, memberNameVisible,
1207: memberFirstIP, memberLastIP, memberViewCount,
1208: memberPostCount, memberCreationDate,
1209: memberModifiedDate, memberExpireDate,
1210: memberLastLogon, memberOption, memberStatus,
1211: memberActivateCode, memberTempPassword,
1212: memberMessageCount, memberMessageOption,
1213: memberPostsPerPage, memberWarnCount,
1214: memberVoteCount, memberVoteTotalStars,
1215: memberRewardPoints, memberTitle, tzone,
1216: memberSignature, memberAvatar, memberSkin,
1217: memberLanguage, memberFirstname,
1218: memberLastname, memberGender, memberBirthday,
1219: memberAddress, memberCity, memberState,
1220: memberCountry, memberPhone, memberMobile,
1221: memberFax, memberCareer, memberHomepage,
1222: memberYahoo, memberAol, memberIcq, memberMsn,
1223: memberCoolLink1, memberCoolLink2);
1224: } else {
1225: if (memberName.equalsIgnoreCase("Anonymous")) {
1226: memberDAO
1227: .create(GUEST_ID, memberName,
1228: memberPassword, memberFirstEmail,
1229: memberEmail, memberEmailVisible,
1230: memberNameVisible, memberFirstIP,
1231: memberLastIP, memberViewCount,
1232: memberPostCount,
1233: memberCreationDate,
1234: memberModifiedDate,
1235: memberExpireDate, memberLastLogon,
1236: memberOption, memberStatus,
1237: memberActivateCode,
1238: memberTempPassword,
1239: memberMessageCount,
1240: memberMessageOption,
1241: memberPostsPerPage,
1242: memberWarnCount, memberVoteCount,
1243: memberVoteTotalStars,
1244: memberRewardPoints, memberTitle,
1245: tzone, memberSignature,
1246: memberAvatar, memberSkin,
1247: memberLanguage, memberFirstname,
1248: memberLastname, memberGender,
1249: memberBirthday, memberAddress,
1250: memberCity, memberState,
1251: memberCountry, memberPhone,
1252: memberMobile, memberFax,
1253: memberCareer, memberHomepage,
1254: memberYahoo, memberAol, memberIcq,
1255: memberMsn, memberCoolLink1,
1256: memberCoolLink2);
1257: } else {
1258: memberDAO.create(memberName, memberPassword,
1259: memberFirstEmail, memberEmail,
1260: memberEmailVisible, memberNameVisible,
1261: memberFirstIP, memberLastIP,
1262: memberViewCount, memberPostCount,
1263: memberCreationDate, memberModifiedDate,
1264: memberExpireDate, memberLastLogon,
1265: memberOption, memberStatus,
1266: memberActivateCode, memberTempPassword,
1267: memberMessageCount, memberMessageOption,
1268: memberPostsPerPage, memberWarnCount,
1269: memberVoteCount, memberVoteTotalStars,
1270: memberRewardPoints, memberTitle, tzone,
1271: memberSignature, memberAvatar, memberSkin,
1272: memberLanguage, memberFirstname,
1273: memberLastname, memberGender,
1274: memberBirthday, memberAddress, memberCity,
1275: memberState, memberCountry, memberPhone,
1276: memberMobile, memberFax, memberCareer,
1277: memberHomepage, memberYahoo, memberAol,
1278: memberIcq, memberMsn, memberCoolLink1,
1279: memberCoolLink2);
1280: }
1281: }
1282: }
1283:
1284: for (int i = 0; i < memeberTypes.size(); i++) {
1285: MemberType memberType = (MemberType) memeberTypes.get(i);
1286: String memberName = memberType.getMemberName();
1287:
1288: int memberID = memberDAO
1289: .getMemberFromMemberName(memberName).getMemberID();
1290: List messageFolderTypes = memberType.getMessageFolderList()
1291: .getMessageFolder();
1292: for (int j = 0; j < messageFolderTypes.size(); j++) {
1293: MessageFolderType messageFolderType = (MessageFolderType) messageFolderTypes
1294: .get(j);
1295:
1296: String folderName = messageFolderType.getFolderName();
1297: int folderOrder = messageFolderType.getFolderOrder();
1298: int folderStatus = 0;
1299: int folderType = 0;
1300: int folderOption = 0;
1301: Timestamp folderCreationDate = ImportExportUtil
1302: .string2TimeStamp(messageFolderType
1303: .getFolderCreationDate());
1304: Timestamp folderModifiedDate = ImportExportUtil
1305: .string2TimeStamp(messageFolderType
1306: .getFolderModifiedDate());
1307:
1308: messageFolderDAO.create(folderName, memberID,
1309: folderOrder, folderStatus, folderOption,
1310: folderType, folderCreationDate,
1311: folderModifiedDate);
1312:
1313: //export message
1314: MessageList messageList = messageFolderType
1315: .getMessageList();
1316: List messageTypes = messageList.getMessage();
1317: for (int t = 0; t < messageTypes.size(); t++) {
1318: MessageType messageType = (MessageType) messageTypes
1319: .get(t);
1320:
1321: String messageSenderName = messageType
1322: .getMessageSenderName();
1323: int messageSenderID = memberDAO
1324: .getMemberFromMemberName(messageSenderName)
1325: .getMemberID();
1326: String messageToList = messageType
1327: .getMessageToList();
1328: String messageCcList = messageType
1329: .getMessageCcList();
1330: String messageBccList = messageType
1331: .getMessageBccList();
1332: String messageTopic = messageType.getMessageTopic();
1333: String messageBody = messageType.getMessageBody();
1334: int messageType1 = messageType.getMessageType();
1335: int messageOption = messageType.getMessageOption();
1336: int messageStatus = messageType.getMessageStatus();
1337: int messageReadStatus = messageType
1338: .getMessageReadStatus();
1339: int messageNotify = messageType.getMessageNotify();
1340: String messageIcon = messageType.getMessageIcon();
1341: int messageAttachCount = messageType
1342: .getMessageAttachCount();
1343: String messageIP = messageType.getMessageIP();
1344: Timestamp messageCreationDate = ImportExportUtil
1345: .string2TimeStamp(messageType
1346: .getMessageCreationDate());
1347:
1348: messageDAO.create(folderName, memberID,
1349: messageSenderID, messageSenderName,
1350: messageToList, messageCcList,
1351: messageBccList, messageTopic, messageBody,
1352: messageType1, messageOption, messageStatus,
1353: messageReadStatus, messageNotify,
1354: messageIcon, messageAttachCount, messageIP,
1355: messageCreationDate);
1356: }
1357: }
1358:
1359: //import globalpermission
1360: List globalPermissions = memberType
1361: .getGlobalPermissionList().getGlobalPermission();
1362: for (int j = 0; j < globalPermissions.size(); j++) {
1363: int globalPermission = ((Integer) globalPermissions
1364: .get(j)).intValue();
1365: memberPermissionDAO.create(memberID, globalPermission);
1366: }
1367:
1368: //import watch list
1369: List globalWatchs = memberType.getGlobalWatchList()
1370: .getGlobalWatch();
1371: for (int j = 0; j < globalWatchs.size(); j++) {
1372: GlobalWatchType globalWatchType = (GlobalWatchType) globalWatchs
1373: .get(j);
1374:
1375: int categoryID = 0;
1376: int forumID = 0;
1377: int threadID = 0;
1378: int watchType = globalWatchType.getWatchType();
1379: int watchOption = globalWatchType.getWatchOption();
1380: int watchStatus = globalWatchType.getWatchStatus();
1381: Timestamp watchCreationDate = ImportExportUtil
1382: .string2TimeStamp(globalWatchType
1383: .getWatchCreationDate());
1384: Timestamp watchLastSentDate = ImportExportUtil
1385: .string2TimeStamp(globalWatchType
1386: .getWatchLastSentDate());
1387: Timestamp watchEndDate = ImportExportUtil
1388: .string2TimeStamp(globalWatchType
1389: .getWatchEndDate());
1390: watchDAO.create(memberID, categoryID, forumID,
1391: threadID, watchType, watchOption, watchStatus,
1392: watchCreationDate, watchLastSentDate,
1393: watchEndDate);
1394:
1395: }
1396: }
1397: }
1398:
1399: public void exportXML() throws FileNotFoundException, JAXBException {
1400: Marshaller marshaller = XMLUtil.getMarshaller();
1401: marshaller.marshal(mvnforum, new FileOutputStream(
1402: "xml/mvnforum.xml"));
1403: }
1404:
1405: public static void main(String[] args) throws CreateException,
1406: DatabaseException, DuplicateKeyException,
1407: ForeignKeyNotFoundException, ParseException,
1408: FileNotFoundException {
1409: try {
1410: ImportExportXML importExportXML = new ImportExportXML();
1411: //importExportXML.importMember();
1412: //importExportXML.exportMemberList();
1413: //importExportXML.exportGroupList();
1414: importExportXML.exportCategoryList();
1415: //importExportXML.exportRankList();
1416: importExportXML.exportXML();
1417: //importExportXML.importRank();
1418: //importExportXML.importGroup();
1419: System.out.println("done export.");
1420: } catch (JAXBException e) {
1421: // TODO Auto-generated catch block
1422: e.printStackTrace();
1423: } catch (DatabaseException e) {
1424: // TODO Auto-generated catch block
1425: e.printStackTrace();
1426: } catch (ObjectNotFoundException e) {
1427: // TODO Auto-generated catch block
1428: e.printStackTrace();
1429: }
1430:
1431: }
1432: }
|