コード例 #1
0
  /**
   * Save endpoint properties
   *
   * @param model
   * @param endpoint
   */
  protected void saveProperties(EndPoint model, AbstractEndpoint endpoint) {
    for (Iterator<EndPointProperty> iterator = model.getProperties().iterator();
        iterator.hasNext(); ) {
      EndPointProperty property = iterator.next();
      MediatorProperty mediatorProperty = new MediatorProperty();
      mediatorProperty.setName(property.getName());

      if (property.getValueType().toString().equals("EXPRESSION")) {
        SynapseXPath XPath = null;
        try {
          XPath = new SynapseXPath(property.getValueExpression().getPropertyValue());
          for (int i = 0; i < property.getValueExpression().getNamespaces().keySet().size(); ++i) {
            String prefix =
                (String) property.getValueExpression().getNamespaces().keySet().toArray()[i];
            String namespaceUri = property.getValueExpression().getNamespaces().get(prefix);
            XPath.addNamespace(prefix, namespaceUri);
            mediatorProperty.setExpression(XPath);
          }
        } catch (JaxenException e) {
          log.error("Error while persisting Endpoint properties", e);
        }
      } else if (property.getValueType().toString().equals("LITERAL")) {
        mediatorProperty.setValue(property.getValue());
      }

      mediatorProperty.setScope(property.getScope().toString().toLowerCase());
      endpoint.addProperty(mediatorProperty);
    }
  }
コード例 #2
0
  public ResolvingEndpoint getEndpointFromXpath(NamespacedProperty nameSpacedProperty)
      throws Exception {

    SynapseXPath synapseXPath = new SynapseXPath(nameSpacedProperty.getPropertyValue());
    for (int i = 0; i < nameSpacedProperty.getNamespaces().keySet().size(); ++i) {
      String prefix = (String) nameSpacedProperty.getNamespaces().keySet().toArray()[i];
      String namespaceUri = nameSpacedProperty.getNamespaces().get(prefix);
      synapseXPath.addNamespace(prefix, namespaceUri);
    }
    ResolvingEndpoint resolvingEndpoint = new ResolvingEndpoint();
    resolvingEndpoint.setKeyExpression(synapseXPath);
    return resolvingEndpoint;
  }
コード例 #3
0
 public AggregateMediator() {
   try {
     aggregationExpression =
         new SynapseXPath(
             "/s11:Envelope/s11:Body/child::*[position()=1] | "
                 + "/s12:Envelope/s12:Body/child::*[position()=1]");
     aggregationExpression.addNamespace("s11", SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
     aggregationExpression.addNamespace("s12", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
   } catch (JaxenException e) {
     if (log.isDebugEnabled()) {
       handleException(
           "Unable to set the default " + "aggregationExpression for the aggregation", e, null);
     }
   }
 }
コード例 #4
0
  private org.apache.synapse.mediators.builtin.ValidateMediator createValidateMediator(
      EsbNode subject, TransformationInfo information) throws TransformerException, JaxenException {

    /*
     * Check subject.
     */
    Assert.isTrue(subject instanceof ValidateMediator, "Invalid subject.");
    ValidateMediator visualValidateMediator = (ValidateMediator) subject;
    /*
     * Configure Validate mediator.
     */

    org.apache.synapse.mediators.builtin.ValidateMediator validateMediator =
        new org.apache.synapse.mediators.builtin.ValidateMediator();
    setCommonProperties(validateMediator, visualValidateMediator);

    NamespacedProperty sourceXPath = visualValidateMediator.getSourceXpath();
    if (sourceXPath.getPropertyValue() != null && !sourceXPath.getPropertyValue().equals("")) {
      SynapseXPath synapseXPath = new SynapseXPath(sourceXPath.getPropertyValue());
      for (Entry<String, String> entry : sourceXPath.getNamespaces().entrySet()) {
        synapseXPath.addNamespace(entry.getKey(), entry.getValue());
      }
      validateMediator.setSource(synapseXPath);
    }

    List<Value> valueList = new ArrayList<Value>();
    for (ValidateSchema schema : visualValidateMediator.getSchemas()) {

      if (schema.getValidateSchemaKeyType().getLiteral().equals(KeyType.STATIC.getLiteral())) {

        if (schema.getValidateStaticSchemaKey() != null
            && schema.getValidateStaticSchemaKey().getKeyValue() != null) {
          Value val = new Value(schema.getValidateStaticSchemaKey().getKeyValue());
          valueList.add(val);
        }

      } else {

        NamespacedProperty dynamicSchemaKey = schema.getValidateDynamicSchemaKey();
        if (dynamicSchemaKey != null && dynamicSchemaKey.getPropertyValue() != null) {
          SynapseXPath xpath = new SynapseXPath(dynamicSchemaKey.getPropertyValue());
          for (Entry<String, String> entry : dynamicSchemaKey.getNamespaces().entrySet()) {
            xpath.addNamespace(entry.getKey(), entry.getValue());
          }
          Value val = new Value(xpath);
          valueList.add(val);
        }
      }
    }
    validateMediator.setSchemaKeys(valueList);

    // ListMediator onFailMediatorList = new AnonymousListMediator();
    SequenceMediator onFailMediatorList = new SequenceMediator();
    TransformationInfo newOnFailInfo = new TransformationInfo();
    newOnFailInfo.setTraversalDirection(information.getTraversalDirection());
    newOnFailInfo.setSynapseConfiguration(information.getSynapseConfiguration());
    newOnFailInfo.setOriginInSequence(information.getOriginInSequence());
    newOnFailInfo.setOriginOutSequence(information.getOriginOutSequence());
    newOnFailInfo.setCurrentProxy(information.getCurrentProxy());
    newOnFailInfo.setParentSequence(onFailMediatorList);
    doTransform(newOnFailInfo, visualValidateMediator.getOnFailOutputConnector());
    validateMediator.addAll(onFailMediatorList.getList());

    for (ValidateFeature feature : visualValidateMediator.getFeatures()) {
      try {
        validateMediator.addFeature(feature.getFeatureName(), feature.isFeatureEnabled());
      } catch (Exception e) {
        log.error(e);
      }
    }

    if (!visualValidateMediator.getResources().isEmpty()) {

      ResourceMap rMap = new ResourceMap();

      for (ValidateResource resource : visualValidateMediator.getResources()) {

        if (resource.getLocation() != null && resource.getKey() != null) {

          rMap.addResource(resource.getLocation(), resource.getKey().getKeyValue());
        }
      }

      validateMediator.setResourceMap(rMap);
    }

    return validateMediator;
  }