private void processKeyStoreElement(
     OMElement bamServerConfig, BAMServerProfile bamServerProfile) {
   OMElement keyStoreElement =
       bamServerConfig.getFirstChildWithName(
           new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "KeyStore"));
   if (keyStoreElement != null) {
     OMAttribute locationAttr = keyStoreElement.getAttribute(new QName("location"));
     OMAttribute passwordAttr = keyStoreElement.getAttribute(new QName("password"));
     if (locationAttr != null
         && passwordAttr != null
         && !locationAttr.getAttributeValue().equals("")
         && !passwordAttr.getAttributeValue().equals("")) {
       bamServerProfile.setKeyStoreLocation(locationAttr.getAttributeValue());
       bamServerProfile.setKeyStorePassword(passwordAttr.getAttributeValue());
     } else {
       String errMsg =
           "Key store details location or password not found for BAM "
               + "server profile: "
               + profileLocation;
       handleError(errMsg);
     }
   } else {
     String errMsg = "Key store element not found for BAM server profile: " + profileLocation;
     handleError(errMsg);
   }
 }
 private void processCredentialElement(
     OMElement bamServerConfig, BAMServerProfile bamServerProfile) throws CryptoException {
   OMElement credentialElement =
       bamServerConfig.getFirstChildWithName(
           new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Credential"));
   if (credentialElement != null) {
     OMAttribute userNameAttr = credentialElement.getAttribute(new QName("userName"));
     OMAttribute passwordAttr = credentialElement.getAttribute(new QName("password"));
     // OMAttribute secureAttr = credentialElement.getAttribute(new QName("secure"));
     if (userNameAttr != null
         && passwordAttr != null
         && /*secureAttr != null &&*/ !userNameAttr.getAttributeValue().equals("")
         && !passwordAttr.getAttributeValue().equals("")
     /*&& !secureAttr.getAttributeValue().equals("")*/ ) {
       bamServerProfile.setUserName(userNameAttr.getAttributeValue());
       bamServerProfile.setPassword(
           new String(
               CryptoUtil.getDefaultCryptoUtil()
                   .base64DecodeAndDecrypt(passwordAttr.getAttributeValue())));
     } else {
       String errMsg = "Username or Password not found for BAM server profile: " + profileLocation;
       handleError(errMsg);
     }
   } else {
     String errMsg = "Credentials not found for BAM server profile: " + profileLocation;
     handleError(errMsg);
   }
 }
Esempio n. 3
0
 private OMElement resolveImports(
     OMElement grammarsElement, String wadlBaseUri, String wadlVersion) throws RegistryException {
   String wadlNamespace = grammarsElement.getNamespace().getNamespaceURI();
   Iterator<OMElement> grammarElements =
       grammarsElement.getChildrenWithName(new QName(wadlNamespace, "include"));
   while (grammarElements.hasNext()) {
     OMElement childElement = grammarElements.next();
     OMAttribute refAttr = childElement.getAttribute(new QName("href"));
     String importUrl = refAttr.getAttributeValue();
     if (importUrl.endsWith(".xsd")) {
       if (!importUrl.startsWith("http")) {
         if (registry.resourceExists(importUrl)) {
           continue;
         } else {
           if (wadlBaseUri != null) {
             importUrl = wadlBaseUri + importUrl;
           }
         }
       }
       String schemaPath = saveSchema(importUrl, wadlVersion);
       importedSchemas.add(schemaPath);
       refAttr.setAttributeValue(schemaPath);
       childElement.addAttribute(refAttr);
     }
   }
   return grammarsElement;
 }
Esempio n. 4
0
  private void processMessages(Iterator messages, AxisOperation operation)
      throws DeploymentException {
    while (messages.hasNext()) {
      OMElement messageElement = (OMElement) messages.next();
      OMAttribute label = messageElement.getAttribute(new QName(TAG_LABEL));

      if (label == null) {
        throw new DeploymentException(Messages.getMessage("messagelabelcannotfound"));
      }

      AxisMessage message = operation.getMessage(label.getAttributeValue());

      Iterator parameters = messageElement.getChildrenWithName(new QName(TAG_PARAMETER));

      // processing <wsp:Policy> .. </..> elements
      Iterator policyElements =
          messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));

      if (policyElements != null) {
        processPolicyElements(policyElements, message.getPolicySubject());
      }

      // processing <wsp:PolicyReference> .. </..> elements
      Iterator policyRefElements =
          messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));

      if (policyRefElements != null) {
        processPolicyRefElements(policyRefElements, message.getPolicySubject());
      }

      processParameters(parameters, message, operation);
    }
  }
Esempio n. 5
0
  /**
   * Make sure that the endpoints created by the factory has a name
   *
   * @param epConfig OMElement containing the endpoint configuration.
   * @param anonymousEndpoint false if the endpoint has a name. true otherwise.
   * @param properties bag of properties to pass in any information to the factory
   * @return Endpoint implementation for the given configuration.
   */
  private Endpoint createEndpointWithName(
      OMElement epConfig, boolean anonymousEndpoint, Properties properties) {

    Endpoint ep = createEndpoint(epConfig, anonymousEndpoint, properties);
    OMElement descriptionElem = epConfig.getFirstChildWithName(DESCRIPTION_Q);
    if (descriptionElem != null) {
      ep.setDescription(descriptionElem.getText());
    }

    // if the endpoint doesn't have a name we will generate a unique name.
    if (anonymousEndpoint && ep.getName() == null) {
      String uuid = UIDGenerator.generateUID();
      uuid = uuid.replace(':', '_');
      ep.setName(ENDPOINT_NAME_PREFIX + uuid);
      if (ep instanceof AbstractEndpoint) {
        ((AbstractEndpoint) ep).setAnonymous(true);
      }
    }

    OMAttribute onFaultAtt = epConfig.getAttribute(ON_FAULT_Q);
    if (onFaultAtt != null) {
      ep.setErrorHandler(onFaultAtt.getAttributeValue());
    }
    return ep;
  }
  public void build(OMElement elem) {
    OMAttribute bean = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "bean"));
    OMAttribute key = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));

    if (bean == null) {
      throw new MediatorException(
          "The 'bean' attribute is required for a Spring mediator definition");
    } else if (key == null) {
      throw new MediatorException("A 'key' attribute is required for a Spring mediator definition");
    } else {

      // after successfully creating the mediator
      // set its common attributes such as tracing etc
      processAuditStatus(this, elem);
      this.beanName = bean.getAttributeValue();
      this.configKey = key.getAttributeValue();
    }
  }
  @SuppressWarnings({"UnusedDeclaration"})
  public static MessageStore createMessageStore(OMElement elem, Properties properties) {

    OMAttribute clss = elem.getAttribute(CLASS_Q);
    MessageStore messageStore;
    if (clss != null) {
      String clssName = clss.getAttributeValue();

      // Make synapse configuration backward compatible
      if (Constants.DEPRECATED_INMEMORY_CLASS.equals(clssName)) {
        clssName = InMemoryStore.class.getName();
      } else if (Constants.DEPRECATED_JMS_CLASS.equals(clssName)) {
        clssName = JmsStore.class.getName();
      }

      try {
        Class cls = Class.forName(clssName);
        messageStore = (MessageStore) cls.newInstance();
      } catch (Exception e) {
        handleException("Error while instantiating the message store", e);
        return null;
      }
    } else {
      messageStore = new InMemoryStore();
    }

    OMAttribute nameAtt = elem.getAttribute(NAME_Q);

    if (nameAtt != null) {
      messageStore.setName(nameAtt.getAttributeValue());
    } else {
      handleException("Message Store name not specified");
    }

    OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
    if (descriptionElem != null) {
      messageStore.setDescription(descriptionElem.getText());
    }

    messageStore.setParameters(getParameters(elem));

    log.info("Successfully created Message Store: " + nameAtt.getAttributeValue());
    return messageStore;
  }
