Package edu.indiana.extreme.xbaya.workflow

Examples of edu.indiana.extreme.xbaya.workflow.WorkflowInvoker


     * @throws XBayaException
     */
    public void testService() throws XBayaException {
        NotificationSender notifier = new NotificationSender(this.configuration
                .getBrokerURL(), "test-topic2");
        WorkflowInvoker invoker = new GenericInvoker(QName
                .valueOf(TEST_SERVICE_QNAME), TEST_AWSDL, "test-node", null,
                this.configuration.getGFacURL().toString(), notifier);
        invoker.setup();
        invoker.setOperation("Run");
        invoker.setInput("inparam1", "test");
        invoker.invoke();
        Object output = invoker.getOutput("outparam1");
        logger.info("output: " + output);
    }
View Full Code Here


    if (fromNode instanceof InputNode) {
      outputVal = ((InputNode) fromNode).getDefaultValue();
    } else if (fromNode instanceof ConstantNode) {
      outputVal = ((ConstantNode) fromNode).getValue();
    } else if (fromNode instanceof EndifNode) {
      WorkflowInvoker fromInvoker = this.invokerMap.get(fromNode);
      outputVal = fromInvoker.getOutput(inputPort.getFromPort().getID());
    } else if (fromNode instanceof InstanceNode){
      return ((InstanceNode)fromNode).getOutputInstanceId();
    } else {
      WorkflowInvoker fromInvoker = this.invokerMap.get(fromNode);
      if(fromInvoker != null)
        outputVal = fromInvoker.getOutput(inputPort.getFromPort().getName());
    }
    return outputVal;
  }
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";
        }
        invoker = new GenericInvoker(portTypeQName, wsdlLocation, node.getID(), this.configuration.getMessageBoxURL().toString(), gfacURLString, this.notifier);
      }
      invoker.setup();
      this.invokerMap.put(node, invoker);
      invoker.setOperation(wsComponent.getOperationName());
    }

    // find inputs
    List<DataPort> inputPorts = node.getInputPorts();
    ODEClient odeClient = new ODEClient();
    List<WSComponentPort> inputComponents = odeClient.getInputs(this.workflow);
    for (DataPort port : inputPorts) {
      Object inputVal = findInputFromPort(port);

      /*
       * Need to override inputValue if it is odeClient
       */
      Node fromNode = port.getFromNode();
      if (port.getFromNode() instanceof InputNode) {
        for (WSComponentPort wsComponentPort : inputComponents) {
          if (fromNode.getName().equals(wsComponentPort.getName())) {
            inputVal = odeClient.parseValue(wsComponentPort, (String) inputVal);
          }
        }
      }

      if (null == inputVal) {
        throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + node.getID());
      }
      invoker.setInput(port.getName(), inputVal);
    }
    invoker.invoke();
  }
View Full Code Here

        type = BasicTypeMapping.STRING_QNAME;
      } else if (fromNode instanceof ConstantNode) {
        type = ((ConstantNode) fromNode).getType();
      } else if ((dataPort.getFromPort() instanceof WSPort)
          && BasicTypeMapping.isArrayType(((WSPort) dataPort.getFromPort()).getComponentPort().getElement())) {
        WorkflowInvoker fromInvoker = this.invokerMap.get(fromNode);       
        inputVal = BasicTypeMapping.getOutputArray(XmlConstants.BUILDER.parseFragmentFromString(fromInvoker.getOutputs().toString()), dataPort.getFromPort().getName(), BasicTypeMapping.getSimpleTypeIndex(((DataPort) dataPort.getFromPort()).getType()));
        type = ((DataPort) dataPort.getFromPort()).getType();
      } else {
        type = ((DataPort) dataPort.getFromPort()).getType();
      }
View Full Code Here

          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);
