Example usage for java.lang Exception getCause

List of usage examples for java.lang Exception getCause

Introduction

In this page you can find the example usage for java.lang Exception getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:com.sisrni.managedbean.MenusAdmMB.java

/**
 * */*from   w w w . ja  v a  2  s .  c om*/
 *
 * @param 
 * @throws Exception
 */
public void preEliminar(SsMenus ssMenus) throws Exception {
    try {
        this.ssMenus = ssMenus;
        int i = 0;
        selectedArrayRoles = new String[ssMenus.getSsRolesList().size()];
        listRolesTemp = ssMenus.getSsRolesList();
        for (SsRoles mn : ssMenus.getSsRolesList()) {
            selectedArrayRoles[i] = mn.getIdRol().toString();
            i++;
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error class MenusOpcionesMB - preEditar()\n" + e.getMessage(), e.getCause());
    } finally {

    }
}

From source file:com.sisrni.managedbean.MenusAdmMB.java

/**
 * */* w w  w .j a  v  a2  s  .  c  o m*/
 * metodo para eliminar menus que no esten amarrados opciones
 * @param 
 * @throws Exception
 */
public void eliminar() throws Exception {
    try {
        this.ssMenus = ssMenus;
        for (SsRoles mn : ssMenus.getSsRolesList()) {
            int deleteMenuOpciones = menusService.deleteMenuRoles(ssMenus.getIdMenu(), mn.getIdRol());
        }
        menusService.delete(ssMenus);
        getMenus();
        RequestContext.getCurrentInstance().update("formAdmin");
        RequestContext.getCurrentInstance().update("formMenu");
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error class MenusOpcionesMB - preEditar()\n" + e.getMessage(), e.getCause());
    } finally {

    }
}

From source file:com.sisrni.managedbean.OpcionesAdmMB.java

/**
 * */*from www. ja v a2  s .co  m*/
 * metodo para eliminar menus que no esten amarrados opciones
 * @param 
 * @throws Exception
 */
public void eliminar() throws Exception {
    try {
        for (SsRoles mn : ssOpciones.getSsRolesList()) {
            int deleteMenuOpciones = opcionesService.deleteOpcionesRoles(ssOpciones.getIdOpcion(),
                    mn.getIdRol());
        }
        opcionesService.delete(ssOpciones);
        getMenus();
        RequestContext.getCurrentInstance().update("formAdmin");
        RequestContext.getCurrentInstance().update("formMenu");
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error class MenusOpcionesMB - preEditar()\n" + e.getMessage(), e.getCause());
    } finally {

    }
}

From source file:name.persistent.behaviours.RemoteGraphSupport.java

private Exception cause(Exception e) throws Exception {
    try {//w  w w  . j  a  v  a 2 s  .c  om
        throw e.getCause();
    } catch (Exception cause) {
        return cause;
    } catch (Error cause) {
        throw cause;
    } catch (Throwable cause) {
        throw e;
    }
}

From source file:de.vandermeer.skb.datatool.commons.DataSet.java

/**
 * Loads a data set from file system, does many consistency checks as well.
 * @param fsl list of files to load data from
 * @param fileExt the file extension used (translated to "." + fileExt + ".json"), empty if none used
 * @return 0 on success, larger than zero on JSON parsing error (number of found errors)
 *///  w  ww.j  a  va2s.  c o  m
@SuppressWarnings("unchecked")
public int load(List<FileSource> fsl, String fileExt) {
    int ret = 0;
    String commonPath = this.calcCommonPath(fsl);

    for (FileSource fs : fsl) {
        String keyStart = this.calcKeyStart(fs, commonPath);
        ObjectMapper om = new ObjectMapper();
        om.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        try {
            List<Map<String, Object>> jsonList = om.readValue(fs.asFile(),
                    new TypeReference<ArrayList<HashMap<String, Object>>>() {
                    });
            for (Map<String, Object> entryMap : jsonList) {
                E entry = this.factory.newInstanceLoaded(keyStart, entryMap);
                if (entry.getKey().contains("#dummy")) {
                    continue;
                }

                String dup = entry.testDuplicate((Collection<DataEntry>) this.entries.values());
                if (this.entries.containsKey(entry.getKey())) {
                    Skb_Console.conError("{}: duplicate key <{}> found in file <{}>",
                            new Object[] { this.cs.getAppName(), entry.getKey(), fs.getAbsoluteName() });
                } else if (dup != null) {
                    Skb_Console.conError("{}: entry already in map: k1 <{}> <> k2 <{}> found in file <{}>",
                            new Object[] { this.cs.getAppName(), dup, entry.getKey(), fs.getAbsoluteName() });
                } else {
                    if (this.excluded == null
                            || (!ArrayUtils.contains(this.excluded, entry.getCompareString()))) {
                        this.entries.put(entry.getKey(), (E) entry);
                    }
                }
            }
            this.files++;
        } catch (IllegalArgumentException iaex) {
            Skb_Console.conError("{}: problem creating entry: <{}> in file <{}>",
                    new Object[] { this.cs.getAppName(), iaex.getMessage(), fs.getAbsoluteName() });
            ret++;
        } catch (URISyntaxException ue) {
            Skb_Console.conError("{}: problem creating a URI for a link: <{}> in file <{}>",
                    new Object[] { this.cs.getAppName(), ue.getMessage(), fs.getAbsoluteName() });
            ret++;
        } catch (NullPointerException npe) {
            npe.printStackTrace();
            ret++;
        } catch (Exception ex) {
            Skb_Console.conError(
                    "reading acronym from JSON failed with exception <{}>, cause <{}> and message <{}> in file <{}>",
                    new Object[] { ex.getClass().getSimpleName(), ex.getCause(), ex.getMessage(),
                            fs.getAbsoluteName() });
            ret++;
        }
    }

    return ret;
}

From source file:com.sisrni.managedbean.MenusAdmMB.java

public void editar() throws Exception {
    try {//from  w  ww .j  a v  a  2  s  . c  om
        for (SsRoles mn : ssMenus.getSsRolesList()) {
            int deleteMenuOpciones = menusService.deleteMenuRoles(ssMenus.getIdMenu(), mn.getIdRol());
        }

        selectedlistRoles = new ArrayList<SsRoles>();
        for (String us : selectedArrayRoles) {
            roles = new SsRoles();
            roles = ssRolesService.findById(Integer.parseInt(us.toString()));
            selectedlistRoles.add(roles);
        }
        ssMenus.setSsRolesList(selectedlistRoles);
        menusService.getDao().merge(ssMenus);
        getMenus();
        RequestContext.getCurrentInstance().update("formAdmin");
        RequestContext.getCurrentInstance().update("formMenu");
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error class MenusOpcionesMB - Editar()\n" + e.getMessage(), e.getCause());
    } finally {
        this.ssMenus = null;
        this.ssMenus = new SsMenus();
    }
}

From source file:com.sisrni.managedbean.OpcionesAdmMB.java

public void preEliminar(SsOpciones ssOpciones) throws Exception {
    try {/*from w w  w.  ja va  2 s  .co  m*/
        this.ssOpciones = ssOpciones;
        int i = 0;
        selectedArrayRoles = new String[ssOpciones.getSsRolesList().size()];
        for (SsRoles mn : ssOpciones.getSsRolesList()) {
            selectedArrayRoles[i] = mn.getIdRol().toString();
            i++;
        }
        if (ssOpciones.getVisible().equalsIgnoreCase("S")) {
            visible = true;
        } else {
            visible = false;
        }

    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error class opcinesAdmMB - preEliminar()\n" + e.getMessage(), e.getCause());
    } finally {

    }
}

From source file:org.cnbi.web.system.listener.WebApplicationInitializer.java

/**
 * ??/*  ww w .ja  v a2 s .com*/
 * 
 * @return
 */
private void queryMenuList() {
    String key = Constants.MENU + Constants.LIST;
    String sql = sqlMap.get(key);
    try {
        @SuppressWarnings("unchecked")
        List<Menu> menuList = (List<Menu>) handleService.query(sql, new Menu());
        servletContext.setAttribute(key, menuList);
    } catch (Exception e) {
        logger.error("???\n" + sql + "--\n" + e);
        throw new RuntimeException(e.getMessage(), e.getCause());
    }
}

From source file:controllers.CensusController.java

/****
 * Metodos externos/*from   w  ww.j  a v  a  2s .  c  o m*/
 ******/

// Create census ----------------------------------------------------------
// Recibe parametros de votacion y crea un censo por votacin

@RequestMapping(value = "/create", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody Census create(@RequestParam int idVotacion, @RequestParam String fechaInicio,
        @RequestParam String fechaFin, @RequestParam String tituloVotacion, String tipoVotacion,
        @CookieValue("user") String username) throws ParseException {
    Census result = null;

    Census c = censusService.create(idVotacion, username, fechaInicio, fechaFin, tituloVotacion, tipoVotacion);
    try {
        result = censusService.save(c);
    } catch (Exception oops) {
        oops.getCause();
    }
    return result;
}

From source file:de.rwth.dbis.acis.activitytracker.service.ActivityTrackerService.java

private List<ActivityEx> getObjectBodies(CloseableHttpClient httpclient, ExecutorService executor,
        String authorizationToken, List<Activity> activities) throws Exception {
    List<ActivityEx> activitiesEx = new ArrayList<>();
    Map<Integer, Future<String>> dataFutures = new HashMap<>();
    Map<Integer, Future<String>> parentDataFutures = new HashMap<>();
    Map<Integer, Future<String>> userFutures = new HashMap<>();
    JsonParser parser = new JsonParser();

    for (int i = 0; i < activities.size(); i++) {
        Activity activity = activities.get(i);
        if (activity.getDataUrl() != null && !activity.getDataUrl().isEmpty()) {
            URIBuilder uriBuilder = new URIBuilder(activity.getDataUrl());
            URI uri = uriBuilder.build();
            HttpGet httpget = new HttpGet(uri);
            if (!authorizationToken.isEmpty()) {
                httpget.addHeader("authorization", authorizationToken);
            }/*from   w ww. j  av  a 2  s  . c  om*/
            dataFutures.put(activity.getId(), executor.submit(new HttpRequestCallable(httpclient, httpget)));
        }
        if (activity.getParentDataUrl() != null && !activity.getParentDataUrl().isEmpty()) {
            URIBuilder uriBuilder = new URIBuilder(activity.getParentDataUrl());
            URI uri = uriBuilder.build();
            HttpGet httpget = new HttpGet(uri);
            if (!authorizationToken.isEmpty()) {
                httpget.addHeader("authorization", authorizationToken);
            }
            parentDataFutures.put(activity.getId(),
                    executor.submit(new HttpRequestCallable(httpclient, httpget)));
        }
        if (activity.getUserUrl() != null && !activity.getUserUrl().isEmpty()) {
            URIBuilder uriBuilder = new URIBuilder(activity.getUserUrl());
            URI uri = uriBuilder.build();
            HttpGet httpget = new HttpGet(uri);
            if (!authorizationToken.isEmpty()) {
                httpget.addHeader("authorization", authorizationToken);
            }
            userFutures.put(activity.getId(), executor.submit(new HttpRequestCallable(httpclient, httpget)));
        }
    }

    for (int i = 0; i < activities.size(); i++) {
        try {
            Activity activity = activities.get(i);
            ActivityEx activityEx = ActivityEx.getBuilderEx().activity(activity).build();
            Future<String> dataFuture = dataFutures.get(activity.getId());
            if (dataFuture != null) {
                activityEx.setData(parser.parse(dataFuture.get()));
            }
            Future<String> parentDataFuture = parentDataFutures.get(activity.getId());
            if (parentDataFuture != null) {
                activityEx.setParentData(parser.parse(parentDataFuture.get()));
            }
            Future<String> userFuture = userFutures.get(activity.getId());
            if (userFuture != null) {
                activityEx.setUser(parser.parse(userFuture.get()));
            }
            activitiesEx.add(activityEx);
        } catch (Exception ex) {
            Throwable exCause = ex.getCause();
            if (exCause instanceof ActivityTrackerException
                    && ((ActivityTrackerException) exCause).getErrorCode() == ErrorCode.AUTHORIZATION) {
                Context.logMessage(this, "Object not visible for user token or anonymous. Skip object.");
            } else if (exCause instanceof ActivityTrackerException
                    && ((ActivityTrackerException) exCause).getErrorCode() == ErrorCode.NOT_FOUND) {
                Context.logMessage(this, "Resource not found. Skip object.");
            } else {
                throw ex;
            }
        }
    }
    return activitiesEx;
}