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);
}
}
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);
}
}
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);
}
Aggregations