View Full Code Here

  private void runInThread(LinkedList<String> listOfValues, ForEachNode forEachNode, WSNode foreachWSNode, EndForEachNode endForEachNode, SystemComponentInvoker tempInvoker) throws XBayaException {
    WSComponent wsComponent = foreachWSNode.getComponent();
    QName portTypeQName = wsComponent.getPortTypeQName();

    WorkflowInvoker invoker = null;
    LinkedList<WorkflowInvoker> invokerList = new LinkedList<WorkflowInvoker>();
    for (Iterator<String> iterator = listOfValues.iterator(); iterator.hasNext();) {
      String input = iterator.next();
      String wsdlLocation = getEPR(foreachWSNode);
      final String gfacURLString = this.engine.getConfiguration().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());
          }
          GsiInvoker secureInvoker = new GsiInvoker(proxy, XBayaSecurity.getTrustedCertificates());
          LeadContextHeader leadCtxHeader = null;
          try {
            // leadCtxHeader = WSDLUtil.buildLeadContextHeader(
            // this.workflow, engine.getConfiguration(),
            // this.engine.getMyLead(), engine.getMonitor()
            // .getConfiguration(), foreachWSNode
            // .getID(), null);

            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()), foreachWSNode.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()), foreachWSNode.getID(), null);
            }

          } catch (URISyntaxException e) {
            raiseException(e);
          }
          // SecureGFacInvoker secureGFacInvoker = new
          // SecureGFacInvoker(portTypeQName,
          // WSDLUtil.wsdlDefinitions5ToWsdlDefintions3
          // (wsNode.getComponent().getWSDL()), node
          // .getID(), gfacURLString, notifier, secureInvoker,
          // leadCtxHeader, wsComponent.getOperationName());
          SecureGFacInvoker secureGFacInvoker = new SecureGFacInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(foreachWSNode.getComponent().getWSDL()), foreachWSNode.getID(), gfacURLString, this.notifier, secureInvoker, leadCtxHeader, wsComponent.getOperationName());
          invoker = secureGFacInvoker;
        } else {
          invoker = new GenericInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(foreachWSNode.getComponent().getWSDL()), foreachWSNode.getID(), this.configuration.getMessageBoxURL().toString(), gfacURLString, this.notifier);
        }

      } else {
        if (!wsdlLocation.endsWith("?wsdl")) {
          wsdlLocation += "?wsdl";
        }
        invoker = new GenericInvoker(portTypeQName, wsdlLocation, foreachWSNode.getID(), this.configuration.getMessageBoxURL().toString(), gfacURLString, this.notifier);
      }
      invoker.setup();
      invoker.setOperation(wsComponent.getOperationName());
      invokerList.add(invoker);
      // find inputs
      List<DataPort> inputPorts = foreachWSNode.getInputPorts();
      for (DataPort port : inputPorts) {       
        Object inputVal = findInputFromPort(port);
       
        /*
         * Handle ForEachNode
         */
        Node fromNode = port.getFromNode();
        if (fromNode instanceof ForEachNode) {
          inputVal = input;
        }
       
        if (null == inputVal) {
          throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + foreachWSNode.getID());
        }
        invoker.setInput(port.getName(), inputVal);
      }
      invoker.invoke();
    }

    String arrayElementName = foreachWSNode.getOperationName() + "ArrayResponse";
    String outputStr = "<" + arrayElementName + ">";
    for (Iterator<WorkflowInvoker> iterator = invokerList.iterator(); iterator.hasNext();) {
      WorkflowInvoker workflowInvoker = iterator.next();
      Object output = workflowInvoker.getOutput(foreachWSNode.getOutputPort(0).getName());
      outputStr += "\n<" + foreachWSNode.getOutputPort(0).getName() + ">" + output + "</" + foreachWSNode.getOutputPort(0).getName() + ">";
    }
    outputStr += "\n</" + arrayElementName + ">";
    tempInvoker.addOutput(endForEachNode.getOutputPort(0).getName(), outputStr);
    forEachNode.getGUI().setBodyColor(NodeState.FINISHED.color);
View Full Code Here

        String adderWSDLLoc = service.getServiceWsdlLocation();

        NotificationSender notifier = new NotificationSender(
                XBayaConstants.DEFAULT_BROKER_URL.toString(), "test-topic");

        WorkflowInvoker invoker = new GenericInvoker(null, adderWSDLLoc,
                "adder", null, null, notifier);
        invoker.setup();
        invoker.setOperation("add");
        invoker.setInput("x", 2);
        invoker.setInput("y", 3);
        invoker.invoke();

        Object output = invoker.getOutput("z");
        logger.info("z = " + output);

        service.shutdownServer();
    }
View Full Code Here

        String multiplierWSDLLoc = multiplier.getServiceWsdlLocation();

        NotificationSender notifier = new NotificationSender(
                XBayaConstants.DEFAULT_BROKER_URL.toString(), "test-topic");

        WorkflowInvoker adderInvoker1 = new GenericInvoker(null, adderWSDLLoc,
                "adder", null, null, notifier);
        adderInvoker1.setup();
        adderInvoker1.setOperation("add");
        adderInvoker1.setInput("x", 2);
        adderInvoker1.setInput("y", 3);
        adderInvoker1.invoke();

        Object output1 = adderInvoker1.getOutput("z");
        logger.info("output1 = " + output1);

        WorkflowInvoker adderInvoker2 = new GenericInvoker(null, adderWSDLLoc,
                "adder", null, null, notifier);
        adderInvoker2.setup();
        adderInvoker2.setOperation("add");
        adderInvoker2.setInput("x", 4);
        adderInvoker2.setInput("y", 5);
        adderInvoker2.invoke();

        Object output2 = adderInvoker2.getOutput("z");
        logger.info("output2 = " + output2);

        WorkflowInvoker multiplierInvoker = new GenericInvoker(null,
                multiplierWSDLLoc, "multiplier", null, null, notifier);
        multiplierInvoker.setup();
        multiplierInvoker.setOperation("multiply");
        multiplierInvoker.setInput("x", output1);
        multiplierInvoker.setInput("y", output2);
        multiplierInvoker.invoke();

        Object output3 = multiplierInvoker.getOutput("z");
        logger.info("output3 = " + output3);

        adder.shutdownServer();
        multiplier.shutdownServer();
    }
View Full Code Here

TOP

Related Classes of edu.indiana.extreme.xbaya.workflow.WorkflowInvoker

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.