List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:org.cagrid.identifiers.namingauthority.NamingAuthorityTestCase.java
@Test public void testRegisterSite() { SecurityInfo secInfo = new SecurityInfoImpl("User2"); try {/*from ww w.java 2s .co m*/ this.NamingAuthority.registerSite(secInfo, "a", "a", "1.0", "srikalyan", "srikalyan@semanticbits.com", "443", "SB"); LOG.info("passed registerSite for " + secInfo.getUser() + "."); } catch (Exception e) { fail("test registeSite for " + secInfo.getUser() + ". MSG: \"" + e.getMessage() + "\""); e.getStackTrace(); } try { this.NamingAuthority.registerSite(secInfo, "a1", "a1", "1.01", "srikalyan1", "srikalyan1@semanticbits.com", "4431", "SB"); fail("test registeSite for user " + secInfo.getUser() + "."); } catch (Exception e) { LOG.info("passed registerSite for " + secInfo.getUser() + " for registiering again. MSG: \"" + e.getMessage() + "\""); } }
From source file:gov.llnl.lc.smt.command.privileged.SmtPrivileged.java
/** * Describe the method here/*from ww w. j a v a 2s. com*/ * * @see gov.llnl.lc.smt.command.SmtCommand#doCommand(gov.llnl.lc.smt.command.config.SmtConfig) * * @param config * @return * @throws Exception ***********************************************************/ @Override public boolean doCommand(SmtConfig config) throws Exception { OsmService = OsmServiceManager.getInstance(); OsmAdminApi adminInterface = null; String subCommand = null; CommandLineResults results = null; if (config != null) { // open a session for the command Map<String, String> map = config.getConfigMap(); String hostNam = map.get(SmtProperty.SMT_HOST.getName()); String portNum = map.get(SmtProperty.SMT_PORT.getName()); try { ParentSession = OsmService.openSession(hostNam, portNum, null, null); adminInterface = ParentSession.getAdminApi(); } catch (Exception e) { logger.severe(e.getStackTrace().toString()); System.exit(0); } subCommand = map.get(SmtProperty.SMT_SUBCOMMAND.getName()); if (subCommand == null) subCommand = SmtProperty.SMT_HELP.getName(); // there should only be one subcommand if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_EXT.getName())) { String cmdArgs = getCommandArgs(map); System.err.println("The command (" + cmdArgs + ")"); results = adminInterface.invokePrivilegedCommand(new CommandLineArguments(cmdArgs)); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_ENABLE.getName())) { String portid = getPortIdentification(map); results = ibportstate(portid + " enable"); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_DISABLE.getName())) { String portid = getPortIdentification(map); results = ibportstate(portid + " disable"); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_QUERY_PORT.getName())) { String portid = getPortIdentification(map); results = ibportstate(portid); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_UPDATE_DESC.getName())) { results = adminInterface.invokePrivilegedCommand( new CommandLineArguments(OsmNativeCommand.OSM_NATIVE_UPDATE_DESC.getCommandName())); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_REROUTE.getName())) { results = adminInterface.invokePrivilegedCommand( new CommandLineArguments(OsmNativeCommand.OSM_NATIVE_REROUTE.getCommandName())); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_PM_CLEAR.getName())) { results = adminInterface.invokePrivilegedCommand( new CommandLineArguments(OsmNativeCommand.OSM_NATIVE_PCLEAR.getCommandName())); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_LT_SWEEP.getName())) { results = adminInterface.invokePrivilegedCommand( new CommandLineArguments(OsmNativeCommand.OSM_NATIVE_LSWEEP.getCommandName())); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_HV_SWEEP.getName())) { results = adminInterface.invokePrivilegedCommand( new CommandLineArguments(OsmNativeCommand.OSM_NATIVE_HSWEEP.getCommandName())); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_PM_SWEEP.getName())) { results = adminInterface.invokePrivilegedCommand( new CommandLineArguments(OsmNativeCommand.OSM_NATIVE_PSWEEP.getCommandName())); } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_OSM_LOG_LEVEL.getName())) { SmtProperty sc = SmtProperty.getByName(subCommand); // now use that property to find the sub commands argument if (sc != null) { String subCommandArg = map.get(sc.getName()); if (subCommandArg != null) { // needs to be in hex format, with 0x out front results = adminInterface.invokePrivilegedCommand(new CommandLineArguments( OsmNativeCommand.OSM_NATIVE_LOGLEVEL.getCommandName() + " " + subCommandArg)); } System.err.println("The subcommand and args are: " + subCommand + ", " + subCommandArg); } } else if (subCommand.equalsIgnoreCase(SmtProperty.SMT_PRIV_PM_SWEEP_PERIOD.getName())) { SmtProperty sc = SmtProperty.getByName(subCommand); // now use that property to find the sub commands argument if (sc != null) { String subCommandArg = map.get(sc.getName()); if (subCommandArg != null) { // needs to be in seconds results = adminInterface.invokePrivilegedCommand(new CommandLineArguments( OsmNativeCommand.OSM_NATIVE_PPERIOD.getCommandName() + " " + subCommandArg)); } System.err.println("The subcommand and args are: " + subCommand + ", " + subCommandArg); } } else { System.err.println("A priv command: " + subCommand + " was NOT handled"); } if (results == null) { System.out.println("Privileged command denied"); return false; } // show the results (color the System.err RED) if ((results.getOutput() != null) && (results.getOutput().length() > 1)) System.out.println(results.getOutput()); if ((results.getError() != null) && (results.getError().length() > 1)) { Console.textNormal(); Console.textColor(Console.ConsoleColor.red); System.out.println(results.getError()); } Console.textNormal(); Console.backgroundNormal(); return true; } return false; }
From source file:eu.abc4trust.abce.pertubationtests.tud.section2.PA_II_2_2_7randomUID.java
private void issueIDCard(IssuerParameters ip) throws Exception { KeyManager userKeyManager = userInjector.getInstance(KeyManager.class); KeyManager issuerKeyManager = issuerInjector.getInstance(KeyManager.class); KeyManager verifierKeyManager = verifierInjector.getInstance(KeyManager.class); IssuancePolicy idcardIssuancePolicy = (IssuancePolicy) XmlUtils .getObjectFromXML(this.getClass().getResourceAsStream(ISSUANCE_POLICY_ID_CARD), true); URI idcardIssuancePolicyUid = idcardIssuancePolicy.getCredentialTemplate().getIssuerParametersUID(); userKeyManager.storeIssuerParameters(idcardIssuancePolicyUid, ip); issuerKeyManager.storeIssuerParameters(idcardIssuancePolicyUid, ip); verifierKeyManager.storeIssuerParameters(idcardIssuancePolicyUid, ip); IssuanceHelper issuanceHelper = new IssuanceHelper(); try {/*from w w w .ja v a 2 s . c om*/ issueAndStoreIdcard(issuerInjector, userInjector, issuanceHelper, CREDENTIAL_SPECIFICATION_ID_CARD); logger.info(testName + ": Managed to issue a credential"); } catch (Exception e) { logger.log(Level.SEVERE, testName + ": Failed to issue credential : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); exceptionHandled = true; //e.printStackTrace(); //logger.info(testName+": Failed to issue credential : "+e.getMessage()); //Assert.fail(e.toString()); } }
From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertInventoryBox.java
@SuppressWarnings("finally") public int generateInventoryBox(InventoryBoxDTO inventoryBox, ADSMSchedulerLogDTO schedulerLog, String fileResDirectory) { int resultCount = 0; try {/*www .jav a2s . co m*/ if (inventoryBox != null) { tambourineConnector.insertInventoryBox(inventoryBox, schedulerLog); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); resultCount = errorCount; } else { schedulerLog.setFailProcess("Parsing error"); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); errorCount = -1; //Parsing error resultCount = -1; } } catch (Exception e) { //log.error("",e); 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() + ")"); } } finally { inventoryResult = new ResultInventory(); if (inventoryBox != null) { inventoryResult.setStart_DT(inventoryBox.getStart_DT()); inventoryResult.setEnd_DT(inventoryBox.getEnd_DT()); inventoryResult.setInventoryVer(inventoryBox.getInventoryVer()); } generateResult(fileResDirectory, inventoryResult, errorCount); return resultCount; } }
From source file:org.apache.lucene.gdata.server.GDataService.java
/** * @see org.apache.lucene.gdata.server.Service#createEntry(org.apache.lucene.gdata.server.GDataRequest, * org.apache.lucene.gdata.server.GDataResponse) *//* ww w .j a va2 s . c o m*/ public BaseEntry createEntry(GDataRequest request, GDataResponse response) throws ServiceException { if (LOG.isInfoEnabled()) LOG.info("create Entry for feedId: " + request.getFeedId()); ServerBaseEntry entry = buildEntry(request, response); entry.setFeedId(request.getFeedId()); entry.setServiceConfig(request.getConfigurator()); BaseEntry tempEntry = entry.getEntry(); tempEntry.setPublished(getCurrentDateTime()); tempEntry.setUpdated(getCurrentDateTime()); BaseEntry retVal = null; removeDynamicElements(entry.getEntry()); try { retVal = this.storage.storeEntry(entry); } catch (Exception e) { ServiceException ex = new ServiceException("Could not store entry", e, GDataResponse.SERVER_ERROR); ex.setStackTrace(e.getStackTrace()); throw ex; } this.entryEventMediator.entryAdded(entry); return retVal; }
From source file:com.mondora.chargify.controller.ChargifyAdapter.java
protected String handleResponseCode(HttpResponse response, HttpRequestBase method) throws ChargifyException { StatusLine line = response.getStatusLine(); String errorMsg = method.getMethod() + " " + String.valueOf(method.getURI()) + " Error " + String.valueOf(line.getStatusCode()) + " " + line.getReasonPhrase(); int code = line.getStatusCode(); if (isError(code)) { try {/*from w ww .jav a 2 s . c om*/ Errors error = (Errors) parse(Errors.class, response, method); if (error != null) { errorMsg = String.valueOf(error) + ". Method " + errorMsg; } } catch (Exception ex) { errorMsg += " " + ex.getMessage() + " " + ex.getStackTrace()[0]; } } return handleResponse(code, errorMsg); }
From source file:my.madet.uniteninfo.OpenVPN.java
public void onSubscribed() { SharedPreferences.Editor editor = sharedPref.edit(); Log.d("oncreate", "enter subscribed"); try {/*from w ww. j a v a 2 s. com*/ if (isSubscribed) { manageSubscriptionButton.setVisibility(View.VISIBLE); subscribeButton.setVisibility(View.GONE); // check if connected to myvpn if (sharedPref.getString("myvpn_user_name", "").equals("")) { linkAccountTextView.setVisibility(View.VISIBLE); linkAccountUserNameEditText.setVisibility(View.VISIBLE); linkAccountPasswordEditText.setVisibility(View.VISIBLE); linkAccountConnectButton.setVisibility(View.VISIBLE); linkAccountConnectButton .setOnClickListener(new LinkAccountButtonClicked(rootView.getContext())); } } else { editor.putString("purchaseData", ""); editor.putString("dataSignature", ""); editor.putString("myvpn_user_name", ""); editor.commit(); manageSubscriptionButton.setVisibility(View.GONE); subscribeButton.setVisibility(View.VISIBLE); } } catch (Exception e) { Log.e("onSubscribed", "Exception: " + e.getStackTrace()); } }
From source file:frame.crawler4j.crawler.WebCrawler.java
private void processPage(WebURL curURL) { if (curURL == null) { return;/*from ww w. j a va2 s. c o m*/ } PageFetchResult fetchResult = null; try { fetchResult = pageFetcher.fetchHeader(curURL); int statusCode = fetchResult.getStatusCode(); handlePageStatusCode(curURL, statusCode, CustomFetchStatus.getStatusDescription(statusCode)); if (statusCode != HttpStatus.SC_OK) { if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) { if (myController.getConfig().isFollowRedirects()) { String movedToUrl = fetchResult.getMovedToUrl(); if (movedToUrl == null) { return; } int newDocId = docIdServer.getDocId(movedToUrl); if (newDocId > 0) { // Redirect page is already seen return; } WebURL webURL = new WebURL(); webURL.setURL(movedToUrl); webURL.setParentDocid(curURL.getParentDocid()); webURL.setParentUrl(curURL.getParentUrl()); webURL.setDepth(curURL.getDepth()); webURL.setDocid(-1); webURL.setAnchor(curURL.getAnchor()); if (shouldVisit(webURL) && robotstxtServer.allows(webURL)) { webURL.setDocid(docIdServer.getNewDocID(movedToUrl)); frontier.schedule(webURL); } } } else if (fetchResult.getStatusCode() == CustomFetchStatus.PageTooBig) { logger.info("Skipping a page which was bigger than max allowed size: " + curURL.getURL()); } return; } if (!curURL.getURL().equals(fetchResult.getFetchedUrl())) { if (docIdServer.isSeenBefore(fetchResult.getFetchedUrl())) { // Redirect page is already seen return; } curURL.setURL(fetchResult.getFetchedUrl()); curURL.setDocid(docIdServer.getNewDocID(fetchResult.getFetchedUrl())); } Page page = new Page(curURL); int docid = curURL.getDocid(); if (!fetchResult.fetchContent(page)) { onContentFetchError(curURL); return; } if (!parser.parse(page, curURL.getURL())) { onParseError(curURL); return; } ParseData parseData = page.getParseData(); if (parseData instanceof HtmlParseData) { HtmlParseData htmlParseData = (HtmlParseData) parseData; List<WebURL> toSchedule = new ArrayList<WebURL>(); int maxCrawlDepth = myController.getConfig().getMaxDepthOfCrawling(); for (WebURL webURL : htmlParseData.getOutgoingUrls()) { webURL.setParentDocid(docid); webURL.setParentUrl(curURL.getURL()); int newdocid = docIdServer.getDocId(webURL.getURL()); if (newdocid > 0) { // This is not the first time that this Url is // visited. So, we set the depth to a negative // number. webURL.setDepth((short) -1); webURL.setDocid(newdocid); } else { webURL.setDocid(-1); webURL.setDepth((short) (curURL.getDepth() + 1)); if (maxCrawlDepth == -1 || curURL.getDepth() < maxCrawlDepth) { if (shouldVisit(webURL) && robotstxtServer.allows(webURL)) { webURL.setDocid(docIdServer.getNewDocID(webURL.getURL())); toSchedule.add(webURL); } } } } frontier.scheduleAll(toSchedule); } try { visit(page); } catch (Exception e) { logger.error("Exception while running the visit method. Message: '" + e.getMessage() + "' at " + e.getStackTrace()[0]); } } catch (Exception e) { logger.error(e.getMessage() + ", while processing: " + curURL.getURL()); } finally { if (fetchResult != null) { fetchResult.discardContentIfNotConsumed(); } } }
From source file:ai.h2o.servicebuilder.CompilePojoServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { File tmp = null;/*from w w w . j a v a2 s .c o m*/ try { //create temp directory tmp = createTempDirectory("compilePojo"); logger.info("tmp dir {}", tmp); // get input files List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); List<String> pojofiles = new ArrayList<String>(); String jarfile = null; for (FileItem i : items) { String field = i.getFieldName(); String filename = i.getName(); if (filename != null && filename.length() > 0) { if (field.equals("pojo")) { pojofiles.add(filename); } if (field.equals("jar")) { jarfile = filename; } FileUtils.copyInputStreamToFile(i.getInputStream(), new File(tmp, filename)); } } if (pojofiles.isEmpty() || jarfile == null) throw new Exception("need pojofile(s) and jarfile"); // create output directory File out = new File(tmp.getPath(), "out"); boolean mkDirResult = out.mkdir(); if (!mkDirResult) throw new Exception("Can't create output directory (out)"); if (servletPath == null) throw new Exception("servletPath is null"); copyExtraFile(servletPath, "extra" + File.separator, tmp, "H2OPredictor.java", "H2OPredictor.java"); FileUtils.copyDirectoryToDirectory( new File(servletPath, "extra" + File.separator + "WEB-INF" + File.separator + "lib"), tmp); copyExtraFile(servletPath, "extra" + File.separator, new File(out, "META-INF"), "MANIFEST.txt", "MANIFEST.txt"); // Compile the pojo(s) for (String pojofile : pojofiles) { runCmd(tmp, Arrays.asList("javac", "-target", JAVA_TARGET_VERSION, "-source", JAVA_TARGET_VERSION, "-J-Xmx" + MEMORY_FOR_JAVA_PROCESSES, "-cp", jarfile + ":lib/*", "-d", "out", pojofile, "H2OPredictor.java"), "Compilation of pojo failed: " + pojofile); } // create jar result file runCmd(out, Arrays.asList("jar", "xf", tmp + File.separator + jarfile), "jar extraction of h2o-genmodel failed"); runCmd(out, Arrays.asList("jar", "xf", tmp + File.separator + "lib" + File.separator + "gson-2.6.2.jar"), "jar extraction of gson failed"); runCmd(out, Arrays.asList("jar", "cfm", tmp + File.separator + "result.jar", "META-INF" + File.separator + "MANIFEST.txt", "."), "jar creation failed"); byte[] resjar = IOUtils.toByteArray(new FileInputStream(tmp + File.separator + "result.jar")); if (resjar == null) throw new Exception("Can't create jar of compiler output"); logger.info("jar created, size {}", resjar.length); // send jar back ServletOutputStream sout = response.getOutputStream(); response.setContentType("application/octet-stream"); String outputFilename = pojofiles.get(0).replace(".java", ""); response.setHeader("Content-disposition", "attachment; filename=" + outputFilename + ".jar"); response.setContentLength(resjar.length); sout.write(resjar); sout.close(); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception e) { logger.error("post failed", e); // send the error message back String message = e.getMessage(); if (message == null) message = "no message"; logger.error(message); response.getWriter().write(message); response.getWriter().write(Arrays.toString(e.getStackTrace())); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } finally { // if the temp directory is still there we delete it try { if (tmp != null && tmp.exists()) FileUtils.deleteDirectory(tmp); } catch (IOException e) { logger.error("Can't delete tmp directory"); } } }
From source file:eu.abc4trust.abce.pertubationtests.tud.section2.PA_II_2_2_7randomUID.java
private void presentIDCard() throws Exception { UserAbcEngine userEngine = userInjector.getInstance(UserAbcEngine.class); VerifierAbcEngine verifierEngine = verifierInjector.getInstance(VerifierAbcEngine.class); InputStream resourceAsStream = this.getClass().getResourceAsStream(PRESENTATION_POLICY_ID_CARD); PresentationPolicyAlternatives presentationPolicyAlternatives = (PresentationPolicyAlternatives) XmlUtils .getObjectFromXML(resourceAsStream, true); RevocationInformation ri = verifierEngine.getLatestRevocationInformation(revParsUid); userInjector.getInstance(KeyManager.class).storeRevocationInformation(ri.getRevocationInformationUID(), ri); presentationPolicyAlternatives.getPresentationPolicy().get(0).getCredential().get(0).getIssuerAlternatives() .getIssuerParametersUID().get(0).setRevocationInformationUID(ri.getRevocationInformationUID()); PresentationToken pt = null;/*from w w w . ja v a 2s. c om*/ try { pt = userEngine.createPresentationTokenFirstChoice(USERNAME, presentationPolicyAlternatives); if (pt == null) { logger.info(testName + ": Failed to create presentation token"); } assertNotNull(pt); logger.info(testName + ": Successfully created a presentation token"); } catch (Exception e) { logger.log(Level.SEVERE, testName + ": Failed to create presentation tokenen : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); exceptionHandled = true; //logger.info(testName+": Failed to create presentation token : "+e.toString()+": "+e.getMessage()); //Assert.fail(e.toString()); } try { PresentationTokenDescription ptd = verifierEngine .verifyTokenAgainstPolicy(presentationPolicyAlternatives, pt, false); if (ptd == null) { logger.info(testName + ": Failed to verify presentation token"); } assertNotNull(ptd); logger.info(testName + ": Succesfully verified presentation token"); } catch (Exception e) { logger.log(Level.SEVERE, testName + ": Failed to verify presentation token : " + e.getMessage() + "\n StackTrace: " + Arrays.toString(e.getStackTrace())); exceptionHandled = true; //logger.info(testName+": Failed to verify presentation token : "+e.toString()+": "+e.getMessage()); //Assert.fail(e.toString()); } }