0001: /*
0002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/MemberXML.java,v 1.16 2007/10/09 11:09:14 lexuanttkhtn Exp $
0003: * $Author: lexuanttkhtn $
0004: * $Revision: 1.16 $
0005: * $Date: 2007/10/09 11:09:14 $
0006: *
0007: * ====================================================================
0008: *
0009: * Copyright (C) 2002-2007 by MyVietnam.net
0010: *
0011: * All copyright notices regarding mvnForum MUST remain
0012: * intact in the scripts and in the outputted HTML.
0013: * The "powered by" text/logo with a link back to
0014: * http://www.mvnForum.com and http://www.MyVietnam.net in
0015: * the footer of the pages MUST remain visible when the pages
0016: * are viewed on the internet or intranet.
0017: *
0018: * This program is free software; you can redistribute it and/or modify
0019: * it under the terms of the GNU General Public License as published by
0020: * the Free Software Foundation; either version 2 of the License, or
0021: * any later version.
0022: *
0023: * This program is distributed in the hope that it will be useful,
0024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0026: * GNU General Public License for more details.
0027: *
0028: * You should have received a copy of the GNU General Public License
0029: * along with this program; if not, write to the Free Software
0030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0031: *
0032: * Support can be obtained from support forums at:
0033: * http://www.mvnForum.com/mvnforum/index
0034: *
0035: * Correspondence and Marketing Questions can be sent to:
0036: * info at MyVietnam net
0037: *
0038: * @author: Igor Manic
0039: */
0040: package com.mvnforum.admin;
0041:
0042: import java.io.IOException;
0043: import java.util.*;
0044:
0045: import com.mvnforum.MVNForumConstant;
0046: import com.mvnforum.admin.importexport.XMLUtil;
0047: import com.mvnforum.admin.importexport.XMLWriter;
0048: import com.mvnforum.auth.MVNForumPermission;
0049: import com.mvnforum.db.*;
0050: import net.myvietnam.mvncore.exception.*;
0051: import net.myvietnam.mvncore.filter.DisableHtmlTagFilter;
0052: import net.myvietnam.mvncore.filter.EnableHtmlTagFilter;
0053:
0054: /**
0055: * @author Igor Manic
0056: * @version $Revision: 1.16 $, $Date: 2007/10/09 11:09:14 $
0057: * <br/>
0058: * <code>MemberXML</code> todo Igor: enter description
0059: *
0060: */
0061: public class MemberXML {
0062:
0063: private int memberID;
0064:
0065: /** Returns <code>MemberID</code> of this member or
0066: * <code>-1</code> if member is not created yet. */
0067: public int getMemberID() {
0068: return memberID;
0069: }
0070:
0071: public MemberXML() {
0072: super ();
0073: memberID = -1;
0074: }
0075:
0076: public void setMemberID(String id) {
0077: memberID = XMLUtil.stringToIntDef(id, -1);
0078: }
0079:
0080: /**
0081: * Creates a member. All argument values (<code>int</code>s, <code>Timestamp</code>s, ...)
0082: * are represented as <code>String</code>s, because of more convenient using
0083: * of this method for XML parsing.
0084: *
0085: * @param memberName MemberName of a member to be created.
0086: * @param memberPassword Password of a member to be created.
0087: * @param memberFirstEmail FirstEmail of a member to be created.
0088: * @param memberEmail Email of a member to be created.
0089: * @param memberEmailVisible Can be null.
0090: * @param memberNameVisible Can be null.
0091: * @param memberFirstIP Can be null.
0092: * @param memberLastIP Can be null.
0093: * @param memberViewCount Can be null.
0094: * @param memberPostCount Can be null.
0095: * @param memberCreationDate Can be null.
0096: * @param memberModifiedDate Can be null.
0097: * @param memberExpireDate Can be null.
0098: * @param memberLastLogon Can be null.
0099: * @param memberOption Can be null.
0100: * @param memberStatus Can be null.
0101: * @param memberActivateCode Can be null.
0102: * @param memberTempPassword Can be null.
0103: * @param memberMessageCount Can be null.
0104: * @param memberMessageOption Can be null.
0105: * @param memberPostsPerPage Can be null.
0106: * @param memberWarnCount Can be null.
0107: * @param memberVoteCount Can be null.
0108: * @param memberVoteTotalStars Can be null.
0109: * @param memberRewardPoints Can be null.
0110: * @param memberTitle Can be null.
0111: * @param memberTimeZone Can be null.
0112: * @param memberSignature Can be null.
0113: * @param memberAvatar Can be null.
0114: * @param memberSkin Can be null.
0115: * @param memberLanguage Can be null.
0116: * @param memberFirstname
0117: * @param memberLastname
0118: * @param memberGender Can be null.
0119: * @param memberBirthday Can be null.
0120: * @param memberAddress Can be null.
0121: * @param memberCity Can be null.
0122: * @param memberState Can be null.
0123: * @param memberCountry Can be null.
0124: * @param memberPhone Can be null.
0125: * @param memberMobile Can be null.
0126: * @param memberFax Can be null.
0127: * @param memberCareer Can be null.
0128: * @param memberHomepage Can be null.
0129: * @param memberYahoo Can be null.
0130: * @param memberAol Can be null.
0131: * @param memberIcq Can be null.
0132: * @param memberMsn Can be null.
0133: * @param memberCoolLink1 Can be null.
0134: * @param memberCoolLink2 Can be null.
0135: *
0136: * @throws CreateException
0137: * @throws DuplicateKeyException
0138: * @throws ObjectNotFoundException
0139: * @throws DatabaseException
0140: *
0141: */
0142: public void addMember(String memberName, String memberPassword,
0143: String memberFirstEmail, String memberEmail,
0144: String memberEmailVisible, String memberNameVisible,
0145: String memberFirstIP, String memberLastIP,
0146: String memberViewCount, String memberPostCount,
0147: String memberCreationDate, String memberModifiedDate,
0148: String memberExpireDate, String memberPasswordExpireDate,
0149: String memberLastLogon, String memberOption,
0150: String memberStatus, String memberActivateCode,
0151: String memberTempPassword, String memberMessageCount,
0152: String memberMessageOption, String memberPostsPerPage,
0153: String memberWarnCount, String memberVoteCount,
0154: String memberVoteTotalStars, String memberRewardPoints,
0155: String memberTitle, String memberTimeZone,
0156: String memberSignature, String memberAvatar,
0157: String memberSkin, String memberLanguage,
0158: String memberFirstname, String memberLastname,
0159: String memberGender, String memberBirthday,
0160: String memberAddress, String memberCity,
0161: String memberState, String memberCountry,
0162: String memberPhone, String memberMobile, String memberFax,
0163: String memberCareer, String memberHomepage,
0164: String memberYahoo, String memberAol, String memberIcq,
0165: String memberMsn, String memberCoolLink1,
0166: String memberCoolLink2) throws CreateException,
0167: DuplicateKeyException, ObjectNotFoundException,
0168: DatabaseException {
0169: String strMemberID = null;
0170: if (memberID >= 0)
0171: strMemberID = Integer.toString(memberID);
0172: addMember(strMemberID, memberName, memberPassword,
0173: memberFirstEmail, memberEmail, memberEmailVisible,
0174: memberNameVisible, memberFirstIP, memberLastIP,
0175: memberViewCount, memberPostCount, memberCreationDate,
0176: memberModifiedDate, memberExpireDate, memberLastLogon,
0177: memberOption, memberStatus, memberActivateCode,
0178: memberTempPassword, memberMessageCount,
0179: memberMessageOption, memberPostsPerPage,
0180: memberWarnCount, memberVoteCount, memberVoteTotalStars,
0181: memberRewardPoints, memberTitle, memberTimeZone,
0182: memberSignature, memberAvatar, memberSkin,
0183: memberLanguage, memberFirstname, memberLastname,
0184: memberGender, memberBirthday, memberAddress,
0185: memberCity, memberState, memberCountry, memberPhone,
0186: memberMobile, memberFax, memberCareer, memberHomepage,
0187: memberYahoo, memberAol, memberIcq, memberMsn,
0188: memberCoolLink1, memberCoolLink2);
0189: }
0190:
0191: /**
0192: * Adds a member. All argument values (<code>int</code>s, <code>Timestamp</code>s, ...)
0193: * are represented as <code>String</code>s, because of more convenient using
0194: * of this method for XML parsing.
0195: *
0196: * @param strMemberID Can be null, and it probably will be in most occasions,
0197: * except when you want to setup an explicit value, like
0198: * "0" for guest or "1" for root system admin.
0199: * @param memberName MemberName of a member to be created.
0200: * @param memberPassword Password of a member to be created.
0201: * @param memberFirstEmail FirstEmail of a member to be created.
0202: * @param memberEmail Email of a member to be created.
0203: * @param memberEmailVisible Can be null.
0204: * @param memberNameVisible Can be null.
0205: * @param memberFirstIP Can be null.
0206: * @param memberLastIP Can be null.
0207: * @param memberViewCount Can be null.
0208: * @param memberPostCount Can be null.
0209: * @param memberCreationDate Can be null.
0210: * @param memberModifiedDate Can be null.
0211: * @param memberLastLogon Can be null.
0212: * @param memberOption Can be null.
0213: * @param memberStatus Can be null.
0214: * @param memberActivateCode Can be null.
0215: * @param memberTempPassword Can be null.
0216: * @param memberMessageCount Can be null.
0217: * @param memberMessageOption Can be null.
0218: * @param memberPostsPerPage Can be null.
0219: * @param memberWarnCount Can be null.
0220: * @param memberVoteCount Can be null.
0221: * @param memberVoteTotalStars Can be null.
0222: * @param memberRewardPoints Can be null.
0223: * @param memberTitle Can be null.
0224: * @param memberTimeZone Can be null.
0225: * @param memberSignature Can be null.
0226: * @param memberAvatar Can be null.
0227: * @param memberSkin Can be null.
0228: * @param memberLanguage Can be null.
0229: * @param memberFirstname Can't be null, but may be empty "", but please avoid that.
0230: * @param memberLastname Can't be null, but may be empty "", but please avoid that.
0231: * @param memberGender Can be null.
0232: * @param memberBirthday Can be null.
0233: * @param memberAddress Can be null.
0234: * @param memberCity Can be null.
0235: * @param memberState Can be null.
0236: * @param memberCountry Can be null.
0237: * @param memberPhone Can be null.
0238: * @param memberMobile Can be null.
0239: * @param memberFax Can be null.
0240: * @param memberCareer Can be null.
0241: * @param memberHomepage Can be null.
0242: * @param memberYahoo Can be null.
0243: * @param memberAol Can be null.
0244: * @param memberIcq Can be null.
0245: * @param memberMsn Can be null.
0246: * @param memberCoolLink1 Can be null.
0247: * @param memberCoolLink2 Can be null.
0248: *
0249: * @throws CreateException
0250: * @throws DuplicateKeyException
0251: * @throws ObjectNotFoundException
0252: * @throws DatabaseException
0253: *
0254: */
0255: public void addMember(String strMemberID, String memberName,
0256: String memberPassword, String memberFirstEmail,
0257: String memberEmail, String memberEmailVisible,
0258: String memberNameVisible, String memberFirstIP,
0259: String memberLastIP, String memberViewCount,
0260: String memberPostCount, String memberCreationDate,
0261: String memberModifiedDate, String memberExpireDate,
0262: String memberPasswordExpireDate, String memberLastLogon,
0263: String memberOption, String memberStatus,
0264: String memberActivateCode, String memberTempPassword,
0265: String memberMessageCount, String memberMessageOption,
0266: String memberPostsPerPage, String memberWarnCount,
0267: String memberVoteCount, String memberVoteTotalStars,
0268: String memberRewardPoints, String memberTitle,
0269: String memberTimeZone, String memberSignature,
0270: String memberAvatar, String memberSkin,
0271: String memberLanguage, String memberFirstname,
0272: String memberLastname, String memberGender,
0273: String memberBirthday, String memberAddress,
0274: String memberCity, String memberState,
0275: String memberCountry, String memberPhone,
0276: String memberMobile, String memberFax, String memberCareer,
0277: String memberHomepage, String memberYahoo,
0278: String memberAol, String memberIcq, String memberMsn,
0279: String memberCoolLink1, String memberCoolLink2)
0280: throws CreateException, DuplicateKeyException,
0281: ObjectNotFoundException, DatabaseException {
0282: if ((memberName == null) || (memberName.equals(""))
0283: || (memberPassword == null)
0284: || (memberPassword.equals(""))
0285: || (memberFirstEmail == null)
0286: || (memberFirstEmail.equals(""))
0287: || (memberEmail == null) || (memberEmail.equals(""))
0288: || (memberFirstname == null) || //first and last name can be empty
0289: (memberLastname == null)) {
0290: throw new CreateException(
0291: "Not enough data to create a member. Check for name, email and password.");
0292: } else {
0293: int memberEmailVisible1;
0294: int memberNameVisible1;
0295: int memberViewCount1;
0296: int memberPostCount1;
0297: java.sql.Timestamp memberCreationDate1;
0298: java.sql.Timestamp memberModifiedDate1;
0299: java.sql.Timestamp memberExpireDate1;
0300: java.sql.Timestamp memberPasswordExpireDate1;
0301: java.sql.Timestamp memberLastLogon1;
0302: int memberOption1;
0303: int memberStatus1;
0304: int memberMessageCount1;
0305: int memberMessageOption1;
0306: int memberPostsPerPage1;
0307: int memberWarnCount1;
0308: int memberVoteCount1;
0309: int memberVoteTotalStars1;
0310: int memberRewardPoints1;
0311: int memberTimeZone1;
0312: int memberGender1;
0313: java.sql.Date memberBirthday1;
0314:
0315: try {
0316: memberEmailVisible1 = (XMLUtil.stringToBooleanDef(
0317: memberEmailVisible, false) ? 1 : 0);
0318: memberNameVisible1 = (XMLUtil.stringToBooleanDef(
0319: memberNameVisible, false) ? 1 : 0);
0320: if (memberFirstIP == null)
0321: memberFirstIP = "0.0.0.0";
0322: if (memberLastIP == null)
0323: memberLastIP = "0.0.0.0";
0324: memberViewCount1 = XMLUtil.stringToIntDef(
0325: memberViewCount, 0);
0326: memberPostCount1 = XMLUtil.stringToIntDef(
0327: memberPostCount, 0);
0328: memberCreationDate1 = XMLUtil
0329: .stringToSqlTimestampDefNow(memberCreationDate);
0330: memberModifiedDate1 = XMLUtil
0331: .stringToSqlTimestampDefNull(memberModifiedDate);
0332: memberExpireDate1 = XMLUtil
0333: .stringToSqlTimestampDefNow(memberExpireDate);
0334: memberPasswordExpireDate1 = XMLUtil
0335: .stringToSqlTimestampDefNow(memberPasswordExpireDate);
0336: memberLastLogon1 = XMLUtil
0337: .stringToSqlTimestampDefNull(memberLastLogon);
0338: memberOption1 = XMLUtil.stringToIntDef(memberOption, 0);
0339: memberStatus1 = XMLUtil.stringToIntDef(memberStatus, 0);
0340: if (memberActivateCode == null)
0341: memberActivateCode = "";
0342: if (memberTempPassword == null)
0343: memberTempPassword = "";
0344: memberMessageCount1 = XMLUtil.stringToIntDef(
0345: memberMessageCount, 0);
0346: memberMessageOption1 = XMLUtil.stringToIntDef(
0347: memberMessageOption, 0);
0348: memberPostsPerPage1 = XMLUtil.stringToIntDef(
0349: memberPostsPerPage, 10);
0350: memberWarnCount1 = XMLUtil.stringToIntDef(
0351: memberWarnCount, 0);
0352: memberVoteCount1 = XMLUtil.stringToIntDef(
0353: memberVoteCount, 0);
0354: memberVoteTotalStars1 = XMLUtil.stringToIntDef(
0355: memberVoteTotalStars, 0);
0356: memberRewardPoints1 = XMLUtil.stringToIntDef(
0357: memberRewardPoints, 0);
0358: if (memberTitle == null)
0359: memberTitle = "";
0360: memberTimeZone1 = XMLUtil.stringToIntDef(
0361: memberTimeZone, 0);
0362: if (memberSignature == null)
0363: memberSignature = "";
0364: if (memberAvatar == null)
0365: memberAvatar = "";
0366: if (memberSkin == null)
0367: memberSkin = "";
0368: if (memberLanguage == null)
0369: memberLanguage = "";
0370: memberGender1 = XMLUtil.stringToGenderDef(memberGender,
0371: 1/*Male*/);
0372: memberBirthday1 = XMLUtil
0373: .stringToSqlDateDefNull(memberBirthday);
0374: if (memberAddress == null)
0375: memberAddress = "";
0376: if (memberCity == null)
0377: memberCity = "";
0378: if (memberState == null)
0379: memberState = "";
0380: if (memberCountry == null)
0381: memberCountry = "";
0382: if (memberPhone == null)
0383: memberPhone = "";
0384: if (memberMobile == null)
0385: memberMobile = "";
0386: if (memberFax == null)
0387: memberFax = "";
0388: if (memberCareer == null)
0389: memberCareer = "";
0390: if (memberHomepage == null)
0391: memberHomepage = "";
0392: if (memberYahoo == null)
0393: memberYahoo = "";
0394: if (memberAol == null)
0395: memberAol = "";
0396: if (memberIcq == null)
0397: memberIcq = "";
0398: if (memberMsn == null)
0399: memberMsn = "";
0400: if (memberCoolLink1 == null)
0401: memberCoolLink1 = "";
0402: if (memberCoolLink2 == null)
0403: memberCoolLink2 = "";
0404: } catch (NumberFormatException e) {
0405: throw new CreateException(
0406: "Invalid data for a member. Expected a number.");
0407: }
0408:
0409: //now ensure that strMemberID is valid number, or null
0410: if ((strMemberID != null) && (!strMemberID.equals(""))) {
0411: try {
0412: if (Integer.parseInt(strMemberID) < 0)
0413: strMemberID = null;
0414: } catch (NumberFormatException e) {
0415: strMemberID = null;
0416: }
0417: } else
0418: strMemberID = null;
0419:
0420: memberPassword = EnableHtmlTagFilter.filter(memberPassword);
0421: memberTempPassword = EnableHtmlTagFilter
0422: .filter(memberTempPassword);
0423: memberTitle = EnableHtmlTagFilter.filter(memberTitle);
0424: memberSignature = EnableHtmlTagFilter
0425: .filter(memberSignature);
0426: //todo Igor: also filter memberAvatar, memberSkin
0427: memberAddress = EnableHtmlTagFilter.filter(memberAddress);
0428: memberCountry = EnableHtmlTagFilter.filter(memberCountry);
0429: memberHomepage = EnableHtmlTagFilter.filter(memberHomepage);
0430: memberYahoo = EnableHtmlTagFilter.filter(memberYahoo);
0431: memberAol = EnableHtmlTagFilter.filter(memberAol);
0432: memberIcq = EnableHtmlTagFilter.filter(memberIcq);
0433: memberMsn = EnableHtmlTagFilter.filter(memberMsn);
0434: memberCoolLink1 = EnableHtmlTagFilter
0435: .filter(memberCoolLink1);
0436: memberCoolLink2 = EnableHtmlTagFilter
0437: .filter(memberCoolLink2);
0438:
0439: if (strMemberID == null) {
0440: DAOFactory.getMemberDAO().create(memberName,
0441: memberPassword, memberFirstEmail, memberEmail,
0442: memberEmailVisible1, memberNameVisible1,
0443: memberFirstIP, memberLastIP, memberViewCount1,
0444: memberPostCount1, memberCreationDate1,
0445: memberModifiedDate1, memberExpireDate1,
0446: memberPasswordExpireDate1, memberLastLogon1,
0447: memberOption1, memberStatus1,
0448: memberActivateCode, memberTempPassword,
0449: memberMessageCount1, memberMessageOption1,
0450: memberPostsPerPage1, memberWarnCount1,
0451: memberVoteCount1, memberVoteTotalStars1,
0452: memberRewardPoints1, memberTitle,
0453: memberTimeZone1, memberSignature, memberAvatar,
0454: memberSkin, memberLanguage, memberFirstname,
0455: memberLastname, memberGender1, memberBirthday1,
0456: memberAddress, memberCity, memberState,
0457: memberCountry, memberPhone, memberMobile,
0458: memberFax, memberCareer, memberHomepage,
0459: memberYahoo, memberAol, memberIcq, memberMsn,
0460: memberCoolLink1, memberCoolLink2);
0461: } else {
0462: //I must change all possible nulls into "", so I don't get "'null'" in sql query
0463: String memberEmailVisible2 = (XMLUtil
0464: .stringToBooleanDef(memberEmailVisible, false) ? "1"
0465: : "0");
0466: String memberNameVisible2 = (XMLUtil
0467: .stringToBooleanDef(memberNameVisible, false) ? "1"
0468: : "0");
0469: String memberModifiedDate2 = XMLUtil
0470: .sqlTimestampToStringDefEmpty(memberModifiedDate1);
0471: String memberLastLogon2 = XMLUtil
0472: .sqlTimestampToStringDefEmpty(memberLastLogon1);
0473: String memberBirthday2 = XMLUtil
0474: .sqlDateToStringDefEmpty(memberBirthday1);
0475:
0476: String query = "INSERT INTO "
0477: + MemberDAO.TABLE_NAME
0478: + " (MemberID, MemberName, MemberPassword, MemberFirstEmail, MemberEmail,"
0479: + " MemberEmailVisible, MemberNameVisible, MemberFirstIP, MemberLastIP,"
0480: + " MemberViewCount, MemberPostCount, MemberCreationDate, MemberModifiedDate, MemberExpireDate,"
0481: + " MemberLastLogon, MemberOption, MemberStatus, MemberActivateCode,"
0482: + " MemberTempPassword, MemberMessageCount, MemberMessageOption,"
0483: + " MemberPostsPerPage, MemberWarnCount, MemberVoteCount,"
0484: + " MemberVoteTotalStars, MemberRewardPoints, MemberTitle,"
0485: + " MemberTimeZone, MemberSignature, MemberAvatar, MemberSkin,"
0486: + " MemberLanguage, MemberFirstname, MemberLastname, MemberGender,"
0487: + " MemberBirthday, MemberAddress, MemberCity, MemberState, MemberCountry,"
0488: + " MemberPhone, MemberMobile, MemberFax, MemberCareer, MemberHomepage,"
0489: + " MemberYahoo, MemberAol, MemberIcq, MemberMsn,"
0490: + " MemberCoolLink1, MemberCoolLink2)"
0491: + " VALUES (" + strMemberID + ", '"
0492: + memberName + "', '" + memberPassword + "', '"
0493: + memberFirstEmail + "', '" + memberEmail
0494: + "', " + memberEmailVisible2 + ", "
0495: + memberNameVisible2 + ", '" + memberFirstIP
0496: + "', '" + memberLastIP + "', "
0497: + memberViewCount1 + ", " + memberPostCount1
0498: + ", '" + memberCreationDate1 + "', '"
0499: + memberModifiedDate2 + "', '"
0500: + memberExpireDate + "', '" + memberLastLogon2
0501: + "', " + memberOption1 + ", " + memberStatus1
0502: + ", '" + memberActivateCode + "', '"
0503: + memberTempPassword + "', "
0504: + memberMessageCount1 + ", "
0505: + memberMessageOption1 + ", "
0506: + memberPostsPerPage1 + ", " + memberWarnCount1
0507: + ", " + memberVoteCount1 + ", "
0508: + memberVoteTotalStars1 + ", "
0509: + memberRewardPoints1 + ", '" + memberTitle
0510: + "', " + memberTimeZone1 + ", '"
0511: + memberSignature + "', '" + memberAvatar
0512: + "', '" + memberSkin + "', '" + memberLanguage
0513: + "', '" + memberFirstname + "', '"
0514: + memberLastname + "', " + memberGender1
0515: + ", '" + memberBirthday2 + "', '"
0516: + memberAddress + "', '" + memberCity + "', '"
0517: + memberState + "', '" + memberCountry + "', '"
0518: + memberPhone + "', '" + memberMobile + "', '"
0519: + memberFax + "', '" + memberCareer + "', '"
0520: + memberHomepage + "', '" + memberYahoo
0521: + "', '" + memberAol + "', '" + memberIcq
0522: + "', '" + memberMsn + "', '" + memberCoolLink1
0523: + "', '" + memberCoolLink2 + "')";
0524: if (ImportWebHelper.execUpdateQuery(query) != 1) {
0525: throw new CreateException(
0526: "Error adding member into table '"
0527: + MemberDAO.TABLE_NAME + "'.");
0528: }
0529: }
0530: this .memberID = DAOFactory.getMemberDAO()
0531: .getMemberIDFromMemberName(memberName);
0532: }
0533: }
0534:
0535: /**
0536: * Adds a permission to this member. In order to know which member we are
0537: * reffering to, this method is supposed to be called after {@link #setMemberID(String)},
0538: * {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
0539: * or {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
0540: * have been called. Otherwise, this permission will be simply ignored.
0541: *
0542: * @param permission Permission to be added.
0543: *
0544: * @throws CreateException
0545: * @throws DatabaseException
0546: * @throws ForeignKeyNotFoundException
0547: */
0548: public void addMemberPermission(String permission)
0549: throws CreateException, DatabaseException,
0550: ForeignKeyNotFoundException {
0551: if (memberID < 0) {
0552: throw new CreateException(
0553: "Found member permission that is not assigned to any known member.");
0554: }
0555: int permission1;
0556: try {
0557: permission1 = XMLUtil.stringToIntDef(permission,
0558: MVNForumPermission.PERMISSION_NO_PERMISSIONS);
0559: } catch (NumberFormatException e) {
0560: throw new CreateException(
0561: "Invalid data for a member permission. Expected a number.");
0562: }
0563: try {
0564: DAOFactory.getMemberPermissionDAO().create(memberID,
0565: permission1);
0566: } catch (DuplicateKeyException e) {
0567: //ignore if already had that permission
0568: }
0569: }
0570:
0571: public static void addGuestMemberPermission(String permission)
0572: throws CreateException, DatabaseException,
0573: ForeignKeyNotFoundException {
0574: int permission1;
0575: try {
0576: permission1 = XMLUtil.stringToIntDef(permission,
0577: MVNForumPermission.PERMISSION_NO_PERMISSIONS);
0578: } catch (NumberFormatException e) {
0579: throw new CreateException(
0580: "Invalid data for a guest member permission. Expected a number.");
0581: }
0582: try {
0583: DAOFactory.getMemberPermissionDAO().create(
0584: MVNForumConstant.MEMBER_ID_OF_GUEST, permission1);
0585: } catch (DuplicateKeyException e) {
0586: //ignore if already had that permission
0587: }
0588: }
0589:
0590: public static void addAdminMemberPermission(String permission)
0591: throws CreateException, DatabaseException,
0592: ForeignKeyNotFoundException {
0593: int permission1;
0594: try {
0595: permission1 = XMLUtil.stringToIntDef(permission,
0596: MVNForumPermission.PERMISSION_NO_PERMISSIONS);
0597: } catch (NumberFormatException e) {
0598: throw new CreateException(
0599: "Invalid data for a guest member permission. Expected a number.");
0600: }
0601: try {
0602: DAOFactory.getMemberPermissionDAO().create(
0603: MVNForumConstant.MEMBER_ID_OF_ADMIN, permission1);
0604: } catch (DuplicateKeyException e) {
0605: //ignore if already had that permission
0606: }
0607: }
0608:
0609: public static void addMemberPermission(String memberName,
0610: String permission) throws CreateException,
0611: DatabaseException, ForeignKeyNotFoundException,
0612: ObjectNotFoundException {
0613: int permission1;
0614: try {
0615: permission1 = XMLUtil.stringToIntDef(permission,
0616: MVNForumPermission.PERMISSION_NO_PERMISSIONS);
0617: } catch (NumberFormatException e) {
0618: throw new CreateException(
0619: "Invalid data for a member permission. Expected a number.");
0620: }
0621: try {
0622: DAOFactory.getMemberPermissionDAO().create(
0623: DAOFactory.getMemberDAO()
0624: .getMemberIDFromMemberName(memberName),
0625: permission1);
0626: } catch (DuplicateKeyException e) {
0627: //ignore if already had that permission
0628: }
0629: }
0630:
0631: /**
0632: * Creates a message folder for this member. In order to know which member we are
0633: * reffering to, this method is supposed to be called after {@link #setMemberID(String)},
0634: * {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
0635: * or {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
0636: * have been called. Otherwise, this message folder will be simply ignored.
0637: *
0638: * @param folderName Name of a folder to be created.
0639: * @param folderOrder Can be null.
0640: * @param folderCreationDate Can be null.
0641: * @param folderModifiedDate Can be null.
0642: *
0643: * @throws CreateException
0644: * @throws DatabaseException
0645: * @throws DuplicateKeyException
0646: * @throws ForeignKeyNotFoundException
0647: */
0648: public void addMessageFolder(String folderName, String folderOrder,
0649: String folderCreationDate, String folderModifiedDate)
0650: throws CreateException, DatabaseException,
0651: DuplicateKeyException, ForeignKeyNotFoundException {
0652: if (memberID < 0) {
0653: throw new CreateException(
0654: "Found message folder that is not assigned to any known member.");
0655: }
0656: if ((folderName == null) || (folderName.equals(""))) {
0657: throw new CreateException(
0658: "Can't create a message folder with empty FolderName.");
0659: }
0660:
0661: int folderOrder1;
0662: java.sql.Timestamp folderCreationDate1;
0663: java.sql.Timestamp folderModifiedDate1;
0664: try {
0665: folderOrder1 = XMLUtil.stringToIntDef(folderOrder, 0);
0666: folderCreationDate1 = XMLUtil
0667: .stringToSqlTimestampDefNow(folderCreationDate);
0668: folderModifiedDate1 = XMLUtil
0669: .stringToSqlTimestampDefNow(folderModifiedDate);
0670: } catch (NumberFormatException e) {
0671: throw new CreateException(
0672: "Invalid data for a message folder. Expected a number.");
0673: }
0674:
0675: folderName = EnableHtmlTagFilter.filter(folderName);
0676: int folderStatus = 0;
0677: int folderOption = 0;
0678: int folderType = 0;
0679: DAOFactory.getMessageFolderDAO().create(folderName, memberID,
0680: folderOrder1, folderStatus, folderOption, folderType,
0681: folderCreationDate1, folderModifiedDate1);
0682: }
0683:
0684: /**
0685: * Adds a global watch for this member. In order to know which member we are
0686: * reffering to, this method is supposed to be called after {@link #setMemberID(String)},
0687: * {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
0688: * or {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
0689: * have been called. Otherwise, this watch will be simply ignored.
0690: *
0691: * @param watchType Can be null.
0692: * @param watchOption Can be null.
0693: * @param watchStatus Can be null.
0694: * @param watchCreationDate Can be null.
0695: * @param watchLastSentDate Can be null.
0696: * @param watchEndDate Can be null.
0697: *
0698: * @throws BadInputException
0699: * @throws CreateException
0700: * @throws DatabaseException
0701: * @throws DuplicateKeyException
0702: * @throws ForeignKeyNotFoundException
0703: */
0704: public void addGlobalWatch(String watchType, String watchOption,
0705: String watchStatus, String watchCreationDate,
0706: String watchLastSentDate, String watchEndDate)
0707: throws CreateException, DatabaseException,
0708: DuplicateKeyException, ForeignKeyNotFoundException {
0709: if (memberID < 0) {
0710: throw new CreateException(
0711: "Found global watch that is not assigned to any known member.");
0712: }
0713:
0714: int watchType1;
0715: int watchOption1;
0716: int watchStatus1;
0717: java.sql.Timestamp watchCreationDate1;
0718: java.sql.Timestamp watchLastSentDate1;
0719: java.sql.Timestamp watchEndDate1;
0720:
0721: try {
0722: watchType1 = XMLUtil.stringToIntDef(watchType, 0);
0723: watchOption1 = XMLUtil.stringToIntDef(watchOption, 0);
0724: watchStatus1 = XMLUtil.stringToIntDef(watchStatus, 0);
0725: watchCreationDate1 = XMLUtil
0726: .stringToSqlTimestampDefNow(watchCreationDate);
0727: watchLastSentDate1 = XMLUtil
0728: .stringToSqlTimestampDefNull(watchLastSentDate);
0729: watchEndDate1 = XMLUtil
0730: .stringToSqlTimestampDefNull(watchEndDate);
0731: } catch (NumberFormatException e) {
0732: throw new CreateException(
0733: "Invalid data for a global watch. Expected a number.");
0734: }
0735:
0736: DAOFactory.getWatchDAO().create(memberID, 0/*categoryID*/,
0737: 0/*forumID*/, 0/*threadID*/, watchType1,
0738: watchOption1, watchStatus1, watchCreationDate1,
0739: watchLastSentDate1, watchEndDate1);
0740: }
0741:
0742: // ===============================================================
0743: // ==================== STATIC EXPORT METHODS ====================
0744: // ===============================================================
0745:
0746: public static void exportMessageFoldersForMember(
0747: XMLWriter xmlWriter, String memberName)
0748: throws ForeignKeyNotFoundException, IOException,
0749: DatabaseException, ExportException {
0750: try {
0751: exportMessageFoldersForMember(xmlWriter, DAOFactory
0752: .getMemberDAO().getMemberIDFromMemberName(
0753: memberName));
0754: } catch (ObjectNotFoundException e) {
0755: throw new ForeignKeyNotFoundException(
0756: "Can't find member with name \"" + memberName
0757: + "\".");
0758: }
0759: }
0760:
0761: public static void exportMessageFoldersForMember(
0762: XMLWriter xmlWriter, int memberID) throws IOException,
0763: DatabaseException, ExportException {
0764: Collection messageFolders = ExportWebHelper
0765: .execSqlQuery("SELECT FolderName, FolderOrder, FolderCreationDate, FolderModifiedDate"
0766: + " FROM "
0767: + MessageFolderDAO.TABLE_NAME
0768: + " WHERE MemberID="
0769: + Integer.toString(memberID));
0770: Iterator iter = messageFolders.iterator();
0771: String[] messageFolder = null;
0772: //try {
0773: xmlWriter.startElement("MessageFolderList");
0774: try {
0775: while ((messageFolder = (String[]) iter.next()) != null) {
0776: if (messageFolder.length != 4) {
0777: throw new ExportException(
0778: "Error while retrieving data about message folder for memberID=="
0779: + memberID);
0780: }
0781: xmlWriter.startElement("MessageFolder");
0782: xmlWriter.startElement("FolderName");
0783: xmlWriter.writeData(DisableHtmlTagFilter
0784: .filter(messageFolder[0]));
0785: xmlWriter.endElement("FolderName");
0786: xmlWriter.startElement("FolderOrder");
0787: xmlWriter.writeData(messageFolder[1]);
0788: xmlWriter.endElement("FolderOrder");
0789: xmlWriter.startElement("FolderCreationDate");
0790: xmlWriter.writeData(messageFolder[2]);
0791: xmlWriter.endElement("FolderCreationDate");
0792: xmlWriter.startElement("FolderModifiedDate");
0793: xmlWriter.writeData(messageFolder[3]);
0794: xmlWriter.endElement("FolderModifiedDate");
0795: xmlWriter.endElement("MessageFolder");
0796: }
0797: } catch (NoSuchElementException e) {
0798: //no more database records
0799: }
0800: xmlWriter.endElement("MessageFolderList");
0801: //} catch throw exportexception
0802: }
0803:
0804: public static void exportGlobalPermissionsForMember(
0805: XMLWriter xmlWriter, String memberName)
0806: throws ForeignKeyNotFoundException, IOException,
0807: DatabaseException, ExportException {
0808: try {
0809: exportGlobalPermissionsForMember(xmlWriter, DAOFactory
0810: .getMemberDAO().getMemberIDFromMemberName(
0811: memberName));
0812: } catch (ObjectNotFoundException e) {
0813: throw new ForeignKeyNotFoundException(
0814: "Can't find member with name \"" + memberName
0815: + "\".");
0816: }
0817: }
0818:
0819: public static void exportGlobalPermissionsForMember(
0820: XMLWriter xmlWriter, int memberID) throws IOException,
0821: DatabaseException, ExportException {
0822: Collection globalPermissions = ExportWebHelper
0823: .execSqlQuery("SELECT Permission" + " FROM "
0824: + MemberPermissionDAO.TABLE_NAME
0825: + " WHERE MemberID="
0826: + Integer.toString(memberID));
0827: Iterator iter = globalPermissions.iterator();
0828: String[] globalPermission = null;
0829: //try {
0830: xmlWriter.startElement("GlobalPermissionList");
0831: try {
0832: while ((globalPermission = (String[]) iter.next()) != null) {
0833: if (globalPermission.length != 1) {
0834: throw new ExportException(
0835: "Error while retrieving data about global permissions for memberID=="
0836: + memberID);
0837: }
0838: xmlWriter.startElement("GlobalPermission");
0839: xmlWriter.writeData(globalPermission[0]);
0840: xmlWriter.endElement("GlobalPermission");
0841: }
0842: } catch (NoSuchElementException e) {
0843: //no more database records
0844: }
0845: xmlWriter.endElement("GlobalPermissionList");
0846: //} catch throw exportexception
0847: }
0848:
0849: public static void exportGlobalWatchesForMember(
0850: XMLWriter xmlWriter, String memberName)
0851: throws ForeignKeyNotFoundException, IOException,
0852: DatabaseException, ExportException {
0853: try {
0854: exportGlobalWatchesForMember(xmlWriter, DAOFactory
0855: .getMemberDAO().getMemberIDFromMemberName(
0856: memberName));
0857: } catch (ObjectNotFoundException e) {
0858: throw new ForeignKeyNotFoundException(
0859: "Can't find member with name \"" + memberName
0860: + "\".");
0861: }
0862: }
0863:
0864: public static void exportGlobalWatchesForMember(
0865: XMLWriter xmlWriter, int memberID) throws IOException,
0866: DatabaseException, ExportException {
0867: Collection globalWatches = ExportWebHelper
0868: .execSqlQuery("SELECT WatchType, WatchOption, WatchStatus, WatchCreationDate, WatchLastSentDate, WatchEndDate"
0869: + " FROM "
0870: + WatchDAO.TABLE_NAME
0871: + " WHERE CategoryID=0 AND ForumID=0 AND ThreadID=0"
0872: + " AND MemberID=" + Integer.toString(memberID));
0873: Iterator iter = globalWatches.iterator();
0874: String[] globalWatch = null;
0875: //try {
0876: xmlWriter.startElement("GlobalWatchList");
0877: try {
0878: while ((globalWatch = (String[]) iter.next()) != null) {
0879: if (globalWatch.length != 6) {
0880: throw new ExportException(
0881: "Error while retrieving data about global watch for memberID=="
0882: + memberID);
0883: }
0884: xmlWriter.startElement("GlobalWatch");
0885: xmlWriter.startElement("WatchType");
0886: xmlWriter.writeData(globalWatch[0]);
0887: xmlWriter.endElement("WatchType");
0888: xmlWriter.startElement("WatchOption");
0889: xmlWriter.writeData(globalWatch[1]);
0890: xmlWriter.endElement("WatchOption");
0891: xmlWriter.startElement("WatchStatus");
0892: xmlWriter.writeData(globalWatch[2]);
0893: xmlWriter.endElement("WatchStatus");
0894: xmlWriter.startElement("WatchCreationDate");
0895: xmlWriter.writeData(globalWatch[3]);
0896: xmlWriter.endElement("WatchCreationDate");
0897: xmlWriter.startElement("WatchLastSentDate");
0898: xmlWriter.writeData(globalWatch[4]);
0899: xmlWriter.endElement("WatchLastSentDate");
0900: xmlWriter.startElement("WatchEndDate");
0901: xmlWriter.writeData(globalWatch[5]);
0902: xmlWriter.endElement("WatchEndDate");
0903: xmlWriter.endElement("GlobalWatch");
0904: }
0905: } catch (NoSuchElementException e) {
0906: //no more database records
0907: }
0908: xmlWriter.endElement("GlobalWatchList");
0909: //} catch throw exportexception
0910: }
0911:
0912: public static void exportMember(XMLWriter xmlWriter,
0913: String memberName) throws ForeignKeyNotFoundException,
0914: IOException, DatabaseException, ExportException {
0915: try {
0916: exportMember(xmlWriter, DAOFactory.getMemberDAO()
0917: .getMemberIDFromMemberName(memberName));
0918: } catch (ObjectNotFoundException e) {
0919: throw new ForeignKeyNotFoundException(
0920: "Can't find member with name \"" + memberName
0921: + "\".");
0922: }
0923: }
0924:
0925: public static void exportMember(XMLWriter xmlWriter, int memberID)
0926: throws IOException, DatabaseException, ExportException {
0927: Collection member1 = ExportWebHelper
0928: .execSqlQuery("SELECT MemberName, MemberPassword, MemberFirstEmail, MemberEmail,"
0929: + " MemberEmailVisible, MemberNameVisible, MemberFirstIP, MemberLastIP,"
0930: + " MemberViewCount, MemberPostCount, MemberCreationDate, MemberModifiedDate, MemberExpireDate, "
0931: + " MemberLastLogon, MemberOption, MemberStatus, MemberActivateCode,"
0932: + " MemberTempPassword, MemberMessageCount, MemberMessageOption, MemberPostsPerPage,"
0933: + " MemberWarnCount, MemberVoteCount, MemberVoteTotalStars, MemberRewardPoints,"
0934: + " MemberTitle, MemberTimeZone, MemberSignature, MemberAvatar,"
0935: + " MemberSkin, MemberLanguage, MemberFirstname, MemberLastname,"
0936: + " MemberGender, MemberBirthday, MemberAddress, MemberCity,"
0937: + " MemberState, MemberCountry, MemberPhone, MemberMobile,"
0938: + " MemberFax, MemberCareer, MemberHomepage, MemberYahoo,"
0939: + " MemberAol, MemberIcq, MemberMsn, MemberCoolLink1,"
0940: + " MemberCoolLink2 FROM "
0941: + MemberDAO.TABLE_NAME
0942: + " WHERE MemberID="
0943: + Integer.toString(memberID));
0944: Iterator iter = member1.iterator();
0945: String[] member = null;
0946: //try {
0947: try {
0948: if ((member = (String[]) iter.next()) == null) {
0949: throw new ExportException(
0950: "Can't find data for memberID==" + memberID);
0951: }
0952: if (member.length != 50) {
0953: throw new ExportException(
0954: "Error while retrieving data about member with memberID=="
0955: + memberID);
0956: }
0957: } catch (NoSuchElementException e) {
0958: throw new ExportException("Can't find data for memberID=="
0959: + memberID);
0960: }
0961:
0962: //if I am here, that means I now have correct object member
0963: if (memberID == MVNForumConstant.MEMBER_ID_OF_GUEST) {
0964: xmlWriter.startElement("Member", new String[] { "class",
0965: "Guest" });
0966: } else if (memberID == MVNForumConstant.MEMBER_ID_OF_ADMIN) {
0967: xmlWriter.startElement("Member", new String[] { "class",
0968: "Admin" });
0969: } else {
0970: xmlWriter.startElement("Member");
0971: }
0972:
0973: xmlWriter.startElement("MemberName");
0974: xmlWriter.writeData(member[0]);
0975: xmlWriter.endElement("MemberName");
0976: xmlWriter.startElement("MemberPassword");
0977: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[1]));
0978: xmlWriter.endElement("MemberPassword");
0979: xmlWriter.startElement("MemberFirstEmail");
0980: xmlWriter.writeData(member[2]);
0981: xmlWriter.endElement("MemberFirstEmail");
0982: xmlWriter.startElement("MemberEmail");
0983: xmlWriter.writeData(member[3]);
0984: xmlWriter.endElement("MemberEmail");
0985: xmlWriter.startElement("MemberEmailVisible");
0986: xmlWriter.writeData(member[4]);
0987: xmlWriter.endElement("MemberEmailVisible");
0988: xmlWriter.startElement("MemberNameVisible");
0989: xmlWriter.writeData(member[5]);
0990: xmlWriter.endElement("MemberNameVisible");
0991: xmlWriter.startElement("MemberFirstIP");
0992: xmlWriter.writeData(member[6]);
0993: xmlWriter.endElement("MemberFirstIP");
0994: xmlWriter.startElement("MemberLastIP");
0995: xmlWriter.writeData(member[7]);
0996: xmlWriter.endElement("MemberLastIP");
0997: xmlWriter.startElement("MemberViewCount");
0998: xmlWriter.writeData(member[8]);
0999: xmlWriter.endElement("MemberViewCount");
1000: xmlWriter.startElement("MemberPostCount");
1001: xmlWriter.writeData(member[9]);
1002: xmlWriter.endElement("MemberPostCount");
1003:
1004: xmlWriter.startElement("MemberCreationDate");
1005: xmlWriter.writeData(member[10]);
1006: xmlWriter.endElement("MemberCreationDate");
1007: xmlWriter.startElement("MemberModifiedDate");
1008: xmlWriter.writeData(member[11]);
1009: xmlWriter.endElement("MemberModifiedDate");
1010: xmlWriter.startElement("MemberExpireDate");
1011: xmlWriter.writeData(member[12]);
1012: xmlWriter.endElement("MemberExpireDate");
1013: xmlWriter.startElement("MemberLastLogon");
1014: xmlWriter.writeData(member[13]);
1015: xmlWriter.endElement("MemberLastLogon");
1016: xmlWriter.startElement("MemberOption");
1017: xmlWriter.writeData(member[14]);
1018: xmlWriter.endElement("MemberOption");
1019: xmlWriter.startElement("MemberStatus");
1020: xmlWriter.writeData(member[15]);
1021: xmlWriter.endElement("MemberStatus");
1022: xmlWriter.startElement("MemberActivateCode");
1023: xmlWriter.writeData(member[16]);
1024: xmlWriter.endElement("MemberActivateCode");
1025: xmlWriter.startElement("MemberTempPassword");
1026: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[17]));
1027: xmlWriter.endElement("MemberTempPassword");
1028: xmlWriter.startElement("MemberMessageCount");
1029: xmlWriter.writeData(member[18]);
1030: xmlWriter.endElement("MemberMessageCount");
1031: xmlWriter.startElement("MemberMessageOption");
1032: xmlWriter.writeData(member[19]);
1033: xmlWriter.endElement("MemberMessageOption");
1034: xmlWriter.startElement("MemberPostsPerPage");
1035: xmlWriter.writeData(member[20]);
1036: xmlWriter.endElement("MemberPostsPerPage");
1037:
1038: xmlWriter.startElement("MemberWarnCount");
1039: xmlWriter.writeData(member[21]);
1040: xmlWriter.endElement("MemberWarnCount");
1041: xmlWriter.startElement("MemberVoteCount");
1042: xmlWriter.writeData(member[22]);
1043: xmlWriter.endElement("MemberVoteCount");
1044: xmlWriter.startElement("MemberVoteTotalStars");
1045: xmlWriter.writeData(member[23]);
1046: xmlWriter.endElement("MemberVoteTotalStars");
1047: xmlWriter.startElement("MemberRewardPoints");
1048: xmlWriter.writeData(member[24]);
1049: xmlWriter.endElement("MemberRewardPoints");
1050: xmlWriter.startElement("MemberTitle");
1051: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[25]));
1052: xmlWriter.endElement("MemberTitle");
1053: xmlWriter.startElement("MemberTimeZone");
1054: xmlWriter.writeData(member[26]);
1055: xmlWriter.endElement("MemberTimeZone");
1056: xmlWriter.startElement("MemberSignature");
1057: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[27]));
1058: xmlWriter.endElement("MemberSignature");
1059: //todo Igor: also filter memberAvatar, memberSkin
1060: xmlWriter.startElement("MemberAvatar");
1061: xmlWriter.writeData(member[28]);
1062: xmlWriter.endElement("MemberAvatar");
1063: xmlWriter.startElement("MemberSkin");
1064: xmlWriter.writeData(member[29]);
1065: xmlWriter.endElement("MemberSkin");
1066: xmlWriter.startElement("MemberLanguage");
1067: xmlWriter.writeData(member[30]);
1068: xmlWriter.endElement("MemberLanguage");
1069:
1070: xmlWriter.startElement("MemberFirstname");
1071: xmlWriter.writeData(member[31]);
1072: xmlWriter.endElement("MemberFirstname");
1073: xmlWriter.startElement("MemberLastname");
1074: xmlWriter.writeData(member[32]);
1075: xmlWriter.endElement("MemberLastname");
1076: xmlWriter.startElement("MemberGender");
1077: xmlWriter.writeData(member[33]);
1078: xmlWriter.endElement("MemberGender");
1079: xmlWriter.startElement("MemberBirthday");
1080: xmlWriter.writeData(member[34]);
1081: xmlWriter.endElement("MemberBirthday");
1082: xmlWriter.startElement("MemberAddress");
1083: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[35]));
1084: xmlWriter.endElement("MemberAddress");
1085: xmlWriter.startElement("MemberCity");
1086: xmlWriter.writeData(member[36]);
1087: xmlWriter.endElement("MemberCity");
1088: xmlWriter.startElement("MemberState");
1089: xmlWriter.writeData(member[37]);
1090: xmlWriter.endElement("MemberState");
1091: xmlWriter.startElement("MemberCountry");
1092: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[38]));
1093: xmlWriter.endElement("MemberCountry");
1094: xmlWriter.startElement("MemberPhone");
1095: xmlWriter.writeData(member[39]);
1096: xmlWriter.endElement("MemberPhone");
1097: xmlWriter.startElement("MemberMobile");
1098: xmlWriter.writeData(member[40]);
1099: xmlWriter.endElement("MemberMobile");
1100:
1101: xmlWriter.startElement("MemberFax");
1102: xmlWriter.writeData(member[41]);
1103: xmlWriter.endElement("MemberFax");
1104: xmlWriter.startElement("MemberCareer");
1105: xmlWriter.writeData(member[42]);
1106: xmlWriter.endElement("MemberCareer");
1107: xmlWriter.startElement("MemberHomepage");
1108: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[43]));
1109: xmlWriter.endElement("MemberHomepage");
1110: xmlWriter.startElement("MemberYahoo");
1111: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[44]));
1112: xmlWriter.endElement("MemberYahoo");
1113: xmlWriter.startElement("MemberAol");
1114: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[45]));
1115: xmlWriter.endElement("MemberAol");
1116: xmlWriter.startElement("MemberIcq");
1117: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[46]));
1118: xmlWriter.endElement("MemberIcq");
1119: xmlWriter.startElement("MemberMsn");
1120: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[47]));
1121: xmlWriter.endElement("MemberMsn");
1122: xmlWriter.startElement("MemberCoolLink1");
1123: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[48]));
1124: xmlWriter.endElement("MemberCoolLink1");
1125: xmlWriter.startElement("MemberCoolLink2");
1126: xmlWriter.writeData(DisableHtmlTagFilter.filter(member[49]));
1127: xmlWriter.endElement("MemberCoolLink2");
1128:
1129: exportGlobalPermissionsForMember(xmlWriter, memberID);
1130: exportMessageFoldersForMember(xmlWriter, memberID);
1131: exportGlobalWatchesForMember(xmlWriter, memberID);
1132: xmlWriter.endElement("Member");
1133: //} catch throw exportexception
1134: }
1135:
1136: public static void exportMemberList(XMLWriter xmlWriter)
1137: throws IOException, DatabaseException, ExportException {
1138: Collection memberIDs = ExportWebHelper
1139: .execSqlQuery("SELECT MemberID" + " FROM "
1140: + MemberDAO.TABLE_NAME);
1141: Iterator iter = memberIDs.iterator();
1142: String[] memberID = null;
1143: //try {
1144: xmlWriter.startElement("MemberList");
1145: /* First, I'll export guest and root admin. If they don't exist, just continue. */
1146: if (MVNForumConstant.MEMBER_ID_OF_GUEST < MVNForumConstant.MEMBER_ID_OF_ADMIN) {
1147: try {
1148: exportMember(xmlWriter,
1149: MVNForumConstant.MEMBER_ID_OF_GUEST);
1150: } catch (Exception e) { /* doesn't exist => ignore */
1151: }
1152: try {
1153: exportMember(xmlWriter,
1154: MVNForumConstant.MEMBER_ID_OF_ADMIN);
1155: } catch (Exception e) { /* doesn't exist => ignore */
1156: }
1157: } else {
1158: try {
1159: exportMember(xmlWriter,
1160: MVNForumConstant.MEMBER_ID_OF_ADMIN);
1161: } catch (Exception e) { /* doesn't exist => ignore */
1162: }
1163: try {
1164: exportMember(xmlWriter,
1165: MVNForumConstant.MEMBER_ID_OF_GUEST);
1166: } catch (Exception e) { /* doesn't exist => ignore */
1167: }
1168: }
1169: try {
1170: while ((memberID = (String[]) iter.next()) != null) {
1171: if (memberID.length != 1) {
1172: throw new ExportException(
1173: "Error while retrieving list of members.");
1174: }
1175: try {
1176: int i = Integer.parseInt(memberID[0]);
1177: if ((i != MVNForumConstant.MEMBER_ID_OF_GUEST)
1178: && (i != MVNForumConstant.MEMBER_ID_OF_ADMIN)) {
1179: exportMember(xmlWriter, i);
1180: }
1181: } catch (NumberFormatException e) {
1182: throw new ExportException(
1183: "Error while retrieving list of members.");
1184: }
1185: }
1186: } catch (NoSuchElementException e) {
1187: //no more database records
1188: }
1189: xmlWriter.endElement("MemberList");
1190: //} catch throw exportexception
1191: }
1192:
1193: }
|