List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:org.libreoffice.ui.LibreOfficeUIActivity.java
private void switchToDocumentProvider(IDocumentProvider provider) { new AsyncTask<IDocumentProvider, Void, Void>() { @Override// w ww . j a v a 2 s . c om protected Void doInBackground(IDocumentProvider... provider) { // switch document provider: // these operations may imply network access and must be run in // a different thread try { documentProvider = provider[0]; homeDirectory = documentProvider.getRootDirectory(); currentDirectory = homeDirectory; filePaths = currentDirectory.listFiles(FileUtilities.getFileFilter(filterMode)); } catch (final RuntimeException e) { final Activity activity = LibreOfficeUIActivity.this; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show(); } }); Log.e(LOGTAG, e.getMessage(), e.getCause()); } return null; } @Override protected void onPostExecute(Void result) { refreshView(); } }.execute(provider); }
From source file:org.libreoffice.ui.LibreOfficeUIActivity.java
public void openDirectory(IFile dir) { if (dir == null) return;/*from www . j ava2s. c om*/ new AsyncTask<IFile, Void, Void>() { @Override protected Void doInBackground(IFile... dir) { // get list of files: // this operation may imply network access and must be run in // a different thread currentDirectory = dir[0]; try { filePaths = currentDirectory.listFiles(FileUtilities.getFileFilter(filterMode)); } catch (final RuntimeException e) { final Activity activity = LibreOfficeUIActivity.this; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show(); } }); Log.e(LOGTAG, e.getMessage(), e.getCause()); } return null; } @Override protected void onPostExecute(Void result) { refreshView(); } }.execute(dir); }
From source file:org.libreoffice.ui.LibreOfficeUIActivity.java
private void share(int position) { new AsyncTask<IFile, Void, File>() { @Override/*from ww w. ja v a 2 s . c o m*/ protected File doInBackground(IFile... document) { // this operation may imply network access and must be run in // a different thread try { return document[0].getDocument(); } catch (final RuntimeException e) { final Activity activity = LibreOfficeUIActivity.this; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show(); } }); Log.e(LOGTAG, e.getMessage(), e.getCause()); return null; } } @Override protected void onPostExecute(File file) { if (file != null) { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); Uri uri = Uri.fromFile(file); sharingIntent.setType(FileUtilities.getMimeType(file.getName())); sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, file.getName()); startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_via))); } } }.execute(filePaths.get(position)); }
From source file:org.libreoffice.ui.LibreOfficeUIActivity.java
public void open(final IFile document) { new AsyncTask<IFile, Void, File>() { @Override//from ww w .ja va 2 s .c o m protected File doInBackground(IFile... document) { // this operation may imply network access and must be run in // a different thread try { return document[0].getDocument(); } catch (final RuntimeException e) { final Activity activity = LibreOfficeUIActivity.this; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show(); } }); Log.e(LOGTAG, e.getMessage(), e.getCause()); return null; } } @Override protected void onPostExecute(File file) { if (file != null) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file)); String packageName = getApplicationContext().getPackageName(); ComponentName componentName = new ComponentName(packageName, LibreOfficeMainActivity.class.getName()); i.setComponent(componentName); // these extras allow to rebuild the IFile object in LOMainActivity i.putExtra("org.libreoffice.document_provider_id", documentProvider.getId()); i.putExtra("org.libreoffice.document_uri", document.getUri()); startActivity(i); } } }.execute(document); }
From source file:org.geowebcache.diskquota.bdb.BDBQuotaStore.java
/** * Synchronously issues the given {@code command} to the working transactional thread * //from w w w .j a v a 2 s .co m * @throws InterruptedException * in case the calling thread was interrupted while waiting for the command to * complete */ private <E> E issueSync(final Callable<E> command) throws InterruptedException { Future<E> result = issue(command); try { return result.get(); } catch (RuntimeException e) { throw e; } catch (InterruptedException e) { log.debug( "Caught InterruptedException while waiting for command " + command.getClass().getSimpleName()); throw e; } catch (ExecutionException e) { log.warn(e); Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } throw new RuntimeException(cause); } }
From source file:org.lsc.AbstractSynchronize.java
public boolean run(IBean entry) { LscModifications lm = null;//from w ww . ja va 2 s. c om IBean dstBean = null; /** Hash table to pass objects into JavaScript condition */ Map<String, Object> conditionObjects = null; try { /* * Log an error if the source object could not be retrieved! This * shouldn't happen. */ if (entry == null) { counter.incrementCountError(); AbstractSynchronize.LOGGER .error("Synchronization aborted because no source object has been found !"); return false; } // Search destination for matching object if (id != null) { dstBean = abstractSynchronize.getBean(task, task.getDestinationService(), id.getKey(), id.getValue(), !fromSource, fromSource); } else { LscDatasets entryDatasets = new LscDatasets(); for (String datasetName : entry.datasets().getAttributesNames()) { entryDatasets.getDatasets().put(datasetName, entry.getDatasetById(datasetName)); } dstBean = abstractSynchronize.getBean(task, task.getDestinationService(), entry.getMainIdentifier(), entryDatasets, !fromSource, fromSource); } // Calculate operation that would be performed LscModificationType modificationType = BeanComparator.calculateModificationType(task, entry, dstBean); // Retrieve condition to evaluate before creating/updating Boolean applyCondition = null; String conditionString = task.getSyncOptions().getCondition(modificationType); // Don't use JavaScript evaluator for primitive cases if (conditionString.matches("true")) { applyCondition = true; } else if (conditionString.matches("false")) { applyCondition = false; } else { conditionObjects = new HashMap<String, Object>(); conditionObjects.put("dstBean", dstBean); conditionObjects.put("srcBean", entry); conditionObjects.putAll(task.getScriptingVars()); // Evaluate if we have to do something applyCondition = ScriptingEvaluator.evalToBoolean(task, conditionString, conditionObjects); } if (applyCondition) { lm = BeanComparator.calculateModifications(task, entry, dstBean); // if there's nothing to do, skip to the next object if (lm == null) { return true; } counter.incrementCountModifiable(); // no modification: log action for debugging purposes and forget if ((modificationType == LscModificationType.CREATE_OBJECT && abstractSynchronize.nocreate) || (modificationType == LscModificationType.UPDATE_OBJECT && abstractSynchronize.noupdate) || (modificationType == LscModificationType.CHANGE_ID && (abstractSynchronize.nomodrdn || abstractSynchronize.noupdate))) { abstractSynchronize.logShouldAction(lm, syncName); return true; } } else { return true; } // if we got here, we have a modification to apply - let's do it! if (task.getDestinationService().apply(lm)) { counter.incrementCountCompleted(); abstractSynchronize.logAction(lm, id, syncName); return true; } else { counter.incrementCountError(); abstractSynchronize.logActionError(lm, (id != null ? id.getValue() : entry.getMainIdentifier()), new Exception("Technical problem while applying modifications to the destination")); return false; } } catch (RuntimeException e) { counter.incrementCountError(); abstractSynchronize.logActionError(lm, (id != null ? id.getValue() : (entry != null ? entry.getMainIdentifier() : e.toString())), e); if (e.getCause() instanceof LscServiceCommunicationException) { AbstractSynchronize.LOGGER.error("Connection lost! Aborting."); } return false; } catch (Exception e) { counter.incrementCountError(); abstractSynchronize.logActionError(lm, (id != null ? id.getValue() : entry.getMainIdentifier()), e); return false; } }
From source file:com.bouncestorage.swiftproxy.v1.ObjectResource.java
private String serverCopyBlob(BlobStore blobStore, String container, String objectName, String destContainer, String destObject, CopyOptions options) { try {//from w ww .j a v a 2 s. c om return blobStore.copyBlob(container, objectName, destContainer, destObject, options); } catch (RuntimeException e) { if (e.getCause() instanceof HttpResponseException) { throw (HttpResponseException) e.getCause(); } else { throw e; } } }
From source file:azkaban.viewer.reportal.ReportalServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); server = (AzkabanWebServer) getApplication(); ReportalMailCreator.azkaban = server; shouldProxy = props.getBoolean("azkaban.should.proxy", false); logger.info("Hdfs browser should proxy: " + shouldProxy); try {/*from www.j a v a2s .com*/ hadoopSecurityManager = loadHadoopSecurityManager(props, logger); ReportalMailCreator.hadoopSecurityManager = hadoopSecurityManager; } catch (RuntimeException e) { e.printStackTrace(); throw new RuntimeException("Failed to get hadoop security manager!" + e.getCause()); } cleanerThread = new CleanerThread(); cleanerThread.start(); }
From source file:org.opentestsystem.authoring.testspecbank.service.impl.TestSpecificationServiceImpl.java
private void handleFailedExport(final String testSpecificationId, final RuntimeException exception) { LOGGER.error("Error during package export", exception); final TestSpecification testSpecification = getTestSpecification(testSpecificationId, false); if (testSpecification == null) { throw new LocalizedException("testspec.id.invalid"); }/*from w ww. j a v a 2 s .c om*/ if (testSpecification.getExportPackage() == null) { throw new LocalizedException("testspec.export.required"); } testSpecification.getExportPackage().setStatus(ExportPackageStatus.FAILED); testSpecification.setLastUpdatedDate(new DateTime()); testSpecification.getExportPackage().setStatusMessage( exception instanceof LocalizedException ? exception.getCause().getMessage() : "unexpected.error"); this.alertBeacon.sendAlert(MnaSeverity.ERROR, MnaAlertType.EXPORT_PACKAGE_FAILED.name(), "Export Package Failed: " + testSpecification.getId() + " - " + testSpecification.getExportPackage().getStatusMessage()); this.testSpecificationRepository.save(testSpecification); if (!(exception instanceof LocalizedException)) { throw exception; } }
From source file:at.jclehner.rxdroid.DrugListActivity2.java
protected void onLoaderException(RuntimeException e) { final DatabaseHelper.DatabaseError error; if (e instanceof WrappedCheckedException && ((WrappedCheckedException) e).getCauseType() == DatabaseHelper.DatabaseError.class) error = (DatabaseHelper.DatabaseError) e.getCause(); else if (e instanceof DatabaseHelper.DatabaseError) error = (DatabaseHelper.DatabaseError) e; else// w w w.jav a2 s .c om throw e; final StringBuilder sb = new StringBuilder(); sb.append(Util.getDbErrorMessage(this, error)); sb.append(" " + RefString.resolve(this, R.string._msg_db_error_footer)); final DialogLike dialog = new DialogLike(); dialog.setTitle(getString(R.string._title_error)); dialog.setMessage(sb); dialog.setNegativeButtonText(getString(R.string._btn_reset)); dialog.setPositiveButtonText(getString(R.string._btn_exit)); getSupportFragmentManager().beginTransaction().replace(android.R.id.content, dialog) .commitAllowingStateLoss(); mIsShowingDbErrorDialog = true; }