Example usage for org.apache.commons.lang.exception NestableException NestableException

List of usage examples for org.apache.commons.lang.exception NestableException NestableException

Introduction

In this page you can find the example usage for org.apache.commons.lang.exception NestableException NestableException.

Prototype

public NestableException(String msg, Throwable cause) 

Source Link

Document

Constructs a new NestableException with specified detail message and nested Throwable.

Usage

From source file:com.pieframework.model.repository.ModelStore.java

public static Model loadModel(Configuration config, Request request, File fileRoot, String instance)
        throws IOException, NestableException {
    if (fileRoot == null || !fileRoot.isDirectory()) {
        throw new IllegalArgumentException("Cannot build Model from given directory.");
    }/*from w  w  w  .  j  a v a2  s .  c  o  m*/

    try {
        System system = getSystem(new File(fileRoot + PATH_DELIMITER + SYSTEM_FILE_NAME));

        Repositories repos = getRepositories(new File(fileRoot + PATH_DELIMITER + REPOSITORIES_FILE_NAME));

        model = new Model().withSystem(system).withRepositories(repos).withModelDirectory(fileRoot.getPath())
                .withConfiguration(config).withRequest(request);

        File instanceFile = new File(
                fileRoot + PATH_DELIMITER + "instances" + PATH_DELIMITER + instance + ".txt");
        if (instanceFile != null && instanceFile.canRead()) {
            applyInstanceOverrides(model, instanceFile);
        }

        // replace @{expression} tags in model
        model = evaluateTemplateExpressions(model);

        // relink the system
        linkComponents(model.getSystem());

        // ////////Experiment////

        // /////////////////////

    } catch (SimpleSerializerException e) {
        Configuration.log().error("Could not parse Model. " + e.getMessage());
        throw new NestableException("Could not parse Model.", e);
    } catch (ParserConfigurationException e) {
        Configuration.log().error("Could not parse Model. " + e.getMessage());
        throw new NestableException("Could not parse Model.", e);
    } catch (SAXException e) {
        Configuration.log().error("Could not parse Model. " + e.getMessage());
        throw new NestableException("Could not parse Model.", e);
    } catch (TransformerException e) {
        Configuration.log().error("Could not parse Model. " + e.getMessage());
        throw new NestableException("Could not parse Model.", e);
    }
    return model;
}

From source file:com.anite.antelope.zebra.om.AntelopeProcessInstance.java

/**
 * Looks for the first list of tasks that come from the child(ren) of this
 * processinstance This is used for finding the next screen. We don't do
 * this exaustively as it could be very large. The first is good enough for
 * determining the next screen//w  w  w. jav a 2s .  c o  m
 */
public List getFirstTasksFromAChildProcess() throws NestableException {

    Stack checkList = new Stack();
    checkList.push(this);
    while (!checkList.isEmpty()) {
        try {
            AntelopeProcessInstance currentProcess = (AntelopeProcessInstance) checkList.pop();
            List childProcesses = currentProcess.getRunningChildProcesses();
            for (Iterator it = childProcesses.iterator(); it.hasNext();) {
                AntelopeProcessInstance child = (AntelopeProcessInstance) it.next();
                List allTasks = child.getUsersTasks();
                if (!allTasks.isEmpty()) {
                    return allTasks;
                }
                checkList.push(child);
            }
        } catch (Exception e) {
            String emsg = "Failed to retrieve child processes";
            log.error(emsg, e);
            throw new NestableException(emsg, e);
        }
    }
    return new ArrayList();
}

From source file:com.anite.antelope.zebra.om.AntelopeProcessInstance.java

/**
 * looks for tasks from the parent(s) of the processInstance
 * /*from   w  w  w .  j  a  v a2s  .c o  m*/
 * @return
 */
