List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:eu.smartenit.unada.sm.MonitorRunner.java
/** * Stores posts of friends in the database. * * @param friendPostList The posts of friends to be stored *//*from w w w .j av a 2 s . c o m*/ private void storeFriendPosts(List<FeedItem> friendPostList) { logger.info("Storing friend posts in database..."); FeedItemDAO feedItemDAO = DAOFactory.getFeedItemDAO(); try { feedItemDAO.insertAll(friendPostList.iterator()); } catch (Exception e) { logger.error("Error while inserting friend posts"); logger.error(e.getMessage(), e.getStackTrace()); } logger.info("Done."); }
From source file:org.apache.juneau.rest.client.RestCallException.java
/** * Constructor.//from w w w. j a va 2 s . c o m * * @param e The inner cause of the exception. */ public RestCallException(Exception e) { super(e.getLocalizedMessage(), e); if (e instanceof FileNotFoundException) { responseCode = 404; } else if (e.getMessage() != null) { Pattern p = Pattern.compile("[^\\d](\\d{3})[^\\d]"); Matcher m = p.matcher(e.getMessage()); if (m.find()) responseCode = Integer.parseInt(m.group(1)); } setStackTrace(e.getStackTrace()); }
From source file:py.edu.ucsa.voto.ws.service.VotoEndpoint.java
@PayloadRoot(localPart = QUERY_GENERICO_REQUEST, namespace = NAMESPACE) public QueryGenericoResponse queryGenerico(QueryGenericoRequest request) { //Date fecha = consultarTransaccionRequestDAO.getDataBaseTime(); //se obtiene la fecha //request.setFchins(fecha); //se setea la fecha QueryGenericoResponse response = new QueryGenericoResponse(); try {/* ww w. jav a 2 s .c om*/ // enviar a cola request // String idMessageRequest = gfvJmsMessageManager // .enviarObjectMessage(request); // recibir response queryGenericoRequestDAO.saveOrUpdate(request); //json string to java object; //ObjectMapper mapper = new ObjectMapper(); //String jsonInString =request.getQuery_generico(); //UcsawsRoles user = mapper.readValue(jsonInString, UcsawsRoles.class); //Date a = new Date(); //user.setFchIns(a); //user.setUsuarioIns("test hacer dinamico"); //Gson gson = new Gson(); //UcsawsRoles albums = gson.fromJson(jsonInString, UcsawsRoles.class); //String json = jsonInString; //ObjectMapper mapper1 = new ObjectMapper(); //mapper1.reader().forType(UcsawsRoles.class).readValue(json); /*Integer codigo = canalizador.parearClase (request).getCodigo(); response.setCodigo(codigo); String respon = canalizador.parearClase (request).getQuery_generico_response(); response.setQuery_generico_response(respon);*/ QueryGenericoResponse aux = canalizador.parearClase(request); response.setCodigo(aux.getCodigo()); response.setQuery_generico_response(aux.getQuery_generico_response()); response.setQueryGenericoRequest(request); //PARA INSERTAR /* if (request.getTipo_query_generico()==1){ rolesDAO.save(user); //generoDAO.saveNativo(request.getQuery_generico()); response.setCodigo(_CODIGO_OK_INSERT); response.setQuery_generico_response("INSERT OK"); response.setQueryGenericoRequest(request); } else //PARA CONSULTAR if(request.getTipo_query_generico()==2){ String string = generoDAO.SelectNativo(request.getQuery_generico()); //String[] parts = ((String) string).split(","); //String part1 =arrObj. //String part2 = parts[1]; //String part3 = parts[2]; response.setCodigo(_CODIGO_OK_SELECT); response.setQuery_generico_response(string); response.setQueryGenericoRequest(request); } else //PARA MODIFICAR if(request.getTipo_query_generico()==3){ generoDAO.updateNativo(request.getQuery_generico()); //String[] parts = ((String) string).split(","); //String part1 =arrObj. //String part2 = parts[1]; //String part3 = parts[2]; response.setCodigo(_CODIGO_OK_UPDATE); response.setQuery_generico_response("UPDATE OK"); response.setQueryGenericoRequest(request); } else //PARA ELIMINAR if(request.getTipo_query_generico()==4){ try { generoDAO.updateNativo(request.getQuery_generico()); } catch (HibernateQueryException e) { // TODO: handle exception e.getMessage(); e.printStackTrace(); } //String[] parts = ((String) string).split(","); //String part1 =arrObj. //String part2 = parts[1]; //String part3 = parts[2]; response.setCodigo(_CODIGO_OK_DELETE); response.setQuery_generico_response("DELETE OK"); response.setQueryGenericoRequest(request); }*/ } catch (Exception e) { logger.error(e.getStackTrace(), e); System.out.println(e.getCause().toString()); System.out.println(e.getCause().getLocalizedMessage()); response.setCodigo(_CODIGO_ERROR_DESCONOCIDO); //response.setQuery_generico_response("ERRORRRRRRR"); String jsonStr = ""; ObjectMapper mapperObj = new ObjectMapper(); try { //jsonStr = mapperObj.writeValueAsString(e.getMessage()); jsonStr = mapperObj.writeValueAsString(e.getCause().toString()); } catch (Exception ex) { System.out.println(ex); } response.setQuery_generico_response(jsonStr); response.setQueryGenericoRequest(request); } if (response.getQuery_generico_response().length() < 500) { queryGenericoResponseDAO.saveOrUpdate(response); } return response; }
From source file:com.niroshpg.android.gmail.CronHandlerServlet.java
public BigInteger getHistoryIdXX(Gmail service, String userId, Credential credential) throws IOException { BigInteger historyId = null;/* w w w. j a v a 2 s . c o m*/ try { URL url = new URL("https://www.googleapis.com/gmail/v1/users/" + userId + "/profile"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //credential.refreshToken(); connection.setRequestProperty("Authorization", "Bearer " + credential.getAccessToken()); connection.setRequestProperty("Content-Type", "application/json"); if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { // OK BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); StringBuffer res = new StringBuffer(); String line; while ((line = reader.readLine()) != null) { res.append(line); logger.warning(line); } reader.close(); JSONObject jsonObj = new JSONObject(res); historyId = BigInteger.valueOf(jsonObj.getLong("historyId")); } else { // Server returned HTTP error code. logger.warning("failed : " + connection.getResponseCode()); BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream())); String error = ""; String text; while ((text = br.readLine()) != null) { error += text; } logger.warning("error : " + error); } } catch (Exception e) { logger.warning("exception : " + e.getMessage() + " , " + e.getStackTrace().toString()); } return historyId; }
From source file:eu.abc4trust.abce.pertubationtests.tud.section2.PA_II_2_2_1malformedCEuri.java
public void runTest(int key, URI engineURI) throws Exception { logger.info(testName + " PA Flow: Running test with security parameter: " + key + " and engine URI: " + engineURI.toString());//ww w. ja v a 2s . c o m SystemParameters sysParams = null; IssuerParameters ip = null; boolean testSuccess = false; logger.info(" Trying to create system parameters"); try { Injector revocationInjector = Guice .createInjector(IntegrationModuleFactory.newModule(new Random(1231))); RevocationProxyAuthority revocationProxyAuthority = revocationInjector .getInstance(RevocationProxyAuthority.class); issuerInjector = Guice .createInjector(IntegrationModuleFactory.newModule(new Random(1231), revocationProxyAuthority)); issuerEngine = issuerInjector.getInstance(IssuerAbcEngine.class); sysParams = SystemParametersUtil.getDefaultSystemParameters_1024(); issuerInjector.getInstance(KeyManager.class).storeSystemParameters(sysParams); userInjector.getInstance(KeyManager.class).storeSystemParameters(sysParams); verifierInjector.getInstance(KeyManager.class).storeSystemParameters(sysParams); } catch (Exception e) { logger.log(Level.SEVERE, " Failed to create SystemParameters : " + e.getMessage() + "\n StackTreacs: " + Arrays.toString(e.getStackTrace())); testSuccess = true; } if (!testSuccess) {//No failure so far if (sysParams == null) { logger.info("TEST FAIL !!! System parameters NULL!!! NO EXCEPTION !!! TEST FAIL !!!"); testSuccess = false; assertTrue(false); } else { logger.info(" System parameters created successfully"); logger.info(" Trying to create IssuerParameters"); try { ip = issuerEngine.setupIssuerParameters(idcardCredSpec, sysParams, uid, hash, algorithmId, revParsUid, null); } catch (Exception e) { logger.log(Level.SEVERE, " Failed to create IssuerParameters: " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); testSuccess = true; } } } if (!testSuccess) {//No failure so far if (ip == null) { logger.info("TEST FAIL !!! Issuer parameters NULL!!! NO EXCEPTION !!! TEST FAIL !!!"); testSuccess = false; assertTrue(false); } else { logger.info(" Issuer parameters created successfully"); } } if (!testSuccess) {//No failure so far boolean idCardIssued = true; if (!testSuccess) {//No failure so far logger.info(" Trying to issue ID Card"); try { issueIDCard(ip); logger.info("Used IssuerParameters to issue a credential"); } catch (Exception e) { logger.log(Level.SEVERE, " Failed to issue credential : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); idCardIssued = false; } } if (idCardIssued) {//Immediate test failure logger.info("PA FLOW TEST FAIL !!! ID CARD ISSUED USING PERTUBATED DATA!!! TEST FAIL !!!"); assertTrue(false); } boolean presentIDCard = true; if (!testSuccess) {//No failure so far logger.info(" Trying to issue Presentation Token"); PresentationToken pt = null; try { pt = createPresentationToken(); } catch (Exception e) { logger.log(Level.SEVERE, "Failed to create presentation token : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); presentIDCard = false; } if (presentIDCard) {//token created without exception if (pt == null) {// token not created, no exception => test fail logger.info( "PA FLOW TEST FAIL !!! Presentation Token NULL!!! NO EXCEPTION !!! TEST FAIL !!!"); assertTrue(false); } logger.info(" Presentation Token Created"); logger.info(" Trying to Verify Presentation Token"); PresentationTokenDescription ptd = null; try { ptd = verifyPresentationToken(pt); } catch (Exception e) { logger.log(Level.SEVERE, "Failed to verify presentation token : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); presentIDCard = false; } if (presentIDCard) {//token description created without exception if (ptd == null) {// token description not created, no exception => test fail logger.info( "PA FLOW TEST FAIL !!! Presentation Token Description NULL!!! NO EXCEPTION !!! TEST FAIL !!!"); assertTrue(false); } logger.info(" Succesfully verified presentation token"); } } } if (presentIDCard) {//Immediate test failure logger.info( "PA FLOW TEST FAIL !!! PRESENTATION TOKEN FOR ID CARD CREATED AND VERIFIED USING PERTUBATED DATA!!! TEST FAIL !!!"); assertTrue(false); } if (!presentIDCard && !idCardIssued) { testSuccess = true; logger.info("Failed to issue Id card and create presentation token"); } } //Test evaluation if (!testSuccess) { logger.info("PA FLOW TEST FAIL !!! NO EXCEPTION !!! TEST FAIL !!!"); assertTrue(false); } else { logger.info("PA FLOW TEST SUCCESSFULL !!! EXCEPTION HANDLED !!! TEST SUCCESSFULL !!!"); assertTrue(true); } }
From source file:gov.nih.nci.cabig.caaers.resolver.BaseResolver.java
/** * Gets the correlation nodes from payload xml. * //w ww. j a va 2s.co m * @param correlationNodeXmlPayload the correlation node xml payload * @return the correlation nodes from payload xml */ public List<CorrelationNode> getCorrelationNodesFromPayloadXml(String correlationNodeXmlPayload) { String correlationNodeArrayXml = ""; try { correlationNodeArrayXml = broadcastSearchCorrelationsWithEntities(correlationNodeXmlPayload, true, true); //System.out.println(correlationNodeArrayXml); } catch (Exception e) { log.error(e.getStackTrace()); } List<String> correlationNodes = XMLUtil.getObjectsFromCoppaResponse(correlationNodeArrayXml); List<CorrelationNode> correlationNodeList = new ArrayList<CorrelationNode>(); //creating a list of correlationNodes for (String correlationNode : correlationNodes) { correlationNodeList.add(CoppaObjectFactory.getCorrelationNodeObjectFromXml(correlationNode)); } return correlationNodeList; }
From source file:net.sf.l2j.gameserver.model.entity.L2JOneoRusEvents.FortressSiege.java
public static void spawnFlag() { L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(getRandomFlagId()); try {//from w w w . jav a 2s. co m _flagSpawn = new L2Spawn(tmpl); _flagSpawn.setLocx(_flagX); _flagSpawn.setLocy(_flagY); _flagSpawn.setLocz(_flagZ); _flagSpawn.setAmount(1); _flagSpawn.setHeading(0); _flagSpawn.setRespawnDelay(1); SpawnTable.getInstance().addNewSpawn(_flagSpawn, false); _flagSpawn.init(); _flagSpawn.getLastSpawn().getStatus().setCurrentHp(999999999); _flagSpawn.getLastSpawn().setTitle(_eventName); _flagSpawn.getLastSpawn().decayMe(); _flagSpawn.getLastSpawn().spawnMe(_flagSpawn.getLastSpawn().getX(), _flagSpawn.getLastSpawn().getY(), _flagSpawn.getLastSpawn().getZ()); _flagSpawn.getLastSpawn()._isFOS_Artifact = true; } catch (Exception e) { _log.error("Fortress Siege Engine[spawnAllFlags()]: exception: " + e.getStackTrace()); } }
From source file:eu.abc4trust.abce.pertubationtests.tud.section2.PA_II_2_2_7randomUID.java
public void runTest(URI uid) throws Exception { testName = "2.2.4-randomUidTest "; exceptionHandled = false;/*from w w w. jav a2 s . c o m*/ try { logger.info(testName + ": Running test with UID: " + uid.toString()); RevocationAbcEngine revocationEngine = revocationInjector.getInstance(RevocationAbcEngine.class); Reference revocationInfoReference = new Reference(); revocationInfoReference.setReferenceType(URI.create("https")); revocationInfoReference.getReferences().add(URI.create("https://example.org")); Reference nonRevocationEvidenceReference = new Reference(); nonRevocationEvidenceReference.setReferenceType(URI.create("https")); nonRevocationEvidenceReference.getReferences().add(URI.create("https://example.org")); Reference nonRrevocationUpdateReference = new Reference(); nonRrevocationUpdateReference.setReferenceType(URI.create("https")); nonRrevocationUpdateReference.getReferences().add(URI.create("https://example.org")); logger.info(testName + ": Trying to create revocation authority parameters"); RevocationAuthorityParameters revocationAuthorityParameters = null; try { revocationAuthorityParameters = revocationEngine.setupRevocationAuthorityParameters(1024, algorithmId, uid, revocationInfoReference, nonRevocationEvidenceReference, nonRrevocationUpdateReference); assertNotNull(revocationAuthorityParameters); logger.info(testName + ": Succesfully produced parameters, now trying to create IssuerParameters"); issuerInjector.getInstance(KeyManager.class).storeRevocationAuthorityParameters(revParsUid, revocationAuthorityParameters); userInjector.getInstance(KeyManager.class).storeRevocationAuthorityParameters(revParsUid, revocationAuthorityParameters); verifierInjector.getInstance(KeyManager.class).storeRevocationAuthorityParameters(revParsUid, revocationAuthorityParameters); } catch (Exception e) { logger.log(Level.SEVERE, testName + ": Failed to create revocation authority parameters : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); exceptionHandled = true; } IssuerParameters ip = null; if (!exceptionHandled) { try { ip = issuerEngine.setupIssuerParameters(idcardCredSpec, syspars, uid, hash, algorithmId, revParsUid, null); assertNotNull(ip); } catch (Exception e) { logger.log(Level.SEVERE, testName + ": Failed to create IssuerParameters : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); //logger.info(testName+": Failed to create IssuerParameters"); //assertTrue(false); exceptionHandled = true; } } if (!exceptionHandled) issueIDCard(ip); if (!exceptionHandled) presentIDCard(); if (!exceptionHandled) logger.info( testName + ": Used Revocation AuthorityParameters to create a valid presentation token"); } catch (Exception e) { logger.log(Level.SEVERE, testName + ": Test Failed due to unexpected exception : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); logger.info(e.getMessage()); Assert.fail(e.getMessage()); } if (!exceptionHandled) { logger.info("Test" + testName + "has failed!!! NO EXCEPTION !!!"); //fail("Test"+ testName + "has failed!!! "); } else { logger.info("Test" + testName + "has been successful!!! "); //assertTrue(false); } }
From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertMenuAxisTreeDTO.java
@Transactional(rollbackFor = Exception.class) public int convertMenuTree(Date date, ADSMSchedulerLogDTO schedulerLog, ADSMJobNameType srcJopType, String treeName, String publisher, Platform platformType) throws Exception { if (schedulerLog == null) { throw new CiRuntimeException("ADSMSchedulerLog is null"); }/* w w w .j a v a 2 s. c om*/ if (treeName == null || treeName.isEmpty()) { throw new CiRuntimeException("Cannot find treeName in generating MenuTree"); } long start = System.currentTimeMillis(); log.info("TreeName : " + treeName + ", srcDataType : " + srcJopType + ". Start Update(" + schedulerLog.getParam() + ")"); int treeID = 0; try { //?, , , ? //tambourineConnector.initializeInventoryCube(date); NodeDTO rootNodeDTO = getRootNode(); if (rootNodeDTO == null) { throw new CiRuntimeException( "Fail to Update Menu Tree (Cannot Check root node Info. " + schedulerLog.getParam() + ")"); } treeID = tambourineConnector.getAxisTreeId(TreeType.MENU_AXIS_TREE, treeName, publisher, platformType, false); //? if (treeID <= 0) treeID = tambourineConnector.registerAxisTree(getAxisTreeDTO(Constants.tree.MENU_TREE_NAME, rootNodeDTO, false, treeID, publisher, platformType), date, TreeType.MENU_AXIS_TREE); makeTreeNode(treeID, date, rootNodeDTO.getExternalNodeId()); insertTreeLogNSyncNoticeboard(null, treeID, treeName, platformType); // ? schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); schedulerLog.setMessage(TREE_NAME_MESSAGE_PREFIX + treeName); } catch (Exception e) { long end = System.currentTimeMillis(); TheLogger.getWriter().error("Fail to Update Menu Tree"); log.error("Fail to update Menu Tree.(" + schedulerLog.getParam() + ") - T(" + (end - start) + ")"); schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { schedulerLog.setFailProcess(stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"); } throw e; } long end = System.currentTimeMillis(); log.info("Complete to Update Menu Tree (" + schedulerLog.getParam() + ") - T(" + (end - start) + ")"); TheLogger.getWriter().info("Complete to Update Menu Tree(" + schedulerLog.getParam() + ")"); return treeID; }
From source file:ca.ualberta.cs.c301_crowdclient.CrowdClient.java
private CrowdSourcerEntry updateEntry() throws Exception { HttpResponse response = httpclient.execute(httpPost); String status = response.getStatusLine().toString(); System.out.println(status);/*from w w w . jav a2 s .co m*/ HttpEntity entity = response.getEntity(); CrowdSourcerEntry updatedEntry = null; if (entity != null) { InputStream is = entity.getContent(); String jsonStringVersion = convertStreamToString(is); Type entryType = CrowdSourcerEntry.class; try { updatedEntry = gson.fromJson(jsonStringVersion, entryType); } catch (Exception e) { Exception myException = new Exception("There was an error " + "getting the entry from JSON. Here is the " + "httpPost entity content: " + convertStreamToString(httpPost.getEntity().getContent()) + "\n" + "CrowdSource response:\n" + jsonStringVersion); myException.setStackTrace(e.getStackTrace()); throw myException; } } entity.consumeContent(); return updatedEntry; }