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


    }

  @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(),invocationContext, "Error during Input File staging");
        }
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, invocationContext);
            } catch (ToolsException e) {
                throw new ProviderException(e.getMessage(), e, invocationContext);
            }
            outputNew.add(paramName, actualParameter);
        }
        invocationContext.setOutput(outputNew);
    }
View Full Code Here

            ct.setServiceName("FileBreedTest");

            /*
            * Input
            */
            ParameterContextImpl input = new ParameterContextImpl();
            ActualParameter input_file = new ActualParameter();
//            URI InputFile =  URI.create("/gpfs1/u/ac/ccguser/alatop.inp");
            String InputFile =  "/gpfs1/u/ac/ccguser/alatop.inp";
            input_file.getType().changeType(URIParameterType.type);
            ((URIParameterType) input_file.getType()).setValue(InputFile);
            input.add("input_file", input_file);

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

            // 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);

View Full Code Here

            ct.addSecurityContext(MYPROXY, gsiSecurityContext);

            ct.setServiceName("SimpleMPIEcho");

            /* Input */
            ParameterContextImpl input = new ParameterContextImpl();
            ActualParameter echo_input = new ActualParameter();
            ((StringParameterType) echo_input.getType()).setValue("echo_mpi_output=hi");
            input.add("echo_mpi_input", echo_input);

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

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

View Full Code Here

            ct.addSecurityContext(MYPROXY, gsiSecurityContext);

            ct.setServiceName("MockPwscfMPIService");

            /* Input */
            ParameterContextImpl input = new ParameterContextImpl();
            ActualParameter echo_input = new ActualParameter();
            ((StringParameterType) echo_input.getType()).setValue("echo_mpi_output=hi");
            input.add("echo_mpi_input", echo_input);

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

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

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

                            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

            ct.addSecurityContext(MYPROXY, gsiSecurityContext);

            ct.setServiceName("MockPwscfMPIService");

            /* Input */
            ParameterContextImpl input = new ParameterContextImpl();
            ActualParameter echo_input = new ActualParameter();
            ((StringParameterType) echo_input.getType()).setValue("echo_mpi_output=hi");
            input.add("echo_mpi_input", echo_input);

            /* Output */
            ParameterContextImpl output = new ParameterContextImpl();
            ActualParameter echo_output = new ActualParameter();
            output.add("echo_mpi_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.