Esempio n. 8
0
  /*
   * process data locator configuration for data retrieval.
   */
  private void processDataLocatorConfig(OMElement dataLocatorElement, AxisService service) {
    OMAttribute serviceOverallDataLocatorclass =
        dataLocatorElement.getAttribute(new QName(DRConstants.CLASS_ATTRIBUTE));
    if (serviceOverallDataLocatorclass != null) {
      String className = serviceOverallDataLocatorclass.getAttributeValue();
      service.addDataLocatorClassNames(DRConstants.SERVICE_LEVEL, className);
    }
    Iterator iterator =
        dataLocatorElement.getChildrenWithName(new QName(DRConstants.DIALECT_LOCATOR_ELEMENT));

    while (iterator.hasNext()) {
      OMElement locatorElement = (OMElement) iterator.next();
      OMAttribute dialect = locatorElement.getAttribute(new QName(DRConstants.DIALECT_ATTRIBUTE));
      OMAttribute dialectclass =
          locatorElement.getAttribute(new QName(DRConstants.CLASS_ATTRIBUTE));
      service.addDataLocatorClassNames(
          dialect.getAttributeValue(), dialectclass.getAttributeValue());
    }
  }
 private void processBAMServerProfileName(
     OMElement bamServerConfig, BAMServerProfile bamServerProfile) {
   OMAttribute name = bamServerConfig.getAttribute(new QName("name"));
   if (name != null) {
     bamServerProfile.setName(name.getAttributeValue());
   } else {
     String errMsg = "Name attribute not found for BAM server profile: " + profileLocation;
     handleError(errMsg);
   }
 }
 private static boolean nodeType(String elementName, OMElement element)
     throws ManagementConfigurationException {
   OMAttribute attribute = element.getAttribute(new QName(elementName));
   if (attribute != null) {
     return attribute.getAttributeValue().equalsIgnoreCase("True");
   } else {
     throw new ManagementConfigurationException(
         "Invalid XML. No attribute with name "
             + ConfigurationConstants.PROCESSING_MODE_NAME_ATTRIBUTE
             + " found in file "
             + ConfigurationConstants.CEP_MANAGEMENT_XML);
   }
 }
  @Override
  protected Mediator createSpecificMediator(OMElement elem, Properties properties) {
    MessageStoreMediator messageStoreMediator = new MessageStoreMediator();
    OMAttribute nameAtt = elem.getAttribute(ATT_NAME);
    if (nameAtt != null) {
      messageStoreMediator.setName(nameAtt.getAttributeValue());
    }

    OMAttribute messageStoreNameAtt = elem.getAttribute(ATT_MESSAGE_STORE);

    if (messageStoreNameAtt != null) {
      messageStoreMediator.setMessageStoreName(messageStoreNameAtt.getAttributeValue());
    } else {
      throw new SynapseException("Message Store mediator must have a Message store defined");
    }

    OMAttribute sequenceAtt = elem.getAttribute(ATT_SEQUENCE);

    if (sequenceAtt != null) {
      messageStoreMediator.setOnStoreSequence(sequenceAtt.getAttributeValue());
    }

    return messageStoreMediator;
  }
Esempio n. 12
0
 private void processConnectionElement(
     OMElement bamServerConfig, BAMServerProfile bamServerProfile) {
   OMElement connectionElement =
       bamServerConfig.getFirstChildWithName(
           new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Connection"));
   if (connectionElement != null) {
     OMAttribute secureAttr = connectionElement.getAttribute(new QName("secure"));
     OMAttribute ipAttr = connectionElement.getAttribute(new QName("ip"));
     OMAttribute authenticationPortAttr = connectionElement.getAttribute(new QName("authPort"));
     OMAttribute receiverPortAttr = connectionElement.getAttribute(new QName("receiverPort"));
     if (ipAttr != null
         && secureAttr != null
         && authenticationPortAttr != null
         && receiverPortAttr != null
         && !ipAttr.getAttributeValue().equals("")
         && !secureAttr.getAttributeValue().equals("")
         && !authenticationPortAttr.getAttributeValue().equals("")
         && !receiverPortAttr.getAttributeValue().equals("")) {
       bamServerProfile.setIp(ipAttr.getAttributeValue());
       if ("true".equals(secureAttr.getAttributeValue())) {
         bamServerProfile.setSecurityEnabled(true);
       } else if ("false".equals(secureAttr.getAttributeValue())) {
         bamServerProfile.setSecurityEnabled(false);
       } else {
         String errMsg =
             "Invalid value found for secure element in BAM server profile: " + profileLocation;
         handleError(errMsg);
       }
       bamServerProfile.setAuthenticationPort(authenticationPortAttr.getAttributeValue());
       bamServerProfile.setReceiverPort(receiverPortAttr.getAttributeValue());
     } else {
       String errMsg = "Connection details are missing for BAM server profile: " + profileLocation;
       handleError(errMsg);
     }
   } else {
     String errMsg = "Connection details not found for BAM server profile: " + profileLocation;
     handleError(errMsg);
   }
 }
Esempio n. 13
0
 public final boolean equals(Object obj) {
   if (this == obj) {
     return true;
   } else if (obj instanceof OMAttribute) {
     try {
       OMAttribute other = (OMAttribute) obj;
       // TODO: using getNamespace is not efficient because it will create a new OMNamespace
       // instance
       return coreGetLocalName().equals(other.getLocalName())
           && ObjectUtils.equals(getNamespace(), other.getNamespace())
           && getAttributeValue().equals(other.getAttributeValue());
     } catch (CoreModelException ex) {
       throw AxiomExceptionTranslator.translate(ex);
     }
   } else {
     return false;
   }
 }
Esempio n. 14
0
  /**
   * This static method will be used to build the Target from the specified element
   *
   * @param elem - OMElement describing the xml configuration of the target
   * @return Target built by parsing the given element
   */
  public static Target createTarget(OMElement elem) {

    if (!TARGET_Q.equals(elem.getQName())) {
      handleException("Element does not match with the target QName");
    }

    Target target = new Target();
    OMAttribute toAttr = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "to"));
    if (toAttr != null && toAttr.getAttributeValue() != null) {
      target.setToAddress(toAttr.getAttributeValue());
    }

    OMAttribute soapAction =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "soapAction"));
    if (soapAction != null && soapAction.getAttributeValue() != null) {
      target.setSoapAction(soapAction.getAttributeValue());
    }

    OMAttribute sequenceAttr =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "sequence"));
    if (sequenceAttr != null && sequenceAttr.getAttributeValue() != null) {
      target.setSequenceRef(sequenceAttr.getAttributeValue());
    }

    OMAttribute endpointAttr =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "endpoint"));
    if (endpointAttr != null && endpointAttr.getAttributeValue() != null) {
      target.setEndpointRef(endpointAttr.getAttributeValue());
    }

    OMElement sequence =
        elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "sequence"));
    if (sequence != null) {
      SequenceMediatorFactory fac = new SequenceMediatorFactory();
      target.setSequence(fac.createAnonymousSequence(sequence));
    }

    OMElement endpoint =
        elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "endpoint"));
    if (endpoint != null) {
      target.setEndpoint(EndpointFactory.getEndpointFromElement(endpoint, true));
    }

    return target;
  }
