Package nz.co.transparent.client.db

Examples of nz.co.transparent.client.db.ControllerException


      log.warning(message);

      if (message.indexOf("Cannot create PoolableConnectionFactory") > -1) {
        throw new FinderException(se);
      } else {
        throw new ControllerException(message);
      }
    }
  }
View Full Code Here


    throws ControllerException {
    MessageDigest md = null;
    try {
      md = MessageDigest.getInstance("SHA"); //step 2
    } catch (NoSuchAlgorithmException e) {
      throw new ControllerException(e.getMessage());
    }
    try {
      md.update(passwordInPlainText.getBytes("UTF-8")); //step 3
    } catch (UnsupportedEncodingException e) {
      throw new ControllerException(e.getMessage());
    }

    byte raw[] = md.digest(); //step 4
    String hash = (new BASE64Encoder()).encode(raw); //step 5
    return hash; //step 6
View Full Code Here

    String msg = null;
   
    if (!jasperFile.exists()) {
      msg = "Cannot find jasper file: " + jasperFileName;
      log.warning(msg);
      throw new ControllerException(msg);
    }
   
    Map clientMap = null;
    Map contactDetailMap = null;
//    InputStream is = getClass().getResourceAsStream("CardReport.jasper");
    GenericController genericController = GenericController.getInstance();
    SpecificController specificController = SpecificController.getInstance();
   
    try {
      clientMap = genericController.findWhere("client", "client_id=" + clientID);
    } catch (FinderException fe) {
      throw new ControllerException("No client record found");
    }

    contactDetailMap = specificController.findDefaultContactDetails(clientID);
    Map reportMap = new HashMap();
    reportMap.put("LastName", clientMap.get("last_name"));
    StringBuffer firstNames = new StringBuffer();

    if (clientMap.get("first_name") != null) {
      firstNames.append(clientMap.get("first_name"));
    }
   
    if (clientMap.get("middle_name") != null) {
      if (firstNames.length() > 0) {
        firstNames.append(",");
      }
       
      firstNames.append(" " + clientMap.get("middle_name"));
    }
   
    reportMap.put("FirstNames", firstNames.toString().trim());
   
    StringBuffer address = new StringBuffer();
    if (clientMap.get("address1") != null) {
      address.append(clientMap.get("address1"));
    }
   
    if (clientMap.get("address2") != null) {
      if (address.length() > 0) {
        address.append(",");
      }
       
      address.append(" " + clientMap.get("address2"));
    }
   
    if (clientMap.get("suburb") != null) {
      if (address.length() > 0) {
        address.append(",");
      }
       
      address.append(" " + clientMap.get("suburb"));
    }
   
    if (clientMap.get("city") != null) {
      if (address.length() > 0) {
        address.append(",");
      }
       
      address.append(" " + clientMap.get("city"));
    }
   
    reportMap.put("Address", address.toString());

    if (clientMap.get("date_of_birth") != null) {
      String pattern = Parameter.getParameter("format.shortdate", Constants.FORMAT_SHORT_DATE);
      SimpleDateFormat localDateFormat = new SimpleDateFormat(pattern, Locale.getDefault());
      reportMap.put("DOB", localDateFormat.format(clientMap.get("date_of_birth")));
    }

    if (contactDetailMap != null) {
      reportMap.put("Phone", contactDetailMap.get("contact_detail"));
    }
   
    try {
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFileName, reportMap, new JREmptyDataSource());
     
      // For print attributes see API docs: j2sdk-1_4_2/docs/api/index.html
      PrintRequestAttributeSet printRequestAttributeSet =
        new HashPrintRequestAttributeSet();
      printRequestAttributeSet.add(OrientationRequested.PORTRAIT);
      printRequestAttributeSet.add(MediaSizeName.ISO_A4);

      PrintServiceAttributeSet printServiceAttributeSet =
        new HashPrintServiceAttributeSet();
      // Linux: print queues like "draft", "normal", "photo", etc
      // Windows: use physical printername like  "Epson Stylus COLOR 680" or "HP LaserJet 5000 Series PCL"

      String printerNameTemp = Configuration.getDecodedProperty("report.cardreport.printer", Constants.REPORT_CARDREPORT_PRINTER);

      if (printerNameTemp.equals("")) {
      } else {
        PrinterName printerName = new PrinterName(printerNameTemp, Locale.getDefault());
        printServiceAttributeSet.add(printerName);
      }

      JRPrintServiceExporter exporter = new JRPrintServiceExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(
        JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
        printRequestAttributeSet);
      exporter.setParameter(
        JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
        printServiceAttributeSet);
      exporter.setParameter(
        JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
        Boolean.FALSE);
      exporter.setParameter(
        JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
        Boolean.TRUE);

      if (printPreview) {
        // preview is started in non_modal
        JasperViewer.viewReport(jasperPrint, false);
      } else {
        exporter.exportReport();
      }
    } catch (JRException je) {
      msg = "\nError printing card report:\nPlease check printer parameter.\n" + je.getMessage();
      log.warning(msg);
      throw new ControllerException(msg);
    }
  }
