Search in sources :

Example 6 with WorkflowException

use of org.apache.airavata.workflow.model.exceptions.WorkflowException in project airavata by apache.

the class GFacServiceCreator method createService.

/**
 * @param serviceQName
 * @return The WSDL definitions of the service created.
 * @throws WorkflowException
 */
public WsdlDefinitions createService(String serviceQName) throws WorkflowException {
    logger.debug(serviceQName);
    try {
        WSIFMessage inputMessage = this.gFacOperation.createInputMessage();
        WSIFMessage outputMessage = this.gFacOperation.createOutputMessage();
        WSIFMessage faultMessage = this.gFacOperation.createFaultMessage();
        inputMessage.setObjectPart(SERVICE_QNAME_PART, serviceQName);
        inputMessage.setObjectPart(SECURITY_PART, SECURITY_NONE);
        logger.debug("inputMessage: " + inputMessage);
        boolean success = this.gFacOperation.executeRequestResponseOperation(inputMessage, outputMessage, faultMessage);
        if (!success) {
            // An implementation of WSIFMessage, WSIFMessageElement,
            // implements toString(), which serialize the message XML.
            String message = "Failed to create a service: " + faultMessage.toString();
            throw new WorkflowException(message);
        }
        String wsdl = (String) outputMessage.getObjectPart(WSDL_PART);
        logger.debug("WSDL: " + wsdl);
        XmlElement definitionsElement = XMLUtil.stringToXmlElement3(wsdl);
        this.serviceDefinitions = new WsdlDefinitions(definitionsElement);
        return this.serviceDefinitions;
    } catch (RuntimeException e) {
        String message = "Failed to create a service";
        throw new WorkflowException(message, e);
    }
}
Also used : WsdlDefinitions(xsul.wsdl.WsdlDefinitions) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) XmlElement(org.xmlpull.v1.builder.XmlElement) WSIFMessage(xsul.wsif.WSIFMessage)

Example 7 with WorkflowException

use of org.apache.airavata.workflow.model.exceptions.WorkflowException in project airavata by apache.

the class Workflow method clone.

/**
 * @see java.lang.Object#clone()
 */
@Override
public Workflow clone() {
    XmlElement originalXML = toXML();
    try {
        XmlElement newXML = XMLUtil.deepClone(originalXML);
        Workflow newWorkflow = new Workflow(newXML);
        return newWorkflow;
    } catch (GraphException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (WorkflowException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (AiravataException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) XmlElement(org.xmlpull.infoset.XmlElement) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 8 with WorkflowException

use of org.apache.airavata.workflow.model.exceptions.WorkflowException in project airavata by apache.

the class XBayaGUI method createFrame.

/**
 * Creates a frame.
 */
private void createFrame() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        // OK. The default will be used.
        logger.error(e.getMessage(), e);
    }
    JFrame.setDefaultLookAndFeelDecorated(false);
    this.frame = new JFrame();
    // Adjust the size
    XBayaConfiguration config = this.engine.getConfiguration();
    int width = config.getWidth();
    int height = config.getHeight();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final int inset = 50;
    this.frame.setLocation(inset, inset);
    Dimension size = new Dimension(screenSize.width - inset * 2, screenSize.height - inset * 2);
    if (width != 0) {
        size.width = width;
    }
    if (height != 0) {
        size.height = height;
    }
    // This controls the size when you open in a huge screen
    if (size.width > 1280 && size.height > 800) {
        size.width = 1280;
        size.height = 800;
    }
    this.frame.setPreferredSize(size);
    this.frame.setTitle(XBayaConstants.APPLICATION_NAME);
    this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    this.frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent event) {
            int result = JOptionPane.showConfirmDialog(frame, "Are you sure you want to exit?", "Exit XBaya", JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.NO_OPTION || (!closeAllGraphCanvas())) {
                return;
            }
            logger.debug(event.toString());
            XBayaGUI.this.frame.setVisible(false);
            try {
                XBayaGUI.this.engine.dispose();
            } catch (WorkflowException e) {
                // Ignore the error.
                logger.error(e.getMessage(), e);
            } catch (RuntimeException e) {
                // Ignore the error.
                logger.error(e.getMessage(), e);
            }
            if (XBayaGUI.this.engine.getConfiguration().isCloseOnExit()) {
                System.exit(0);
            }
        }

        @Override
        public void windowClosed(WindowEvent e) {
            logger.debug(e.toString());
            try {
                XBayaGUI.this.engine.getMonitor().stop();
            } catch (MonitorException e1) {
                logger.error(e1.getMessage(), e1);
            }
            // Dispose only when it can be disposed to prevent infinite loop
            if (XBayaGUI.this.frame.isDisplayable()) {
                XBayaGUI.this.frame.dispose();
            }
        }
    });
    this.frame.setIconImage(SwingUtil.createImage("airavata-2.png"));
}
Also used : XBayaConfiguration(org.apache.airavata.xbaya.XBayaConfiguration) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException)

