com.huateng.ebank.business.common.GlobalInfo.java Source code

Java tutorial

Introduction

Here is the source code for com.huateng.ebank.business.common.GlobalInfo.java

Source

/*
 * ===================================================================
 * The Huateng Software License
 *
 * Copyright (c) 2003-2004 Huateng Software System.  All rights
 * reserved.
 * ===================================================================
 */

package com.huateng.ebank.business.common;

import java.io.Serializable;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

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

import com.huateng.ebank.framework.exceptions.CommonException;
import com.huateng.ebank.framework.util.DataFormat;
import com.huateng.ebank.framework.util.ExceptionUtil;

/**
 * @author jason.mao
 * @date 2010-07-28
 * @desc ?
 */

public class GlobalInfo extends BaseGlobalData implements Serializable {

    public GlobalInfo() {
    }

    /**
    *
    */
    private static final long serialVersionUID = 1L;
    private static ThreadLocal session = new ThreadLocal();
    private static final Log log = LogFactory.getLog(GlobalInfo.class);

    public static String KEY_GLOBAL_INFO = "GLOBAL_INFO";

    /***
     * post
     */
    private Date txdate = null; //
    private String tlrno = null; //??
    private String brno = null; //?
    private String brcode = null; //?
    private String branchBrcode = null; //?
    private String brClass = null; //
    private String workflowRoleId = "";//????
    private String funcCode; //?
    private String sessionId = "";//session
    private String language = null;//,?
    private String tokenId = null;

    /**
     * ,
     */
    private String ip = null; //IP
    private Time txtime = null; //
    private int tlsrnoPr = 0; //??
    private int tlsrnoEx = 0; //??

    /**
     * ,,?
     */
    private String contractno = null; //???
    private String cino = null; //??
    private String custcd = null; //?
    private String appno = null; //?
    private double txamt = 0; //?

    /**
     * 
     */
    private Map allFunctions = Collections.synchronizedMap(new LinkedHashMap());//??\
    private String workflowTlrno;//?????

    private String contractnoFlag = "0";
    private String custcdFlag = "0";
    private String appnoFlag = "0";
    private String txamtFlag = "0";

    //add by learncy.zou 2011-02-15 begin
    private String taskId = "";// ?
    private String procInsId = "";// ??
    private int roleId = 0;
    //add by learncy.zou 2011-02-15 end

    /* add by shishu.zhang for TopReport 2012-8-15 begin.*/
    private Date lastDate; //
    private String brName;
    //============================================report============
    private String fileDate;//?

    private String saveQueryLog;//?

    private List confrimCodeList = new ArrayList();//??

    private String menuCode;//??

    //==============================================================

    public String getFileDate() {
        return fileDate;
    }

    public void setFileDate(String fileDate) {
        this.fileDate = fileDate;
    }

    public String getBrName() {
        return brName;
    }

    public void setBrName(String brName) {
        this.brName = brName;
    }

    public Date getLastDate() {
        return lastDate;
    }

    public void setLastDate(Date lastDate) {
        this.lastDate = lastDate;
    }
    /* add by shishu.zhang for TopReport 2012-8-15 end.*/

    private String sContextPath = "";

    /* modify by shen_anotnio JIRA:FPP-4 2011-12-18 begin.*/
    private String assignedOprid = null;

    public String getAssignedOprid() {
        return assignedOprid;
    }

    public void setAssignedOprid(String assignedOprid) {
        this.assignedOprid = assignedOprid;
    }
    /* modify by shen_anotnio JIRA:FPP-4 2011-12-18 end.*/

    public String getTaskId() {
        return taskId;
    }

    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getProcInsId() {
        return procInsId;
    }

    public void setProcInsId(String procInsId) {
        this.procInsId = procInsId;
    }

    public String getContractnoFlag() {
        return contractnoFlag;
    }

    public void setContractnoFlag(String contractnoFlag) {
        this.contractnoFlag = contractnoFlag;
    }

    public String getCustcdFlag() {
        return custcdFlag;
    }

    public void setCustcdFlag(String custcdFlag) {
        this.custcdFlag = custcdFlag;
    }

    public String getAppnoFlag() {
        return appnoFlag;
    }

    public void setAppnoFlag(String appnoFlag) {
        this.appnoFlag = appnoFlag;
    }

    public String getTxamtFlag() {
        return txamtFlag;
    }

    public void setTxamtFlag(String txamtFlag) {

        this.txamtFlag = txamtFlag;
    }