Esempio n. 15
0
  protected void processServiceModuleConfig(
      Iterator moduleConfigs, ParameterInclude parent, AxisService service)
      throws DeploymentException {
    while (moduleConfigs.hasNext()) {
      OMElement moduleConfig = (OMElement) moduleConfigs.next();
      OMAttribute moduleName_att = moduleConfig.getAttribute(new QName(ATTRIBUTE_NAME));

      if (moduleName_att == null) {
        throw new DeploymentException(
            Messages.getMessage(DeploymentErrorMsgs.INVALID_MODULE_CONFIG));
      } else {
        String module = moduleName_att.getAttributeValue();
        ModuleConfiguration moduleConfiguration = new ModuleConfiguration(module, parent);
        Iterator parameters = moduleConfig.getChildrenWithName(new QName(TAG_PARAMETER));

        processParameters(parameters, moduleConfiguration, parent);
        service.addModuleConfig(moduleConfiguration);
      }
    }
  }
  private static Map<String, Object> getParameters(OMElement elem) {
    Iterator params = elem.getChildrenWithName(PARAMETER_Q);
    Map<String, Object> parameters = new HashMap<String, Object>();

    while (params.hasNext()) {
      Object o = params.next();
      if (o instanceof OMElement) {
        OMElement prop = (OMElement) o;
        OMAttribute paramName = prop.getAttribute(NAME_Q);
        String paramValue = prop.getText();
        if (paramName != null) {
          if (paramValue != null) {
            parameters.put(paramName.getAttributeValue(), paramValue);
          }
        } else {
          handleException("Invalid MessageStore parameter - Parameter must have a name ");
        }
      }
    }
    return parameters;
  }
Esempio n. 17
0
  /**
   * Gets the list of modules that is required to be engaged globally.
   *
   * @param moduleRefs <code>java.util.Iterator</code>
   * @throws DeploymentException <code>DeploymentException</code>
   */
  protected void processModuleRefs(Iterator moduleRefs) throws DeploymentException {
    //		try {
    while (moduleRefs.hasNext()) {
      OMElement moduleref = (OMElement) moduleRefs.next();
      OMAttribute moduleRefAttribute = moduleref.getAttribute(new QName(TAG_REFERENCE));

      if (moduleRefAttribute != null) {
        String refName = moduleRefAttribute.getAttributeValue();
        service.addModuleref(refName);
        //					if (axisConfig.getModule(refName) == null) {
        //						throw new DeploymentException(Messages.getMessage(
        //								DeploymentErrorMsgs.MODULE_NOT_FOUND, refName));
        //					} else {
        //						service.addModuleref(refName);
        //					}
      }
    }
    //		} catch (AxisFault axisFault) {
    //			throw new DeploymentException(axisFault);
    //		}
  }
Esempio n. 18
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);
    }
  }
Esempio n. 19
0
 void validate_internal_classifications(OMElement e)
     throws MetadataValidationException, MetadataException {
   String e_id = e.getAttributeValue(MetadataSupport.id_qname);
   if (e_id == null || e_id.equals("")) return;
   for (Iterator it = e.getChildElements(); it.hasNext(); ) {
     OMElement child = (OMElement) it.next();
     OMAttribute classified_object_att =
         child.getAttribute(MetadataSupport.classified_object_qname);
     if (classified_object_att != null) {
       String value = classified_object_att.getAttributeValue();
       if (!e_id.equals(value)) {
         throw new MetadataValidationException(
             "Classification "
                 + m.getIdentifyingString(child)
                 + "\n   is nested inside "
                 + m.getIdentifyingString(e)
                 + "\n   but classifies object "
                 + m.getIdentifyingString(value));
       }
     }
   }
 }
Esempio n. 20
0
  public static Entry createEntry(OMElement elem, Properties properties) {
    String customFactory = SynapsePropertiesLoader.getPropertyValue("synapse.entry.factory", "");
    if (customFactory != null && !"".equals(customFactory)) {
      try {
        Class c = Class.forName(customFactory);
        Object o = c.newInstance();
        if (o instanceof IEntryFactory) {
          return ((IEntryFactory) o).createEntry(elem);
        }
      } catch (ClassNotFoundException e) {
        handleException(
            "Class specified by the synapse.entry.factory "
                + "synapse property not found: "
                + customFactory,
            e);
      } catch (InstantiationException e) {
        handleException(
            "Class specified by the synapse.entry.factory "
                + "synapse property cannot be instantiated: "
                + customFactory,
            e);
      } catch (IllegalAccessException e) {
        handleException(
            "Class specified by the synapse.entry.factory "
                + "synapse property cannot be accessed: "
                + customFactory,
            e);
      }
    }

    OMAttribute key = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));
    if (key == null) {
      handleException("The 'key' attribute is required for a local registry entry");
      return null;

    } else {

      Entry entry = new Entry(key.getAttributeValue());

      OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
      if (descriptionElem != null) {
        entry.setDescription(descriptionElem.getText());
        descriptionElem.detach();
      }

      String src = elem.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "src"));

      // if a src attribute is present, this is a URL source resource,
      // it would now be loaded from the URL source, as all static properties
      // are initialized at startup
      if (src != null) {
        try {
          entry.setSrc(new URL(src.trim()));
          entry.setType(Entry.URL_SRC);
          entry.setValue(SynapseConfigUtils.getObject(entry.getSrc(), properties));
        } catch (MalformedURLException e) {
          handleException("The entry with key : " + key + " refers to an invalid URL");
        }

      } else {
        OMNode nodeValue = elem.getFirstOMChild();
        OMElement elemValue = elem.getFirstElement();

        if (elemValue != null) {
          entry.setType(Entry.INLINE_XML);
          entry.setValue(elemValue);
        } else if (nodeValue != null && nodeValue instanceof OMText) {
          entry.setType(Entry.INLINE_TEXT);
          entry.setValue(elem.getText().trim());
        }
      }

      return entry;
    }
  }
