Search in sources :

Example 1 with MIssue

use of org.compiere.model.MIssue in project adempiere by adempiere.

the class IssueReport method doIt.

//	prepare
/**
	 * 	Do It
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("AD_Issue_ID=" + m_AD_Issue_ID);
    if (!MSystem.get(getCtx()).isAutoErrorReport())
        return "NOT reported - Enable Error Reporting in Window System";
    //
    MIssue issue = new MIssue(getCtx(), m_AD_Issue_ID, get_TrxName());
    if (issue.get_ID() == 0)
        return "No Issue to report - ID=" + m_AD_Issue_ID;
    //
    String error = issue.report();
    if (error != null)
        throw new AdempiereSystemError(error);
    if (issue.save())
        return "Issue Reported: " + issue.getRequestDocumentNo();
    throw new AdempiereSystemError("Issue Not Saved");
}
Also used : MIssue(org.compiere.model.MIssue) AdempiereSystemError(org.compiere.util.AdempiereSystemError)

Example 2 with MIssue

use of org.compiere.model.MIssue in project adempiere by adempiere.

the class IssueReportServlet method doGet.

//  destroy
/**************************************************************************
	 *  Process the initial HTTP Get request.
	 *  Reads the Parameter Amt and optional C_Invoice_ID
	 *
	 *  @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());
    Properties ctx = JSPEnv.getCtx(request);
    HttpSession session = request.getSession(true);
    //	WEnv.dump(session);
    //	WEnv.dump(request);
    int AD_Issue_ID = WebUtil.getParameterAsInt(request, "RECORDID");
    String DBAddress = WebUtil.getParameter(request, "DBADDRESS");
    String Comments = WebUtil.getParameter(request, "COMMENTS");
    String IssueString = WebUtil.getParameter(request, "ISSUE");
    //
    StringBuffer responseText = new StringBuffer("Adempiere Support - ").append(new Date().toString()).append("\n");
    MIssue issue = null;
    if (AD_Issue_ID != 0) {
        issue = new MIssue(ctx, AD_Issue_ID, null);
        if (issue.get_ID() != AD_Issue_ID)
            responseText.append("Issue Unknown - Request Ignored");
        else if (!issue.getDBAddress().equals(DBAddress))
            responseText.append("Not Issue Owner - Request Ignored");
        else {
            issue.addComments(Comments);
            responseText.append(issue.createAnswer());
        }
    } else if (IssueString == null || IssueString.length() == 0) {
        responseText.append("Unknown Request");
    } else {
        issue = MIssue.create(ctx, IssueString);
        if (issue == null || !issue.save())
            responseText.append("Could not save Issue");
        else
            responseText.append(issue.process());
    }
    //
    StringBuffer answer = new StringBuffer();
    if (issue != null && issue.get_ID() != 0) {
        answer.append("RECORDID=").append(issue.get_ID()).append(MIssue.DELIMITER);
    //	answer.append("DOCUMENTNO=").append(".")
    //		.append(MIssue.DELIMITER);
    }
    answer.append("RESPONSE=").append(responseText);
    //
    response.setHeader("Cache-Control", "no-cache");
    response.setContentType("text/html; charset=UTF-8");
    //  with character encoding support
    PrintWriter out = response.getWriter();
    out.write(URLEncoder.encode(answer.toString(), "UTF-8"));
    out.flush();
    if (out.checkError())
        log.log(Level.SEVERE, "error writing");
    out.close();
}
Also used : MIssue(org.compiere.model.MIssue) HttpSession(javax.servlet.http.HttpSession) Properties(java.util.Properties) Date(java.util.Date) PrintWriter(java.io.PrintWriter)

Aggregations

MIssue (org.compiere.model.MIssue)2 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1 Properties (java.util.Properties)1 HttpSession (javax.servlet.http.HttpSession)1 AdempiereSystemError (org.compiere.util.AdempiereSystemError)1