List of usage examples for java.io IOException getStackTrace
public StackTraceElement[] getStackTrace()
From source file:org.apache.taverna.security.credentialmanager.impl.CredentialManagerImplTest.java
@After // Clean up the credentialManagerDirectory we created for testing public void cleanUp() { // assertTrue(credentialManagerDirectory.exists()); // assertFalse(credentialManagerDirectory.listFiles().length == 0); // something was created there if (credentialManagerDirectory.exists()) { try {//from w ww . j a va 2 s .co m FileUtils.deleteDirectory(credentialManagerDirectory); System.out.println( "Deleting Credential Manager's directory: " + credentialManagerDirectory.getAbsolutePath()); } catch (IOException e) { System.out.println(e.getStackTrace()); } } }
From source file:org.cvrgrid.waveform.WaveformGlobusConnect.java
/** * Private API that activates an endpoint for the transfer. *//*from w ww.java2 s. c o m*/ private Status activateEP(GlobusConnectConfiguration globusConnectConfiguration, String EpUsername, String EpPassword, String endpoint) { String myProxy = globusConnectConfiguration.getDestinationMyProxy(); System.out.println("Activating Endpoint: " + endpoint); try { JSONTransferAPIClient client = globusConnectConfiguration.getClient(); org.globusonline.transfer.Example GOClient = new Example(client); if (EpUsername == null || EpUsername == "") { System.out.println( "EP username and password is null. Attempting Autoactivations without username/passwd."); if (!GOClient.autoActivate(endpoint)) { System.err.println("Unable to auto activate GO endpoint : " + endpoint); return Status.FAIL; } } else { if (myproxyActivateEP(client, EpUsername, EpPassword, endpoint, myProxy).equals(Status.FAIL)) { System.err.println("Unable to activate GO endpoint : " + endpoint); return Status.FAIL; } } return Status.OK; } catch (IOException e) { System.err.println("Got an IO exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } catch (JSONException e) { System.err.println("Got an JSON exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } catch (GeneralSecurityException e) { System.err.println("Got an Security exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } catch (APIError e) { System.err.println("Got an APIError exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } }
From source file:org.cvrgrid.waveform.WaveformGlobusConnect.java
private Status myproxyActivateEP(JSONTransferAPIClient client, String myproxyUsername, String myproxyPassphrase, String endpointName, String myproxyHostname) { System.out.println("Activating Endpoint using myproxy: " + endpointName); try {//from ww w .java2s .co m String url = client.endpointPath(endpointName) + "/activation_requirements"; JSONTransferAPIClient.Result r = client.getResult(url); // Go through requirements and find the myproxy type, then fill // in with the values from the function^Wmethod parameters. System.out.println("Endpoint activated:" + r.document.getString("activated")); JSONArray reqsArray = r.document.getJSONArray("DATA"); for (int i = 0; i < reqsArray.length(); i++) { JSONObject reqObject = reqsArray.getJSONObject(i); if (reqObject.getString("type").equals("myproxy")) { String name = reqObject.getString("name"); if (name.equals("hostname")) { reqObject.put("value", myproxyHostname); } else if (name.equals("username")) { reqObject.put("value", myproxyUsername); } else if (name.equals("passphrase")) { reqObject.put("value", myproxyPassphrase); } // optional arguments are 'server_dn', required if the hostname // does not match the DN in the server's certificate, and // 'lifetime_in_hours', to ask for a specific lifetime rather // than accepting the server default. // See also: // https://transfer.api.globusonline.org/v0.10/document_type/activation_requirements/example?format=json } } url = client.endpointPath(endpointName) + "/activate"; r = client.postResult(url, r.document); // return r; yge: should check on r to determine what to return if (r.statusCode >= 400) { System.err.println("Returned statusCode >=400 : " + r.statusCode + "\n"); return Status.FAIL; } return Status.OK; } catch (IOException e) { System.err.println("Got an IO exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } catch (JSONException e) { System.err.println("Got an JSON exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } catch (GeneralSecurityException e) { System.err.println("Got an Security exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } catch (APIError e) { System.err.println("Got an APIError exception..\n"); System.err.println(e.getMessage()); System.err.println(e.getStackTrace().toString()); e.printStackTrace(); return Status.FAIL; } }
From source file:com.spinn3r.api.BaseClient.java
protected URLConnection getConnection(String resource) throws IOException { URLConnection conn = null;/*w w w . j a v a 2 s .c o m*/ try { // create the HTTP connection. URL request = new URL(resource); conn = request.openConnection(); // set the UserAgent so Spinn3r know which client lib is calling. conn.setRequestProperty(USER_AGENT_HEADER, USER_AGENT + "; " + getConfig().getCommandLine()); conn.setRequestProperty(ACCEPT_ENCODING_HEADER, GZIP_ENCODING); conn.setConnectTimeout(20000); conn.connect(); } catch (IOException ioe) { //create a custom exception message with the right error. String message = conn.getHeaderField(null); IOException ce = new IOException(message); ce.setStackTrace(ioe.getStackTrace()); throw ce; } return conn; }
From source file:org.vpac.web.controller.DataController.java
@RequestMapping(value = "/Plot", method = RequestMethod.GET) public ModelAndView plot(@RequestParam(required = true) String datasetId, @RequestParam(required = false) String bandName, @RequestParam(required = true) double x, @RequestParam(required = true) double y, @RequestParam(required = false) Date start, @RequestParam(required = false) Date end, @RequestParam(required = false) boolean omitNodata, Model model) throws IOException, InvalidRangeException, QueryConfigurationException { Dataset ds = null;//from ww w .j av a 2s .co m if (datasetId.contains("/")) { String[] splittedDatasetId = datasetId.split("/"); String name = splittedDatasetId[0]; CellSize resolution = CellSize.fromHumanString(splittedDatasetId[1]); ds = datasetDao.findDatasetByName(name, resolution); } else { ds = datasetDao.retrieve(datasetId); } if (ds == null) return null; List<TimeSlice> tsList = datasetDao.findTimeSlices(ds.getId(), start, end); if (tsList == null) return null; List<Band> bands = null; if (bandName == null || bandName == "") { bands = datasetDao.getBands(ds.getId()); } else { List<String> bandNames = new ArrayList<String>(); bandNames.add(bandName); bands = datasetDao.findBandsByName(ds.getId(), bandNames); } if (bands == null) return null; RsaAggregationFactory factory = new RsaAggregationFactory(); ModelAndView modelNView = new ModelAndView("DisplayPlot"); try { AggregationDefinition def = factory.create(ds, tsList, bands, new Box(x, y, x, y)); log.info("TS0:" + tsList.get(0).getCreated()); log.info("TSN:" + tsList.get(tsList.size() - 1).getCreated()); AggregationOpener opener = new AggregationOpener(); NetcdfDataset dataset = opener.open(def, ""); Variable varx = dataset.findVariable("x"); Variable vary = dataset.findVariable("y"); int xIndex = getArrayIndex(varx, x); int yIndex = getArrayIndex(vary, y); int[] origin = new int[] { 0, yIndex, xIndex }; int[] shape = new int[] { tsList.size(), 1, 1 }; Map<String, List<Pair>> bandPlotPair = new HashMap<String, List<Pair>>(); Array ar = null; NodataStrategyFactory ndsfac = new NodataStrategyFactory(); for (Band b : bands) { Variable var = dataset.findVariable(b.getName()); Type type = Type.get(var.getDataType(), var.isUnsigned()); NodataStrategy nds = ndsfac.create(var, type); ar = var.read(origin, shape); ArrayAdapter arradapt = ArrayAdapterImpl.createAndPromote(ar, var.getDataType(), nds); List<Pair> plotValues = new ArrayList<Pair>(); for (int i = 0; i < ar.getIndex().getSize(); i++) { ScalarElement elem = arradapt.get(i); Date timeval = tsList.get(i).getCreated(); if (elem.isValid()) plotValues.add(new Pair(timeval, elem.doubleValue())); else if (!omitNodata) plotValues.add(new Pair(timeval, null)); } bandPlotPair.put(b.getName(), plotValues); } modelNView.addObject("bandPlotValues", bandPlotPair); modelNView.addObject("datasetName", ds.getName()); modelNView.addObject("pointX", x); modelNView.addObject("pointY", y); model.addAttribute(ControllerHelper.RESPONSE_ROOT, new DatasetPlotResponse(tsList, ar)); } catch (IOException e) { log.error(e.getStackTrace().toString()); throw e; } return modelNView; }
From source file:es.bsc.servicess.ide.PackagingUtils.java
private static void preInstrumentOrchestration(String runtime, String orchClass, List<String> methods, IFolder classes, List<Dependency> depLibraries, IProgressMonitor myProgressMonitor) throws CoreException { Runtime rt = Runtime.getRuntime(); if (runtime != null && orchClass != null && methods != null && methods.size() > 0) { String classpath = new String(); for (Dependency d : depLibraries) { if (d.getType().equalsIgnoreCase(ProjectMetadata.JAR_DEP_TYPE) || d.getType().equalsIgnoreCase(ProjectMetadata.CLASS_FOLDER_DEP_TYPE)) classpath = classpath.concat(":" + d.getLocation()); }/*from www . ja v a 2s . c o m*/ boolean first = true; String methodsString = new String(); for (String m : methods) { if (first) { methodsString = methodsString.concat(m); first = false; } else methodsString = methodsString.concat(" " + m); } String command = new String(runtime + "/../scripts/pre_instrument.sh " + classes.getLocation().toOSString() + classpath + " " + runtime + "/.." + " " + classes.getLocation().toOSString() + " " + orchClass + " " + methodsString); log.debug("Command to exec: " + command); Process ps; try { ps = rt.exec(command); BufferedReader stdInput = new BufferedReader(new InputStreamReader(ps.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(ps.getErrorStream())); String s = null; // read the output from the command log.debug("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { log.debug(s); } // read any errors from the attempted command log.debug("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { log.debug(s); } // if (ps.exitValue() != 0){ if (ps.waitFor() != 0) { throw (new CoreException( new Status(IStatus.ERROR, Activator.PLUGIN_ID, "metadata info not found"))); } } catch (IOException e) { CoreException ce = new CoreException( new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); ce.setStackTrace(e.getStackTrace()); throw (ce); } catch (InterruptedException e) { CoreException ce = new CoreException( new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); ce.setStackTrace(e.getStackTrace()); throw (ce); } } else { throw (new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "metadata info not found"))); } }
From source file:es.bsc.servicess.ide.PackagingUtils.java
private static void instrumentOrchestrations(String runtime, String[] cls, IFolder classes, List<Dependency> depLibraries, IProgressMonitor myProgressMonitor) throws CoreException { Runtime rt = Runtime.getRuntime(); if (runtime != null && cls != null) { String classpath = new String(); for (Dependency d : depLibraries) { if (d.getType().equalsIgnoreCase(ProjectMetadata.JAR_DEP_TYPE) || d.getType().equalsIgnoreCase(ProjectMetadata.CLASS_FOLDER_DEP_TYPE)) classpath = classpath.concat(":" + d.getLocation()); }/*from ww w . jav a 2 s . co m*/ for (String cl : cls) { String command = new String( runtime + "/../scripts/instrument.sh " + cl + " " + classes.getLocation().toOSString() + classpath + " " + runtime + "/.." + " " + classes.getLocation().toOSString()); log.debug("Command to exec: " + command); Process ps; try { ps = rt.exec(command); BufferedReader stdInput = new BufferedReader(new InputStreamReader(ps.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(ps.getErrorStream())); String s = null; // read the output from the command log.debug("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { log.debug(s); } // read any errors from the attempted command log.debug("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { log.debug(s); } // if (ps.exitValue() != 0){ if (ps.waitFor() != 0) { throw (new CoreException( new Status(IStatus.ERROR, Activator.PLUGIN_ID, "metadata info not found"))); } } catch (IOException e) { CoreException ce = new CoreException( new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); ce.setStackTrace(e.getStackTrace()); throw (ce); } catch (InterruptedException e) { CoreException ce = new CoreException( new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); ce.setStackTrace(e.getStackTrace()); throw (ce); } } } else { throw (new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "metadata info not found"))); } }
From source file:com.loloof64.android.capturing_audio.MainActivity.java
public void recordingButtonClicked(View view) { try {// w w w . j av a2 s . c om recorderFragment.toggleRecordingState(); } catch (IOException e) { Log.e("RecordingAudio", e.getMessage(), e); /////////////////////////////////////////////////////////////////////// AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle("Error"); ScrollView scrollingView = new ScrollView(dialogBuilder.getContext()); scrollingView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); EditText textView = new EditText(dialogBuilder.getContext()); textView.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setText(Arrays.toString(e.getStackTrace())); scrollingView.addView(textView); dialogBuilder.setView(scrollingView); dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialogBuilder.show(); //////////////////////////////////////////////////////////////////////// Toast.makeText(this, R.string.could_not_create_temporary_file, Toast.LENGTH_SHORT).show(); } }
From source file:com.cyberway.issue.io.arc.ARCReader.java
/** * Create new arc record./* ww w .j ava2 s. co m*/ * * Encapsulate housekeeping that has to do w/ creating a new record. * * <p>Call this method at end of constructor to read in the * arcfile header. Will be problems reading subsequent arc records * if you don't since arcfile header has the list of metadata fields for * all records that follow. * * <p>When parsing through ARCs writing out CDX info, we spend about * 38% of CPU in here -- about 30% of which is in getTokenizedHeaderLine * -- of which 16% is reading. * * @param is InputStream to use. * @param offset Absolute offset into arc file. * @return An arc record. * @throws IOException */ protected ARCRecord createArchiveRecord(InputStream is, long offset) throws IOException { ArrayList<String> firstLineValues = new ArrayList<String>(20); getTokenizedHeaderLine(is, firstLineValues); int bodyOffset = 0; if (offset == 0 && isAlignedOnFirstRecord()) { // If offset is zero and we were aligned at first record on // creation (See #alignedOnFirstRecord for more on this), then no // records have been read yet and we're reading our first one, the // record of ARC file meta info. Its special. In ARC versions // 1.x, first record has three lines of meta info. We've just read // the first line. There are two more. The second line has misc. // info. We're only interested in the first field, the version // number. The third line is the list of field names. Here's what // ARC file version 1.x meta content looks like: // // filedesc://testIsBoundary-JunitIAH200401070157520.arc 0.0.0.0 \\ // 20040107015752 text/plain 77 // 1 0 InternetArchive // URL IP-address Archive-date Content-type Archive-length // ArrayList<String> secondLineValues = new ArrayList<String>(20); bodyOffset += getTokenizedHeaderLine(is, secondLineValues); setVersion((String) secondLineValues.get(0) + "." + (String) secondLineValues.get(1)); // Just read over the 3rd line. We used to parse it and use // values found here but now we just hardcode them to avoid // having to read this 3rd line even for random arc file accesses. bodyOffset += getTokenizedHeaderLine(is, null); } try { currentRecord( new ARCRecord(is, (ArchiveRecordHeader) computeMetaData(this.headerFieldNameKeys, firstLineValues, getVersion(), offset), bodyOffset, isDigest(), isStrict(), isParseHttpHeaders())); } catch (IOException e) { if (e instanceof RecoverableIOException) { // Don't mess with RecoverableIOExceptions. Let them out. throw e; } IOException newE = new IOException(e.getMessage() + " (Offset " + offset + ")."); newE.setStackTrace(e.getStackTrace()); throw newE; } return (ARCRecord) getCurrentRecord(); }
From source file:listener.Handler.java
License:asdf
private void switchPower(String[] message) { if (acc.hasAccountPrivilege(AccountPrivileges.PERM_CMD_SWITCHPOWER)) { // if (message.length > ) if (message.length > 3) { String infoString = "Executing switch command"; if (verbose) Logger.logMessage('I', this, infoString); this.replyMessage(infoString); if (verbose) Logger.logMessage('I', this, "infoString"); try { Runtime.getRuntime().exec("sudo send " + message[1] + " " + message[2] + " " + message[3]); } catch (IOException e) { String error = "Error when trying to execute send command"; Logger.logException('E', error, e); this.replyMessage(error + " " + e.getMessage() + System.lineSeparator() + e.getStackTrace()); }//w w w .j a v a 2 s. c o m } else { String error = "usage: switchOn <systemID> <unitID>; switchOff <systemID> <unitID>; switch <systemID> <unitID> <state>; see help for more information."; // TODO: Multi-line messages Logger.logMessage('E', "not enough arguments for switchOn command. " + error); this.replyMessage(error); } } else { this.noPermAns("switchPower"); } }