Esempio n. 21
0
  /**
   * Populates service from corresponding OM.
   *
   * @param service_element an OMElement for the &lt;service&gt; tag
   * @return a filled-in AxisService, configured from the passed XML
   * @throws DeploymentException if there is a problem
   */
  public AxisService populateService(OMElement service_element) throws DeploymentException {
    try {
      // Determine whether service should be activated.
      String serviceActivate = service_element.getAttributeValue(new QName(ATTRIBUTE_ACTIVATE));
      if (serviceActivate != null) {
        if ("true".equals(serviceActivate)) {
          service.setActive(true);
        } else if ("false".equals(serviceActivate)) {
          service.setActive(false);
        }
      }

      // Processing service level parameters
      OMAttribute serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME));

      // If the service name is explicitly specified in the services.xml
      // then use that as the service name
      if (serviceNameatt != null) {
        if (!"".equals(serviceNameatt.getAttributeValue().trim())) {
          AxisService wsdlService = wsdlServiceMap.get(serviceNameatt.getAttributeValue());
          if (wsdlService != null) {
            wsdlService.setClassLoader(service.getClassLoader());
            wsdlService.setParent(service.getAxisServiceGroup());
            service = wsdlService;
            service.setWsdlFound(true);
            service.setCustomWsdl(true);
          }
          service.setName(serviceNameatt.getAttributeValue());
          // To be on the safe side
          if (service.getDocumentation() == null) {
            service.setDocumentation(serviceNameatt.getAttributeValue());
          }
        }
      }

      Iterator itr = service_element.getChildrenWithName(new QName(TAG_PARAMETER));
      processParameters(itr, service, service.getParent());

      Parameter childFirstClassLoading =
          service.getParameter(Constants.Configuration.ENABLE_CHILD_FIRST_CLASS_LOADING);
      if (childFirstClassLoading != null) {
        ClassLoader cl = service.getClassLoader();
        if (cl instanceof DeploymentClassLoader) {
          DeploymentClassLoader deploymentClassLoader = (DeploymentClassLoader) cl;
          if (JavaUtils.isTrueExplicitly(childFirstClassLoading.getValue())) {
            deploymentClassLoader.setChildFirstClassLoading(true);
          } else if (JavaUtils.isFalseExplicitly(childFirstClassLoading.getValue())) {
            deploymentClassLoader.setChildFirstClassLoading(false);
          }
        }
      }

      // If multiple services in one service group have different values
      // for the PARENT_FIRST
      // parameter then the final value become the value specified by the
      // last service in the group
      // Parameter parameter =
      // service.getParameter(DeploymentClassLoader.PARENT_FIRST);
      // if (parameter !=null && "false".equals(parameter.getValue())) {
      // ClassLoader serviceClassLoader = service.getClassLoader();
      // ((DeploymentClassLoader)serviceClassLoader).setParentFirst(false);
      // }
      // process service description
      OMElement descriptionElement =
          service_element.getFirstChildWithName(new QName(TAG_DESCRIPTION));
      if (descriptionElement != null) {
        OMElement descriptionValue = descriptionElement.getFirstElement();
        if (descriptionValue != null) {
          service.setDocumentation(descriptionValue);
        } else {
          service.setDocumentation(descriptionElement.getText());
        }
      } else {
        serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME));

        if (serviceNameatt != null) {
          if (!"".equals(serviceNameatt.getAttributeValue().trim())
              && service.getDocumentation() == null) {
            service.setDocumentation(serviceNameatt.getAttributeValue());
          }
        }
      }

      if (service.getParameter("ServiceClass") == null) {
        log.debug("The Service " + service.getName() + " does not specify a Service Class");
      }

      // Process WS-Addressing flag attribute
      OMAttribute addressingRequiredatt =
          service_element.getAttribute(new QName(ATTRIBUTE_WSADDRESSING));
      if (addressingRequiredatt != null) {
        String addressingRequiredString = addressingRequiredatt.getAttributeValue();
        AddressingHelper.setAddressingRequirementParemeterValue(service, addressingRequiredString);
      }

      // Setting service target namespace if any
      OMAttribute targetNameSpace = service_element.getAttribute(new QName(TARGET_NAME_SPACE));

      if (targetNameSpace != null) {
        String nameSpeceVale = targetNameSpace.getAttributeValue();
        if (nameSpeceVale != null && !"".equals(nameSpeceVale)) {
          service.setTargetNamespace(nameSpeceVale);
        }
      } else {
        if (service.getTargetNamespace() == null || "".equals(service.getTargetNamespace())) {
          service.setTargetNamespace(Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE);
        }
      }

      // Processing service lifecycle attribute
      OMAttribute serviceLifeCycleClass = service_element.getAttribute(new QName(TAG_CLASS_NAME));
      if (serviceLifeCycleClass != null) {
        String className = serviceLifeCycleClass.getAttributeValue();
        loadServiceLifeCycleClass(className);
      }
      // Setting schema namespece if any
      OMElement schemaElement = service_element.getFirstChildWithName(new QName(SCHEMA));
      if (schemaElement != null) {
        OMAttribute schemaNameSpace = schemaElement.getAttribute(new QName(SCHEMA_NAME_SPACE));
        if (schemaNameSpace != null) {
          String nameSpeceVale = schemaNameSpace.getAttributeValue();
          if (nameSpeceVale != null && !"".equals(nameSpeceVale)) {
            service.setSchemaTargetNamespace(nameSpeceVale);
          }
        }
        OMAttribute elementFormDefault =
            schemaElement.getAttribute(new QName(SCHEMA_ELEMENT_QUALIFIED));
        if (elementFormDefault != null) {
          String value = elementFormDefault.getAttributeValue();
          if ("true".equals(value)) {
            service.setElementFormDefault(true);
          } else if ("false".equals(value)) {
            service.setElementFormDefault(false);
          }
        }

        // package to namespace mapping. This will be an element that
        // maps pkg names to a namespace
        // when this is doing AxisService.getSchemaTargetNamespace will
        // be overridden
        // This will be <mapping/> with @namespace and @package
        Iterator mappingIterator = schemaElement.getChildrenWithName(new QName(MAPPING));
        if (mappingIterator != null) {
          Map<String, String> pkg2nsMap = new Hashtable<String, String>();
          while (mappingIterator.hasNext()) {
            OMElement mappingElement = (OMElement) mappingIterator.next();
            OMAttribute namespaceAttribute =
                mappingElement.getAttribute(new QName(ATTRIBUTE_NAMESPACE));
            OMAttribute packageAttribute =
                mappingElement.getAttribute(new QName(ATTRIBUTE_PACKAGE));
            if (namespaceAttribute != null && packageAttribute != null) {
              String namespaceAttributeValue = namespaceAttribute.getAttributeValue();
              String packageAttributeValue = packageAttribute.getAttributeValue();
              if (namespaceAttributeValue != null && packageAttributeValue != null) {
                pkg2nsMap.put(packageAttributeValue.trim(), namespaceAttributeValue.trim());
              } else {
                log.warn(
                    "Either value of @namespce or @packagename not available. Thus, generated will be selected.");
              }
            } else {
              log.warn(
                  "Either @namespce or @packagename not available. Thus, generated will be selected.");
            }
          }
          service.setP2nMap(pkg2nsMap);
        }
      }

      // processing Default Message receivers
      OMElement messageReceiver =
          service_element.getFirstChildWithName(new QName(TAG_MESSAGE_RECEIVERS));
      if (messageReceiver != null) {
        HashMap<String, MessageReceiver> mrs =
            processMessageReceivers(service.getClassLoader(), messageReceiver);
        for (Map.Entry<String, MessageReceiver> entry : mrs.entrySet()) {
          service.addMessageReceiver(entry.getKey(), entry.getValue());
        }
      }

      // Removing exclude operations
      OMElement excludeOperations =
          service_element.getFirstChildWithName(new QName(TAG_EXCLUDE_OPERATIONS));
      ArrayList<String> excludeops = null;
      if (excludeOperations != null) {
        excludeops = processExcludeOperations(excludeOperations);
      }
      if (excludeops == null) {
        excludeops = new ArrayList<String>();
      }
      Utils.addExcludeMethods(excludeops);

      // <schema targetNamespace="http://x.y.z"/>
      // setting the PolicyInclude
      // processing <wsp:Policy> .. </..> elements
      Iterator policyElements =
          service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));

      if (policyElements != null && policyElements.hasNext()) {
        processPolicyElements(policyElements, service.getPolicySubject());
      }

      // processing <wsp:PolicyReference> .. </..> elements
      Iterator policyRefElements =
          service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));

      if (policyRefElements != null && policyRefElements.hasNext()) {
        processPolicyRefElements(policyRefElements, service.getPolicySubject());
      }

      // processing service scope
      String sessionScope = service_element.getAttributeValue(new QName(ATTRIBUTE_SCOPE));
      if (sessionScope != null) {
        service.setScope(sessionScope);
      }

      // processing service-wide modules which required to engage globally
      Iterator moduleRefs = service_element.getChildrenWithName(new QName(TAG_MODULE));

      processModuleRefs(moduleRefs);

      // processing transports
      OMElement transports = service_element.getFirstChildWithName(new QName(TAG_TRANSPORTS));
      if (transports != null) {
        Iterator transport_itr = transports.getChildrenWithName(new QName(TAG_TRANSPORT));
        ArrayList<String> trs = new ArrayList<String>();
        while (transport_itr.hasNext()) {
          OMElement trsEle = (OMElement) transport_itr.next();
          String transportName = trsEle.getText().trim();
          if (axisConfig.getTransportIn(transportName) == null) {
            log.warn(
                "Service [ "
                    + service.getName()
                    + "] is trying to expose in a transport : "
                    + transportName
                    + " and which is not available in Axis2");
          } else {
            trs.add(transportName);
          }
        }

        if (trs.isEmpty()) {
          throw new AxisFault(
              "Service ["
                  + service.getName()
                  + "] is trying expose in tranpsorts: "
                  + transports
                  + " and which is/are not available in Axis2");
        }
        service.setExposedTransports(trs);
      }
      // processing operations
      Iterator operationsIterator = service_element.getChildrenWithName(new QName(TAG_OPERATION));
      ArrayList ops = processOperations(operationsIterator);

      for (int i = 0; i < ops.size(); i++) {
        AxisOperation operationDesc = (AxisOperation) ops.get(i);
        ArrayList wsamappings = operationDesc.getWSAMappingList();
        if (wsamappings == null) {
          continue;
        }
        if (service.getOperation(operationDesc.getName()) == null) {
          service.addOperation(operationDesc);
        }
        for (int j = 0; j < wsamappings.size(); j++) {
          String mapping = (String) wsamappings.get(j);
          if (mapping.length() > 0) {
            service.mapActionToOperation(mapping, operationDesc);
          }
        }
      }
      String objectSupplierValue = (String) service.getParameterValue(TAG_OBJECT_SUPPLIER);
      if (objectSupplierValue != null) {
        loadObjectSupplierClass(objectSupplierValue);
      }
      // Set the default message receiver for the operations that were
      // not listed in the services.xml
      setDefaultMessageReceivers();
      Utils.processBeanPropertyExclude(service);
      if (!service.isUseUserWSDL()) {
        // Generating schema for the service if the impl class is Java
        if (!service.isWsdlFound()) {
          // trying to generate WSDL for the service using JAM and
          // Java reflection
          try {
            if (generateWsdl(service)) {
              Utils.fillAxisService(service, axisConfig, excludeops, null);
            } else {
              ArrayList nonRpcOperations = getNonRPCMethods(service);
              Utils.fillAxisService(service, axisConfig, excludeops, nonRpcOperations);
            }
          } catch (Exception e) {
            throw new DeploymentException(
                Messages.getMessage("errorinschemagen", e.getMessage()), e);
          }
        }
      }
      if (service.isCustomWsdl()) {
        OMElement mappingElement =
            service_element.getFirstChildWithName(new QName(TAG_PACKAGE2QNAME));
        if (mappingElement != null) {
          processTypeMappings(mappingElement);
        }
      }

      for (String opName : excludeops) {
        service.removeOperation(new QName(opName));
      }

      // Need to call the same logic towice
      setDefaultMessageReceivers();
      Iterator moduleConfigs = service_element.getChildrenWithName(new QName(TAG_MODULE_CONFIG));
      processServiceModuleConfig(moduleConfigs, service, service);

      // Loading Data Locator(s) configured
      OMElement dataLocatorElement =
          service_element.getFirstChildWithName(new QName(DRConstants.DATA_LOCATOR_ELEMENT));
      if (dataLocatorElement != null) {
        processDataLocatorConfig(dataLocatorElement, service);
      }

      processEndpoints(service);
      processPolicyAttachments(service_element, service);

    } catch (AxisFault axisFault) {
      throw new DeploymentException(axisFault);
    }

    startupServiceLifecycle();
    return service;
  }
