Пример #1
0
  public String parse(String serviceName, String fileName, int fileId, String ipAddr) {
    logger.info("ABOUT TO PARSE!");

    int i = 0;
    try {
      ArrayList messages = Utilities.separateMessages(fileName);

      for (i = 0; i < messages.size(); i++) {

        String msg = (String) messages.get(i);

        MessageUploader.routeReport(serviceName, "TDIS", msg, fileId);
      }

      // Since the gdml labs show more than one lab on the same page when
      // grouped
      // by accession number their abnormal status must be updated to
      // reflect the
      // other labs that they are grouped with aswell
      updateLabStatus(messages.size());
      logger.info("Parsed OK");
    } catch (Exception e) {
      MessageUploader.clean(fileId);
      logger.error("Could not upload message", e);
      return null;
    }
    return ("success");
  }
Пример #2
0
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);
    if (!securityInfoManager.hasPrivilege(loggedInInfo, "_lab", "w", null)) {
      throw new SecurityException("missing required security object (_lab)");
    }

    LabUploadForm frm = (LabUploadForm) form;
    FormFile importFile = frm.getImportFile();
    String filename = importFile.getFileName();
    String proNo = (String) request.getSession().getAttribute("user");
    String outcome = "failure";

    InputStream formFileIs = null;
    InputStream localFileIs = null;

    try {
      formFileIs = importFile.getInputStream();

      String type = request.getParameter("type");
      if (type.equals("OTHER")) type = request.getParameter("otherType");

      String filePath = Utilities.saveFile(formFileIs, filename);
      File file = new File(filePath);

      localFileIs = new FileInputStream(filePath);
      int checkFileUploadedSuccessfully =
          FileUploadCheck.addFile(file.getName(), localFileIs, proNo);

      if (checkFileUploadedSuccessfully != FileUploadCheck.UNSUCCESSFUL_SAVE) {
        logger.debug("filePath" + filePath);
        logger.debug("Type :" + type);
        MessageHandler msgHandler = HandlerClassFactory.getHandler(type);
        if (msgHandler != null) {
          logger.debug("MESSAGE HANDLER " + msgHandler.getClass().getName());
        }
        if ((msgHandler.parse(
                loggedInInfo,
                getClass().getSimpleName(),
                filePath,
                checkFileUploadedSuccessfully,
                request.getRemoteAddr()))
            != null) outcome = "success";

      } else {
        outcome = "uploaded previously";
      }

    } catch (Exception e) {
      logger.error("Error: ", e);
      outcome = "exception";
    } finally {
      IOUtils.closeQuietly(formFileIs);
      IOUtils.closeQuietly(localFileIs);
    }

    request.setAttribute("outcome", outcome);
    return mapping.findForward("success");
  }