Search in sources :

Example 1 with WebInfo

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

the class InvoiceServlet method doGet.

//  destroy
/**
	 *  Process the HTTP Get request.
	 * 	(logout, deleteCookie)
	 *  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("From " + request.getRemoteHost() + " - " + request.getRemoteAddr());
    String url = "/invoices.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 = Invoice_ID - if invoice is valid and belongs to wu then create PDF & stream it
        String msg = streamInvoice(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)

Example 2 with WebInfo

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

the class NoteServlet method doGet.

/**
	 *  Process the HTTP Get request.
	 *  Attachment Download request
	 *
	 *  @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 = "/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 = 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)

Example 3 with WebInfo

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

the class Generator method generateRequest.

/**
	 * Creates the XML tree for request tables.
	 * 
	 * @param httpRequest
	 * @param thisXML
	 * @param ctx
	 */
private void generateRequest(HttpServletRequest httpRequest, org.compiere.cm.cache.XML thisXML, Properties ctx) {
    HttpSession thisSession = httpRequest.getSession(false);
    WebInfo wi = null;
    if (thisSession != null) {
        if (thisSession.getAttribute(WebInfo.NAME) != null)
            wi = (WebInfo) thisSession.getAttribute(WebInfo.NAME);
        xmlCode.append("<requestTables>\n");
        int l_nClientID = Integer.parseInt(ctx.getProperty("#AD_Client_ID"));
        if (wi != null) {
            if (wi.getC_BPartner_ID() != -1) {
                genTable("AD_User", "(AD_User.IsActive='Y' AND AD_User.AD_Client_ID=" + l_nClientID + "  AND AD_User.C_BPartner_ID=@C_BPartner_ID@) ORDER BY AD_User.AD_User_ID", false, ctx, wi);
                genTable("C_BPartner", "(C_BPartner.IsActive='Y' AND C_BPartner.AD_Client_ID=" + l_nClientID + "  AND C_BPartner.C_BPartner_ID=@C_BPartner_ID@)ORDER BY C_BPartner.C_BPartner_ID", false, ctx, wi);
                genTable("C_Invoice", "(C_Invoice.IsActive='Y' AND C_Invoice.AD_Client_ID=" + l_nClientID + "  AND C_Invoice.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Invoice.C_Invoice_ID", false, ctx, wi);
                genTable("C_Order", "(C_Order.IsActive='Y' AND C_Order.AD_Client_ID=" + l_nClientID + "  AND C_Order.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Order.C_Order_ID", false, ctx, wi);
                genTable("C_Payment", "(C_Payment.IsActive='Y' AND C_Payment.AD_Client_ID=" + l_nClientID + "  AND C_Payment.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Payment.C_Payment_ID", false, ctx, wi);
                genTable("C_Project", "(C_Project.IsActive='Y' AND C_Project.AD_Client_ID=" + l_nClientID + "  AND C_Project.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Project.C_Project_ID", false, ctx, wi);
                genTable("M_InOut", "(M_InOut.IsActive='Y' AND M_InOut.AD_Client_ID=" + l_nClientID + "  AND M_InOut.C_BPartner_ID=@C_BPartner_ID@) ORDER BY M_InOut.M_InOut_ID", false, ctx, wi);
                genTable("R_Request", "(R_Request.IsActive='Y' AND R_Request.AD_Client_ID=" + l_nClientID + "  AND R_Request.C_BPartner_ID=@C_BPartner_ID@) ORDER BY R_Request.R_Request_ID", true, ctx, wi);
                genTable("R_RequestUpdate", "(R_RequestUpdate.IsActive='Y' AND R_RequestUpdate.AD_Client_ID=" + l_nClientID + "  AND R_RequestUpdate.R_Request_ID IN (SELECT R_Request.R_Request_ID FROM R_Request WHERE R_Request.IsActive='Y' AND R_Request.AD_Client_ID=" + l_nClientID + "  AND R_Request.C_BPartner_ID=@C_BPartner_ID@)) ORDER BY R_RequestUpdate.R_RequestUpdate_ID", true, ctx, wi);
            }
            genTable("A_Asset", "A_Asset.IsActive='Y' AND A_Asset.AD_Client_ID=" + l_nClientID + "  ORDER BY A_Asset.A_Asset_ID", false, ctx, wi);
            //genTable("AD_Role", "AD_Role.IsActive='Y' AND AD_Role.AD_Client_ID=" + l_nClientID + "  ORDER BY AD_Role.AD_Role_ID", false, ctx, wi);
            genTable("C_Activity", "C_Activity.IsActive='Y' AND C_Activity.AD_Client_ID=" + l_nClientID + "  ORDER BY C_Activity.C_Activity_ID", false, ctx, wi);
            genTable("C_Campaign", "C_Campaign.IsActive='Y' AND C_Campaign.AD_Client_ID=" + l_nClientID + "  ORDER BY C_Campaign.C_Campaign_ID", false, ctx, wi);
            genTable("M_Product", "M_Product.IsActive='Y' AND M_Product.AD_Client_ID=" + l_nClientID + " AND M_Product.Value like 'cd_%' ORDER BY M_Product.M_Product_ID", false, ctx, wi);
            genTable("M_RMA", "M_RMA.IsActive='Y' AND M_RMA.AD_Client_ID=" + l_nClientID + "  ORDER BY M_RMA.M_RMA_ID", false, ctx, wi);
            genTable("R_Category", "R_Category.IsActive='Y' AND R_Category.AD_Client_ID=" + l_nClientID + "  ORDER BY R_Category.R_Category_ID", false, ctx, wi);
            genTable("R_Group", "R_Group.IsActive='Y' AND R_Group.AD_Client_ID=" + l_nClientID + "  ORDER BY R_Group.R_Group_ID", false, ctx, wi);
            genTable("R_MailText", "R_MailText.IsActive='Y' AND R_MailText.AD_Client_ID=" + l_nClientID + "  ORDER BY R_MailText.R_MailText_ID", true, ctx, wi);
            genTable("R_RequestType", "R_RequestType.IsActive='Y' AND R_RequestType.AD_Client_ID=" + l_nClientID + "  ORDER BY R_RequestType.R_RequestType_ID", false, ctx, wi);
            genTable("R_Resolution", "R_Resolution.IsActive='Y' AND R_Resolution.AD_Client_ID=" + l_nClientID + "  ORDER BY R_Resolution.R_Resolution_ID", false, ctx, wi);
            genTable("R_StandardResponse", "R_StandardResponse.IsActive='Y' AND R_StandardResponse.AD_Client_ID=" + l_nClientID + "  ORDER BY R_StandardResponse.R_StandardResponse_ID", false, ctx, wi);
            genTable("R_Status", "R_Status.IsActive='Y' AND R_Status.AD_Client_ID=" + l_nClientID + "  ORDER BY R_Status.R_Status_ID", false, ctx, wi);
            genTable("_PriorityRule", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=154) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
            genTable("R_Request_Confidential", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=340) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
            genTable("R_Request_Due_Typ", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=222) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
            genTable("R_Request_Next_Action", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=219) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
            genTable("R_Request_TaskStatus", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=366) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
        }
        xmlCode.append("</requestTables>\n");
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebInfo(org.compiere.util.WebInfo)

Example 4 with WebInfo

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

the class Generator method generateExternalTables.

private void generateExternalTables(Properties ctx, HttpServletRequest httpRequest) {
    HttpSession thisSession = httpRequest.getSession(false);
    WebInfo wi = null;
    if (thisSession != null)
        if (thisSession.getAttribute(WebInfo.NAME) != null)
            wi = (WebInfo) thisSession.getAttribute(WebInfo.NAME);
    int[] tableKeys = X_CM_TemplateTable.getAllIDs("CM_TemplateTable", "CM_Template_ID=" + thisRequest.getCM_Container().getCM_Template_ID(), "WebCM");
    if (tableKeys.length > 0) {
        xmlCode.append("<externalTables>\n");
        for (int i = 0; i < tableKeys.length; i++) {
            X_CM_TemplateTable thisTemplateTable = new X_CM_TemplateTable(ctx, tableKeys[i], "WebCM");
            try {
                StringBuffer tempXML = new StringBuffer();
                tempXML.append("<" + thisTemplateTable.getName() + ">\n");
                MTable table = MTable.get(ctx, thisTemplateTable.getAD_Table_ID());
                String trxName = null;
                int[] ids = PO.getAllIDs(table.getTableName(), replaceSessionElements(wi, thisTemplateTable.getWhereClause()), trxName);
                if (ids != null && ids.length > 0) {
                    for (int j = 0; j < ids.length; j++) {
                        PO po = null;
                        po = table.getPO(ids[j], null);
                        if (po != null) {
                            tempXML = po.get_xmlString(tempXML);
                        }
                    }
                }
                tempXML.append("\n</" + thisTemplateTable.getName() + ">\n");
                xmlCode.append(tempXML);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        xmlCode.append("\n</externalTables>\n");
    }
}
Also used : MTable(org.compiere.model.MTable) HttpSession(javax.servlet.http.HttpSession) WebInfo(org.compiere.util.WebInfo) SQLException(java.sql.SQLException) X_CM_TemplateTable(org.compiere.model.X_CM_TemplateTable) PO(org.compiere.model.PO)

Example 5 with WebInfo

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

the class AssetServlet method doGet.

//  destroy
/**
	 *  Process the HTTP Get request.
	 * 	(logout, deleteCookie)
	 *  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("Get from " + request.getRemoteHost() + " - " + request.getRemoteAddr());
    Properties ctx = JSPEnv.getCtx(request);
    HttpSession session = request.getSession(false);
    //
    String url = "/assets.jsp";
    if (session == null || session.getAttribute(WebInfo.NAME) == null || session.getAttribute(WebUser.NAME) == null)
        url = "/login.jsp";
    else {
        session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
        WebInfo info = (WebInfo) session.getAttribute(WebInfo.NAME);
        if (info != null)
            info.setMessage("");
        //	Parameter = Asset_ID - if invoice is valid and belongs to wu then create PDF & stream it
        String msg = streamAsset(request, response);
        if (info != null)
            info.setMessage(Msg.parseTranslation(ctx, msg));
        if (//	OK 
        msg == null || msg.length() == 0 || msg.startsWith("**"))
            //	if not returned - results in exception: Cannot forward after response has been committed 
            return;
    }
    log.info("Forward to " + url);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response);
}
Also used : HttpSession(javax.servlet.http.HttpSession) Properties(java.util.Properties) 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