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

📄 orgaccess.java

📁 EOS的一个很好的例子.包括页面构件、展现构件
💻 JAVA
字号:
/** EOS Tag Java File **/
package com.primeton.eos.fbframe.tag;

import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import org.w3c.dom.*;

import com.primeton.eos.bizlets.util.BNXmlUtil;
import com.primeton.tp.common.xml.XmlUtil;
import com.primeton.tp.core.api.PersistenceBroker;
import com.primeton.tp.core.bizservice.EOSParameter;
import com.primeton.tp.core.config.EOSAppConfiguration;
import com.primeton.tp.core.prservice.context.RequestContext;
import com.primeton.tp.core.prservice.context.SessionContext;
import com.primeton.tp.web.driver.webdriver.WebDriver;


public class OrgAccess extends TagSupport {
	private String id;
	private String orgIdProperty;
	private String orgSeqProperty;
	
	/**
	 * @return 返回 id。
	 */
	public String getId() {
		return id;
	}
	/**
	 * @param id 要设置的 id。
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * @return 返回 orgIdProperty。
	 */
	public String getOrgIdProperty() {
		return orgIdProperty;
	}
	/**
	 * @param orgIdProperty 要设置的 orgIdProperty。
	 */
	public void setOrgIdProperty(String orgIdProperty) {
		this.orgIdProperty = orgIdProperty;
	}
	/**
	 * @return 返回 orgSeqProperty。
	 */
	public String getOrgSeqProperty() {
		return orgSeqProperty;
	}
	/**
	 * @param orgSeqProperty 要设置的 orgSeqProperty。
	 */
	public void setOrgSeqProperty(String orgSeqProperty) {
		this.orgSeqProperty = orgSeqProperty;
	}
	public OrgAccess() {
		id = WebDriver.REQUEST_REQUEST_CONTEXT;
		orgIdProperty = null;
		orgSeqProperty = null;
	}

	public int doStartTag() throws JspException {
		//TODO Add your code here. 
		String orgId = null;
		String orgSeq = null;
		SessionContext sessioncontext = (SessionContext)pageContext.getSession().getAttribute("sessionContext");
		if (sessioncontext == null)
			throw new JspException("Session not find");

		try
		{
			RequestContext requestcontext = (RequestContext)pageContext.getAttribute(id);
			if (requestcontext == null)
				requestcontext = (RequestContext)pageContext.getRequest().getAttribute(id);
			if (requestcontext == null)
				requestcontext = (RequestContext)pageContext.getSession().getAttribute(id);
			if (requestcontext == null)
				throw new JspException("can not find dom");
			if (orgIdProperty != null)
				orgId = requestcontext.getProperty(orgIdProperty);
			if (orgSeqProperty != null)
				orgSeq = requestcontext.getProperty(orgSeqProperty);
		}
		catch (Exception exception)
		{
			throw new JspException(exception.toString());
		}

		if ((orgId == null || orgId.equals("")) && (orgSeq == null || orgSeq.equals("")))
			return 1;
		if (orgSeq == null|| orgSeq.equals("")) {
			EOSParameter param = new EOSParameter();
	        param.setAppID(EOSAppConfiguration.getDefaultAppID());
	        param.setUnitName("fborg");
	        param.setUnitId("0");
	        Document dom = XmlUtil.newDocument();
			Element org = dom.createElement("EOSORG_T_Organization");
			BNXmlUtil.setNodeValue(org, "orgID", orgId);
			org.setAttribute("criteria", "=");
			try {
				PersistenceBroker dbroker = param.getDBBroker();
				dbroker.expandAll(org);
				orgSeq = XmlUtil.getNodeValue(XmlUtil.findNode(org, "EOSORG_T_Organization/orgSEQ"));
			} catch (Exception e) {
				try {
					param.closeDB();
				} catch (Exception e1) {
					// TODO 自动生成 catch 块
					e1.printStackTrace();
				}
				e.printStackTrace();
				throw new JspException(e.toString());
			}
		}
		if (orgSeq == null|| orgSeq.equals("")) {
			throw new JspException("the organization info is error!");
		}
		Node sessionEntity = sessioncontext.getSessionEntity();
		try {
			NodeList rolelist = XmlUtil.findNodes(sessionEntity, "SessionEntity/rolelist/EOSOperatorRole/roleID");
			for (int i=0; i<rolelist.getLength(); i++) {
				Node roleid = rolelist.item(i);
				String id = XmlUtil.getNodeValue(roleid);
				if (id != null && id.equals("eosadmin")) {
					return 1;
				}
			}
			Node seq = XmlUtil.findNode(sessionEntity, "SessionEntity/orgSEQ");
			if (seq != null && !seq.equals("")) {
				String org_seq = XmlUtil.getNodeValue(seq);
				if (org_seq != null && orgSeq.startsWith(org_seq)) {
					return 1;
				}
				return 0;
			} else {
				String userId = sessioncontext.getUserID();
				String sOrgId = null;
				String sOrgSeq = null;
				EOSParameter param = new EOSParameter();
		        param.setAppID(EOSAppConfiguration.getDefaultAppID());
		        param.setUnitName("fborg");
		        param.setUnitId("0");
		        Document dom = XmlUtil.newDocument();
				Element user = dom.createElement("EOSORG_V_Users");
				BNXmlUtil.setNodeValue(user, "userID", userId);
				user.setAttribute("criteria", "=");
				try {
					PersistenceBroker dbroker = param.getDBBroker();
					dbroker.expandAll(user);
					sOrgId = XmlUtil.getNodeValue(XmlUtil.findNode(user, "EOSORG_V_Users/orgID"));
					sOrgSeq = XmlUtil.getNodeValue(XmlUtil.findNode(user, "EOSORG_V_Users/orgSEQ"));
				} catch (Exception e) {
					try {
						param.closeDB();
					} catch (Exception e1) {
						// TODO 自动生成 catch 块
						e1.printStackTrace();
					}
					e.printStackTrace();
					throw new JspException(e.toString());
				}
				if (sOrgSeq == null) sOrgSeq = "";
				if (sOrgId == null) sOrgId = "";
				if (sOrgSeq.equals("")) {
					throw new JspException("the organization info is error!");
				}
				BNXmlUtil.setNodeValue(sessionEntity, "orgID", sOrgId);
				BNXmlUtil.setNodeValue(sessionEntity, "orgSEQ", sOrgSeq);
				if (orgSeq.startsWith(sOrgSeq)) {
					return 1;
				}
			}
		} catch (Exception e) {
			throw new JspException(e.toString());
		}
		return 0;
	}
	
	
	/* (非 Javadoc)
	 * @see javax.servlet.jsp.tagext.Tag#release()
	 */
	public void release() {
		// TODO 自动生成方法存根
		orgIdProperty = null;
		orgSeqProperty = null;
		super.release();
	}

	public int doEndTag() throws JspException {
		//TODO Add your code here. 
		return super.doEndTag();
	}
}

⌨️ 快捷键说明

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