Package edu.indiana.extreme.xbaya.graph.ws

Examples of edu.indiana.extreme.xbaya.graph.ws.WSNode


    /**
     * @see edu.indiana.extreme.xbaya.component.Component#createNode(edu.indiana.extreme.xbaya.graph.Graph)
     */
    @Override
    public Node createNode(Graph graph) {
        return createNode(graph, new WSNode(graph));
    }
View Full Code Here


     */
    public Collection<XmlElement> getWSDLs() {
        Collection<XmlElement> wsdls = new ArrayList<XmlElement>();
        for (Node node : this.graph.getNodes()) {
            if (node instanceof WSNode) {
                WSNode wsNode = (WSNode) node;
                WSComponent component = wsNode.getComponent();
                wsdls.add(component.toXML());
            }
        }
        return wsdls;
    }
View Full Code Here

   * @throws GraphException
   */
  public static Node clone(Node node, WSGraph wsGraph) throws GraphException {
   
    if(node instanceof WSNode){
      WSNode wsNode = new WSNode(((WSNode) node).toXML());
      ((NodeImpl)wsNode).setGraph(wsGraph);
      List<DataPort> inputPorts = node.getInputPorts();
      for (DataPort dataPort : inputPorts) {
        wsNode.addInputPort(new CepPort(dataPort.toXML()));
      }
     
      List<DataPort> outputPorts = node.getOutputPorts();
      for (DataPort dataPort : outputPorts) {
        wsNode.addOutputPort(new CepPort(dataPort.toXML()));
      }
      return wsNode;
    }else if(node instanceof CepNode){
      CepNode cepNode = new CepNode(((CepNode) node).toXML());
     
View Full Code Here

        } else {
          endForEachNode = (EndForEachNode) node2;
        }

      }
      final WSNode foreachWSNode = (WSNode) middleNode;
      WorkflowInvoker workflowInvoker = this.invokerMap.get(forEachNode.getInputPort(0).getFromNode());
      final LinkedList<String> listOfValues = new LinkedList<String>();
      if (workflowInvoker != null) {
        if (workflowInvoker instanceof GenericInvoker) {
          String message = ((GenericInvoker) workflowInvoker).getOutputs().toString();
          XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString(message);
          Iterator children = msgElmt.children().iterator();
          while (children.hasNext()) {
            Object object = children.next();
            if (object instanceof XmlElement) {
              XmlElement child = (XmlElement) object;
              Iterator valItr = child.children().iterator();
              if (valItr.hasNext()) {
                Object object2 = valItr.next();
                if (object2 instanceof String) {
                  listOfValues.add(object2.toString());
                }

              }
            }

          }
        }
        if (listOfValues.size() > 0) {
          forEachNode.getGUI().setBodyColor(NodeState.EXECUTING.color);
          foreachWSNode.getGUI().setBodyColor(NodeState.EXECUTING.color);
          endForEachNode.getGUI().setBodyColor(NodeState.EXECUTING.color);
          final EndForEachNode tempendForEachNode = endForEachNode;
          final SystemComponentInvoker systemInvoker = new SystemComponentInvoker();
          this.invokerMap.put(endForEachNode, systemInvoker);
          new Thread() {
View Full Code Here

    }

   
   
   
    WSNode node = (WSNode)activeNode;
    WsdlDefinitions serviceWSDL = workflow.getWSDLs().get(node.getWSDLID());
    XmlElement serviceSchema = serviceWSDL.getTypes().element(null, "schema");
    String serviceTns = serviceSchema.attributeValue("targetNamespace");
   
    String nsPrefix = null;
    String oldNSPrefix = null;
    boolean introduceNewNS = false;
    String operationName = node.getOperationName();
    WsdlMessage newInputMessage = null;
    Iterable<WsdlPortType> servicePortTypes = serviceWSDL.portTypes();
    WsdlPortTypeOperation serviceOperation = null;
    WsdlPortType servicePortType = null;
    for (WsdlPortType wsdlPortType : servicePortTypes) {
     
      serviceOperation = wsdlPortType.getOperation(operationName);
      if(serviceOperation != null){
        QName inputMessageName = serviceOperation.getInput().getMessage();
        WsdlMessagePart part = WSDLUtil.getfirst(serviceWSDL.getMessage(inputMessageName.getLocalPart()).parts());
       
        nsPrefix = part.getElement().getPrefix();
        oldNSPrefix = nsPrefix;
        introduceNewNS = false;
        while( null != wsdl.xml().lookupNamespaceByPrefix(nsPrefix)){
          //this namespace is already there so keep adding control at the end and check for
          //its existance
          nsPrefix += "_control";
          introduceNewNS = true;
        }
       
        wsdl.xml().declareNamespace(BUILDER.newNamespace(nsPrefix, serviceTns));
       
       
        WsdlMessage inputMessage = serviceWSDL.getMessage(inputMessageName.getLocalPart());
        newInputMessage = wsdl.addMessage(inputMessageName.getLocalPart());
        Iterable<WsdlMessagePart> parts = inputMessage.parts();
        for (WsdlMessagePart wsdlMessagePart : parts) {
          XmlElement newPart = null;
          if(introduceNewNS){
            XmlElement clone = wsdlMessagePart.xml().clone();
            String xmlAsString = BUILDER.serializeToString(clone).replaceAll(oldNSPrefix+":", nsPrefix+":");
            newPart= BUILDER.parseFragmentFromString(xmlAsString);
          }else{
            newPart = wsdlMessagePart.xml().clone();
          }
          newInputMessage.xml().addElement(newPart);
        }
        //add lead header part to the new input messag because this message is copied from the service wsdl.
       
        XmlElement newLeadHeaderPart = newInputMessage.xml().addElement(newInputMessage.xml().getNamespace(), "part");
        newLeadHeaderPart.setAttributeValue("name", "leadHeader");
        newLeadHeaderPart.setAttributeValue("element", "lc:context");
       
        WsdlMessage newOutputMessage = null;
        if(null != serviceOperation.getOutput()){
          QName outputMessageName = serviceOperation.getOutput().getMessage();
          WsdlMessage outputMessage = serviceWSDL.getMessage(outputMessageName.getLocalPart());
          newOutputMessage = wsdl.addMessage(outputMessageName.getLocalPart());
          Iterable<WsdlMessagePart> parts2 = outputMessage.parts();
          for (WsdlMessagePart wsdlMessagePart : parts2) {
            XmlElement newPart = null;
            if(introduceNewNS){
              XmlElement clone = wsdlMessagePart.xml().clone();
              String xmlAsString = BUILDER.serializeToString(clone).replaceAll(oldNSPrefix+":", nsPrefix+":");
              newPart = BUILDER.parseFragmentFromString(xmlAsString);
            }else{
              newPart = wsdlMessagePart.xml().clone();
            }
            newOutputMessage.xml().addElement(newPart);
          }
        }
       
       
       
       
        if(introduceNewNS){
          List<XmlNamespace> namespacesPresentInSchema = WSDLUtil.getNamespaces(serviceSchema);
          WSDLUtil.print(serviceSchema);
          for (XmlNamespace shouldBeDefinedNamespaces : namespacesPresentInSchema) {
            if(shouldBeDefinedNamespaces.getPrefix() != null &&
                null == wsdl.xml().lookupNamespaceByPrefix(shouldBeDefinedNamespaces.getPrefix())){
              wsdl.xml().declareNamespace(shouldBeDefinedNamespaces);
            }
           
          }
          XmlElement clone = serviceSchema.clone();
          String xmlAsString = BUILDER.serializeToString(clone).replaceAll(oldNSPrefix+":", nsPrefix+":");
          XmlElement newSchema= BUILDER.parseFragmentFromString(xmlAsString);
          types.addChild(newSchema);
         
          XmlElement crosscutImport = BUILDER.newFragment(newSchema.getNamespace(), "import");
          crosscutImport.setAttributeValue("namespace", "http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/");
          crosscutImport.setAttributeValue("schemaLocation", "lead-crosscut-parameters.xsd");
          newSchema.addChild(0, crosscutImport);
        }else{
          types.addChild(serviceSchema.clone());
        }
        //adding new operation for the receive
        Iterator<WsdlPortType> portTypes = wsdl.portTypes().iterator();
        if(portTypes.hasNext()){
          WsdlPortType newOperationPortType = portTypes.next();
          WsdlPortTypeOperation newOp = newOperationPortType.addOperation(node.getOperationName());
          XmlNamespace wsaNS = BUILDER.newNamespace("http://www.w3.org/2006/05/addressing/wsdl");
         
          newOp.setInput(newInputMessage.getName(),newInputMessage);
          String inputAction = serviceOperation.getInput().xml().attributeValue(wsaNS, "Action");
          newInputMessage.xml().setAttributeValue(wsaNS, "Action", inputAction);
                   
          if(newOutputMessage != null){
            newOp.setOutput(newOutputMessage.getName(), newOutputMessage);
            String outputAction = serviceOperation.getOutput().xml().attributeValue(wsaNS, "Action");
            newOutputMessage.xml().setAttributeValue(wsaNS, "Action", outputAction);
          }
        }
        servicePortType = wsdlPortType;
      }
     
     
     
      addreceive(workflow.getOdeProcess(null, null), wsdl, operationName, newInputMessage.getName() ) ;
    }
   
   
   
//    find the binding for the operation in the service wsdl
    Iterable<WsdlBinding> serviceBindings = serviceWSDL.bindings();
    WsdlBinding serviceBinding = null;
    for (WsdlBinding wsdlBinding : serviceBindings) {
      if(wsdlBinding.getPortType().equals(servicePortType.getQName())){
        serviceBinding = wsdlBinding;
        break;
      }
    }
    WsdlBindingOperation serviceBindingOperation = serviceBinding.getOperation(node.getOperationName());
   
    //find the binding in the final wsdl
    Iterator<WsdlPortType> portTypeItr = wsdl.portTypes().iterator();
    if(portTypeItr.hasNext()){
      WsdlPortType portType = portTypeItr.next();
      Iterable<WsdlBinding> bindings = wsdl.bindings();
      for (WsdlBinding wsdlBinding : bindings) {
        if(wsdlBinding.getPortType().equals(portType.getQName())){
          WsdlBindingOperation newBindingOperation = wsdlBinding.addOperation(node.getOperationName());
          Iterable serviceBindingChildren = serviceBindingOperation.xml().children();
          for (Object object : serviceBindingChildren) {
            if(object instanceof XmlElement){
              XmlElement newBindingOperationChild  = ((XmlElement)object).clone();
              newBindingOperation.xml().addElement(newBindingOperationChild);
View Full Code Here

            // If there are more than one nodes to invoke, they can run
            // concurrently using threads.
            boolean thread = (nextNodes.size() > 1);
            for (Node node : nextNodes) {
                if (node instanceof WSNode) {
                    WSNode wsNode = (WSNode) node;
                    writeInvocation(wsNode, thread, pw);
                   
                } else {
                    // TODO conditions, loops might come here.
                }
View Full Code Here

  private void handleWSComponent(Node node) throws XBayaException {
    WSComponent wsComponent = ((WSComponent) node.getComponent());
    QName portTypeQName = wsComponent.getPortTypeQName();
    WorkflowInvoker invoker = this.invokerMap.get(node);
    if (invoker == null) {
      final WSNode wsNode = (WSNode) node;
      String wsdlLocation = this.getEPR(wsNode);
      final String gfacURLString = this.configuration.getGFacURL().toString();
      if (null == wsdlLocation) {
        if (gfacURLString.startsWith("https")) {
          GSSCredential proxy = null;
          if (this.mode == GUI_MODE) {
            this.myProxyChecker.loadIfNecessary();
            MyProxyClient myProxyClient = this.engine.getMyProxyClient();
            proxy = myProxyClient.getProxy();
          } else {
            proxy = SecurityUtil.getGSSCredential(this.username, this.password, this.configuration.getMyProxyServer());
          }

          LeadContextHeader leadCtxHeader = null;
          try {
            if (this.mode == GUI_MODE) {
              leadCtxHeader = WSDLUtil.buildLeadContextHeader(this.workflow, this.configuration, this.engine.getMyLead(), new MonitorConfiguration(this.configuration.getBrokerURL(), this.topic, true, this.configuration.getMessageBoxURL()), wsNode.getID(), null);
            } else {
              leadCtxHeader = WSDLUtil.buildLeadContextHeader(this.workflow, this.configuration,
              // Set the userdn in the right proxy if necessary
                  new MyLead(new MyLeadConfiguration(), proxy), new MonitorConfiguration(this.configuration.getBrokerURL(), this.topic, true, this.configuration.getMessageBoxURL()), wsNode.getID(), null);
            }
          } catch (URISyntaxException e) {
            throw new XBayaException(e);
          }

          leadCtxHeader.setServiceId(node.getID());
          try {
            leadCtxHeader.setWorkflowId(new URI(this.workflow.getName()));

            // We do this so that the wsdl resolver can is setup
            // wsdlresolver.getInstance is static so once this is
            // done
            // rest of the loading should work.

            XBayaSecurity.init();

          } catch (URISyntaxException e) {
            throw new XBayaRuntimeException(e);
          }
         
          /*
           * Resource Mapping Header
           */
          if(this.resourceMapping != null){
            leadCtxHeader.setResourceMapping(this.resourceMapping);
          }
         
          /*
           * If there is a instance control component connects to this component
           * send information in soap header
           */
          for (Node n : wsNode.getControlInPort().getFromNodes()) {
            if (n instanceof InstanceNode){
              //TODO make it as constant
              LeadResourceMapping x = new LeadResourceMapping("AMAZON");
             
              x.addAttribute("ACCESS_KEY", AmazonCredential.getInstance().getAwsAccessKeyId());
              x.addAttribute("SECRET_KEY", AmazonCredential.getInstance().getAwsSecretAccessKey());             
                           
              if(((InstanceNode) n).isStartNewInstance()){
                x.addAttribute("AMI_ID", ((InstanceNode) n).getIdAsValue());
                x.addAttribute("INS_TYPE", ((InstanceNode) n).getInstanceType());               
              }else{
                x.addAttribute("INS_ID", ((InstanceNode) n).getIdAsValue());
              }
             
              x.addAttribute("USERNAME", ((InstanceNode) n).getUsername());
             
              //set to leadHeader
              leadCtxHeader.setResourceMapping(x);
            }           
          }

          invoker = new WorkflowInvokerWrapperForGFacInvoker(portTypeQName, gfacURLString, this.configuration.getMessageBoxURL().toString(), leadCtxHeader, this.notifier.createServiceNotificationSender(node.getID()));
         
        } else {
          invoker = new GenericInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(), this.configuration.getMessageBoxURL().toString(), gfacURLString, this.notifier, this.configuration, null);
        }

      } else {
        if (!wsdlLocation.endsWith("?wsdl")) {
          wsdlLocation += "?wsdl";
View Full Code Here

    Collection<Node> nextNodes = getNextNodes();
    while (nextNodes.size() > 0) {
      for (Node node : nextNodes) {

        if (node instanceof WSNode) {
          WSNode wsNode = (WSNode) node;
          List<DataPort> inputPorts = node.getInputPorts();
          writeSplitorPerService(scufl, wsNode);

        } else {
          // TODO conditions, loops might come here.
View Full Code Here

  private void writeServices(XmlElement scufl) throws GraphException {

    Collection<NodeImpl> nextNodes = this.graph.getNodes();
    for (NodeImpl node : nextNodes) {
      if (node instanceof WSNode) {
        WSNode wsNode = (WSNode) node;
        createWSProcess(wsNode, scufl);
      }
    }
  }
View Full Code Here

    List<DataPort> inputPorts = node.getInputPorts();
    for (DataPort inPort : inputPorts) {
      Port fromPort = inPort.getFromPort();
      Node fromNode = inPort.getFromNode();
      if (fromNode instanceof WSNode) {
        WSNode fromWsNode = (WSNode) fromNode;
        if (null != fromPort && fromPort instanceof DataPort) {
          DataPort fromDataPort = (DataPort) fromPort;
          WsdlDefinitions wsdl = engine.getWorkflow().getWSDLs().get(
              fromWsNode.getWSDLID());
          System.out.println(xsul5.XmlConstants.BUILDER
              .serializeToString(wsdl.xml()));
          Iterator<XmlNamespace> itr = wsdl.xml().namespaces()
              .iterator();
          try {
View Full Code Here

TOP

Related Classes of edu.indiana.extreme.xbaya.graph.ws.WSNode

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.