    public static GlobalInfo getFromRequest(HttpServletRequest request) throws CommonException {
        HttpSession httpSession = request.getSession();
        GlobalInfo globalInfo = (GlobalInfo) httpSession.getAttribute(GlobalInfo.KEY_GLOBAL_INFO);

        if (log.isDebugEnabled()) {
            log.debug("session id = " + httpSession.getId());
        }

        if (null != globalInfo) {
            setCurrentInstance(globalInfo);
            String oldSessionId = globalInfo.getSessionId();
            String sessionId = httpSession.getId();
            if (!sessionId.equals(oldSessionId)) {
                ExceptionUtil.throwCommonException("???, ?.",
                        ErrorCode.ERROR_CODE_TLRNO_SESSION_BINDED);
            }
            globalInfo.setSessionId(sessionId);
        }
        return globalInfo;
    }

    /* shen_antonio .*/
    public static GlobalInfo getFromRequest2(HttpServletRequest request) throws CommonException {
        HttpSession httpSession = request.getSession();
        GlobalInfo globalInfo = (GlobalInfo) httpSession.getAttribute(GlobalInfo.KEY_GLOBAL_INFO);

        if (log.isDebugEnabled()) {
            log.debug("session id = " + httpSession.getId());
        }

        if (null != globalInfo) {
            setCurrentInstance(globalInfo);
            String sessionId = httpSession.getId();
            globalInfo.setSessionId(sessionId);
        }
        return globalInfo;
    }

    public static void setGlobalInfo2HttpSession(HttpSession httpSession, GlobalInfo globalInfo) {
        httpSession.setAttribute(GlobalInfo.KEY_GLOBAL_INFO, globalInfo);
        globalInfo.setSessionId(httpSession.getId());
    }

    public static GlobalInfo getCurrentInstance() throws CommonException {
        GlobalInfo gi = (GlobalInfo) session.get();

        if (null == gi) {
            ExceptionUtil.throwCommonException("GlobalInfo",
                    ErrorCode.ERROR_CODE_NO_GLOBALINFO_INSTANCE);
        }

        return gi;
    }

    public static GlobalInfo getCurrentInstanceWithoutException() {
        GlobalInfo gi = (GlobalInfo) session.get();
        return gi;
    }

    public static void setCurrentInstance(GlobalInfo gi) {
        session.set(gi);
    }

    /**
     * ???
     * @param tlsrnoPr
     * @param tlsrnoEx
     */
    public void initTlsrno(int tlsrnoPr, int tlsrnoEx) {
        this.tlsrnoPr = tlsrnoPr;
        this.tlsrnoEx = tlsrnoEx;
    }

    /**
     * ???
     * @return
     */
    public String getTlsrno() {
        return DataFormat.intToString(tlsrnoPr, 5) + DataFormat.intToString(tlsrnoEx, 4);
    }

    /**
     * ???
     * @return
     */
    public String getNextTlsrno() {
        tlsrnoEx++;
        return DataFormat.intToString(tlsrnoPr, 5) + DataFormat.intToString(tlsrnoEx, 4);
    }

    public Date getTxdate() {
        return txdate;
    }

    public void setTxdate(Date txdate) {
        this.txdate = txdate;
    }

    public String getTlrno() {
        return tlrno;
    }

    public void setTlrno(String tlrno) {
        this.tlrno = tlrno;
    }

    public String getBrno() {
        return brno;
    }

    public void setBrno(String brno) {
        this.brno = brno;
    }

    public String getBrcode() {
        return brcode;
    }

    public void setBrcode(String brcode) {
        this.brcode = brcode;
    }

    public String getBranchBrcode() {
        return branchBrcode;
    }

    public void setBranchBrcode(String branchBrcode) {
        this.branchBrcode = branchBrcode;
    }

    public String getBrClass() {
        return brClass;
    }

    public void setBrClass(String brClass) {
        this.brClass = brClass;
    }

    public String getWorkflowRoleId() {
        return workflowRoleId;
    }

    public void setWorkflowRoleId(String workflowRoleId) {
        this.workflowRoleId = workflowRoleId;
    }

    public String getFuncCode() {
        return funcCode;
    }

