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