Package org.wijiscommons.ssaf.drop_off.wrapper

Examples of org.wijiscommons.ssaf.drop_off.wrapper.GetResponsesResponse


    boolean getConfirmations = false;
    String mailBoxURI = null;
    boolean getErrors = false;
    boolean countsOnly = false;

    GetResponsesResponse getResponsesResponse = new GetResponsesResponse();
    Element responseDocumentElement = null;

    HashMap<String, String> attributesMap = SSAFUtil
        .getMessageAttributes(docElement);

    mailBoxURI = attributesMap.get("dropoffMailBoxURI");
    getConfirmations = Boolean.valueOf(docElement.getAttributeNS(
        SSAFNamespaces.drop_off.getNamespace(),
        SSAFNodes.get_confirmations.getLocalName()));
    getErrors = Boolean.valueOf(docElement.getAttributeNS(
        SSAFNamespaces.drop_off.getNamespace(), SSAFNodes.get_errors
            .getLocalName()));
    countsOnly = Boolean.valueOf(docElement.getAttributeNS(
        SSAFNamespaces.drop_off.getNamespace(), SSAFNodes.counts_only
            .getLocalName()));

    int numberOfConfirmationsFiles = 0;
    int numberOfErrorFiles = 0;
    List<Element> acceptedMessages = new ArrayList<Element>();
    List<Element> failedMessages = new ArrayList<Element>();

    if (getConfirmations)
    {
      File confirmationDirectory = Drop_OffUtil.getDirectoryName(
          mailBoxes_root + mailBoxURI, "confirm_box");
      if (confirmationDirectory != null)
      {
        File[] files = confirmationDirectory.listFiles();

        numberOfConfirmationsFiles = files.length;

        if (countsOnly)
        {
          // set number of files present on filesystem
          responseDocumentElement = DropOffHelperMethods
              .createGetResponse(getConfirmations,
                        getErrors,
                        countsOnly,
                        numberOfConfirmationsFiles,
                        numberOfErrorFiles,
                        acceptedMessages,
                        failedMessages);
          getResponsesResponse.setAny(responseDocumentElement);
        }
        else
        {
          for (File file : files)
          {
            acceptedMessages.add(Drop_OffUtil
                .extractElementFromFile(file,"accepted_message"));
          }
          responseDocumentElement = DropOffHelperMethods
              .createGetResponse(getConfirmations,
                        getErrors,
                        countsOnly,
                        numberOfConfirmationsFiles,
                        numberOfErrorFiles,
                        acceptedMessages,
                        failedMessages);
          getResponsesResponse.setAny(responseDocumentElement);
        }
      }
      else
      {    // it should not come to this else block here bcoz - interceptor will check if
        // mailBox name is correct are not. Just to be safe we have this log statement
        log.error("Directory by that name does not exists in a filesystem");
      }

    }
    if (getErrors)
    {
      File errorDirectory = Drop_OffUtil.getDirectoryName(mailBoxes_root
          + mailBoxURI, "fail_box");
      if (errorDirectory != null)
      {
        File[] files = errorDirectory.listFiles();

        numberOfErrorFiles = files.length;

        if (countsOnly)
        {
          // set number of error files present on filesystem
          responseDocumentElement = DropOffHelperMethods
              .createGetResponse(getConfirmations, getErrors,
                  countsOnly, numberOfConfirmationsFiles,
                  numberOfErrorFiles, acceptedMessages,
                  failedMessages);
          getResponsesResponse.setAny(responseDocumentElement);
        }
        else
        {
          for (File file : files)
          {
            failedMessages.add(Drop_OffUtil.extractElementFromFile(
                file, "failed_message"));
          }
          responseDocumentElement = DropOffHelperMethods
              .createGetResponse(getConfirmations,
                        getErrors,
                        countsOnly,
                        numberOfConfirmationsFiles,
                        numberOfErrorFiles,
                        acceptedMessages,
                        failedMessages);
          getResponsesResponse.setAny(responseDocumentElement);
        }
      }
      else
      {
        // it should not come to this else block here bcoz - interceptor will check if
View Full Code Here

TOP

Related Classes of org.wijiscommons.ssaf.drop_off.wrapper.GetResponsesResponse

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.