コード例 #1
0
  @ActionMapping(params = "javax.portlet.action=uploadXDR")
  public void response(MultipartActionRequest request, ActionResponse response) throws IOException {

    JSONArray fileJson;
    JSONObject jsonResponseBody;

    if (this.props == null) {
      this.loadProperties();
    }

    // handle the files:

    response.setRenderParameter("javax.portlet.action", "uploadXDR");
    MultipartFile file = request.getFile("file");
    String endpoint = request.getParameter("wsdlLocation");
    String fromDirectAddress = request.getParameter("fromDirectAddress");

    if (fromDirectAddress == null || fromDirectAddress.trim().equals("")) {
      fromDirectAddress = "*****@*****.**";
    }

    String toDirectAddress = request.getParameter("toDirectAddress");

    if (toDirectAddress == null || toDirectAddress.trim().equals("")) {
      toDirectAddress = "*****@*****.**";
    }

    String messageType = request.getParameter("messageType");
    String encodedFile = Base64.encodeBase64String(file.getBytes());

    fileJson = new JSONArray();

    jsonResponseBody = new JSONObject();

    String xdrResponse = null;

    if (messageType.equalsIgnoreCase("full")) {
      xdrResponse =
          XDR.sendValidFullXDRMessage(
              endpoint, encodedFile, file.getName(), toDirectAddress, fromDirectAddress, endpoint);
    } else {
      xdrResponse =
          XDR.sendValidMinimalXDRMessage(
              endpoint, encodedFile, file.getName(), toDirectAddress, fromDirectAddress, endpoint);
    }
    logger.info(xdrResponse);

    try {

      JSONObject jsono = new JSONObject();
      jsono.put("name", file.getOriginalFilename());
      jsono.put("size", file.getSize());

      fileJson.put(jsono);

      // handle the data
      jsonResponseBody.put("IsSuccess", "true");
      jsonResponseBody.put("ErrorMessage", "Message Sent Successfully!");
      jsonResponseBody.put("xdrResponse", xdrResponse);

      statisticsManager.addXdrReceive(
          endpoint, fromDirectAddress, toDirectAddress, messageType, false, true, false);

    } catch (Exception e) {
      // statisticsManager.addCcdaValidation(ccda_type_value, false, false, false, true);
      statisticsManager.addXdrReceive(
          endpoint, fromDirectAddress, toDirectAddress, messageType, false, false, true);
      throw new RuntimeException(e);
    }

    xdrReceiveResults.setFileJson(fileJson);
    xdrReceiveResults.setJsonResponseBody(jsonResponseBody);
  }
コード例 #2
0
  @ActionMapping(params = "javax.portlet.action=precannedXDR")
  public void responsePrecanned(ActionRequest request, ActionResponse response) throws IOException {

    JSONArray fileJson;
    JSONObject jsonResponseBody;

    if (this.props == null) {
      this.loadProperties();
    }

    // handle the files:

    response.setRenderParameter("javax.portlet.action", "precannedXDR");
    String endpoint = request.getParameter("precannedWsdlLocation");
    // MultipartFile file = request.getFile("file");
    String fromDirectAddress = request.getParameter("precannedFromDirectAddress");

    if (fromDirectAddress == null || fromDirectAddress.trim().equals("")) {
      fromDirectAddress = "*****@*****.**";
    }

    String toDirectAddress = request.getParameter("precannedToDirectAddress");

    if (toDirectAddress == null || toDirectAddress.trim().equals("")) {
      toDirectAddress = "*****@*****.**";
    }

    String sampleCcdaDir = props.getProperty("sampleCcdaDir");
    String precannedfile = request.getParameter("precannedfilepath");
    String precannedMessageType = request.getParameter("precannedMessageType");

    String serverFilePath = sampleCcdaDir + "/" + precannedfile;

    File ccdaFile = new File(serverFilePath);

    byte[] byteArray = this.read(ccdaFile);

    String base64String = Base64.encodeBase64String(byteArray);

    fileJson = new JSONArray();

    jsonResponseBody = new JSONObject();

    String xdrResponse = null;

    if (precannedMessageType.equalsIgnoreCase("full")) {
      xdrResponse =
          XDR.sendValidFullXDRMessage(
              endpoint,
              base64String,
              ccdaFile.getName(),
              toDirectAddress,
              fromDirectAddress,
              endpoint);
    } else {
      xdrResponse =
          XDR.sendValidMinimalXDRMessage(
              endpoint,
              base64String,
              ccdaFile.getName(),
              toDirectAddress,
              fromDirectAddress,
              endpoint);
    }
    logger.info(xdrResponse);

    try {

      JSONObject jsono = new JSONObject();
      // jsono.put("name", file.getOriginalFilename());
      // jsono.put("size", file.getSize());

      fileJson.put(jsono);

      // handle the data
      jsonResponseBody.put("IsSuccess", "true");
      jsonResponseBody.put("ErrorMessage", "Message Sent Successfully!");
      jsonResponseBody.put("xdrResponse", xdrResponse);

      statisticsManager.addXdrReceive(
          endpoint, fromDirectAddress, toDirectAddress, precannedMessageType, true, false, false);

    } catch (Exception e) {
      // statisticsManager.addCcdaValidation(ccda_type_value, false, false, false, true);
      statisticsManager.addXdrReceive(
          endpoint, fromDirectAddress, toDirectAddress, precannedMessageType, false, false, true);
      throw new RuntimeException(e);
    }

    xdrReceiveResults.setFileJson(fileJson);
    xdrReceiveResults.setJsonResponseBody(jsonResponseBody);
  }