Search in sources :

Example 6 with WebInfo

use of org.compiere.util.WebInfo in project adempiere by adempiere.

the class WorkflowServlet method doGet.

/**
	 *  Process the HTTP Get request.
	 *  Sends Web Request Page
	 *
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.info("doGet from " + request.getRemoteHost() + " - " + request.getRemoteAddr() + " - forward to notes.jsp");
    String url = "/notes.jsp";
    //
    HttpSession session = request.getSession(false);
    if (session == null || session.getAttribute(WebInfo.NAME) == null)
        url = "/login.jsp";
    else {
        session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
        WebInfo info = (WebInfo) session.getAttribute(WebInfo.NAME);
        if (info != null)
            info.setMessage("");
        //	Parameter = Activity_ID - if valid and belongs to wu then create PDF & stream it
        String msg = streamAttachment(request, response);
        if (msg == null || msg.length() == 0)
            return;
        if (info != null)
            info.setMessage(msg);
    }
    log.info("doGet - Forward to " + url);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebInfo(org.compiere.util.WebInfo) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 7 with WebInfo

use of org.compiere.util.WebInfo in project adempiere by adempiere.

the class Generator method generateSessionEquiv.

private void generateSessionEquiv(HttpServletCM thisServlet, HttpServletRequest httpRequest, Properties ctx) {
    xmlCode.append("<session>\n");
    HttpSession thisSession = httpRequest.getSession(false);
    if (thisSession != null) {
        if (thisSession.getAttribute(WebInfo.NAME) != null) {
            WebInfo wi = (WebInfo) thisSession.getAttribute(WebInfo.NAME);
            xmlCode.append("<WebInfo>\n");
            xmlCode.append("<Info><![CDATA[" + wi.getInfo() + "]]></Info>\n");
            if (wi.getUser_ID() > 0) {
                MUser thisUser = MUser.get(ctx, wi.getAD_User_ID());
                xmlCode = thisUser.get_xmlString(xmlCode);
                MBPartner thisBPartner = new MBPartner(ctx, wi.getC_BPartner_ID(), null);
                if (thisBPartner != null)
                    xmlCode = thisBPartner.get_xmlString(xmlCode);
                MBPartnerLocation thisBPartnerLocation = thisBPartner.getPrimaryC_BPartner_Location();
                if (thisBPartnerLocation != null)
                    xmlCode = thisBPartnerLocation.get_xmlString(xmlCode);
                MLocation thisLocation = MLocation.getBPLocation(ctx, thisBPartnerLocation.get_ID(), null);
                if (thisLocation != null)
                    xmlCode = thisLocation.get_xmlString(xmlCode);
                MBPBankAccount[] theseBPBankAccount = thisBPartner.getBankAccounts(true);
                if (theseBPBankAccount != null && theseBPBankAccount.length > 0)
                    for (int i = 0; i < theseBPBankAccount.length; i++) xmlCode = theseBPBankAccount[i].get_xmlString(xmlCode);
                if (thisSession.getAttribute("EMail") == null)
                    thisSession.setAttribute("EMail", thisUser.getEMail());
            }
            if (wi.getWebUser().getPasswordMessage() != null) {
                xmlCode.append("<PasswordMessage><![CDATA[" + wi.getWebUser().getPasswordMessage() + "]]></PasswordMessage>\n");
                wi.getWebUser().setPasswordMessage(null);
            }
            if (wi.getWebUser().getSaveErrorMessage() != null) {
                xmlCode.append("<SaveErrorMessage><![CDATA[" + wi.getWebUser().getSaveErrorMessage() + "]]></SaveErrorMessage>\n");
                wi.getWebUser().setSaveErrorMessage(null);
            }
            if (thisSession.getAttribute("hdrMessage") != null) {
                xmlCode.append("<hdrMessage><![CDATA[" + thisSession.getAttribute("hdrMessage") + "]]></hdrMessage>\n");
                thisSession.removeAttribute("hdrMessage");
            }
            xmlCode.append("<WebUser>\n");
            xmlCode.append("<LoggedIn>" + wi.getWebUser().isLoggedIn() + "</LoggedIn>\n");
            xmlCode.append("</WebUser>\n");
            xmlCode.append("</WebInfo>\n");
        }
        if (thisSession.getAttribute("EMail") != null)
            xmlCode.append("<EMail><![CDATA[" + thisSession.getAttribute("EMail") + "]]></EMail>\n");
    }
    xmlCode.append("</session>\n");
}
Also used : HttpSession(javax.servlet.http.HttpSession) MBPBankAccount(org.compiere.model.MBPBankAccount) MBPartner(org.compiere.model.MBPartner) WebInfo(org.compiere.util.WebInfo) MUser(org.compiere.model.MUser) MLocation(org.compiere.model.MLocation) MBPartnerLocation(org.compiere.model.MBPartnerLocation)

Example 8 with WebInfo

use of org.compiere.util.WebInfo in project adempiere by adempiere.

the class InfoLinkTag method doStartTag.

//	setOneLine
/**
	 *  Start Tag
	 *  @return SKIP_BODY
	 * 	@throws JspException
	 */
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    //	creates wsc/wu
    Properties ctx = JSPEnv.getCtx(request);
    WebSessionCtx wsc = WebSessionCtx.get(request);
    //
    HttpSession session = pageContext.getSession();
    WebUser wu = (WebUser) session.getAttribute(WebUser.NAME);
    if (wu != null && wu.isLoggedIn()) {
        if (ctx != null) {
            WebInfo info = (WebInfo) session.getAttribute(WebInfo.NAME);
            if (info == null || wu.getAD_User_ID() != info.getAD_User_ID()) {
                info = new WebInfo(ctx, wu);
                session.setAttribute(WebInfo.NAME, info);
            }
        }
        //
        //	log.fine("WebUser exists - " + wu);
        //
        JspWriter out = pageContext.getOut();
        HtmlCode html = new HtmlCode();
        //
        if (wu.isCustomer() || wu.isVendor())
            menuBPartner(html, wsc.wstore);
        if (wu.isSalesRep())
            menuSalesRep(html, wsc.wstore);
        if (wu.isEmployee() || wu.isSalesRep())
            menuUser(html, wu.isEmployee(), wsc.wstore);
        menuAll(html, wsc.wstore);
        //
        html.output(out);
    } else {
        if (CLogMgt.isLevelFiner())
            log.fine("No WebUser");
        if (session.getAttribute(WebInfo.NAME) == null)
            session.setAttribute(WebInfo.NAME, WebInfo.getGeneral());
    }
    return (SKIP_BODY);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HtmlCode(org.compiere.util.HtmlCode) HttpSession(javax.servlet.http.HttpSession) WebUser(org.compiere.util.WebUser) Properties(java.util.Properties) WebSessionCtx(org.compiere.util.WebSessionCtx) JspWriter(javax.servlet.jsp.JspWriter) WebInfo(org.compiere.util.WebInfo)

