Package org.apache.lenya.workflow

Examples of org.apache.lenya.workflow.WorkflowException


     * @throws WorkflowException if something goes wrong.
     */
    public WorkflowInstanceImpl getInstance() throws WorkflowException {
        if (this.instance == null) {
            if (!isInitialized()) {
                throw new WorkflowException(
                        "The workflow history has not been initialized: The file ["
                                + getHistoryFile() + "] is missing.");
            }

            WorkflowInstanceImpl instance = createInstance();
            NamespaceHelper helper = getNamespaceHelper();

            String workflowId = getWorkflowId(helper);
            if (null == workflowId) {
                throw new WorkflowException("No workflow attribute set in history document!");
            }

            instance.setWorkflow(workflowId);

            restoreState(instance, helper);
View Full Code Here


            saveVariables(helper);

            DocumentHelper.writeDocument(xmlDocument, getHistoryFile());
        } catch (Exception e) {
            throw new WorkflowException(e);
        }
    }
View Full Code Here

                    parent.appendChild(element);
                }

                element.setAttribute(VALUE_ATTRIBUTE, Boolean.toString(value));
            } catch (TransformerException e) {
                throw new WorkflowException(e);
            }
        }
    }
View Full Code Here

            sourceStream.close();
            destinationStream.close();
            File directory = historyFile.getParentFile();
            boolean deleted = historyFile.delete();
            if (!deleted) {
                throw new WorkflowException("The old history file could not be deleted!");
            }
            if (directory.exists() && directory.isDirectory() && directory.listFiles().length == 0) {
                directory.delete();
            }
        } catch (IOException e) {
            throw new WorkflowException(e);
        } finally {
            try {
                if (sourceStream != null)
                    sourceStream.close();
                if (destinationStream != null)
                    destinationStream.close();
            } catch (IOException e) {
                throw new WorkflowException(e);
            }
        }
    }
View Full Code Here

     * @throws WorkflowException when something went wrong.
     */
    protected Version restoreVersion(NamespaceHelper helper, Element element)
            throws WorkflowException {
        if (!element.getLocalName().equals(VERSION_ELEMENT)) {
            throw new WorkflowException("Invalid history XML!");
        }

        Event event = null;
        String eventId = element.getAttribute(EVENT_ATTRIBUTE);
        if (eventId != null && !"".equals(eventId)) {
View Full Code Here

     * @throws WorkflowException when something went wrong.
     */
    public void delete() throws WorkflowException {
        System.out.println("Deleting file [" + getHistoryFile() + "]");
        if (!isInitialized()) {
            throw new WorkflowException("The workflow history is not initialized!");
        }

        boolean deleted = getHistoryFile().delete();

        if (!deleted) {
            throw new WorkflowException("The workflow history could not be deleted!");
        }

    }
View Full Code Here

     */
    public void setExpression(String expression) throws WorkflowException {
        super.setExpression(expression);
        String[] sides = expression.split("=");
        if (sides.length != 2) {
            throw new WorkflowException(
                "The expression '" + expression + "' must be of the form 'name = [true|false]'");
        }
       
        variableName = sides[0].trim();
        value = Boolean.valueOf(sides[1].trim()).booleanValue();
View Full Code Here

        try {
            Document document = DocumentHelper.readDocument(file);
            workflow = buildWorkflow(document);
        } catch (Exception e) {
            throw new WorkflowException(e);
        }

        return workflow;
    }
View Full Code Here

     * @throws WorkflowException when the event may not be invoked.
     */
    public void invoke(Situation situation, Event event)
        throws WorkflowException {
        if (!Arrays.asList(getExecutableEvents(situation)).contains(event)) {
            throw new WorkflowException("The event '" + event +
                "' cannot be invoked in the situation '" + situation + "'.");
        }

        fire(getNextTransition(event));

View Full Code Here

        for (int i = 0; i < transitions.length; i++) {
            if (transitions[i].getEvent().equals(event)) {
               
                if (nextTransition != null) {
                    throw new WorkflowException("More than one transition found for event [" + event + "]!");
                }
               
                nextTransition = (TransitionImpl) transitions[i];
            }
        }
       
        if (nextTransition == null) {
            throw new WorkflowException("No transition found for event [" + event + "]!");
        }
       
        return nextTransition;
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.workflow.WorkflowException

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.