View Full Code Here

    String msg = null;

    if (!jasperFile.exists()) {
      msg = "Cannot find jasper file: " + jasperFileName;
      log.warning(msg);
      throw new ControllerException(msg);
    }

    Map clientMap = null;
    Map titleMap = null;
    GenericController genericController = GenericController.getInstance();
    SpecificController specificController =
      SpecificController.getInstance();

    try {
      clientMap =
        genericController.findWhere("client", "client_id=" + clientID);
    } catch (FinderException fe) {
      throw new ControllerException("No client record found");
    }

    try {
      titleMap =
        genericController.findWhere("title", "title_id=" + clientMap.get("title_id"));
    } catch (FinderException fe) {
      throw new ControllerException("No title record found for title_id =" + clientMap.get("title_id"));
    }

    Map reportMap = new HashMap();
    // Get sender address
    Map parameterMap = null;

    // Sender address must be decoded from Base64
    reportMap.put(
      "SenderAddress",
      Configuration.getDecodedProperty(
        "report.envelopreport.sender.address",
        ""));
    StringBuffer receiverAddress = new StringBuffer();
    if (titleMap != null && titleMap.get("title_code") != null) {
      receiverAddress.append(titleMap.get("title_code"));
    }

    if (clientMap.get("first_name") != null) {
      receiverAddress.append(" " + clientMap.get("first_name"));
    }

    //    if (clientMap.get("middle_name") != null) {
    //      if (receiverAddress.length() > 0) {
    //        receiverAddress.append(",");
    //      }
    //       
    //      receiverAddress.append(" " + clientMap.get("middle_name"));
    //    }

    if (clientMap.get("last_name") != null) {
      receiverAddress.append(" ");
      receiverAddress.append(clientMap.get("last_name"));
      receiverAddress.append("\n");
    }

    if (clientMap.get("address1") != null) {
      receiverAddress.append(clientMap.get("address1"));
      receiverAddress.append("\n");
    }

    if (clientMap.get("address2") != null) {
      receiverAddress.append(clientMap.get("address2"));
      receiverAddress.append("\n");
    }

    if (clientMap.get("suburb") != null) {
      receiverAddress.append(clientMap.get("suburb"));
      receiverAddress.append("\n");
    }

    if (clientMap.get("city") != null) {
      receiverAddress.append(clientMap.get("city"));
      receiverAddress.append("\n");
    }

    reportMap.put("ReceiverAddress", receiverAddress.toString().trim());

    try {
      JasperPrint jasperPrint =
        JasperFillManager.fillReport(
          jasperFileName,
          reportMap,
          new JREmptyDataSource());

      // For print attributes see API docs:
      // j2sdk-1_4_2/docs/api/index.html
      PrintRequestAttributeSet printRequestAttributeSet =
        new HashPrintRequestAttributeSet();
      printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
      printRequestAttributeSet.add(MediaSizeName.ISO_A4);

      PrintServiceAttributeSet printServiceAttributeSet =
        new HashPrintServiceAttributeSet();
      // Linux: print queues like "draft", "normal", "photo", etc
      // Windows: use physical printername like "Epson Stylus COLOR 680"
      // or "HP LaserJet 5000 Series PCL"

      String printerNameTemp =
        Configuration.getDecodedProperty(
          "report.envelopreport.printer",
          Constants.REPORT_ENVELOPREPORT_PRINTER);

      if (printerNameTemp.equals("")) {
      } else {
        PrinterName printerName =
          new PrinterName(printerNameTemp, Locale.getDefault());
        printServiceAttributeSet.add(printerName);
      }

      JRPrintServiceExporter exporter = new JRPrintServiceExporter();
      exporter.setParameter(
        JRExporterParameter.JASPER_PRINT,
        jasperPrint);
      exporter.setParameter(
        JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
        printRequestAttributeSet);
      exporter.setParameter(
        JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
        printServiceAttributeSet);
      exporter.setParameter(
        JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
        Boolean.FALSE);
      exporter.setParameter(
        JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
        Boolean.TRUE);

      if (printPreview) {
        // preview is started in non_modal
        JasperViewer.viewReport(jasperPrint, false);
      } else {
        exporter.exportReport();
      }
    } catch (JRException je) {
      msg =
        "\nError printing envelop:\nPlease check printer parameter.\n"
          + je.getMessage();
      log.warning(msg);
      throw new ControllerException(msg);
    }
  }
View Full Code Here

TOP

Related Classes of nz.co.transparent.client.db.ControllerException

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.