Example 9 with WebInfo

use of org.compiere.util.WebInfo in project adempiere by adempiere.

the class RfQServlet method doGet.

/**
	 *  Process the HTTP Get request
	 *  Sends Web Request Page
	 *
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.info("doGet from " + request.getRemoteHost() + " - " + request.getRemoteAddr());
    String url = "/rfqs.jsp";
    //
    HttpSession session = request.getSession(false);
    if (session == null || session.getAttribute(WebInfo.NAME) == null)
        url = "/login.jsp";
    else {
        session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
        WebInfo info = (WebInfo) session.getAttribute(WebInfo.NAME);
        if (info != null)
            info.setMessage("");
        //	Parameter = Note_ID - if is valid create PDF & stream it
        String msg = streamAttachment(request, response);
        if (msg == null || msg.length() == 0)
            return;
        if (info != null)
            info.setMessage(msg);
    }
    log.info("doGet - Forward to " + url);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebInfo(org.compiere.util.WebInfo) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 10 with WebInfo

use of org.compiere.util.WebInfo in project adempiere by adempiere.

the class RequestServlet method doGet.

/**
	 *  Process the HTTP Get request.
	 *  Sends Attachment
	 *
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.info("From " + request.getRemoteHost() + " - " + request.getRemoteAddr());
    String url = "/requestDetails.jsp";
    //
    HttpSession session = request.getSession(false);
    if (session == null || session.getAttribute(WebInfo.NAME) == null)
        url = "/login.jsp";
    else {
        session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
        WebInfo info = (WebInfo) session.getAttribute(WebInfo.NAME);
        if (info != null)
            info.setMessage("");
        //	Parameter = Note_ID - if is valid and belongs to wu then create PDF & stream it
        String msg = streamAttachment(request, response);
        if (msg == null || msg.length() == 0)
            return;
        if (info != null)
            info.setMessage(msg);
    }
    log.info("Forward to " + url);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebInfo(org.compiere.util.WebInfo) RequestDispatcher(javax.servlet.RequestDispatcher)

Aggregations

HttpSession (javax.servlet.http.HttpSession)10 WebInfo (org.compiere.util.WebInfo)10 RequestDispatcher (javax.servlet.RequestDispatcher)6 Properties (java.util.Properties)2 SQLException (java.sql.SQLException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspWriter (javax.servlet.jsp.JspWriter)1 MBPBankAccount (org.compiere.model.MBPBankAccount)1 MBPartner (org.compiere.model.MBPartner)1 MBPartnerLocation (org.compiere.model.MBPartnerLocation)1 MLocation (org.compiere.model.MLocation)1 MTable (org.compiere.model.MTable)1 MUser (org.compiere.model.MUser)1 PO (org.compiere.model.PO)1 X_CM_TemplateTable (org.compiere.model.X_CM_TemplateTable)1 HtmlCode (org.compiere.util.HtmlCode)1 WebSessionCtx (org.compiere.util.WebSessionCtx)1 WebUser (org.compiere.util.WebUser)1