Package org.apache.airavata.core.gfac.context.message.impl

Examples of org.apache.airavata.core.gfac.context.message.impl.ParameterContextImpl


            ct.setServiceName("SimpleEcho");

            /*
            * Input
            */
            ParameterContextImpl input = new ParameterContextImpl();
            ActualParameter echo_input = new ActualParameter();
            ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
            input.add("echo_input", echo_input);

            /*
            * Output
            */
            ParameterContextImpl output = new ParameterContextImpl();
            ActualParameter echo_output = new ActualParameter();
            output.add("echo_output", echo_output);

            // parameter
            ct.setInput(input);
            ct.setOutput(output);

View Full Code Here


            ServiceDescription serviceDescription = getRegistry(context).getServiceDescription(serviceName);

            /*
             * Input
             */
            ParameterContextImpl inputParam = new ParameterContextImpl();
            ServiceDescriptionType serviceDescriptionType = serviceDescription.getType();

            for (Parameter parameter : serviceDescriptionType.getInputParametersArray()) {
                OMElement element = input.getFirstChildWithName(new QName(null,parameter.getParameterName()));
                if (element == null) {
                    throw new Exception("Parameter is not found in the message");
                }
                //todo this implementation doesn't work when there are n number of nodes connecting .. need to fix

//                String xmlContent = "";
//                if(!element.getChildElements().hasNext()){
//                    xmlContent = "<type:GFacParameter xsi:type=\"type:" + MappingFactory.getActualParameterType(parameter.getParameterType().getType())
//                        +"\" xmlns:type=\"http://schemas.airavata.apache.org/gfac/type\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + element.getText() + "</type:GFacParameter>";
//                }else{
//                    xmlContent = "<type:GFacParameter xsi:type=\"type:" + MappingFactory.getActualParameterType(parameter.getParameterType().getType())
//                            +"\" xmlns:type=\"http://schemas.airavata.apache.org/gfac/type\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + element.toStringWithConsume() + "</type:GFacParameter>";
//                }
//                System.out.println(xmlContent);
//                inputParam.add(parameter.getParameterName(),ActualParameter.fromXML(xmlContent));

                ActualParameter actualParameter = getInputActualParameter(parameter, element);
                inputParam.add(parameter.getParameterName(),actualParameter);
            }

            /*
             * Output
             */
            ParameterContextImpl outputParam = new ParameterContextImpl();


            // List<Parameter> outputs = serviceDescription.getOutputParameters();
            for (OutputParameterType parameter : serviceDescriptionType.getOutputParametersArray()) {
                ActualParameter actualParameter = new ActualParameter();
                if("String".equals(parameter.getParameterType().getName())){
                   actualParameter.getType().changeType(StringParameterType.type);
                }else if("Double".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(DoubleParameterType.type);
                }else if("Integer".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(IntegerParameterType.type);
                }else if("Float".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(FloatParameterType.type);
                }else if("Boolean".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(BooleanParameterType.type);
                }else if("File".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(FileParameterType.type);
                }else if("URI".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(URIParameterType.type);
                }else if("StringArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(StringArrayType.type);
                }else if("DoubleArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(DoubleArrayType.type);
                }else if("IntegerArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(IntegerArrayType.type);
                }else if("FloatArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(FloatArrayType.type);
                }else if("BooleanArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(BooleanArrayType.type);
                }else if("FileArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(FileArrayType.type);
                }else if("URIArray".equals(parameter.getParameterType().getName())){
                    actualParameter.getType().changeType(URIArrayType.type);
                }
                outputParam.add(parameter.getParameterName(), new ActualParameter());
            }

            invocationContext.setInput(inputParam);
            invocationContext.setOutput(outputParam);

            if (service == null) {
                service = new PropertyServiceFactory(GFacService.REPOSITORY_PROPERTIES).createService();
            }
            // invoke service
            service.execute(invocationContext);

            /*
             * Process Output
             */
            OMFactory fac = OMAbstractFactory.getOMFactory();
            OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "ns1");
            outputElement = fac.createOMElement("invokeResponse", omNs);

            ParameterContextImpl paramContext = (ParameterContextImpl) invocationContext
                    .<ActualParameter> getMessageContext("output");
            for (Iterator<String> iterator = paramContext.getNames(); iterator.hasNext();) {
                String name = iterator.next();
                String outputString = paramContext.getValue(name).toXML().replaceAll("GFacParameter", name);
                XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(outputString));
                StAXOMBuilder builder = new StAXOMBuilder(reader);
                outputElement.addChild(builder.getDocumentElement());
            }

