Esempio n. 1
0
 public void setController(SessionController controller) {
   super.setController(controller);
   lastestVersion = controller.getAttribute("ActivePOSVersion", "2");
   downloadURL =
       controller.getAttribute(
           "ActivePOSURL", "ftp://*****:*****@sina.com@localhost/download/setup.exe");
   checkSum = controller.getAttribute("ActivePOSCheckSum", "unknown"); // "unknown" is keyword
   fileLength = controller.getAttribute("ActivePOSFileLength", "-1");
   cvsRoot = controller.getAttribute("CVSROOT", ":pserver:error@error:/error");
   cvsFileRoot = controller.getAttribute("CVSDir", "/cvs");
   cvsPassword = controller.getAttribute("CVSPassword", "abc123");
   cvsPOSModule = controller.getAttribute("CVSPOSModule", "pos");
   try {
     isLimitToSpecialUpdateClients =
         (new Boolean(controller.getAttribute("LimitSpecialUpdateClients", "false")))
             .booleanValue();
   } catch (Exception e) {
     isLimitToSpecialUpdateClients = false;
   }
   if (isLimitToSpecialUpdateClients) {
     specialUpdateClients = toArray(controller.getAttribute("SpecialUpdateClients", ""), ",");
     logger.debug(
         "Only these clients will be notified new version:"
             + Tools.toString(specialUpdateClients));
     this.specialNoUpdateClients =
         toArray(controller.getAttribute("SpecialNoUpdateClients", ""), ",");
     logger.debug(
         "Only these clients will *NOT* be notified new version:"
             + Tools.toString(specialNoUpdateClients));
   }
   sessionMsgPrefix = controller.getCommander().getSessionMsgPrefix();
 }
Esempio n. 2
0
  /**
   * return OutputStream of JasperReport object, this page could only be viewed from localhost for
   * security concern. parameter can be (id), or (table and type)
   *
   * @param id - report id, or
   * @param table - table name
   * @param type - reporttype "s","l","o", case insensitive
   * @param client(*) - client domain
   * @param version - version number, default to -1
   */
  public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String clientName = request.getParameter("client");
    int objectId = ParamUtils.getIntAttributeOrParameter(request, "id", -1);
    if (objectId == -1) {
      // try using table and type
      objectId =
          getReportId(clientName, request.getParameter("table"), request.getParameter("type"));
    }
    if (objectId == -1) {
      logger.error("report not found, request is:" + Tools.toString(request));
      throw new NDSException("report not found");
    }
    int version = ParamUtils.getIntAttributeOrParameter(request, "version", -1);
    File reportXMLFile = new File(ReportTools.getReportFile(objectId, clientName));
    if (reportXMLFile.exists()) {
      // generate jasperreport if file not exists or not newer
      String reportName =
          reportXMLFile.getName().substring(0, reportXMLFile.getName().lastIndexOf("."));
      File reportJasperFile = new File(reportXMLFile.getParent(), reportName + ".jasper");
      if (!reportJasperFile.exists()
          || reportJasperFile.lastModified() < reportXMLFile.lastModified()) {
        JasperCompileManager.compileReportToFile(
            reportXMLFile.getAbsolutePath(), reportJasperFile.getAbsolutePath());
      }
      InputStream is = new FileInputStream(reportJasperFile);
      response.setContentType("application/octetstream;");
      response.setContentLength((int) reportJasperFile.length());

      // response.setHeader("Content-Disposition","inline;filename=\""+reportJasperFile.getName()+"\"");
      ServletOutputStream os = response.getOutputStream();

      byte[] b = new byte[8192];
      int bInt;
      while ((bInt = is.read(b, 0, b.length)) != -1) {
        os.write(b, 0, bInt);
      }
      is.close();
      os.flush();
      os.close();
    } else {
      throw new NDSException("Not found report template");
    }
  }