Search in sources :

Example 6 with ComponentRegistryException

use of org.apache.airavata.workflow.model.component.ComponentRegistryException in project airavata by apache.

the class WebComponentRegistry method parse.

private void parse() throws ComponentRegistryException {
    try {
        HttpURLConnection connection = (HttpURLConnection) this.url.openConnection();
        connection.setInstanceFollowRedirects(false);
        connection.connect();
        int count = 0;
        // TODO checking 3 is not enough
        while (String.valueOf(connection.getResponseCode()).startsWith("3")) {
            String location = connection.getHeaderField("Location");
            logger.debug("Redirecting to " + location);
            connection.disconnect();
            this.url = new URL(location);
            connection = (HttpURLConnection) this.url.openConnection();
            connection.setInstanceFollowRedirects(false);
            connection.connect();
            count++;
            if (count > 10) {
                throw new ComponentRegistryException("Too many redirect");
            }
        }
        InputStream inputStream = connection.getInputStream();
        InputStreamReader reader = new InputStreamReader(inputStream);
        HtmlRegistryParserCallback callback = new HtmlRegistryParserCallback();
        ParserDelegator parser = new ParserDelegator();
        parser.parse(reader, callback, false);
    } catch (IOException e) {
        throw new ComponentRegistryException(e);
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) ParserDelegator(javax.swing.text.html.parser.ParserDelegator) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) IOException(java.io.IOException) URL(java.net.URL)

Example 7 with ComponentRegistryException

use of org.apache.airavata.workflow.model.component.ComponentRegistryException in project airavata by apache.

the class GraphCanvas method drop.

private void drop(final DropTargetDropEvent event) {
    logger.debug("Event:" + event);
    Transferable transferable = event.getTransferable();
    try {
        // Cannot cast transferable.
        final ComponentReference componentReference = (ComponentReference) transferable.getTransferData(ComponentSourceTransferable.FLAVOR);
        final Point location = event.getLocation();
        // The component might not have loaded if the network is slow.
        new Thread() {

            @Override
            public void run() {
                try {
                    Component component = componentReference.getComponent();
                    addNode(component, location);
                    // To be able to delete the added node by the keyboard.
                    GraphCanvas.this.panel.requestFocusInWindow();
                    // XXX this sometimes throws exception.
                    event.dropComplete(true);
                } catch (ComponentException e) {
                    // If there is any error, the component tree viewer
                    // shows the error dialog.
                    logger.error(e.getMessage(), e);
                    event.dropComplete(false);
                } catch (ComponentRegistryException e) {
                    logger.error(e.getMessage(), e);
                    event.dropComplete(false);
                }
            }
        }.start();
    } catch (UnsupportedFlavorException e) {
        // Should not happen.
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        // Should not happen.
        logger.error(e.getMessage(), e);
    }
}
Also used : ComponentSourceTransferable(org.apache.airavata.xbaya.ui.widgets.component.ComponentSourceTransferable) Transferable(java.awt.datatransfer.Transferable) ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Point(java.awt.Point) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) IOException(java.io.IOException) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) Component(org.apache.airavata.workflow.model.component.Component) OutputComponent(org.apache.airavata.workflow.model.component.system.OutputComponent) JComponent(javax.swing.JComponent) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Example 8 with ComponentRegistryException

use of org.apache.airavata.workflow.model.component.ComponentRegistryException in project airavata by apache.

the class SimpleWSClient method createMessage.

private void createMessage(String paramName, Object value, XmlElement inputMsgElem) throws ComponentRegistryException {
    XmlElement paramsElem = builder.newFragment(this.requestNS, paramName);
    if (value instanceof String) {
        paramsElem.addChild(value);
    } else if (value instanceof Collection) {
        Collection list = (Collection) value;
        Iterator arrayValues = list.iterator();
        while (arrayValues.hasNext()) {
            XmlElement item = builder.newFragment("value");
            item.addChild(arrayValues.next());
            paramsElem.addChild(item);
        }
    } else if (value instanceof ArrayList) {
        Collection list = (Collection) value;
        Iterator arrayValues = list.iterator();
        while (arrayValues.hasNext()) {
            XmlElement item = builder.newFragment("value");
            item.addChild(arrayValues.next());
            paramsElem.addChild(item);
        }
    } else if (value instanceof String[]) {
        String[] list = (String[]) value;
        for (int i = 0; i < list.length; i++) {
            XmlElement item = builder.newFragment("value");
            item.addChild(list[i]);
            paramsElem.addChild(item);
        }
    } else {
        throw new ComponentRegistryException("Simple WS Client can not handle the value of type " + value);
    }
    inputMsgElem.addElement(paramsElem);
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) XmlElement(org.xmlpull.v1.builder.XmlElement) Collection(java.util.Collection) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException)

Aggregations

ComponentRegistryException (org.apache.airavata.workflow.model.component.ComponentRegistryException)8 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 Component (org.apache.airavata.workflow.model.component.Component)2 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)2 ComponentReference (org.apache.airavata.workflow.model.component.ComponentReference)2 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)2 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)2 XmlElement (org.xmlpull.v1.builder.XmlElement)2 Point (java.awt.Point)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 ActionEvent (java.awt.event.ActionEvent)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1