View Full Code Here

      ct.setServiceName("SimpleEcho");

      /*
       * Input
       */     
      ParameterContextImpl input = new ParameterContextImpl();
      ActualParameter echo_input = new ActualParameter();
      ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
      input.add("echo_input", echo_input);

      /*
       * Output
       */
      ParameterContextImpl output = new ParameterContextImpl();
      ActualParameter echo_output = new ActualParameter();
      output.add("echo_output", echo_output);

      // parameter
      ct.setInput(input);
      ct.setOutput(output);

View Full Code Here

      ct.setServiceName("SimpleEcho");

      /*
       * Input
       */
      ParameterContextImpl input = new ParameterContextImpl();
      ActualParameter echo_input = new ActualParameter();
      ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
      input.add("echo_input", echo_input);

      /*
       * Output
       */
      ParameterContextImpl output = new ParameterContextImpl();
      ActualParameter echo_output = new ActualParameter();
      output.add("echo_output", echo_output);

      // parameter
      ct.setInput(input);
      ct.setOutput(output);
            ct.getExecutionContext().setRegistryService(jcrRegistry);
View Full Code Here

        /*
    * Add workflow context
    */
        ServiceDescription serviceDescription = gfacConfig.getRegistry().getServiceDescription(jobContext.getServiceName());
        ServiceDescriptionType serviceDescriptionType = serviceDescription.getType();
        ParameterContextImpl inputParam = new ParameterContextImpl();
        WorkflowContextImpl workflowContext = new WorkflowContextImpl();
        workflowContext.setValue(WorkflowContextImpl.WORKFLOW_ID, URI.create(jobContext.getTopic()).toString());
        invocationContext.addMessageContext(WorkflowContextImpl.WORKFLOW_CONTEXT_NAME, workflowContext);
        for(Parameter parameter:jobContext.getParameters().keySet()){
            inputParam.add(parameter.getParameterName(), jobContext.getParameters().get(parameter));
        }

        /*
    * Output
    */
        ParameterContextImpl outputParam = new ParameterContextImpl();


        // List<Parameter> outputs = serviceDescription.getOutputParameters();
        for (OutputParameterType parameter : serviceDescriptionType.getOutputParametersArray()) {
            ActualParameter actualParameter = new ActualParameter();
            if ("String".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(StringParameterType.type);
            } else if ("Double".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(DoubleParameterType.type);
            } else if ("Integer".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(IntegerParameterType.type);
            } else if ("Float".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FloatParameterType.type);
            } else if ("Boolean".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(BooleanParameterType.type);
            } else if ("File".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FileParameterType.type);
            } else if ("URI".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(URIParameterType.type);
            } else if ("StringArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(StringArrayType.type);
            } else if ("DoubleArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(DoubleArrayType.type);
            } else if ("IntegerArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(IntegerArrayType.type);
            } else if ("FloatArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FloatArrayType.type);
            } else if ("BooleanArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(BooleanArrayType.type);
            } else if ("FileArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(FileArrayType.type);
            } else if ("URIArray".equals(parameter.getParameterType().getName())) {
                actualParameter.getType().changeType(URIArrayType.type);
            }
            outputParam.add(parameter.getParameterName(), actualParameter);
        }

        invocationContext.setInput(inputParam);
        invocationContext.setOutput(outputParam);
        GenericService service = new PropertyServiceFactory(GfacAPI.REPOSITORY_PROPERTIES).createService();
View Full Code Here

    }
  @Override
  protected Map<String, ?> processInput(InvocationContext invocationContext)
            throws ProviderException {
        MessageContext<ActualParameter> inputNew = new ParameterContextImpl();
        try {
        MessageContext<Object> input = invocationContext.getInput();
        for (Iterator<String> iterator = input.getNames(); iterator.hasNext();) {
      String paramName = iterator.next();
      String paramValue = input.getStringValue(paramName);
      ActualParameter actualParameter = (ActualParameter) input
          .getValue(paramName);
      //TODO: Review this with type
      if ("URI".equals(actualParameter.getType().getType().toString())) {
                        ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(invocationContext, paramValue, actualParameter));
            }else if("URIArray".equals(actualParameter.getType().getType().toString())){
                List<String> split = Arrays.asList(paramValue.split(","));
                List<String> newFiles = new ArrayList<String>();
                    for (String paramValueEach : split) {
                        newFiles.add(stageInputFiles(invocationContext, paramValueEach, actualParameter));
                    }
                ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
            }
      inputNew.add(paramName, actualParameter);
    }
        }catch (Exception e){
           invocationContext.getExecutionContext().getNotifier().executionFail(invocationContext,e,"Error during Input File staging");
            throw new ProviderException("Error while input File Staging", e.getCause());
        }