    public void setFuncCode(String funcCode) {
        this.funcCode = funcCode;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Time getTxtime() {
        return txtime;
    }

    public void setTxtime(Time txtime) {
        this.txtime = txtime;
    }

    public int getTlsrnoPr() {
        return tlsrnoPr;
    }

    public void setTlsrnoPr(int tlsrnoPr) {
        this.tlsrnoPr = tlsrnoPr;
    }

    public int getTlsrnoEx() {
        return tlsrnoEx;
    }

    public void setTlsrnoEx(int tlsrnoEx) {
        this.tlsrnoEx = tlsrnoEx;
    }

    public String getContractno() {
        return contractno;
    }

    public void setContractno(String contractno) {
        this.contractno = contractno;
    }

    public String getCino() {
        return cino;
    }

    public void setCino(String cino) {
        this.cino = cino;
    }

    public String getCustcd() {
        return custcd;
    }

    public void setCustcd(String custcd) {
        this.custcd = custcd;
    }

    public String getAppno() {
        return appno;
    }

    public void setAppno(String appno) {
        this.appno = appno;
    }

    public double getTxamt() {
        return txamt;
    }

    public void setTxamt(double txamt) {
        this.txamt = txamt;
    }

    public Map getAllFunctions() {
        return allFunctions;
    }

    public void setAllFunctions(Map allFunctions) {
        this.allFunctions = allFunctions;
    }

    public String getTokenId() {
        return tokenId;
    }

    public void setTokenId(String tokenId) {
        this.tokenId = tokenId;
    }

    public String getWorkflowTlrno() {
        return workflowTlrno;
    }

    public void setWorkflowTlrno(String workflowTlrno) {
        this.workflowTlrno = workflowTlrno;
    }

    /**
     * set?
     * @param contractno
     * @param custcd
     * @param appno
     * @param txamt
     */
    public void setTransData(String contractno, String custcd, String appno, String txamt) {
        if (!DataFormat.isEmpty(contractno)) {
            this.contractno = contractno;
        }
        if (!DataFormat.isEmpty(custcd)) {
            this.custcd = custcd;
        }
        if (!DataFormat.isEmpty(appno)) {
            this.appno = appno;
        }
        if (!DataFormat.isEmpty(txamt) && !txamt.equals("null")) {
            this.txamt = Double.valueOf(txamt);
        }
    }

    public String getFormatedDate() {

        return DataFormat.dateToString(txdate);
    }

    private boolean isHeadBrcode = false; // ??

    public boolean isHeadBrcode() {
        return isHeadBrcode;
    }

    public void setHeadBrcode(boolean isHeadBrcode) {
        this.isHeadBrcode = isHeadBrcode;
    }

    public String getSContextPath() {
        return sContextPath;
    }

    public void setSContextPath(String contextPath) {
        sContextPath = contextPath;
    }

    /** add by zhaozhiguo ??? BMS-3153 begin */
    private boolean pswdForcedToChange = false;
    private Date lastpwdchgtm;
    private int effectiveDay;
    private static String pswdStrength = "0";

    public boolean isPswdForcedToChange() {
        return pswdForcedToChange;
    }

    public void setPswdForcedToChange(boolean pswdForcedToChange) {
        this.pswdForcedToChange = pswdForcedToChange;
    }

    public Date getLastpwdchgtm() {
        return lastpwdchgtm;
    }

    public void setLastpwdchgtm(Date lastpwdchgtm) {
        this.lastpwdchgtm = lastpwdchgtm;
    }

    public int getEffectiveDay() {
        return effectiveDay;
    }

    public void setEffectiveDay(int effectiveDay) {
        this.effectiveDay = effectiveDay;
    }

    public static String getPswdStrength() {
        return pswdStrength;
    }

    public static void setPswdStrength(String pswdStrength) {
        GlobalInfo.pswdStrength = pswdStrength;
    }

    /** add by zhaozhiguo ??? BMS-3153 end */

    /* modify by zhiguo.zhao JIRA: FPP-3 2011-12-16 begin .*/
    private Locale locale;

    public Locale getLocale() {
        if (locale == null) {
            log.warn("locale is null, is setted to default.");
            return Locale.getDefault();
        } else {
            return locale;
        }
    }

    public void setLocale(Locale locale) {
        this.locale = locale;
    }
    /* modify by zhiguo.zhao JIRA: FPP-3 2011-12-16 end .*/

    public String getSaveQueryLog() {
        return saveQueryLog;
    }

    public void setSaveQueryLog(String saveQueryLog) {
        this.saveQueryLog = saveQueryLog;
    }

    public List getConfrimCodeList() {
        return confrimCodeList;
    }

    public void setConfrimCodeList(List confrimCodeList) {
        this.confrimCodeList = confrimCodeList;
    }

    public String getMenuCode() {
        return menuCode;
    }

    public void setMenuCode(String menuCode) {
        this.menuCode = menuCode;
    }

}