List of usage examples for java.io IOException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.att.android.arodatacollector.main.AROCollectorService.java
/** * Sample file content: FLURRY_API_KEY=YKN7M4TDXRKXH97PX565 * Each Flurry API Key corresponds to an Application on Flurry site. It is absolutely * necessary that the Flurry API Key-value from user's device is correct in order to log to the Flurry application. * /* www .j a v a 2 s . c o m*/ * No validation on the API key allows creation of a new Flurry application by client at any time * The API key is communicated to the user group who would put the API key name-value pair into * properties file specified by variable flurryFileName below. * * If no key-value is found, the default API key is used below. Default is intended for users of * ATT Developer Program. */ private void setFlurryApiKey() { if (DEBUG) { Log.d(TAG, "entered setFlurryApiKey"); } final String flurryFileName = ARODataCollector.ARO_TRACE_ROOTDIR + ARODataCollector.FLURRY_API_KEY_REL_PATH; InputStream flurryFileReaderStream = null; try { final ClassLoader loader = ClassLoader.getSystemClassLoader(); flurryFileReaderStream = loader.getResourceAsStream(flurryFileName); Properties prop = new Properties(); try { if (flurryFileReaderStream != null) { prop.load(flurryFileReaderStream); mApp.app_flurry_api_key = prop.containsKey(ARODataCollector.FLURRY_API_KEY_NAME) && !prop.getProperty(ARODataCollector.FLURRY_API_KEY_NAME) .equals(AROCollectorUtils.EMPTY_STRING) ? prop.getProperty(ARODataCollector.FLURRY_API_KEY_NAME).trim() : mApp.app_flurry_api_key; if (DEBUG) { Log.d(TAG, "flurry Property String: " + prop.toString()); Log.d(TAG, "flurry app_flurry_api_key: " + mApp.app_flurry_api_key); } } else { if (DEBUG) { Log.d(TAG, "flurryFileReader stream is null. Using default: " + mApp.app_flurry_api_key); } } } catch (IOException e) { Log.d(TAG, e.getClass().getName() + " thrown trying to load file "); } } finally { try { if (flurryFileReaderStream != null) { flurryFileReaderStream.close(); } } catch (IOException e) { //log and exit method-nothing else to do. if (DEBUG) { Log.d(TAG, "setFlurryApiKey method reached catch in finally method, trying to close flurryFileReader"); } } Log.d(TAG, "exiting setFlurryApiKey"); } }
From source file:org.dasein.cloud.google.compute.server.ServerSupport.java
public void terminateVmDisk(@Nonnull String diskName, String zone) throws InternalException, CloudException { try {//from w ww. java2s. com APITrace.begin(getProvider(), "terminateVM"); try { Compute gce = provider.getGoogleCompute(); Operation job = gce.disks().delete(provider.getContext().getAccountNumber(), zone, diskName) .execute(); GoogleMethod method = new GoogleMethod(provider); method.getOperationComplete(provider.getContext(), job, GoogleOperationType.ZONE_OPERATION, null, zone); } catch (IOException ex) { if (ex.getClass() == GoogleJsonResponseException.class) { GoogleJsonResponseException gjre = (GoogleJsonResponseException) ex; if ((404 == gjre.getStatusCode()) && (gjre.getStatusMessage().equals("Not Found"))) { // remain silent. this happens when instance is created with delete root volume on terminate is selected. //throw new CloudException("Virtual Machine disk image '" + vmId + "' was not found."); } else { throw new GoogleException(CloudErrorType.GENERAL, gjre.getStatusCode(), gjre.getContent(), gjre.getDetails().getMessage()); } } else throw new CloudException( "An error occurred while deleting VM disk: " + diskName + ": " + ex.getMessage()); } catch (Exception ex) { throw new CloudException(ex); // catch exception from getOperationComplete } } finally { APITrace.end(); } }
From source file:edu.ku.brc.specify.toycode.mexconabio.CopyFromGBIF.java
/** * /*from w ww .j a v a 2 s . co m*/ */ public void index() { IndexWriter writer = null; try { analyzer = new StandardAnalyzer(Version.LUCENE_36); FileUtils.deleteDirectory(INDEX_DIR); System.out.println("Indexing to directory '" + INDEX_DIR + "'..."); long totalRecs = BasicSQLUtils.getCount(srcDBConn, "SELECT COUNT(*) FROM raw"); long procRecs = 0; long startTime = System.currentTimeMillis(); int secsThreshold = 0; PrintWriter pw = null; final double HRS = 1000.0 * 60.0 * 60.0; Statement stmt = null; try { writer = new IndexWriter(FSDirectory.open(INDEX_DIR), analyzer, true, IndexWriter.MaxFieldLength.LIMITED); pw = new PrintWriter("gbif.log"); System.out.println("Total Records: " + totalRecs); pw.println("Total Records: " + totalRecs); stmt = srcDBConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); //String[] fldNames = {"id", "cn", "gn", "sp", "cln", "ctr", "yr", "mn", "dy"}; ResultSet rs = stmt.executeQuery( "SELECT id, catalogue_number, genus, species, collector_num, collector_name, year, month, day, state_province, county FROM raw");// LIMIT 100000,1000"); ResultSetMetaData rsmd = rs.getMetaData(); StringBuilder sb = new StringBuilder(); while (rs.next()) { String id = rs.getString(1); Document doc = new Document(); doc.add(new Field("id", id.toString(), Field.Store.YES, Field.Index.NO)); sb.setLength(0); for (int i = 2; i <= rsmd.getColumnCount(); i++) { String val = rs.getString(i); if (StringUtils.isNotEmpty(val)) { sb.append(val); sb.append(' '); } } doc.add(new Field("contents", sb.toString(), Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); procRecs++; if (procRecs % 10000 == 0) { long endTime = System.currentTimeMillis(); long elapsedTime = endTime - startTime; double timePerRecord = (elapsedTime / procRecs); double hrsLeft = ((totalRecs - procRecs) * timePerRecord) / HRS; int seconds = (int) (elapsedTime / 60000.0); if (secsThreshold != seconds) { secsThreshold = seconds; String msg = String.format("Elapsed %8.2f hr.mn Percent: %6.3f Hours Left: %8.2f ", ((double) (elapsedTime)) / HRS, 100.0 * ((double) procRecs / (double) totalRecs), hrsLeft); System.out.println(msg); pw.println(msg); pw.flush(); } } } } catch (SQLException sqlex) { sqlex.printStackTrace(); } catch (IOException e) { e.printStackTrace(); System.out.println("IOException adding Lucene Document: " + e.getMessage()); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { e.printStackTrace(); } } } } catch (IOException e) { e.printStackTrace(); System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } finally { analyzer.close(); analyzer = null; if (writer != null) { try { System.out.println("Optimizing..."); writer.optimize(); writer.close(); System.out.println("Done Optimizing."); } catch (CorruptIndexException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } writer = null; } } }
From source file:com.qweex.callisto.podcast.DownloadTask.java
@Override protected Boolean doInBackground(String... params) { String TAG = StaticBlob.TAG(); boolean isVideo; Cursor current;//from www .ja v a 2 s. com long id = 0, identity = 0; Log.e(TAG, "Preparing to start: " + StaticBlob.databaseConnector.getActiveDownloads().getCount() + " downloads"); boolean canceled = false; while (StaticBlob.databaseConnector.getActiveDownloads().getCount() > 0) { if (isCancelled()) //Checks to see if it has been canceled by somewhere else { mNotificationManager.cancel(NOTIFICATION_ID); return false; } try { Cursor c = StaticBlob.databaseConnector.getActiveDownloads(); c.moveToFirst(); id = c.getLong(c.getColumnIndex("_id")); identity = c.getLong(c.getColumnIndex("identity")); isVideo = c.getInt(c.getColumnIndex("video")) > 0; current = StaticBlob.databaseConnector.getOneEpisode(identity); current.moveToFirst(); //Get info AudLink = current.getString(current.getColumnIndex("mp3link")); VidLink = current.getString(current.getColumnIndex("vidlink")); AudSize = current.getLong(current.getColumnIndex("mp3size")); VidSize = current.getLong(current.getColumnIndex("vidsize")); Title = current.getString(current.getColumnIndex("title")); Date = current.getString(current.getColumnIndex("date")); Show = current.getString(current.getColumnIndex("show")); Date = StaticBlob.sdfFile.format(StaticBlob.sdfRaw.parse(Date)); //Getting target Target = new File(StaticBlob.storage_path + File.separator + Show); Target.mkdirs(); if (Title.indexOf("|") > 0) Title = Title.substring(0, Title.indexOf("|")); Title = Title.trim(); AudFile = new File(Target, Date + "__" + StaticBlob.makeFileFriendly(Title) + EpisodeDesc.getExtension(AudLink)); if (VidLink != null) VidFile = new File(Target, Date + "__" + StaticBlob.makeFileFriendly(Title) + EpisodeDesc.getExtension(VidLink)); Target = isVideo ? VidFile : AudFile; //Prepare the HTTP Log.i(TAG, "Path: " + Target.getPath()); URL url = new URL(isVideo ? VidLink : AudLink); Log.i(TAG, "Starting download: " + url.toString()); Log.i(TAG, "Opening the connection..."); HttpURLConnection ucon = (HttpURLConnection) url.openConnection(); String lastModified = ucon.getHeaderField("Last-Modified"); ucon = (HttpURLConnection) url.openConnection(); if (Target.exists()) { ucon.setRequestProperty("Range", "bytes=" + Target.length() + "-"); ucon.setRequestProperty("If-Range", lastModified); } ucon.setReadTimeout(TIMEOUT_CONNECTION); ucon.setConnectTimeout(TIMEOUT_SOCKET); ucon.connect(); //Notification mBuilder.setProgress(100, 0, true) .setContentTitle(this.context.getResources().getString(R.string.downloading) + " " + StaticBlob.current_download + " " + this.context.getResources().getString(R.string.of) + " " + downloading_count) .setContentText(Show + ": " + Title); // Displays the progress bar for the first time. mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); //Actually do the DLing InputStream is = ucon.getInputStream(); TotalSize = ucon.getContentLength() + Target.length(); BufferedInputStream inStream = new BufferedInputStream(is, 1024 * 5); FileOutputStream outStream; byte buff[]; Log.i(TAG, "mmk skipping the downloaded portion..." + Target.length() + " of " + TotalSize); if (Target.exists()) //Append if it exists outStream = new FileOutputStream(Target, true); else outStream = new FileOutputStream(Target); buff = new byte[5 * 1024]; Log.i(TAG, "Getting content length (size)"); int len = 0; long downloadedSize = Target.length(), percentDone = 0; //SPEED_COUNT == the number of times through the buffer loop to go through before updating the speed // currentDownloadLoopIndex == ??? // lastTime == The time that the last speed was calculated at // all_spds == All speeds tabulated thus far from currentDownloadLoopIndex to SPEED_COUNT // avg_speed == the average speed when SPEED_COUNT is reached int SPEED_COUNT = 200, currentDownloadLoopIndex = 0; long lastTime = (new java.util.Date()).getTime(), all_spds = 0; double avg_speed = 0; DecimalFormat df = new DecimalFormat("#.##"); //Wifi lock WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (DownloadList.Download_wifiLock == null) DownloadList.Download_wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "Callisto_download"); if (!DownloadList.Download_wifiLock.isHeld()) DownloadList.Download_wifiLock.acquire(); Log.i(TAG, "FINALLY starting the download"); inner_failures = 0; //-----------------Here is where the actual downloading happens---------------- while (len != -1) { Cursor active = StaticBlob.databaseConnector.getActiveDownloads(); if (StaticBlob.databaseConnector.getActiveDownloads().getCount() == 0) canceled = true; else { active.moveToFirst(); canceled = active.getLong(active.getColumnIndex("identity")) != identity; } if (canceled) { Log.i(TAG, "Download has been canceled, deleting."); Target.delete(); break; } if (isCancelled()) { mNotificationManager.cancel(NOTIFICATION_ID); return false; } try { len = inStream.read(buff); if (len == -1) break; outStream.write(buff, 0, len); downloadedSize += len; percentDone = downloadedSize * 100; percentDone /= TotalSize; //Add to the average speed long temp_spd = 0; long time_diff = ((new java.util.Date()).getTime() - lastTime); if (time_diff > 0) { temp_spd = len * 100 / time_diff; currentDownloadLoopIndex++; all_spds += temp_spd; lastTime = (new java.util.Date()).getTime(); } } catch (IOException e) { Log.e(TAG + ":IOException", "IO is a moon - " + inner_failures); inner_failures++; if (inner_failures == INNER_LIMIT) break; try { Thread.sleep(500); } catch (InterruptedException e1) { } //Add failure to average currentDownloadLoopIndex++; lastTime = (new java.util.Date()).getTime(); } catch (Exception e) { Log.e(TAG + ":??Exception", e.getClass() + " : " + e.getMessage()); try { Thread.sleep(500); } catch (InterruptedException e1) { } //Add failure to average currentDownloadLoopIndex++; lastTime = (new java.util.Date()).getTime(); } //If the time is right, get the average if (currentDownloadLoopIndex >= SPEED_COUNT) { avg_speed = all_spds * 1.0 / currentDownloadLoopIndex / 100; all_spds = 0; currentDownloadLoopIndex = 0; if (DownloadList.thisInstance != null) { DownloadList.thisInstance.runOnUiThread( DownloadList.thisInstance.new DownloadProgressUpdater((int) (TotalSize / 1000), (int) (downloadedSize / 1000))); } mBuilder.setProgress((int) (TotalSize / 1000), (int) (downloadedSize / 1000), false) .setContentTitle(this.context.getResources().getString(R.string.downloading) + " " + StaticBlob.current_download + " " + this.context.getResources().getString(R.string.of) + " " + downloading_count + " - " + percentDone + "% (" + df.format(avg_speed) + "kb/s)") .setContentText(Show + ": " + Title); // Displays the progress bar for the first time. mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } } // END download of single file outStream.flush(); outStream.close(); inStream.close(); if (inner_failures == INNER_LIMIT) { throw new Exception("Inner exception has passed " + INNER_LIMIT); } Cursor active = StaticBlob.databaseConnector.getActiveDownloads(); if (StaticBlob.databaseConnector.getActiveDownloads().getCount() == 0) canceled = true; else { active.moveToFirst(); canceled = active.getLong(active.getColumnIndex("identity")) != identity; } if (!canceled) { Log.i(TAG, "Trying to finish with " + Target.length() + "==" + TotalSize); if (Target.length() == TotalSize) { StaticBlob.current_download++; Log.i(TAG, (inner_failures < INNER_LIMIT ? "Successfully" : "FAILED") + " downloaded to : " + Target.getPath()); //Move the download from active to completed. StaticBlob.databaseConnector.markDownloadComplete(id); Log.i(TAG, " " + DownloadList.rebuildHeaderThings); if (DownloadList.rebuildHeaderThings != null) DownloadList.rebuildHeaderThings.sendEmptyMessage(0); boolean queue = PreferenceManager.getDefaultSharedPreferences(context) .getBoolean("download_to_queue", false); if (queue) { StaticBlob.databaseConnector.appendToQueue(identity, false, isVideo); StaticBlob.playerInfo.update(context); } //Episode Desc if (EpisodeDesc.currentInstance != null) EpisodeDesc.currentInstance.determineButtons(); //ShowList if (ShowList.thisInstance != null && ShowList.thisInstance.currentDownloadItem != null) { ShowList.thisInstance.runOnUiThread(ShowList.thisInstance.new updateBoldOrItalic(id, ShowList.thisInstance.currentDownloadItem, AudFile, VidFile, AudSize, VidSize)); ShowList.thisInstance.currentDownloadItem = null; } } } else Target.delete(); } catch (ParseException e) { Log.e(TAG + ":ParseException", "Error parsing a date from the SQLite db: "); Log.e(TAG + ":ParseException", Date); Log.e(TAG + ":ParseException", "(This should never happen)."); outer_failures++; e.printStackTrace(); } catch (Exception e) { outer_failures++; Log.e(TAG + ":Exception " + e.getClass(), "[" + outer_failures + "] Msg: " + e.getMessage()); e.printStackTrace(); try { Thread.sleep(1000); } catch (InterruptedException e1) { } } if (outer_failures == OUTER_LIMIT) { boolean quit = false; //if(quit = aDownloads.charAt(1)=='x') // aDownloads = aDownloads.replaceAll("x",""); quit = true; if (DownloadList.rebuildHeaderThings != null) DownloadList.rebuildHeaderThings.sendEmptyMessage(0); failed++; outer_failures = 0; if (quit) break; } } Log.i(TAG, "Finished Downloading"); if (DownloadList.thisInstance != null) DownloadList.thisInstance.updateMenu(); //Wifi lock if (DownloadList.Download_wifiLock != null && DownloadList.Download_wifiLock.isHeld()) DownloadList.Download_wifiLock.release(); //Notification mNotificationManager.cancel(NOTIFICATION_ID); if (downloading_count > 0) { mBuilder.setProgress(100, 0, false) .setContentTitle("Finished downloading " + downloading_count + " files"); if (failed > 0) mBuilder.setContentText(failed + " failed, try them again later"); mBuilder.setAutoCancel(true); mBuilder.setOngoing(false); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); StaticBlob.current_download = 1; downloading_count = 0; } else { StaticBlob.current_download = 1; downloading_count = 0; return false; } return true; }
From source file:com.exedio.copernica.ItemForm.java
private void save() { final ArrayList<SetValue<?>> setValues = new ArrayList<SetValue<?>>(); for (Iterator<?> i = getFields().iterator(); i.hasNext();) { final Field field = (Field) i.next(); if (field.key instanceof DataField) { final DataField attribute = (DataField) field.key; final Media media = Media.get(attribute); final FileItem fileItem = getParameterFile(attribute.getName()); if (fileItem != null) { String contentType = fileItem.getContentType(); if (contentType != null) { // fix for MSIE behaviour if ("image/pjpeg".equals(contentType)) contentType = "image/jpeg"; try { final InputStream data = fileItem.getInputStream(); media.set(item, data, contentType); } catch (IOException e) { throw new RuntimeException(e); }/* w w w.j a va 2s . c om*/ } } } if (field.error == null) { final FunctionField<?> attribute = (FunctionField<?>) field.key; setValues.add(Cope.mapAndCast(attribute, field.getContent())); } } try { item.set(setValues.toArray(new SetValue<?>[setValues.size()])); } catch (MandatoryViolationException e) { final Field field = getFieldByKey(e.getFeature()); field.error = "error.notnull:" + e.getFeature().toString(); } catch (FinalViolationException e) { throw new RuntimeException(e); } catch (UniqueViolationException e) { final Field field = getFieldByKey(e.getFeature().getFields().iterator().next()); field.error = e.getClass().getName(); } catch (StringLengthViolationException e) { final Field field = getFieldByKey(e.getFeature()); field.error = e.getClass().getName(); } }
From source file:org.dasein.cloud.google.compute.server.ServerSupport.java
@Override public void start(@Nonnull String vmId) throws InternalException, CloudException { Compute gce = provider.getGoogleCompute(); try {//from w w w.j a v a 2s.c om VirtualMachine vm = getVirtualMachine(vmId); gce.instances().start(provider.getContext().getAccountNumber(), vm.getProviderDataCenterId(), getVmNameFromId(vmId)).execute(); } catch (IOException ex) { logger.error(ex.getMessage()); if (ex.getClass() == GoogleJsonResponseException.class) { GoogleJsonResponseException gjre = (GoogleJsonResponseException) ex; throw new GoogleException(CloudErrorType.GENERAL, gjre.getStatusCode(), gjre.getContent(), gjre.getDetails().getMessage()); } else throw new CloudException("An error occurred while rebooting VM: " + vmId + ": " + ex.getMessage()); } }
From source file:org.dasein.cloud.google.compute.server.ServerSupport.java
@Override public void stop(@Nonnull String vmId, boolean force) throws InternalException, CloudException { Compute gce = provider.getGoogleCompute(); try {/*from w ww. j av a2 s .co m*/ VirtualMachine vm = getVirtualMachine(vmId); gce.instances().stop(provider.getContext().getAccountNumber(), vm.getProviderDataCenterId(), getVmNameFromId(vmId)).execute(); } catch (IOException ex) { logger.error(ex.getMessage()); if (ex.getClass() == GoogleJsonResponseException.class) { GoogleJsonResponseException gjre = (GoogleJsonResponseException) ex; throw new GoogleException(CloudErrorType.GENERAL, gjre.getStatusCode(), gjre.getContent(), gjre.getDetails().getMessage()); } else throw new CloudException("An error occurred while rebooting VM: " + vmId + ": " + ex.getMessage()); } }
From source file:org.dasein.cloud.google.compute.server.ServerSupport.java
@Override public @Nonnull String getConsoleOutput(@Nonnull String vmId) throws InternalException, CloudException { try {//from ww w . j a v a 2 s .c o m for (VirtualMachine vm : listVirtualMachines()) { if (vm.getProviderVirtualMachineId().equalsIgnoreCase(vmId)) { Compute gce = provider.getGoogleCompute(); SerialPortOutput output = gce.instances() .getSerialPortOutput(provider.getContext().getAccountNumber(), vm.getProviderDataCenterId(), getVmNameFromId(vmId)) .execute(); return output.getContents(); } } } catch (IOException ex) { logger.error(ex.getMessage()); if (ex.getClass() == GoogleJsonResponseException.class) { GoogleJsonResponseException gjre = (GoogleJsonResponseException) ex; throw new GoogleException(CloudErrorType.GENERAL, gjre.getStatusCode(), gjre.getContent(), gjre.getDetails().getMessage()); } else throw new CloudException( "An error occurred when getting console output for VM: " + vmId + ": " + ex.getMessage()); } throw new InternalException("The Virtual Machine: " + vmId + " could not be found."); }
From source file:org.dasein.cloud.google.compute.server.ServerSupport.java
@Override public VirtualMachineProduct getProduct(@Nonnull String productId) throws InternalException, CloudException { try {/*from ww w. jav a 2s . c o m*/ Compute gce = provider.getGoogleCompute(); String[] parts = productId.split("\\+"); if ((parts != null) && (parts.length > 1)) { MachineTypeList types = gce.machineTypes().list(provider.getContext().getAccountNumber(), parts[1]) .setFilter("name eq " + parts[0]).execute(); if ((null != types) && (null != types.getItems())) { for (MachineType type : types.getItems()) { if (parts[0].equals(type.getName())) return toProduct(type); } } } return null; // Tests indicate null should come back, rather than exception //throw new CloudException("The product: " + productId + " could not be found."); } catch (IOException ex) { logger.error(ex.getMessage()); if (ex.getClass() == GoogleJsonResponseException.class) { GoogleJsonResponseException gjre = (GoogleJsonResponseException) ex; throw new GoogleException(CloudErrorType.GENERAL, gjre.getStatusCode(), gjre.getContent(), gjre.getDetails().getMessage()); } else throw new CloudException( "An error occurred retrieving the product: " + productId + ": " + ex.getMessage()); } }
From source file:org.dasein.cloud.google.compute.server.ServerSupport.java
@Override public VirtualMachine getVirtualMachine(@Nonnull String vmId) throws InternalException, CloudException { APITrace.begin(getProvider(), "getVirtualMachine"); try {/*ww w.j a v a 2 s.c om*/ try { Compute gce = provider.getGoogleCompute(); InstanceAggregatedList instances = gce.instances() .aggregatedList(provider.getContext().getAccountNumber()) .setFilter("name eq " + getVmNameFromId(vmId)).execute(); Iterator<String> it = instances.getItems().keySet().iterator(); while (it.hasNext()) { String zone = it.next(); if (instances.getItems() != null && instances.getItems().get(zone) != null && instances.getItems().get(zone).getInstances() != null) { for (Instance instance : instances.getItems().get(zone).getInstances()) { if (instance.getName().equals(getVmNameFromId(vmId))) { return toVirtualMachine(instance); } } } } return null; // not found } catch (IOException ex) { logger.error(ex.getMessage()); if (ex.getClass() == GoogleJsonResponseException.class) { GoogleJsonResponseException gjre = (GoogleJsonResponseException) ex; throw new GoogleException(CloudErrorType.GENERAL, gjre.getStatusCode(), gjre.getContent(), gjre.getDetails().getMessage()); } else throw new CloudException("An error occurred retrieving VM: " + vmId + ": " + ex.getMessage()); } } finally { APITrace.end(); } }