Esempio n. 22
0
  /**
   * Builds a SOAPEnvelope from DOM Document.
   *
   * @param doc - The dom document that contains a SOAP message
   * @param useDoom
   * @return
   * @throws WSSecurityException
   */
  public static SOAPEnvelope getSOAPEnvelopeFromDOMDocument(Document doc, boolean useDoom)
      throws WSSecurityException {

    if (useDoom) {
      try {
        // Get processed headers
        SOAPEnvelope env = (SOAPEnvelope) doc.getDocumentElement();
        ArrayList processedHeaderQNames = new ArrayList();
        SOAPHeader soapHeader = env.getHeader();

        if (soapHeader != null) {
          Iterator headerBlocs = soapHeader.getChildElements();
          while (headerBlocs.hasNext()) {

            OMElement element = (OMElement) headerBlocs.next();
            SOAPHeaderBlock header = null;

            if (element instanceof SOAPHeaderBlock) {
              header = (SOAPHeaderBlock) element;

              // If a header block is not an instance of SOAPHeaderBlock, it means that
              // it is a header we have added in rampart eg. EncryptedHeader and should
              // be converted to SOAPHeaderBlock for processing
            } else {
              header = soapHeader.addHeaderBlock(element.getLocalName(), element.getNamespace());
              Iterator attrIter = element.getAllAttributes();
              while (attrIter.hasNext()) {
                OMAttribute attr = (OMAttribute) attrIter.next();
                header.addAttribute(
                    attr.getLocalName(), attr.getAttributeValue(), attr.getNamespace());
              }
              Iterator nsIter = element.getAllDeclaredNamespaces();
              while (nsIter.hasNext()) {
                OMNamespace ns = (OMNamespace) nsIter.next();
                header.declareNamespace(ns);
              }
              // retrieve all child nodes (including any text nodes)
              // and re-attach to header block
              Iterator children = element.getChildren();
              while (children.hasNext()) {
                OMNode child = (OMNode) children.next();
                child.detach();
                header.addChild(child);
              }

              element.detach();

              soapHeader.build();

              header.setProcessed();
            }

            if (header.isProcessed()) {
              processedHeaderQNames.add(element.getQName());
            }
          }
        }
        XMLStreamReader reader = ((OMElement) doc.getDocumentElement()).getXMLStreamReader();
        StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(reader, null);
        SOAPEnvelope envelope = stAXSOAPModelBuilder.getSOAPEnvelope();

        // Set the processed flag of the processed headers
        SOAPHeader header = envelope.getHeader();
        for (Iterator iter = processedHeaderQNames.iterator(); iter.hasNext(); ) {
          QName name = (QName) iter.next();
          Iterator omKids = header.getChildrenWithName(name);
          if (omKids.hasNext()) {
            ((SOAPHeaderBlock) omKids.next()).setProcessed();
          }
        }

        envelope.build();

        return envelope;

      } catch (FactoryConfigurationError e) {
        throw new WSSecurityException(e.getMessage());
      }
    } else {
      try {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        XMLUtils.outputDOM(doc.getDocumentElement(), os, true);
        ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray());

        StAXSOAPModelBuilder stAXSOAPModelBuilder =
            new StAXSOAPModelBuilder(
                XMLInputFactory.newInstance().createXMLStreamReader(bais), null);
        return stAXSOAPModelBuilder.getSOAPEnvelope();
      } catch (Exception e) {
        throw new WSSecurityException(e.getMessage());
      }
    }
  }