View Full Code Here

        }
        return destURI.getPath();
    }

    private void stageOutputFiles(InvocationContext invocationContext,String outputFileStagingPath) throws ProviderException {
        MessageContext<ActualParameter> outputNew = new ParameterContextImpl();
        MessageContext<Object> input = invocationContext.getOutput();
        for (Iterator<String> iterator = input.getNames(); iterator.hasNext(); ) {
            String paramName = iterator.next();
            String paramValue = input.getStringValue(paramName);
            ActualParameter actualParameter = (ActualParameter) input
                    .getValue(paramName);
            //TODO: Review this with type
            GlobusHostType host = (GlobusHostType) invocationContext.getExecutionDescription().getHost().getType();
            GridFtp ftp = new GridFtp();
            gssContext = (GSISecurityContext) invocationContext.getSecurityContext(MYPROXY_SECURITY_CONTEXT);
            GSSCredential gssCred = null;
            try {
                gssCred = gssContext.getGssCredentails();
            } catch (SecurityException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            try {
                if ("URI".equals(actualParameter.getType().getType().toString())) {
                    for (String endpoint : host.getGridFTPEndPointArray()) {
                        ((URIParameterType) actualParameter.getType()).setValue(doStaging(outputFileStagingPath,
                                paramValue, actualParameter, ftp, gssCred, endpoint));
                    }
                } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
                    List<String> split = Arrays.asList(paramValue.split(","));
                    List<String> newFiles = new ArrayList<String>();
                    for (String endpoint : host.getGridFTPEndPointArray()) {
                        for (String paramValueEach : split) {
                            newFiles.add(doStaging(outputFileStagingPath, paramValueEach, actualParameter, ftp, gssCred, endpoint));
                        }
                        ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
                    }

                }
            } catch (URISyntaxException e) {
                throw new ProviderException(e.getMessage(), e);
            } catch (ToolsException e) {
                throw new ProviderException(e.getMessage(), e);
            }
            outputNew.add(paramName, actualParameter);
        }
        invocationContext.setOutput(outputNew);
    }
View Full Code Here

                            EmbeddedGFacInvoker.this.configuration.getMyProxyPassphrase(),EmbeddedGFacInvoker.this.configuration.getMyProxyLifetime(),
                                EmbeddedGFacInvoker.this.registry, EmbeddedGFacInvoker.this.configuration.getTrustedCertLocation());

                        GfacAPI gfacAPI1 = new GfacAPI();
                        InvocationContext defaultInvocationContext = gfacAPI1.gridJobSubmit(jobContext, gFacConfiguration);
                        ParameterContextImpl outputParamContext = (ParameterContextImpl) defaultInvocationContext
                                .<ActualParameter>getMessageContext("output");
                        if (outputParamContext.getNames().hasNext()) {
                            /*
                            * Process Output
                            */
                            OMFactory fac = OMAbstractFactory.getOMFactory();
                            OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "ns1");
                            OMElement outputElement = fac.createOMElement("invokeResponse", omNs);

                            for (Iterator<String> iterator = outputParamContext.getNames(); iterator.hasNext(); ) {
                                String name = iterator.next();
                                String outputString = outputParamContext.getValue(name).toXML().replaceAll("GFacParameter", name);
                                XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(outputString));
                                StAXOMBuilder builder = new StAXOMBuilder(reader);
                                outputElement.addChild(builder.getDocumentElement());
                            }
                            // Send notification
View Full Code Here

        try {
            /*
             * Add notifiable object
             */

            ParameterContextImpl outputParamContext = (ParameterContextImpl) invocationContext
                    .<ActualParameter> getMessageContext("output");
            /*
             * Process Output
             */
            OMFactory fac = OMAbstractFactory.getOMFactory();
            OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "ns1");
            outputElement = fac.createOMElement("invokeResponse", omNs);

            for (Iterator<String> iterator = outputParamContext.getNames(); iterator.hasNext();) {
                String name = iterator.next();
                String outputString = outputParamContext.getValue(name).toXML().replaceAll("GFacParameter", name);
                XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(outputString));
                StAXOMBuilder builder = new StAXOMBuilder(reader);
                outputElement.addChild(builder.getDocumentElement());
            }

View Full Code Here

      ct.setServiceName("SimpleEcho");

      /*
       * Input
       */     
      ParameterContextImpl input = new ParameterContextImpl();
      ActualParameter echo_input = new ActualParameter();
      ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
      input.add("echo_input", echo_input);

      /*
       * Output
       */
      ParameterContextImpl output = new ParameterContextImpl();
      ActualParameter echo_output = new ActualParameter();
      output.add("echo_output", echo_output);

      // parameter
      ct.setInput(input);
      ct.setOutput(output);

View Full Code Here

TOP

Related Classes of org.apache.airavata.core.gfac.context.message.impl.ParameterContextImpl

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.