Package it.eng.spagobi.utilities.callbacks.audit

Examples of it.eng.spagobi.utilities.callbacks.audit.AuditAccessUtils


  }
  logger.debug("Request parameters read sucesfully" + params);
 
  // AUDIT UPDATE
  String auditId = request.getParameter("SPAGOBI_AUDIT_ID");
  AuditAccessUtils auditAccessUtils = (AuditAccessUtils) request.getSession().getAttribute("SPAGOBI_AUDIT_UTILS");
  if (auditAccessUtils != null)
      auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, new Long(System
        .currentTimeMillis()), null, "EXECUTION_STARTED", null, null);
 
  logger.debug("GetConnection...");
  JasperReportRunner jasperReportRunner = new JasperReportRunner(session);
  logger.debug("GetConnection...");
  Connection con = getConnection(requestConnectionName,session,profile,documentId);

  if (con == null) {
      logger.error("Cannot obtain" + " connection for engine ["
        + this.getClass().getName() + "] control document configurations");
      // AUDIT UPDATE
      if (auditAccessUtils != null)
    auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, null, new Long(System
      .currentTimeMillis()), "EXECUTION_FAILED", "No connection available", null);
      return;
  }
  try {
      String outputType = (params.get(PARAM_OUTPUT_FORMAT) == null)?"html":(String) params.get(PARAM_OUTPUT_FORMAT);
      String tmpdir = (String) EnginConf.getInstance().getConfig().getAttribute("GENERALSETTINGS.tmpdir");
      if (!tmpdir.startsWith("/")) {
    String contRealPath = getServletContext().getRealPath("/");
    if (contRealPath.endsWith("\\") || contRealPath.endsWith("/")) {
        contRealPath = contRealPath.substring(0, contRealPath.length() - 1);
    }
    tmpdir = contRealPath + "/" + tmpdir;
      }
      tmpdir = tmpdir + System.getProperty("file.separator") + "reports";
      File dir = new File(tmpdir);
      dir.mkdirs();
      File tmpFile = File.createTempFile("report", "." + outputType, dir);
      OutputStream out = new FileOutputStream(tmpFile);
      jasperReportRunner.runReport(con, params, out, getServletContext(), response, request);
      out.flush();
      out.close();

     // if (outputType == null)  outputType = "html";
    //outputType = ExporterFactory.getDefaultType();
     
      response.setHeader("Content-Disposition", "filename=\"report." + outputType + "\";");
      // response.setContentType((String)extensions.get(outputType));
      response.setContentLength((int) tmpFile.length());

      BufferedInputStream in = new BufferedInputStream(new FileInputStream(tmpFile));
      int b = -1;
      while ((b = in.read()) != -1) {
        response.getOutputStream().write(b);
      }
      response.getOutputStream().flush();
      in.close();
      // instant cleaning
      tmpFile.delete();

      // AUDIT UPDATE
      if (auditAccessUtils != null)
    auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, null, new Long(System
      .currentTimeMillis()), "EXECUTION_PERFORMED", null, null);
  } catch (Exception e) {
      logger.error( "Error during report production \n\n " + e);
      // AUDIT UPDATE
      if (auditAccessUtils != null)
    auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, null, new Long(System
      .currentTimeMillis()), "EXECUTION_FAILED", e.getMessage(), null);
      return;
  } finally {
    try {     
      if (con != null && !con.isClosed())
View Full Code Here


 
  public AuditServiceProxy(String auditId, String userId, HttpSession session) {
    setAuditId(auditId);
    setUserId(userId);
    setSession(session);
    proxy = new AuditAccessUtils(auditId);
  }
View Full Code Here

            }
          }
         
         
          if (auditId != null) {
          AuditAccessUtils auditAccessUtils = (AuditAccessUtils) ioManager.getSession().getAttribute("SPAGOBI_AUDIT_UTILS");
          if (auditAccessUtils == null) {
              auditAccessUtils = new AuditAccessUtils(auditId);
              ioManager.setInSession("SPAGOBI_AUDIT_UTILS", auditAccessUtils);
              ioManager.contextManager.set("SPAGOBI_AUDIT_UTILS", auditAccessUtils);
          } else {
              auditAccessUtils.addAuditId(auditId);
          }
          }
      }
     
      List list = ioManager.contextManager.getKeys();