Esempio n. 23
0
  private ArrayList<AxisOperation> processOperations(Iterator operationsIterator) throws AxisFault {
    ArrayList<AxisOperation> operations = new ArrayList<AxisOperation>();
    while (operationsIterator.hasNext()) {
      OMElement operation = (OMElement) operationsIterator.next();
      // getting operation name
      OMAttribute op_name_att = operation.getAttribute(new QName(ATTRIBUTE_NAME));
      if (op_name_att == null) {
        throw new DeploymentException(
            Messages.getMessage(
                Messages.getMessage(DeploymentErrorMsgs.INVALID_OP, "operation name missing")));
      }

      // setting the MEP of the operation
      OMAttribute op_mep_att = operation.getAttribute(new QName(TAG_MEP));
      String mepurl = null;

      if (op_mep_att != null) {
        mepurl = op_mep_att.getAttributeValue();
      }

      String opname = op_name_att.getAttributeValue();
      AxisOperation op_descrip = null;

      // getting the namesapce from the attribute.
      OMAttribute operationNamespace = operation.getAttribute(new QName(ATTRIBUTE_NAMESPACE));
      if (operationNamespace != null) {
        String namespace = operationNamespace.getAttributeValue();
        op_descrip = service.getOperation(new QName(namespace, opname));
      }
      if (op_descrip == null) {
        op_descrip = service.getOperation(new QName(opname));
      }

      if (op_descrip == null) {
        op_descrip = service.getOperation(new QName(service.getTargetNamespace(), opname));
      }
      if (op_descrip == null) {
        if (mepurl == null) {
          // assumed MEP is in-out
          op_descrip = new InOutAxisOperation();
          op_descrip.setParent(service);

        } else {
          op_descrip = AxisOperationFactory.getOperationDescription(mepurl);
        }
        op_descrip.setName(new QName(opname));
        String MEP = op_descrip.getMessageExchangePattern();
        if (WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP)
            || WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)
            || WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP)
            || WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
            || WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
            || WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
          AxisMessage inaxisMessage = op_descrip.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
          if (inaxisMessage != null) {
            inaxisMessage.setName(opname + Java2WSDLConstants.MESSAGE_SUFFIX);
          }
        }

        if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
            || WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP)
            || WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)
            || WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
            || WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
          AxisMessage outAxisMessage = op_descrip.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
          if (outAxisMessage != null) {
            outAxisMessage.setName(opname + Java2WSDLConstants.RESPONSE);
          }
        }
      }

      // setting the PolicyInclude

      // processing <wsp:Policy> .. </..> elements
      Iterator policyElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));

      if (policyElements != null && policyElements.hasNext()) {
        processPolicyElements(policyElements, op_descrip.getPolicySubject());
      }

      // processing <wsp:PolicyReference> .. </..> elements
      Iterator policyRefElements =
          operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));

      if (policyRefElements != null && policyRefElements.hasNext()) {
        processPolicyRefElements(policyRefElements, op_descrip.getPolicySubject());
      }

      // Operation Parameters
      Iterator parameters = operation.getChildrenWithName(new QName(TAG_PARAMETER));
      processParameters(parameters, op_descrip, service);
      // To process wsamapping;
      processActionMappings(operation, op_descrip);

      // loading the message receivers
      OMElement receiverElement = operation.getFirstChildWithName(new QName(TAG_MESSAGE_RECEIVER));

      if (receiverElement != null) {
        MessageReceiver messageReceiver =
            loadMessageReceiver(service.getClassLoader(), receiverElement);

        op_descrip.setMessageReceiver(messageReceiver);
      } else {
        // setting default message receiver
        MessageReceiver msgReceiver =
            loadDefaultMessageReceiver(op_descrip.getMessageExchangePattern(), service);
        op_descrip.setMessageReceiver(msgReceiver);
      }

      // Process Module Refs
      Iterator modules = operation.getChildrenWithName(new QName(TAG_MODULE));

      processOperationModuleRefs(modules, op_descrip);

      // processing Messages
      Iterator messages = operation.getChildrenWithName(new QName(TAG_MESSAGE));

      processMessages(messages, op_descrip);

      // setting Operation phase
      if (axisConfig != null) {
        PhasesInfo info = axisConfig.getPhasesInfo();

        info.setOperationPhases(op_descrip);
      }
      Iterator moduleConfigs = operation.getChildrenWithName(new QName(TAG_MODULE_CONFIG));
      processOperationModuleConfig(moduleConfigs, op_descrip, op_descrip);
      // adding the operation
      operations.add(op_descrip);
    }
    return operations;
  }
