⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractsampleauthenticator.java

📁 解觖java技术中后台无法上传数给的情况
💻 JAVA
字号:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/auth/AbstractSampleAuthenticator.java,v 1.3 2006/04/14 16:29:56 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.3 $
 * $Date: 2006/04/14 16:29:56 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2006 by MyVietnam.net
 *
 * All copyright notices regarding mvnForum MUST remain 
 * intact in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in 
 * the footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at MyVietnam net
 *
 * @author: Minh Nguyen
 * @author: Anh Dong Thi Lan
 */
package com.mvnforum.auth;

import java.sql.Date;
import java.sql.Timestamp;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.myvietnam.mvncore.exception.CreateException;
import net.myvietnam.mvncore.exception.DatabaseException;
import net.myvietnam.mvncore.exception.DuplicateKeyException;
import net.myvietnam.mvncore.exception.ForeignKeyNotFoundException;
import net.myvietnam.mvncore.exception.ObjectNotFoundException;
import net.myvietnam.mvncore.util.DateUtil;
import net.myvietnam.mvncore.util.ParamUtil;
import net.myvietnam.mvncore.web.GenericRequest;

import com.mvnforum.MVNForumConfig;
import com.mvnforum.MVNForumConstant;
import com.mvnforum.common.SendMailUtil;
import com.mvnforum.db.DAOFactory;
import com.mvnforum.db.MemberBean;
import com.mvnforum.search.member.MemberIndexer;


public abstract class AbstractSampleAuthenticator extends AbstractAuthenticator {

    private static Log log = LogFactory.getLog(AbstractSampleAuthenticator.class);

    protected static void createAccount(String memberName, GenericRequest request)
        throws ObjectNotFoundException, CreateException, DatabaseException,
        DuplicateKeyException, ForeignKeyNotFoundException {

        Timestamp now = DateUtil.getCurrentGMTTimestamp();
        Date memberBirthday = new java.sql.Date(now.getTime());

        // You should think of creating the email based on your company policy
        String email = memberName + "@yourdomain.com";

        DAOFactory.getMemberDAO().create(memberName, OnlineUserManager.PASSWORD_OF_METHOD_CUSTOMIZATION, email,
                email, MemberBean.MEMBER_EMAIL_VISIBLE, MemberBean.MEMBER_NAME_VISIBLE,
                request.getRemoteAddr(), request.getRemoteAddr(), 0/*memberViewCount*/,
                0/*memberPostCount*/, now, now,now,
                now/*memberLastLogon*/, 0, MemberBean.MEMBER_STATUS_ENABLE,
                "", ""/*memberTempPassword*/, 0/*memberMessageCount*/,
                0, 10, 0/*memberWarnCount*/,
                0/*memberVoteCount*/, 0/*memberVoteTotalStars*/, 0/*memberRewardPoints*/,
                ""/*memberTitle*/, 0/*memberTimeZone*/, ""/*memberSignature*/,
                ""/*memberAvatar*/, ""/*memberSkin*/, ""/*memberLanguage*/,
                ""/*memberFirstname*/, ""/*memberLastname*/, 1/*memberGender*/,
                memberBirthday, ""/*memberAddress*/, ""/*memberCity*/,
                ""/*memberState*/, ""/*memberCountry*/, ""/*memberPhone*/,
                ""/*memberMobile*/, ""/*memberFax*/, ""/*memberCareer*/,
                ""/*memberHomepage*/, ""/*memberYahoo*/, ""/*memberAol*/,
                ""/*memberIcq*/, ""/*memberMsn*/, ""/*memberCoolLink1*/,
                ""/*memberCoolLink2*/);

        // Now, create 4 default folders for each member
        int memberID = DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName);
        int folderStatus = 0;
        int folderOption = 0;
        int folderType = 0;
        DAOFactory.getMessageFolderDAO().create(MVNForumConstant.MESSAGE_FOLDER_INBOX, memberID, 0/*order*/, folderStatus, folderOption, folderType, now, now);
        DAOFactory.getMessageFolderDAO().create(MVNForumConstant.MESSAGE_FOLDER_DRAFT, memberID, 1/*order*/, folderStatus, folderOption, folderType, now, now);
        DAOFactory.getMessageFolderDAO().create(MVNForumConstant.MESSAGE_FOLDER_SENT, memberID, 2/*order*/, folderStatus, folderOption, folderType, now, now);
        DAOFactory.getMessageFolderDAO().create(MVNForumConstant.MESSAGE_FOLDER_TRASH, memberID, 3/*order*/, folderStatus, folderOption, folderType, now, now);

        // Add member to the lucene index
        MemberBean memberBean = DAOFactory.getMemberDAO().getMember_forPublic(memberID);
        MemberIndexer.scheduleAddMemberTask(memberBean);

        // now, if require activation, then we will send mail
        // Note that because after this page succeed,
        // we redirect to usermanagement so not use mvnforum.mail.failed now
        if (MVNForumConfig.getRequireActivation()) {
            String serverName = ParamUtil.getServerPath(); //ParamUtil.getServer2(request);
            try {
                SendMailUtil.sendActivationCodeEmail(memberID, serverName);
            } catch (Exception ex) {
                log.error("Cannot send mail after registration!", ex);
                request.setAttribute("mvnforum.mail.failed", "Cannot send activation email after registration!");
                //@todo: save the error message to displayed later
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -