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(Throwable cause) 

Source Link

Document

Constructs a new NestableException with specified nested Throwable.

Usage

From source file:ExceptionUtilsV1.java

public static void loadFile() throws Exception {
    try {/*from www  .j a v a  2 s .  c o m*/
        FileInputStream fis = new FileInputStream(new File("nosuchfile"));
    } catch (FileNotFoundException fe) {
        throw new NestableException(fe);
    }
}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * Get a process definition by process name
 * //w  ww.j a v a  2s  . co  m
 * @param name
 * @return @throws
 *         NestableException
 */
public AntelopeProcessDefinition getProcessDefinition(String name) throws NestableException {
    try {
        return (AntelopeProcessDefinition) this.getDefinitionFactory().getProcessDefinition(name);
    } catch (Exception e) {
        log.error("Failed to load ProcessDef:" + name, e);
        throw new NestableException(e);
    }
}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * Get a task instance by ID/*  w  w w.  ja v a  2 s  .c  o m*/
 * 
 * @return Task Instance
 * @throws NestableException
 */
public AntelopeTaskInstance getTaskInstance(Long taskInstanceId) throws NestableException {
    try {
        Session session = PersistenceLocator.getInstance().getCurrentSession();

        return (AntelopeTaskInstance) session.load(AntelopeTaskInstance.class, taskInstanceId);
    } catch (Exception e) {
        log.error("Failed to load Task Instance:" + taskInstanceId.toString(), e);
        throw new NestableException(e);
    }
}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * Create a process in a paused state/*from   w ww  .  j av a  2s . c o m*/
 * 
 * @param processDef
 * @return A Process Instance
 * @throws NestableException
 */
public AntelopeProcessInstance createProcessPaused(AntelopeProcessDefinition processDef)
        throws NestableException {
    try {
        AntelopeProcessInstance processInstance = (AntelopeProcessInstance) this.getEngine()
                .createProcess(processDef);
        return processInstance;
    } catch (Exception e) {
        log.error("Failed to create paused instance of:" + processDef.getName(), e);
        throw new NestableException(e);
    }
}

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

/**
 * constructor from another instance (e.g. for history)
 * /*from  w w  w .  j av a 2  s .c  om*/
 * @param processInstance
 *            AntelopeProcessInstance
 */
public AntelopeProcessInstance(AntelopeProcessInstance processInstance) throws NestableException {
    if (processInstance == null) {
        throw new NestableException(
                "Cannot instantiate AntelopeProcessInstance class without a valid AntelopeProcessInstance object");
    }
}

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

/**
 * constructor from another instance (e.g. for history)
 * //from   w  w w  . j a va  2  s.c  om
 * @param processInstance
 *            AntelopeProcessInstance
 */
public ZebraProcessInstance(ZebraProcessInstance processInstance) throws NestableException {
    if (processInstance == null) {
        throw new NestableException(
                "Cannot instantiate ProcessInstance class without a valid ProcessInstance object");
    }
}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * Get the task list for the passed user
 * @param user/*from   ww  w . j a  v  a 2 s . co  m*/
 * @return
 * @throws HibernateException
 * @throws NestableException
 */
public List getTaskList(User user) throws NestableException {

    try {
        Session session = PersistenceLocator.getInstance().getCurrentSession();
        Query tasks = session.getNamedQuery("AllUsersTasks");
        tasks.setBoolean("show", true);

        tasks.setCacheable(true);

        List usersTasks = new ArrayList();

        UserManager manager = AvalonServiceHelper.instance().getSecurityService().getUserManager();

        DynamicAccessControlList acl = (DynamicAccessControlList) manager.getACL(user);

        Iterator allTasks = tasks.iterate();
        while (allTasks.hasNext()) {
            AntelopeTaskInstance taskInstance = (AntelopeTaskInstance) allTasks.next();
            Iterator taskPermissions = taskInstance.getPermissions().iterator();
            while (taskPermissions.hasNext()) {
                if (acl.hasPermission((Permission) taskPermissions.next())) {
                    usersTasks.add(taskInstance);
                    break;
                }
            }
        }

        return usersTasks;
    } catch (InitializationException e) {
        log.error("Failed to load users service", e);
        throw new NestableException(e);
    } catch (UnknownEntityException e) {
        log.error("User does not exist", e);
        throw new NestableException(e);
    } catch (HibernateException e) {
        log.error("Datastore problems building task list", e);
        throw new NestableException(e);
    }

}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * Get the task list for the passed user
 * @param user/*w ww.j  ava  2 s. com*/
 * @return
 * @throws HibernateException
 * @throws NestableException
 */