Esempio n. 24
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);
    }
  }
  public void build(OMElement elem) {

    OMAttribute mediaType = elem.getAttribute(ATT_MEDIA);
    if (mediaType != null) {
      this.type = mediaType.getAttributeValue();
    }
    OMElement formatElem = elem.getFirstChildWithName(FORMAT_Q);

    if (formatElem != null) {
      OMAttribute n = formatElem.getAttribute(ATT_KEY);
      if (n == null) {
        if (type != null && (type.contains(JSON_TYPE) || type.contains(TEXT_TYPE))) {
          this.format = formatElem.getText();
        } else {
          this.format = formatElem.getFirstElement().toString();
        }
      } else {
        this.formatKey = n.getAttributeValue();
        this.dynamic = true;
      }
    } else {
      handleException("format element of payloadFactoryMediator is required");
    }

    OMElement argumentsElem = elem.getFirstChildWithName(ARGS_Q);

    if (argumentsElem != null) {

      Iterator itr = argumentsElem.getChildElements();

      while (itr.hasNext()) {
        OMElement argElem = (OMElement) itr.next();
        Argument arg = new Argument();
        String attrValue;
        String deepCheckValue;
        if ((deepCheckValue = argElem.getAttributeValue(ATT_DEEP_CHECK)) != null) {
          if (deepCheckValue.equalsIgnoreCase("false")) {
            arg.setDeepCheck(false);
          } else {
            arg.setDeepCheck(true);
          }
        }

        if ((attrValue = argElem.getAttributeValue(ATT_VALUE)) != null) {

          arg.setValue(attrValue);
          argumentList.add(arg);
        } else if ((attrValue = argElem.getAttributeValue(ATT_EXPRN)) != null) {
          if (attrValue.trim().length() == 0) {
            handleException("Attribute value for expression cannot be empty");
          } else {
            try {
              String evaluator;

              if ((evaluator = argElem.getAttributeValue(ATT_EVAL)) != null
                  && evaluator.contains(JSON_TYPE)) {

                arg.setEvaluator(evaluator);
                arg.setJsonPath(SynapseJsonPathFactory.getSynapseJsonPath(attrValue));
                argumentList.add(arg);

              } else {

                if (evaluator != null && evaluator.equals(XML_TYPE)) {
                  arg.setEvaluator(XML_TYPE);
                }
                arg.setExpression(SynapseXPathFactory.getSynapseXPath(argElem, ATT_EXPRN));
                argumentList.add(arg);
              }

            } catch (JaxenException e) {
              handleException(
                  "Invalid XPath expression for attribute expression : " + attrValue, e);
            }
          }

        } else {
          handleException("Unsupported arg type or expression attribute required");
        }

        /// argumentList.add(arg); values and args all get added to this.
        // need to change this part of the cord.
      }
    }

    // set its common attributes such as tracing etc
    processAuditStatus(this, elem);
  }
  /** {@inheritDoc} */
  public void build(OMElement elem) {
    getList().clear();
    OMAttribute attRemoteServiceUri = elem.getAttribute(PROP_NAME_SERVICE_EPR);
    OMAttribute attRemoteServiceUserName = elem.getAttribute(PROP_NAME_USER);
    OMAttribute attRemoteServicePassword = elem.getAttribute(PROP_NAME_PASSWORD);
    OMAttribute attCallbackClass = elem.getAttribute(PROP_NAME_CALLBACK_CLASS);
    OMAttribute attThriftHost = elem.getAttribute(PROP_NAME_THRIFT_HOST);
    OMAttribute attThriftPort = elem.getAttribute(PROP_NAME_THRIFT_PORT);
    OMAttribute attClient = elem.getAttribute(PROP_NAME_CLIENT_CLASS);
    this.onAcceptSeqKey = null;
    this.onRejectSeqKey = null;
    this.adviceSeqKey = null;
    this.obligationsSeqKey = null;

    if (attRemoteServiceUri != null) {
      remoteServiceUrl = attRemoteServiceUri.getAttributeValue();
    } else {
      throw new MediatorException(
          "The 'remoteServiceUrl' attribute is required for the Entitlement mediator");
    }

    if (attRemoteServiceUserName != null) {
      remoteServiceUserName = attRemoteServiceUserName.getAttributeValue();
    } else {
      throw new MediatorException(
          "The 'remoteServiceUserName' attribute is required for the Entitlement mediator");
    }

    if (attRemoteServicePassword != null) {
      remoteServicePassword = attRemoteServicePassword.getAttributeValue();
    } else {
      throw new MediatorException(
          "The 'remoteServicePassword' attribute is required for the Entitlement mediator");
    }

    if (attCallbackClass != null) {
      callbackClass = attCallbackClass.getAttributeValue();
    }

    if (attClient != null) {
      client = attClient.getAttributeValue();
    }

    if (attThriftHost != null) {
      thriftHost = attThriftHost.getAttributeValue();
    }

    if (attThriftPort != null) {
      thriftPort = attThriftPort.getAttributeValue();
    }

    OMAttribute onReject =
        elem.getAttribute(
            new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.ONREJECT));
    if (onReject != null) {
      String onRejectValue = onReject.getAttributeValue();
      if (onRejectValue != null) {
        onRejectSeqKey = onRejectValue.trim();
      }
    } else {
      OMElement onRejectMediatorElement =
          elem.getFirstChildWithName(
              new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, XMLConfigConstants.ONREJECT));
      if (onRejectMediatorElement != null) {
        OnRejectMediator onRejectMediator = new OnRejectMediator();
        onRejectMediator.build(onRejectMediatorElement);
        addChild(onRejectMediator);
      }
    }
    OMAttribute onAccept =
        elem.getAttribute(
            new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.ONACCEPT));
    if (onAccept != null) {
      String onAcceptValue = onAccept.getAttributeValue();
      if (onAcceptValue != null) {
        onAcceptSeqKey = onAcceptValue;
      }
    } else {
      OMElement onAcceptMediatorElement =
          elem.getFirstChildWithName(
              new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, XMLConfigConstants.ONACCEPT));
      if (onAcceptMediatorElement != null) {
        OnAcceptMediator onAcceptMediator = new OnAcceptMediator();
        onAcceptMediator.build(onAcceptMediatorElement);
        addChild(onAcceptMediator);
      }
    }
    OMAttribute advice = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, ADVICE));
    if (advice != null) {
      String adviceValue = advice.getAttributeValue();
      if (adviceValue != null) {
        adviceSeqKey = adviceValue;
      }
    } else {
      OMElement adviceMediatorElement =
          elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, ADVICE));
      if (adviceMediatorElement != null) {
        AdviceMediator adviceMediator = new AdviceMediator();
        adviceMediator.build(adviceMediatorElement);
        addChild(adviceMediator);
      }
    }
    OMAttribute obligations =
        elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, OBLIGATIONS));
    if (obligations != null) {
      String obligationsValue = obligations.getAttributeValue();
      if (obligationsValue != null) {
        onAcceptSeqKey = obligationsValue;
      }
    } else {
      OMElement obligationsMediatorElement =
          elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, OBLIGATIONS));
      if (obligationsMediatorElement != null) {
        ObligationsMediator obligationsMediator = new ObligationsMediator();
        obligationsMediator.build(obligationsMediatorElement);
        addChild(obligationsMediator);
      }
    }
  }
