Package edu.indiana.extreme.xbaya.workflow

Examples of edu.indiana.extreme.xbaya.workflow.WorkflowEngineException


                } catch (GcResourceNotFoundException e) {
                    // The workflow was not found in the engine.
                    logger.caught(e);
                    template = null;
                } catch (RuntimeException e) {
                    throw new WorkflowEngineException(ErrorMessages.GPEL_ERROR, e);
                }
            }
        }

        String title = workflow.getName();
        if (template == null) {
            // This case is either it is a new deploy or the tempate does not
            // exist in the GPEL Engine.

            template = this.client.createTemplate(title);
            links = new ArrayList<GcWebResource>();
            template.setLinks(links);
        } else {
            // Redeploy

            template.setTitle(title);
            links = template.getLinks();

            // Look for each resource.
            for (GcWebResource link : links) {
                String rel = link.getRel();
                logger.finest("rel: " + rel);
                if (GpelConstants.REL_PROCESS.equals(rel)) {
                    processResource = (GcProcessResource) link;
                } else if (GPELLinksFilter.REL_XWF.equals(rel)) {
                    graphResource = (GcXmlWebResource) link;
                } else if (GPELLinksFilter.REL_IMAGE.equals(rel)) {
                    imageResource = (GcBinaryWebResource) link;
                } else if (GpelConstants.REL_WSDL.equals(rel)) {
                    GcWsdlResource wsdlResouece = (GcWsdlResource) link;
                    String wsdlTitle = wsdlResouece.getTitle();
                    logger.finest("wsdlTitle: " + wsdlTitle);
                    // XXX Can we rely on the title to do the matching?
                    wsdlResourceMap.put(wsdlTitle, wsdlResouece);
                }
            }
        }

        // BPEL process
        GpelProcess process = workflow.getGpelProcess();
        if (processResource == null) {
            processResource = new GcProcessResource(PROCESS_GPEL_TITLE, process);
            links.add(processResource);
        } else {
            processResource.setXmlContent(process.xml());
        }

        // WSDL for the process
        workflowWSDLresource = wsdlResourceMap.remove(PROCESS_WSDL_TYTLE);
        WsdlDefinitions workflowWSDL = workflow.getWorkflowWSDL();
        logger.finest(workflowWSDL.xmlString());
        if (workflowWSDLresource == null) {
            workflowWSDLresource = new GcWsdlResource(PROCESS_WSDL_TYTLE,
                    workflowWSDL);
            links.add(workflowWSDLresource);
        } else {
            workflowWSDLresource.setXmlContent(workflowWSDL.xml());
        }

        Map<String, WsdlDefinitions> wsdlMap = workflow.getWSDLs();
        for (String id : wsdlMap.keySet()) {
            WsdlDefinitions wsdl = wsdlMap.get(id);
            GcWsdlResource wsdlResource = wsdlResourceMap.remove(id);
            if (wsdlResource == null) {
                wsdlResource = new GcWsdlResource(id, wsdl);
                links.add(wsdlResource);
            } else {
                wsdlResource.setXmlContent(wsdl.xml());
            }
        }

        // Remove the rest of unused WSDL from the links.
        for (GcWsdlResource resource : wsdlResourceMap.values()) {
            links.remove(resource);
        }

        // Graph
        Graph graph = workflow.getGraph();
        if (graphResource == null) {
            logger.finest("Creating a new graphResource");
            graphResource = new GcXmlWebResource("process.xgr", graph.toXML(),
                    GRAPH_MIME_TYPE);
            graphResource.setRel(GPELLinksFilter.REL_XWF);
            links.add(graphResource);
        } else {
            logger.finest("Updating the graphResource");
            graphResource.setXmlContent(graph.toXML());
        }

        // Image
        try {
            BufferedImage image = workflow.getImage();
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            ImageIO.write(image, XBayaConstants.PNG_FORMAT_NAME, outStream);
            byte[] bytes = outStream.toByteArray();

            if (imageResource == null) {
                imageResource = new GcBinaryWebResource("image.png", bytes,
                        PNG_MIME_TYPE);
                imageResource.setRel(GPELLinksFilter.REL_IMAGE);
                links.add(imageResource);
            } else {
                imageResource.setBinaryContent(bytes);
            }
        } catch (IOException e) {
            // It's OK to not save the image for now.
            logger.caught(e);
        } catch (IllegalArgumentException e) {
            // This happens only from junit tests.
            logger.caught(e);
        }

        try {
            this.client.deployTemplate(template);

            // this needs to be kept and reused
            URI templateID = template.getTemplateId();
            workflow.setGPELTemplateID(templateID);

            logger.exiting();
            return templateID;
        } catch (RuntimeException e) {
            throw new WorkflowEngineException(ErrorMessages.GPEL_ERROR, e);
        }
    }
View Full Code Here


                    // This doesn't happen
                    throw new XBayaRuntimeException();
            }
        } catch (GcResourceNotFoundException e) {
            // The workflow was not found in the engine.
            throw new WorkflowEngineException(
                    ErrorMessages.GPEL_WORKFLOW_NOT_FOUND_ERROR, e);
        } catch (RuntimeException e) {
            throw new WorkflowEngineException(ErrorMessages.GPEL_ERROR, e);
        }

        GcProcessResource processResource = null;
        if (workflowInstance != null) {
            processResource = (GcProcessResource) workflowInstance
View Full Code Here

                    throw new XBayaRuntimeException();
            }

            return results;
        } catch (RuntimeException e) {
            throw new WorkflowEngineException(e);
        }
    }
View Full Code Here

            }
            return instance;
        } catch (RuntimeException e) {
            String message = "Error while creating a workflow instance. template ID: "
                    + templateID + ", instanceID: " + instanceID;
            throw new WorkflowEngineException(message, e);
        }
    }
View Full Code Here

                instance.store();
            }
            return instance;
        } catch (RuntimeException e) {
            throw new WorkflowEngineException(e);
        }
    }
View Full Code Here

                    workflowPublicWsdl.getXmlContent());
            return workflowCWSDL;
        } catch (RuntimeException e) {
            String message = "Error while starting a workflow instance. instance ID: "
                    + instanceID;
            throw new WorkflowEngineException(message, e);
        }
    }
View Full Code Here

            this.client.setFilter(this.linksFilter);
            sendSafeEvent(new Event(Event.Type.GPEL_ENGINE_CONNECTED));
        } catch (RuntimeException e) {
            this.client = null;
            sendSafeEvent(new Event(Event.Type.GPEL_ENGINE_DISCONNECTED));
            throw new WorkflowEngineException(ErrorMessages.GPEL_CONNECTION_ERROR, e);
        }
    }
View Full Code Here

TOP

Related Classes of edu.indiana.extreme.xbaya.workflow.WorkflowEngineException

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.