Ejemplo n.º 1
0
  private void processStreamElement(OMElement streamElement, BAMServerProfile bamServerProfile) {
    OMAttribute nameAttr = streamElement.getAttribute(new QName("name"));
    OMAttribute versionAttr = streamElement.getAttribute(new QName("version"));
    OMAttribute nickNameAttr = streamElement.getAttribute(new QName("nickName"));
    OMAttribute descriptionAttr = streamElement.getAttribute(new QName("description"));
    if (nameAttr != null
        && nickNameAttr != null
        && descriptionAttr != null
        && !nameAttr.getAttributeValue().equals("")
        && !nickNameAttr.getAttributeValue().equals("")
        && !descriptionAttr.getAttributeValue().equals("")) {
      BAMStreamConfiguration streamConfiguration =
          new BAMStreamConfiguration(
              nameAttr.getAttributeValue(),
              nickNameAttr.getAttributeValue(),
              descriptionAttr.getAttributeValue(),
              versionAttr.getAttributeValue());
      OMElement dataElement =
          streamElement.getFirstChildWithName(
              new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Data"));
      if (dataElement == null) {
        String errMsg = "Data element is not available for BAM server profile: " + profileLocation;
        handleError(errMsg);
      }

      Iterator itr =
          dataElement.getChildrenWithName(new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Key"));
      OMElement keyElement;
      while (itr.hasNext()) {
        keyElement = (OMElement) itr.next();
        processKeyElement(keyElement, streamConfiguration);
      }
      bamServerProfile.addBAMStreamConfiguration(
          streamConfiguration.getName(), streamConfiguration);
    } else {
      String errMsg =
          "One or many of the attributes of Stream element is not available "
              + "for BAM server profile: "
              + profileLocation;
      handleError(errMsg);
    }
  }
Ejemplo n.º 2
0
  private void processKeyElement(OMElement keyElement, BAMStreamConfiguration streamConfiguration) {
    BAMKey bamKey;
    String name;
    BAMKey.BAMKeyType type;
    String variable;
    String expression;
    String part = null;
    String query = null;

    OMAttribute nameAttribute = keyElement.getAttribute(new QName("name"));
    if (nameAttribute == null || "".equals(nameAttribute.getAttributeValue())) {
      String errMsg =
          "name attribute of Key element cannot be null for BAM server "
              + "profile: "
              + profileLocation;
      handleError(errMsg);
    }
    name = nameAttribute.getAttributeValue();

    OMAttribute typeAttribute = keyElement.getAttribute(new QName("type"));
    if (typeAttribute == null || "".equals(typeAttribute.getAttributeValue())) {
      type = BAMKey.BAMKeyType.PAYLOAD;
      log.debug(
          "type attribute of Key element: "
              + name
              + " is not available. "
              + "Type is default to payload");
    }
    type = BAMKey.BAMKeyType.valueOf(typeAttribute.getAttributeType());

    OMElement fromElement =
        keyElement.getFirstChildWithName(new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "From"));
    if (fromElement == null) {
      String errMsg =
          "From element not found for Key element: "
              + name
              + " for BAM server "
              + "profile: "
              + profileLocation;
      handleError(errMsg);
    }

    OMAttribute variableAttribute = fromElement.getAttribute(new QName("variable"));
    if (variableAttribute != null && !"".equals(variableAttribute.getAttributeValue())) {
      variable = variableAttribute.getAttributeValue();

      OMAttribute partAttribute = fromElement.getAttribute(new QName("part"));
      if (partAttribute != null) {
        part = partAttribute.getAttributeValue();
      }

      OMElement queryElement =
          fromElement.getFirstChildWithName(
              new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Query"));
      if (queryElement == null || "".equals(queryElement.getText())) {
        query = queryElement.getText();
      }
      bamKey = new BAMKey(name, variable, part, query, type);
    } else {
      if (fromElement.getText() == null || "".equals(fromElement.getText())) {
        String errMsg =
            "Variable name or XPath expression not found for From of Key: "
                + name
                + " for BAM server profile: "
                + profileLocation;
        handleError(errMsg);
      }
      expression = fromElement.getText().trim();
      bamKey = new BAMKey(name, type);
      bamKey.setExpression(expression);
    }

    switch (bamKey.getType()) {
      case PAYLOAD:
        streamConfiguration.addPayloadBAMKey(bamKey);
        break;
      case CORRELATION:
        streamConfiguration.addCorrelationBAMKey(bamKey);
        break;
      case META:
        streamConfiguration.addMetaBAMKey(bamKey);
        break;
      default:
        String errMsg =
            "Unknown BAM key type: "
                + type
                + " with BAM key name: "
                + bamKey.getName()
                + " in stream: "
                + streamConfiguration.getName();
        handleError(errMsg);
    }
  }