Example 9 with WorkflowException

use of org.apache.airavata.workflow.model.exceptions.WorkflowException in project airavata by apache.

the class BasicTypeMapping method getOutputArray.

public static Object getOutputArray(XmlElement element, String name, int simpleIndex) throws WorkflowException {
    try {
        // This code doesn't work when the output is a complex type.
        // Object output = this.outputMessage.getObjectPart(name);
        // return output;
        XmlElement outputElement = (XmlElement) element;
        Iterator valueElementItr = outputElement.elements(null, name).iterator();
        LinkedList<String> ret = new LinkedList<String>();
        while (valueElementItr.hasNext()) {
            XmlElement valueElement = (XmlElement) valueElementItr.next();
            Iterator childIt = valueElement.children().iterator();
            int numberOfChildren = 0;
            while (childIt.hasNext()) {
                childIt.next();
                numberOfChildren++;
            }
            if (numberOfChildren == 1) {
                Object child = valueElement.children().iterator().next();
                if (child instanceof String) {
                    // Value is a simple type. Return the string.
                    String value = (String) child;
                    ret.add(value);
                }
            }
        }
        switch(simpleIndex) {
            case 0:
                Integer[] intRet = new Integer[ret.size()];
                for (int i = 0; i < ret.size(); i++) {
                    intRet[i] = Integer.parseInt(ret.get(i));
                }
                return intRet;
            case 1:
                String[] strRet = new String[ret.size()];
                for (int i = 0; i < ret.size(); i++) {
                    strRet[i] = ret.get(i);
                }
                return strRet;
        }
        throw new WorkflowException("Unknown type");
    } catch (RuntimeException e) {
        String message = "Error in getting output. name: " + name;
        throw new WorkflowException(message, e);
    }
}
Also used : WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) Iterator(java.util.Iterator) XmlElement(org.xmlpull.infoset.XmlElement) LinkedList(java.util.LinkedList)

Example 10 with WorkflowException

use of org.apache.airavata.workflow.model.exceptions.WorkflowException in project airavata by apache.

the class GFacServiceCreator method shutdownService.

/**
 * Shutdowns the service created.
 *
 * @throws WorkflowException
 */
public void shutdownService() throws WorkflowException {
    WSIFService service = WSIFServiceFactory.newInstance().getService(this.serviceDefinitions);
    WSIFPort port = service.getPort();
    WSIFOperation operation = port.createOperation(SHUTDOWN_OPERATION);
    WSIFMessage inputMessage = operation.createInputMessage();
    WSIFMessage outputMessage = operation.createOutputMessage();
    WSIFMessage faultMessage = operation.createFaultMessage();
    boolean success = operation.executeRequestResponseOperation(inputMessage, outputMessage, faultMessage);
    if (!success) {
        // An implementation of WSIFMessage, WSIFMessageElement,
        // implements toString(), which serialize the message XML.
        String message = "Failed to shutdown the service: " + faultMessage.toString();
        throw new WorkflowException(message);
    }
}
Also used : WSIFService(xsul.wsif.WSIFService) WSIFOperation(xsul.wsif.WSIFOperation) WSIFPort(xsul.wsif.WSIFPort) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) WSIFMessage(xsul.wsif.WSIFMessage)

Aggregations

WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)13 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)5 AiravataException (org.apache.airavata.common.exception.AiravataException)4 RegistryException (org.apache.airavata.registry.cpi.RegistryException)4 Node (org.apache.airavata.workflow.model.graph.Node)3 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)3 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)3 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)3 Workflow (org.apache.airavata.workflow.model.wf.Workflow)3 TException (org.apache.thrift.TException)3 Method (java.lang.reflect.Method)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 DataPort (org.apache.airavata.workflow.model.graph.DataPort)2 XmlElement (org.xmlpull.infoset.XmlElement)2 WSIFMessage (xsul.wsif.WSIFMessage)2 Dimension (java.awt.Dimension)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1