List of usage examples for java.lang RuntimeException printStackTrace
public void printStackTrace()
From source file:org.odk.collect.android.activities.SplashScreenActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_PERMISSIONS_WRITE_STORAGE); } else {// w w w . j a v a 2s. c om // must be at the beginning of any activity that can be called from an external intent try { Collect.createODKDirs(); } catch (RuntimeException e) { createErrorDialog(e.getMessage(), EXIT); return; } } mImageMaxWidth = getWindowManager().getDefaultDisplay().getWidth(); // this splash screen should be a blank slate requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splash_screen); // get the shared preferences object SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = mSharedPreferences.edit(); // get the package info object with version number PackageInfo packageInfo = null; try { packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { e.printStackTrace(); } boolean firstRun = mSharedPreferences.getBoolean(PreferencesActivity.KEY_FIRST_RUN, true); boolean showSplash = mSharedPreferences.getBoolean(PreferencesActivity.KEY_SHOW_SPLASH, false); String splashPath = mSharedPreferences.getString(PreferencesActivity.KEY_SPLASH_PATH, getString(R.string.default_splash_path)); // if you've increased version code, then update the version number and set firstRun to true if (mSharedPreferences.getLong(PreferencesActivity.KEY_LAST_VERSION, 0) < packageInfo.versionCode) { editor.putLong(PreferencesActivity.KEY_LAST_VERSION, packageInfo.versionCode); editor.commit(); firstRun = true; } // do all the first run things if (firstRun || showSplash) { editor.putBoolean(PreferencesActivity.KEY_FIRST_RUN, false); editor.commit(); startSplashScreen(splashPath); } else { endSplashScreen(); } }
From source file:com.dngames.mobilewebcam.PhotoSettings.java
public void SetCameraParameters(Camera cam, boolean configure) { Camera.Parameters params = cam.getParameters(); if (params != null) { SetCameraParameters(params, configure); try {/*from www .j a va 2 s . c o m*/ cam.setParameters(params); } catch (RuntimeException e) { e.printStackTrace(); } } }
From source file:org.apache.poi.ss.format.CellNumberFormatter.java
private void writeFraction(double value, StringBuffer result, double fractional, StringBuffer output, Set<StringMod> mods) { // Figure out if we are to suppress either the integer or fractional part. // With # the suppressed part is removed; with ? it is replaced with spaces. if (!improperFraction) { // If fractional part is zero, and numerator doesn't have '0', write out // only the integer part and strip the rest. if (fractional == 0 && !hasChar('0', numeratorSpecials)) { writeInteger(result, output, integerSpecials, mods, false); Special start = integerSpecials.get(integerSpecials.size() - 1); Special end = denominatorSpecials.get(denominatorSpecials.size() - 1); if (hasChar('?', integerSpecials, numeratorSpecials, denominatorSpecials)) { //if any format has '?', then replace the fraction with spaces mods.add(replaceMod(start, false, end, true, ' ')); } else { // otherwise, remove the fraction mods.add(deleteMod(start, false, end, true)); }//from w ww .ja v a 2 s .c o m // That's all, just return return; } else { // New we check to see if we should remove the integer part boolean allZero = (value == 0 && fractional == 0); boolean willShowFraction = fractional != 0 || hasChar('0', numeratorSpecials); boolean removeBecauseZero = allZero && (hasOnly('#', integerSpecials) || !hasChar('0', numeratorSpecials)); boolean removeBecauseFraction = !allZero && value == 0 && willShowFraction && !hasChar('0', integerSpecials); if (removeBecauseZero || removeBecauseFraction) { Special start = integerSpecials.get(integerSpecials.size() - 1); if (hasChar('?', integerSpecials, numeratorSpecials)) { mods.add(replaceMod(start, true, numerator, false, ' ')); } else { mods.add(deleteMod(start, true, numerator, false)); } } else { // Not removing the integer part -- print it out writeInteger(result, output, integerSpecials, mods, false); } } } // Calculate and print the actual fraction (improper or otherwise) try { int n; int d; // the "fractional % 1" captures integer values in improper fractions if (fractional == 0 || (improperFraction && fractional % 1 == 0)) { // 0 as a fraction is reported by excel as 0/1 n = (int) Math.round(fractional); d = 1; } else { Fraction frac = new Fraction(fractional, maxDenominator); n = frac.getNumerator(); d = frac.getDenominator(); } if (improperFraction) n += Math.round(value * d); writeSingleInteger(numeratorFmt, n, output, numeratorSpecials, mods); writeSingleInteger(denominatorFmt, d, output, denominatorSpecials, mods); } catch (RuntimeException ignored) { ignored.printStackTrace(); } }
From source file:org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.java
@SuppressWarnings("rawtypes") public Object decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Object returnedObject) throws AccessDeniedException { if (log.isDebugEnabled() && object instanceof MethodInvocation) { MethodInvocation mi = (MethodInvocation) object; log.debug("Method: " + mi.getMethod().toString()); }// w w w .jav a 2s. c o m try { if (AuthenticationUtil.isRunAsUserTheSystemUser()) { if (log.isDebugEnabled()) { log.debug("Allowing system user access"); } return returnedObject; } else if (returnedObject == null) { if (log.isDebugEnabled()) { log.debug("Allowing null object access"); } return null; } else if (PermissionCheckedValue.class.isAssignableFrom(returnedObject.getClass())) { // The security provider was not already present return decide(authentication, object, config, (PermissionCheckedValue) returnedObject); } else if (PermissionCheckValue.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (PermissionCheckValue) returnedObject); } else if (StoreRef.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, nodeService.getRootNode((StoreRef) returnedObject)) .getStoreRef(); } else if (NodeRef.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (NodeRef) returnedObject); } else if (Pair.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (Pair) returnedObject); } else if (ChildAssociationRef.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (ChildAssociationRef) returnedObject); } else if (SolrJSONResultSet.class.isAssignableFrom(returnedObject.getClass()) && (!anyDenyDenies || (!postProcessDenies && ((SolrJSONResultSet) returnedObject).getProcessedDenies()))) { return returnedObject; } else if (CMISResultSet.class.isAssignableFrom(returnedObject.getClass())) { return returnedObject; } else if (PagingLuceneResultSet.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (PagingLuceneResultSet) returnedObject); } else if (ResultSet.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (ResultSet) returnedObject); } else if (QueryEngineResults.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (QueryEngineResults) returnedObject); } else if (Collection.class.isAssignableFrom(returnedObject.getClass())) { return decide(authentication, object, config, (Collection) returnedObject); } else if (returnedObject.getClass().isArray()) { return decide(authentication, object, config, (Object[]) returnedObject); } else { if (log.isDebugEnabled()) { log.debug("Uncontrolled object - access allowed for " + object.getClass().getName()); } return returnedObject; } } catch (AccessDeniedException ade) { if (log.isDebugEnabled()) { log.debug("Access denied"); ade.printStackTrace(); } throw ade; } catch (RuntimeException re) { if (log.isDebugEnabled()) { log.debug("Access denied by runtime exception"); re.printStackTrace(); } throw re; } }
From source file:org.LexGrid.LexBIG.gui.LB_VSD_GUI.java
/** * Instantiates a new GUI with the given command arguments and the given * LexBIGService.// w w w . j a v a2s . c o m * * @param args * Recognized arguments: -d, Disables admin options. * @param service * The LexBIGService to invoke for GUI functions. * @throws LBInvocationException */ public LB_VSD_GUI(String[] args, LexBIGService service) throws LBInvocationException { isAdminEnabled = !(ArrayUtils.contains(args, "-d") || ArrayUtils.contains(args, "-D")); lbs_ = service != null ? service : LexBIGServiceImpl.defaultInstance(); Display display = new Display(); shell_ = new Shell(display); shell_.setText("LexBIG Value Sets " + Constants.version); init(); setSizeFromPreviousRun(); // shell_.setMaximized(true); shell_.open(); try { while (!shell_.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (RuntimeException e) { System.err.println(e); e.printStackTrace(); errorHandler.showError("ERROR", "Unhandled error, see log for details - exiting."); } display.dispose(); System.exit(0); }
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 w w w . j a va2 s . 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.opencms.applet.upload.FileUploadApplet.java
/** * Uploads the zipfile to the OpenCms.<p> * /*from w ww . ja va 2s . c om*/ * @param uploadFile the zipfile to upload */ private void uploadZipFile(File uploadFile) { m_action = m_actionOutputUpload; repaint(); PostMethod post = new PostMethod(m_targetUrl); try { Part[] parts = new Part[5]; parts[0] = new FilePart(uploadFile.getName(), uploadFile); parts[1] = new StringPart("action", "submitform"); parts[2] = new StringPart("unzipfile", "true"); parts[3] = new StringPart("uploadfolder", m_uploadFolder); parts[4] = new StringPart("clientfolder", m_fileSelector.getCurrentDirectory().getAbsolutePath()); HttpMethodParams methodParams = post.getParams(); methodParams.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); MultipartRequestEntity request = new MultipartRequestEntity(parts, methodParams); post.setRequestEntity(request); // add jsessionid query string String sessionId = getParameter("sessionId"); String query = ";" + C_JSESSIONID.toLowerCase() + "=" + sessionId; post.setQueryString(query); post.addRequestHeader(C_JSESSIONID, sessionId); HttpClient client = new HttpClient(); HttpConnectionParams connectionParams = client.getHttpConnectionManager().getParams(); connectionParams.setConnectionTimeout(5000); // add the session cookie client.getState(); client.getHostConfiguration().getHost(); HttpState initialState = new HttpState(); URI uri = new URI(m_targetUrl, false); Cookie sessionCookie = new Cookie(uri.getHost(), C_JSESSIONID, sessionId, "/", null, false); initialState.addCookie(sessionCookie); client.setState(initialState); // no execute the file upload int status = client.executeMethod(post); if (status == HttpStatus.SC_OK) { //return to the specified url and frame target getAppletContext().showDocument(new URL(m_redirectUrl), m_redirectTargetFrame); } else { // create the error text String error = m_errorLine1 + "\n" + post.getStatusLine(); //JOptionPane.showMessageDialog(this, error, "Error!", JOptionPane.ERROR_MESSAGE); getAppletContext().showDocument(new URL(m_errorUrl + "?action=showerror&uploaderror=" + error), "explorer_files"); } } catch (RuntimeException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { post.releaseConnection(); // finally delete the zipFile on the harddisc uploadFile.delete(); } }
From source file:org.zkoss.poi.ss.format.CellNumberFormatter.java
private void writeFraction(double value, StringBuffer result, double fractional, StringBuffer output, Set<StringMod> mods) { // Figure out if we are to suppress either the integer or fractional part. // With # the suppressed part is removed; with ? it is replaced with spaces. if (!improperFraction) { // If fractional part is zero, and numerator doesn't have '0', write out // only the integer part and strip the rest. if (fractional == 0 && !hasChar('0', numeratorSpecials)) { writeInteger(result, output, integerSpecials, mods, false, false); Special start = integerSpecials.get(integerSpecials.size() - 1); Special end = denominatorSpecials.get(denominatorSpecials.size() - 1); if (hasChar('?', integerSpecials, numeratorSpecials, denominatorSpecials)) { //if any format has '?', then replace the fraction with spaces mods.add(replaceMod(start, false, end, true, ' ')); } else { // otherwise, remove the fraction mods.add(deleteMod(start, false, end, true)); }//from w w w . jav a 2 s . c om // That's all, just return return; } else { // New we check to see if we should remove the integer part boolean allZero = (value == 0 && fractional == 0); boolean willShowFraction = fractional != 0 || hasChar('0', numeratorSpecials); boolean removeBecauseZero = allZero && (hasOnly('#', integerSpecials) || !hasChar('0', numeratorSpecials)); boolean removeBecauseFraction = !allZero && value == 0 && willShowFraction && !hasChar('0', integerSpecials); if (removeBecauseZero || removeBecauseFraction) { Special start = integerSpecials.get(integerSpecials.size() - 1); if (hasChar('?', integerSpecials, numeratorSpecials)) { mods.add(replaceMod(start, true, numerator, false, ' ')); } else { mods.add(deleteMod(start, true, numerator, false)); } } else { // Not removing the integer part -- print it out writeInteger(result, output, integerSpecials, mods, false, false); } } } // Calculate and print the actual fraction (improper or otherwise) try { int n; int d; // the "fractional % 1" captures integer values in improper fractions if (fractional == 0 || (improperFraction && fractional % 1 == 0)) { // 0 as a fraction is reported by excel as 0/1 n = (int) Math.round(fractional); d = fixDenominator ? maxDenominator : 1; } else if (fixDenominator) { //20100913, henrichen@zkoss.org: handle fixed denominator case d = maxDenominator; n = (int) Math.round(fractional * d); } else { Fraction frac = new Fraction(fractional, maxDenominator); n = frac.getNumerator(); d = frac.getDenominator(); } if (improperFraction) n += Math.round(value * d); writeSingleInteger(numeratorFmt, n, output, numeratorSpecials, mods); //20100913, henrichen@zkoss.org: handle 0 in ???/??? text format writeSingleInteger(d == 1 ? leftAlignNumberFormat(denominatorSpecials) : denominatorFmt, d, output, denominatorSpecials, mods); } catch (RuntimeException ignored) { ignored.printStackTrace(); } }
From source file:org.opencms.applet.upload.FileUploadApplet.java
/** * @see java.lang.Runnable#run()//from w ww . j a va 2 s . c om */ public void run() { try { boolean ok = true; while (ok) { ok = true; m_message = ""; m_resources = 0; m_step = 0; // create a new file chooser if (m_fileSelector == null) { m_fileSelector = new UploadAppletFileChooser(this); } // file selector can read files and folders m_fileSelector.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); m_fileSelector.setDialogTitle(m_actionOutputSelect); FileFilter imageFilter = new ImageFilter(); FileFilter officeFilter = new OfficeFilter(); FileFilter webFilter = new WebFilter(); // add two custom file filters (office and images) and the default filters m_fileSelector.addChoosableFileFilter(imageFilter); m_fileSelector.addChoosableFileFilter(officeFilter); m_fileSelector.addChoosableFileFilter(webFilter); m_fileSelector.setAcceptAllFileFilterUsed(true); // enable multi-selection of files m_fileSelector.setMultiSelectionEnabled(true); // add custom icons for file types. m_fileSelector.setFileView(new ImageFileView(m_opencms, m_fileExtensions)); // add the image preview pane. m_fileSelector.setAccessory(new ImagePreview(m_fileSelector, m_messageNoPreview)); if ((m_clientFolder != null) && !m_clientFolder.trim().equals("")) { File clientFolder = new File(m_clientFolder); if (clientFolder.exists() && clientFolder.isDirectory()) { m_fileSelector.setCurrentDirectory(clientFolder); } } m_action = m_actionOutputSelect; // pre - selection of the filter: if ((m_fileFilterSelection != null) && !m_fileFilterSelection.trim().equals("")) { if (WebFilter.FILTER_ID.equals(m_fileFilterSelection)) { m_fileSelector.setFileFilter(webFilter); } else if (OfficeFilter.FILTER_ID.equals(m_fileFilterSelection)) { m_fileSelector.setFileFilter(officeFilter); } else if (ImageFilter.FILTER_ID.equals(m_fileFilterSelection)) { m_fileSelector.setFileFilter(imageFilter); } } repaint(); m_overwrites = new ArrayList(); int returnVal = m_fileSelector.showDialog(this, "OK"); // process the results. if (returnVal == JFileChooser.APPROVE_OPTION) { // count all resources m_outputMode = 1; m_action = m_actionOutputCount; repaint(); File[] files = m_fileSelector.getSelectedFiles(); List fileNames = new ArrayList(); for (int i = 0; i < files.length; i++) { getRelativeFilePaths(files[i], fileNames); } if (m_overwrites.size() > 0) { // subtract all duplicate files first files = subtractDuplicates(fileNames, m_overwrites); files = addOverwrites(files, ((FileSelectionPanel) m_overwriteDialog.getControlPanel().getComponent(1)) .getSelectedFiles()); } else { fileNames = new ArrayList(); for (int i = 0; i < files.length; i++) { getFilesInTree(files[i], fileNames); } files = (File[]) fileNames.toArray(new File[fileNames.size()]); } m_resources = countResources(files); // create the zipfile m_outputMode = 2; if (files.length > 0) { File targetFile = createZipFile(files); // check the size of the zip files if ((targetFile == null) || ((m_maxsize > 0) && (targetFile.length() > m_maxsize))) { // show some details in the applet itself m_outputMode = 4; if (targetFile == null) { m_message = m_messageOutputErrorZip; } else { m_message = m_messageOutputErrorSize + " " + targetFile.length() + " > " + m_maxsize; } m_action = m_actionOutputError; repaint(); // show an error-alertbog JOptionPane.showMessageDialog(this, m_message, m_action, JOptionPane.ERROR_MESSAGE); } else { m_outputMode = 3; m_message = m_messageOutputUpload + " (" + targetFile.length() / 1024 + " kb)"; repaint(); // upload the zipfile FileUploadThread uploadThreat = new FileUploadThread(); uploadThreat.init(this); uploadThreat.start(); uploadZipFile(targetFile); ok = false; } } else { // zero files were selected for upload (might be that all potential overwrites were deselected) ok = false; getAppletContext().showDocument(new URL(m_redirectUrl), m_redirectTargetFrame); } } else { //the cancel button was used, so go back to the workplace ok = false; getAppletContext().showDocument(new URL(m_redirectUrl), m_redirectTargetFrame); } } } catch (RuntimeException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.apache.geode.internal.net.SocketCreator.java
/** * Initialize this SocketCreator./*from w w w. j a v a 2s.com*/ * <p> * Caller must synchronize on the SocketCreator instance. */ @SuppressWarnings("hiding") private void initialize() { try { // set p2p values... if (SecurableCommunicationChannel.CLUSTER.equals(sslConfig.getSecuredCommunicationChannel())) { if (this.sslConfig.isEnabled()) { System.setProperty("p2p.useSSL", "true"); System.setProperty("p2p.oldIO", "true"); System.setProperty("p2p.nodirectBuffers", "true"); } else { System.setProperty("p2p.useSSL", "false"); } } try { if (this.sslConfig.isEnabled() && sslContext == null) { sslContext = createAndConfigureSSLContext(); SSLContext.setDefault(sslContext); } } catch (Exception e) { throw new GemFireConfigException("Error configuring GemFire ssl ", e); } // make sure TCPConduit picks up p2p properties... org.apache.geode.internal.tcp.TCPConduit.init(); initializeClientSocketFactory(); this.ready = true; } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (Error t) { // Whenever you catch Error or Throwable, you must also // catch VirtualMachineError (see above). However, there is // _still_ a possibility that you are dealing with a cascading // error condition, so you also need to check to see if the JVM // is still usable: SystemFailure.checkFailure(); t.printStackTrace(); throw t; } catch (RuntimeException re) { re.printStackTrace(); throw re; } }