Esempio n. 27
0
 /**
  * Sets content of the given WSDL artifact to the given resource on the registry.
  *
  * @param wsdl the WSDL artifact.
  * @param wsdlResource the content resource.
  * @throws GovernanceException if the operation failed.
  */
 protected void setContent(Wsdl wsdl, Resource wsdlResource) throws GovernanceException {
   if (wsdl.getWsdlElement() != null) {
     OMElement contentElement = wsdl.getWsdlElement().cloneOMElement();
     try {
       for (String importType : new String[] {"import", "include"}) {
         List<OMElement> wsdlImports =
             GovernanceUtils.evaluateXPathToElements("//wsdl:" + importType, contentElement);
         for (OMElement wsdlImport : wsdlImports) {
           OMAttribute location = wsdlImport.getAttribute(new QName("location"));
           if (location != null) {
             String path = location.getAttributeValue();
             if (path.indexOf(";version:") > 0) {
               location.setAttributeValue(path.substring(0, path.lastIndexOf(";version:")));
             }
           }
         }
       }
       for (String importType : new String[] {"import", "include", "redefine"}) {
         List<OMElement> schemaImports =
             GovernanceUtils.evaluateXPathToElements("//xsd:" + importType, contentElement);
         for (OMElement schemaImport : schemaImports) {
           OMAttribute location = schemaImport.getAttribute(new QName("schemaLocation"));
           if (location != null) {
             String path = location.getAttributeValue();
             if (path.indexOf(";version:") > 0) {
               location.setAttributeValue(path.substring(0, path.lastIndexOf(";version:")));
             }
           }
         }
       }
     } catch (JaxenException ignore) {
     }
     String wsdlContent = contentElement.toString();
     try {
       wsdlResource.setContent(wsdlContent);
     } catch (RegistryException e) {
       String msg =
           "Error in setting the content from wsdl, wsdl id: "
               + wsdl.getId()
               + ", wsdl path: "
               + wsdl.getPath()
               + ".";
       log.error(msg, e);
       throw new GovernanceException(msg, e);
     }
   }
   // and set all the attributes as properties.
   String[] attributeKeys = wsdl.getAttributeKeys();
   if (attributeKeys != null) {
     Properties properties = new Properties();
     for (String attributeKey : attributeKeys) {
       String[] attributeValues = wsdl.getAttributes(attributeKey);
       if (attributeValues != null) {
         // The list obtained from the Arrays#asList method is
         // immutable. Therefore,
         // we create a mutable object out of it before adding it as
         // a property.
         properties.put(attributeKey, new ArrayList<String>(Arrays.asList(attributeValues)));
       }
     }
     wsdlResource.setProperties(properties);
   }
   wsdlResource.setUUID(wsdl.getId());
 }
Esempio n. 28
0
    @Override
    public void serialize(
        final javax.xml.namespace.QName parentQName,
        final javax.xml.stream.XMLStreamWriter xmlWriter,
        final boolean serializeType)
        throws javax.xml.stream.XMLStreamException {

      java.lang.String prefix = null;
      java.lang.String namespace = null;

      prefix = parentQName.getPrefix();
      namespace = parentQName.getNamespaceURI();
      this.writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter);

      if (serializeType) {

        final java.lang.String namespacePrefix =
            this.registerPrefix(
                xmlWriter, "http://www.portalfiscal.inf.br/nfe/wsdl/CadConsultaCadastro2");
        if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) {
          this.writeAttribute(
              "xsi",
              "http://www.w3.org/2001/XMLSchema-instance",
              "type",
              namespacePrefix + ":nfeCabecMsg",
              xmlWriter);
        } else {
          this.writeAttribute(
              "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "nfeCabecMsg", xmlWriter);
        }
      }

      if (this.localExtraAttributes != null) {
        for (OMAttribute localExtraAttribute : this.localExtraAttributes) {
          this.writeAttribute(
              localExtraAttribute.getNamespace().getNamespaceURI(),
              localExtraAttribute.getLocalName(),
              localExtraAttribute.getAttributeValue(),
              xmlWriter);
        }
      }
      if (this.localVersaoDadosTracker) {
        namespace = "http://www.portalfiscal.inf.br/nfe/wsdl/CadConsultaCadastro2";
        this.writeStartElement(null, namespace, "versaoDados", xmlWriter);

        if (this.localVersaoDados == null) {
          // write the nil attribute

          throw new org.apache.axis2.databinding.ADBException("versaoDados cannot be null!!");

        } else {

          xmlWriter.writeCharacters(this.localVersaoDados);
        }

        xmlWriter.writeEndElement();
      }
      if (this.localCUFTracker) {
        namespace = "http://www.portalfiscal.inf.br/nfe/wsdl/CadConsultaCadastro2";
        this.writeStartElement(null, namespace, "cUF", xmlWriter);

        if (this.localCUF == null) {
          // write the nil attribute

          throw new org.apache.axis2.databinding.ADBException("cUF cannot be null!!");

        } else {

          xmlWriter.writeCharacters(this.localCUF);
        }

        xmlWriter.writeEndElement();
      }
      xmlWriter.writeEndElement();
    }