public List getFirstTasksFromAParentProcess() throws NestableException {
    AntelopeProcessInstance parentInstance = null;
    try {
        parentInstance = this.getParentProcessInstance();
        while (parentInstance != null) {
            if (log.isInfoEnabled()) {
                log.info("Getting tasks for parent process  " + this.getProcessInstanceId());
            }
            // get parent tasks
            List allTasks = parentInstance.getUsersTasks();

            if (!allTasks.isEmpty()) {
                return allTasks;
            }
            parentInstance = parentInstance.getParentProcessInstance();
        }
    } catch (Exception e) {
        String emsg = "Problem accessing parent process tasks";
        log.error(emsg, e);
        throw new NestableException(emsg, e);
    }
    return new ArrayList();
}

From source file:com.anite.zebra.hivemind.om.state.ZebraProcessInstance.java

/**
 * Looks for the first list of tasks that come from the child(ren) of this
 * processinstance This is used for finding the next screen. We don't do
 * this exaustively as it could be very large. The first is good enough for
 * determining the next screen// w  w  w  .  ja  v  a  2 s.  co  m
 */
@Transient
public List<ZebraTaskInstance> getFirstTasksFromAChildProcess() throws NestableException {

    Stack<ZebraProcessInstance> checkList = new Stack<ZebraProcessInstance>();
    checkList.push(this);
    while (!checkList.isEmpty()) {
        try {
            ZebraProcessInstance currentProcess = checkList.pop();
            List childProcesses = currentProcess.getRunningChildProcesses();
            for (Iterator it = childProcesses.iterator(); it.hasNext();) {
                ZebraProcessInstance child = (ZebraProcessInstance) it.next();
                List<ZebraTaskInstance> allTasks = child.getUsersTasks();
                if (!allTasks.isEmpty()) {
                    return allTasks;
                }
                checkList.push(child);
            }
        } catch (Exception e) {
            String emsg = "Failed to retrieve child processes";
            log.error(emsg, e);
            throw new NestableException(emsg, e);
        }
    }
    return new ArrayList<ZebraTaskInstance>();
}

From source file:com.anite.zebra.hivemind.om.state.ZebraProcessInstance.java

/**
 * looks for tasks from the parent(s) of the processInstance
 * //from  w ww.  ja  va  2s  . c  o m
 * @return
 */
@Transient
public List getFirstTasksFromAParentProcess() throws NestableException {
    ZebraProcessInstance parentInstance = null;
    try {
        parentInstance = this.getParentProcessInstance();
        while (parentInstance != null) {
            if (log.isInfoEnabled()) {
                log.info("Getting tasks for parent process  " + this.getProcessInstanceId());
            }
            // get parent tasks
            List allTasks = parentInstance.getUsersTasks();

            if (!allTasks.isEmpty()) {
                return allTasks;
            }
            parentInstance = parentInstance.getParentProcessInstance();
        }
    } catch (Exception e) {
        String emsg = "Problem accessing parent process tasks";
        log.error(emsg, e);
        throw new NestableException(emsg, e);
    }
    return new ArrayList();
}

From source file:org.eclipse.wb.tests.gef.UiContext.java

/**
 * Executes one {@link UIRunnable} (can block UI) and uses other {@link UIRunnable} to check
 * result.//from   w w  w  .  ja va  2  s  .  com
 */
public void executeAndCheck(UIRunnable uiRunnable, final UIRunnable checkRunnable) throws Exception {
    // run checkRunnable
    final Throwable[] checkException = new Throwable[1];
    Thread checkThread = new Thread("UIContext_checkThread") {
        @Override
        public void run() {
            m_display.asyncExec(new Runnable() {
                public void run() {
                    try {
                        checkRunnable.run(UiContext.this);
                    } catch (Throwable e) {
                        e.printStackTrace();
                        checkException[0] = e;
                    }
                }
            });
        }
    };
    checkThread.start();
    // now run uiRunnable, it can block
    uiRunnable.run(this);
    // wait also for 'checkThread'
    checkThread.join();
    // check for exception
    if (checkException[0] != null) {
        if (checkException[0] instanceof AssertionFailedError) {
            AssertionFailedError error = (AssertionFailedError) checkException[0];
            throw error;
        }
        throw new NestableException("Exception during running 'check' UIRunnable.", checkException[0]);
    }
}