View Full Code Here

      IEngUserProfile profile = (IEngUserProfile) session.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
      logger.debug("profile from session: " + profile);
     
      // AUDIT UPDATE
      String auditId = request.getParameter("SPAGOBI_AUDIT_ID");
      AuditAccessUtils auditAccessUtils = (AuditAccessUtils) request.getSession().getAttribute("SPAGOBI_AUDIT_UTILS");
      if (auditAccessUtils != null)
          auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, new Long(System
            .currentTimeMillis()), null, "EXECUTION_STARTED", null, null);
     
     
      //read connection from request 
      String requestConnectionName = (String) request.getParameter(CONNECTION_NAME);
      if (requestConnectionName==null) logger.debug("requestConnectionName is NULL");
      else logger.debug("requestConnectionName:"+requestConnectionName);
     
      Connection con = null;
      String query= null;

      SpagoBiDataSet dataset = getDataSet(requestConnectionName, session, profile, documentId);
      if (dataset == null) {
          logger.debug("No dataset query associated to this document");
          logger.debug("Try to get datasource");
          con = getConnection(requestConnectionName,session,profile,documentId);
          if(con == null){
            logger.error("Document "+documentId+" has no dataset query neither datasource associated!");
            // AUDIT UPDATE
            if (auditAccessUtils != null)
          auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, null, new Long(System
            .currentTimeMillis()), "EXECUTION_FAILED", "No connection available", null);
            return;
          } else{
            //get the request query parameter name
            query = (String) request.getParameter(QUERY);
           
          }        
      } else{
        //get query
        query = dataset.getQuery();
        try {
        con = dataset.getDataSource().readConnection(dataset.getDataSource().getSchemaAttribute());
      } catch (Exception e) {
        logger.error("Unable to get connection", e);
          if (auditAccessUtils != null)
          auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, null, new Long(System
            .currentTimeMillis()), "EXECUTION_FAILED", e.getMessage(), null);
          return;
      }     
       
      }  
      //call dao to execute query
      try {
        //gets request parameters to execute query
        HashMap<String, String> parameters = cleanParameters(request);
       
      String xmlResult = QueryExecutor.executeQuery(con, query, parameters);

      byte[] xsl = getDocumentXSL(requestConnectionName, session, profile, documentId);

        byte[] html = Transformation.tarnsformXSLT(xmlResult, xsl);

        String outputType = "html";
        response.setContentType("text/html");
      response.getOutputStream().write(html);

        response.getOutputStream().flush();
       

    } catch (Exception e1) {
      logger.error("Unable to output result", e1);
        if (auditAccessUtils != null)
        auditAccessUtils.updateAudit(session,(String) profile.getUserUniqueIdentifier(), auditId, null, new Long(System
          .currentTimeMillis()), "EXECUTION_FAILED", e1.getMessage(), null);
        return;
    }

      logger.debug("OUT");
View Full Code Here

    logger.debug("documentId=" + documentId);

    // AUDIT UPDATE
    String auditId = request.getParameter("SPAGOBI_AUDIT_ID");
    logger.debug("auditId=" + auditId);
    AuditAccessUtils auditAccessUtils = (AuditAccessUtils) request.getSession().getAttribute("SPAGOBI_AUDIT_UTILS");
    if (auditId != null) {
      if (auditAccessUtils != null)
        auditAccessUtils.updateAudit(session, userId, auditId, new Long(System.currentTimeMillis()), null,
            "EXECUTION_STARTED", null, null);
    }
    try {
      runReport(request, response);
      // AUDIT UPDATE
      if (auditId != null) {
        if (auditAccessUtils != null)
          auditAccessUtils.updateAudit(session, userId, auditId, null, new Long(System.currentTimeMillis()),
              "EXECUTION_PERFORMED", null, null);
      }
    } catch (ConnectionDefinitionException e) {
      logger.error("Error during report production \n\n " + e);
      PrintWriter writer = response.getWriter();
      String resp = "<html><body><center>" + e.getDescription() + "</center></body></html>";
      writer.write(resp);
      writer.flush();
      writer.close();
      // AUDIT UPDATE
      if (auditId != null) {
        if (auditAccessUtils != null)
          auditAccessUtils.updateAudit(session, userId, auditId, null, new Long(System.currentTimeMillis()),
              "EXECUTION_FAILED", e.getDescription(), null);
      }
    } catch (Exception e) {
      logger.error( "Error during report production \n\n ", e);
      // AUDIT UPDATE
      if (auditId != null) {
        if (auditAccessUtils != null)
          auditAccessUtils.updateAudit(session, userId, auditId, null, new Long(System.currentTimeMillis()),
              "EXECUTION_FAILED", e.getMessage(), null);
      }
    }

    logger.info(" Request processed");
View Full Code Here

TOP

Related Classes of it.eng.spagobi.utilities.callbacks.audit.AuditAccessUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.