public List getOwnerTaskList(User user) throws NestableException {

    try {
        Session session = PersistenceLocator.getInstance().getCurrentSession();
        Query tasks = session.getNamedQuery("UsersTasks");
        tasks.setParameter("user", user);
        tasks.setBoolean("show", true);
        tasks.setCacheable(true);

        //return tasks.list();

        List usersTasks = new ArrayList();

        UserManager manager = AvalonServiceHelper.instance().getSecurityService().getUserManager();

        DynamicAccessControlList acl = (DynamicAccessControlList) manager.getACL(user);

        Iterator allTasks = tasks.iterate();
        while (allTasks.hasNext()) {
            AntelopeTaskInstance taskInstance = (AntelopeTaskInstance) allTasks.next();
            Iterator taskPermissions = taskInstance.getPermissions().iterator();
            while (taskPermissions.hasNext()) {
                if (acl.hasPermission((Permission) taskPermissions.next())) {
                    usersTasks.add(taskInstance);
                    break;
                }
            }
        }

        return usersTasks;
    } catch (InitializationException e) {
        log.error("Failed to load users service", e);
        throw new NestableException(e);
    } catch (UnknownEntityException e) {
        log.error("User does not exist", e);
        throw new NestableException(e);
    } catch (HibernateException e) {
        log.error("Datastore problems building task list", e);
        throw new NestableException(e);
    }

}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * Gets a permission set for String[] of permission names
 * @param permissions//from  w  ww .  j a  va2s . c om
 * @return
 * @throws NestableException
 */
public PermissionSet getPermissionSet(String[] permissions) throws NestableException {
    try {
        PermissionManager permissionManager = AvalonServiceHelper.instance().getSecurityService()
                .getPermissionManager();

        PermissionSet permissionSet = new PermissionSet();
        for (int i = 0; i < permissions.length; i++) {
            try {
                permissionSet.add(permissionManager.getPermissionByName(permissions[i]));
            } catch (UnknownEntityException e1) {
                // Does not exist yet so create it
                try {
                    Permission permission = permissionManager.getPermissionInstance(permissions[i]);
                    permissionManager.addPermission(permission);
                    permissionSet.add(permission);
                } catch (UnknownEntityException e) {
                    log.error("Cannot find permission", e);
                    throw new NestableException(e);
                } catch (EntityExistsException e) {
                    log.error("Somehow the entity exists and does not exist", e);
                    throw new NestableException(e);
                }
            }
        }

        return permissionSet;
    } catch (InitializationException e) {
        log.error("Trying to initialize start permissions not possible", e);
        throw new NestableException(e);
    } catch (DataBackendException e) {
        log.error("Trying to initialize start permissions not possible", e);
        throw new NestableException(e);
    }
}

From source file:com.anite.antelope.zebra.helper.ZebraHelper.java

/**
 * loads a permission or creates it if it doesn't already exist. 
 * @param permissionName/*  www . j a v a2 s . c  o  m*/
 * @return
 * @throws InitializationException
 */
public Permission loadOrCreatePermission(String permissionName) throws NestableException {

    try {
        PermissionManager permissionManager = AvalonServiceHelper.instance().getSecurityService()
                .getPermissionManager();

        Permission permission = permissionManager.getPermissionInstance(permissionName);
        if (permissionManager.checkExists(permission)) {
            return permissionManager.getPermissionByName(permissionName);
        }
        permissionManager.addPermission(permission);
        return permission;
    } catch (DataBackendException e) {
        log.error("Failed to find or create permission:" + permissionName, e);
        throw new NestableException(e);
    } catch (UnknownEntityException e) {
        log.error("Failed to find or create permission:" + permissionName, e);
        throw new NestableException(e);
    } catch (InitializationException e) {
        log.error("Failed to find or create permission:" + permissionName, e);
        throw new NestableException(e);
    } catch (EntityExistsException e) {
        log.error("Failed to find or create permission:" + permissionName, e);
        throw new NestableException(e);
    }
}