001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/common/MemberDAOExternalUserDatabaseAbstract.java,v 1.20 2007/10/09 11:09:22 lexuanttkhtn Exp $
003: * $Author: lexuanttkhtn $
004: * $Revision: 1.20 $
005: * $Date: 2007/10/09 11:09:22 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Phong Ta
039: */
040: package com.mvnforum.db.common;
041:
042: import java.sql.*;
043: import java.util.Collection;
044:
045: import net.myvietnam.mvncore.db.DBUtils;
046: import net.myvietnam.mvncore.exception.*;
047:
048: import org.apache.commons.logging.Log;
049: import org.apache.commons.logging.LogFactory;
050:
051: import com.mvnforum.db.*;
052:
053: public class MemberDAOExternalUserDatabaseAbstract implements MemberDAO {
054:
055: private static Log log = LogFactory
056: .getLog(MemberDAOExternalUserDatabaseAbstract.class);
057:
058: protected MemberDAO memberDAO = DAOFactory.getLocalMemberDAO();
059:
060: public boolean isSupportCreate() {
061: return true;
062: }
063:
064: // To create forum-account if this is the first time the existing member go to the forum in portal
065: public void create(String memberName, String memberPassword,
066: String memberFirstEmail, String memberEmail,
067: int memberEmailVisible, int memberNameVisible,
068: String memberFirstIP, String memberLastIP,
069: int memberViewCount, int memberPostCount,
070: Timestamp memberCreationDate, Timestamp memberModifiedDate,
071: Timestamp memberExpireDate,
072: Timestamp memberPasswordExpireDate,
073: Timestamp memberLastLogon, int memberOption,
074: int memberStatus, String memberActivateCode,
075: String memberTempPassword, int memberMessageCount,
076: int memberMessageOption, int memberPostsPerPage,
077: int memberWarnCount, int memberVoteCount,
078: int memberVoteTotalStars, int memberRewardPoints,
079: String memberTitle, double memberTimeZone,
080: String memberSignature, String memberAvatar,
081: String memberSkin, String memberLanguage,
082: String memberFirstname, String memberLastname,
083: int memberGender, Date memberBirthday,
084: String memberAddress, String memberCity,
085: String memberState, String memberCountry,
086: String memberPhone, String memberMobile, String memberFax,
087: String memberCareer, String memberHomepage,
088: String memberYahoo, String memberAol, String memberIcq,
089: String memberMsn, String memberCoolLink1,
090: String memberCoolLink2) throws CreateException,
091: DatabaseException, DuplicateKeyException {
092:
093: memberDAO.create(memberName, memberPassword, memberFirstEmail,
094: memberEmail, memberEmailVisible, memberNameVisible,
095: memberFirstIP, memberLastIP, memberViewCount,
096: memberPostCount, memberCreationDate,
097: memberModifiedDate, memberExpireDate,
098: memberPasswordExpireDate, memberLastLogon,
099: memberOption, memberStatus, memberActivateCode,
100: memberTempPassword, memberMessageCount,
101: memberMessageOption, memberPostsPerPage,
102: memberWarnCount, memberVoteCount, memberVoteTotalStars,
103: memberRewardPoints, memberTitle, memberTimeZone,
104: memberSignature, memberAvatar, memberSkin,
105: memberLanguage, memberFirstname, memberLastname,
106: memberGender, memberBirthday, memberAddress,
107: memberCity, memberState, memberCountry, memberPhone,
108: memberMobile, memberFax, memberCareer, memberHomepage,
109: memberYahoo, memberAol, memberIcq, memberMsn,
110: memberCoolLink1, memberCoolLink2);
111: }
112:
113: public final String getNameFromID(int memberID)
114: throws ObjectNotFoundException, DatabaseException {
115:
116: Connection connection = null;
117: PreparedStatement statement = null;
118: ResultSet resultSet = null;
119: String sql = "SELECT MemberName FROM " + TABLE_NAME
120: + " WHERE MemberID = ?";
121: try {
122: connection = DBUtils.getConnection();
123: statement = connection.prepareStatement(sql);
124: statement.setInt(1, memberID);
125: resultSet = statement.executeQuery();
126: if (!resultSet.next()) {
127: throw new ObjectNotFoundException(
128: "Cannot find the row in table Member where MemberName = "
129: + memberID);
130: }
131: return resultSet.getString(1);
132: } catch (SQLException sqle) {
133: log.error("Sql Execution Error!", sqle);
134: throw new DatabaseException(
135: "Error executing SQL in MemberDAOExternalUserDatabaseAbstract.getMemberIDFromMemberName.");
136: } finally {
137: DBUtils.closeResultSet(resultSet);
138: DBUtils.closeStatement(statement);
139: DBUtils.closeConnection(connection);
140: }
141: }
142:
143: public boolean isSupportDeleteByPrimaryKey() {
144: return false;
145: }
146:
147: public void deleteByPrimaryKey(int memberID)
148: throws DatabaseException {
149: throw new IllegalStateException();
150: }
151:
152: public boolean isSupportFindByAlternateKey_MemberEmail() {
153: return false;
154: }
155:
156: public void findByAlternateKey_MemberEmail(String memberEmail)
157: throws ObjectNotFoundException, DatabaseException {
158: throw new IllegalStateException();
159: }
160:
161: public boolean isSupportFindByAlternateKey_MemberName() {
162: return true;
163: }
164:
165: // check reference to the other tables in forum portlet
166: public String findByAlternateKey_MemberName(String memberName)
167: throws ObjectNotFoundException, DatabaseException {
168: return memberDAO.findByAlternateKey_MemberName(memberName);
169: }
170:
171: public boolean isSupportFindByPrimaryKey() {
172: return true;
173: }
174:
175: // check reference to the other tables in forum portlet
176: public void findByPrimaryKey(int memberID)
177: throws ObjectNotFoundException, DatabaseException {
178: memberDAO.findByPrimaryKey(memberID);
179: }
180:
181: public boolean isSupportFindByPrimaryKey2() {
182: return true;
183: }
184:
185: // check reference to the other tables in forum portlet
186: public void findByPrimaryKey2(int memberID, String memberName)
187: throws ObjectNotFoundException, DatabaseException {
188: memberDAO.findByPrimaryKey2(memberID, memberName);
189: }
190:
191: public boolean isSupportGetActivateCode() {
192: return true;
193: }
194:
195: // need in OnlineUserFactoryImpl to check for user is activated or not
196: public String getActivateCode(int memberID)
197: throws ObjectNotFoundException, DatabaseException {
198: return memberDAO.getActivateCode(memberID);
199: //throw new IllegalStateException();
200: }
201:
202: public boolean isSupportGetAuthorizedMembers() {
203: return false;
204: }
205:
206: public Collection getAuthorizedMembers() throws DatabaseException {
207: throw new IllegalStateException();
208: }
209:
210: public boolean isSupportGetEnableMembers_inActivationStatus() {
211: return false;
212: }
213:
214: // need in GeneralAdminTasksWebHandler.sendMail() to send email to all activation members
215: public Collection getEnableMembers_inActivationStatus(String kind)
216: throws DatabaseException {
217: throw new IllegalStateException();
218: }
219:
220: public boolean isSupportGetEnableMembers_inGroup() {
221: return false;
222: }
223:
224: public Collection getEnableMembers_inGroup(int groupID)
225: throws DatabaseException {
226: throw new IllegalStateException();
227: }
228:
229: public boolean isSupportGetForumsAuthorizedMembers() {
230: return false;
231: }
232:
233: public Collection getForumsAuthorizedMembers()
234: throws DatabaseException {
235: throw new IllegalStateException();
236: }
237:
238: public boolean isSupportGetMember() {
239: return true;
240: }
241:
242: // Temporarily, to get member information when list post in a certain thread
243: public MemberBean getMember(int memberID)
244: throws ObjectNotFoundException, DatabaseException {
245: return memberDAO.getMember(memberID);
246: }
247:
248: public boolean isSupportGetMemberIDFromMemberEmail() {
249: return false;
250: }
251:
252: public int getMemberIDFromMemberEmail(String memberEmail)
253: throws ObjectNotFoundException, DatabaseException {
254: throw new IllegalStateException();
255: }
256:
257: public boolean isSupportGetMemberIDFromMemberName() {
258: return true;
259: }
260:
261: // we need this method because the viewmember and login need this method
262: public int getMemberIDFromMemberName(String memberName)
263: throws ObjectNotFoundException, DatabaseException {
264: return memberDAO.getMemberIDFromMemberName(memberName);
265: }
266:
267: public boolean isSupportGetMembers_inExpire_limit() {
268: return false;
269: }
270:
271: public Collection getMembers_inExpire_limit(Timestamp expireDate,
272: int offset, int rowsToReturn, String sort, String order)
273: throws IllegalArgumentException, DatabaseException {
274: throw new IllegalStateException();
275: }
276:
277: public boolean isSupportGetMembers_withSortSupport_limit() {
278: return false;
279: }
280:
281: public Collection getMembers_withSortSupport_limit(int offset,
282: int rowsToReturn, String sort, String order,
283: int memberStatus) throws IllegalArgumentException,
284: DatabaseException {
285: throw new IllegalStateException();
286: }
287:
288: public boolean isSupportGetMembers() {
289: return false;
290: }
291:
292: public Collection getMembers() throws DatabaseException {
293: throw new IllegalStateException();
294: }
295:
296: public boolean isSupportGetNonActivatedNoPostMembers() {
297: return false;
298: }
299:
300: public Collection getNonActivatedNoPostMembers(Timestamp before)
301: throws DatabaseException {
302: throw new IllegalStateException();
303: }
304:
305: public boolean isSupportGetNumberOfMembers_inActivationStatus() {
306: return false;
307: }
308:
309: public int getNumberOfMembers_inActivationStatus(
310: boolean activationStatus) throws DatabaseException {
311: throw new IllegalStateException();
312: }
313:
314: public boolean isSupportGetNumberOfMembers_inExpire() {
315: return false;
316: }
317:
318: public int getNumberOfMembers_inExpire(Timestamp expireDate)
319: throws DatabaseException {
320: throw new IllegalStateException();
321: }
322:
323: public boolean isSupportGetNumberOfMembers_inMemberStatus() {
324: return false;
325: }
326:
327: public int getNumberOfMembers_inMemberStatus(int memberStatus)
328: throws DatabaseException {
329: throw new IllegalStateException();
330: }
331:
332: public boolean isSupportGetNumberOfMembers() {
333: return true;
334: }
335:
336: // Ensure the forum is inited successfully @see com.mvnforum.MVNForumConfig
337: public int getNumberOfMembers() throws DatabaseException {
338: return memberDAO.getNumberOfMembers();
339: }
340:
341: public boolean isSupportGetPassword() {
342: return true;
343: }
344:
345: // This method is need by WatchMail.createWatchMessageBean to create the ConfirmedCode
346: public String getPassword(int memberID)
347: throws ObjectNotFoundException, DatabaseException {
348: return memberDAO.getPassword(memberID);
349: }
350:
351: public boolean isSupportGetTempPassword() {
352: return false;
353: }
354:
355: public String getTempPassword(int memberID)
356: throws ObjectNotFoundException, DatabaseException {
357: throw new IllegalStateException();
358: }
359:
360: public boolean isSupportIncreasePostCount() {
361: return true;
362: }
363:
364: // it is neccessary to change post count
365: public void increasePostCount(int memberID)
366: throws DatabaseException, ObjectNotFoundException {
367: memberDAO.increasePostCount(memberID);
368: }
369:
370: public boolean isSupportIncreaseViewCount() {
371: return true;
372: }
373:
374: // it is neccessary to change view count
375: public void increaseViewCount(int memberID)
376: throws DatabaseException, ObjectNotFoundException {
377: memberDAO.increaseViewCount(memberID);
378: }
379:
380: public boolean isSupportUpdate() {
381: return false;
382: }
383:
384: public void update(int memberID, int memberEmailVisible,
385: int memberNameVisible, Timestamp memberModifiedDate,
386: int memberOption, int memberStatus,
387: int memberMessageOption, int memberPostsPerPage,
388: double memberTimeZone, String memberSkin,
389: String memberLanguage, String memberFirstname,
390: String memberLastname, int memberGender,
391: Date memberBirthday, String memberAddress,
392: String memberCity, String memberState,
393: String memberCountry, String memberPhone,
394: String memberMobile, String memberFax, String memberCareer,
395: String memberHomepage, String memberYahoo,
396: String memberAol, String memberIcq, String memberMsn,
397: String memberCoolLink1, String memberCoolLink2)
398: throws ObjectNotFoundException, DatabaseException {
399:
400: throw new IllegalStateException();
401: }
402:
403: public boolean isSupportUpdateActivateCode() {
404: return true;
405: }
406:
407: // SendMailUtil.getActivationCodeEmail() use this method to change the activation code
408: public void updateActivateCode(int memberID,
409: String memberActivateCode) throws ObjectNotFoundException,
410: DatabaseException {
411: memberDAO.updateActivateCode(memberID, memberActivateCode);
412: }
413:
414: public boolean isSupportUpdateAvatar() {
415: return false;
416: }
417:
418: public void updateAvatar(int memberID, String memberAvatar)
419: throws ObjectNotFoundException, DatabaseException {
420: throw new IllegalStateException();
421: }
422:
423: public boolean isSupportUpdateEmail() {
424: return false;
425: }
426:
427: public void updateEmail(int memberID, String memberEmail)
428: throws ObjectNotFoundException, DatabaseException,
429: DuplicateKeyException {
430: throw new IllegalStateException();
431: }
432:
433: public boolean isSupportUpdateLastLogon() {
434: return true;
435: }
436:
437: // need in method OnlineUserFactoryImpl.getAuthenticatedUser
438: public void updateLastLogon(int memberID,
439: Timestamp memberLastLogon, String lastIP)
440: throws ObjectNotFoundException, DatabaseException {
441: memberDAO.updateLastLogon(memberID, memberLastLogon, lastIP);
442: }
443:
444: public boolean isSupportUpdateMember_expireDate() {
445: return false;
446: }
447:
448: public void updateMember_expireDate(int memberID,
449: Timestamp expireDate) throws ObjectNotFoundException,
450: DatabaseException {
451: throw new IllegalStateException();
452: }
453:
454: public boolean isSupportUpdatePassword() {
455: return false;
456: }
457:
458: public void updatePassword(int memberID, String memberPassword,
459: Timestamp memberPasswordExpireDate)
460: throws ObjectNotFoundException, DatabaseException {
461: throw new IllegalStateException();
462: }
463:
464: public boolean isSupportUpdatePostCount() {
465: return true;
466: }
467:
468: // use in StatisticsUtil.updateMemberStatistics called by PostWebHandler.processAdd
469: public void updatePostCount(int memberID, int memberPostCount)
470: throws ObjectNotFoundException, DatabaseException {
471: memberDAO.updatePostCount(memberID, memberPostCount);
472: }
473:
474: public boolean isSupportUpdateSignature() {
475: return false;
476: }
477:
478: public void updateSignature(int memberID, String memberSignature)
479: throws ObjectNotFoundException, DatabaseException {
480: throw new IllegalStateException();
481: }
482:
483: public boolean isSupportUpdateStatus() {
484: return false;
485: }
486:
487: public void updateStatus(int memberID, int memberStatus)
488: throws ObjectNotFoundException, DatabaseException {
489: throw new IllegalStateException();
490: }
491:
492: public boolean isSupportUpdateTempPassword() {
493: return false;
494: }
495:
496: public void updateTempPassword(int memberID,
497: String memberTempPassword) throws ObjectNotFoundException,
498: DatabaseException {
499: throw new IllegalStateException();
500: }
501:
502: public boolean isSupportUpdateTitle() {
503: return false;
504: }
505:
506: public void updateTitle(int memberID, String memberTitle)
507: throws ObjectNotFoundException, DatabaseException {
508: throw new IllegalStateException();
509: }
510:
511: public boolean isSupportGetMaxMemberID() {
512: return false;
513: }
514:
515: public int getMaxMemberID() throws DatabaseException {
516: throw new IllegalStateException();
517: }
518:
519: public boolean isSupportGetMembersFromIDRange() {
520: return false;
521: }
522:
523: public Collection getMembers_fromIDRange(int fromID, int toID)
524: throws IllegalArgumentException, DatabaseException {
525: throw new IllegalStateException();
526: }
527:
528: }
|