Example usage for java.lang SecurityException printStackTrace

List of usage examples for java.lang SecurityException printStackTrace

Introduction

In this page you can find the example usage for java.lang SecurityException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.example.xwalkembedded.LocationActivity.java

private void setup() {
    Location gpsLocation = null;//  w w  w. j a va 2 s .  c o m
    Location networkLocation = null;
    try {
        mLocationManager.removeUpdates(listener);
    } catch (SecurityException e) {
        e.printStackTrace();
    }
    mLatLng.setText(R.string.unknown);
    mAddress.setText(R.string.unknown);
    // Get fine location updates only.
    if (mUseFine) {
        mFineProviderButton.setBackgroundResource(R.drawable.button_active);
        mBothProviderButton.setBackgroundResource(R.drawable.button_inactive);
        // Request updates from just the fine (gps) provider.
        gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
        // Update the UI immediately if a location is obtained.
        if (gpsLocation != null)
            updateUILocation(gpsLocation);
    } else if (mUseBoth) {
        // Get coarse and fine location updates.
        mFineProviderButton.setBackgroundResource(R.drawable.button_inactive);
        mBothProviderButton.setBackgroundResource(R.drawable.button_active);
        // Request updates from both fine (gps) and coarse (network) providers.
        gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
        networkLocation = requestUpdatesFromProvider(LocationManager.NETWORK_PROVIDER,
                R.string.not_support_network);

        // If both providers return last known locations, compare the two and use the better
        // one to update the UI.  If only one provider returns a location, use it.
        if (gpsLocation != null && networkLocation != null) {
            updateUILocation(getBetterLocation(gpsLocation, networkLocation));
            Log.d("fujunwei", "======getBetterLocation ");
        } else if (gpsLocation != null) {
            Log.d("fujunwei", "======gpsLocation ");
            updateUILocation(gpsLocation);
        } else if (networkLocation != null) {
            Log.d("fujunwei", "======networkLocation ");
            updateUILocation(networkLocation);
        }
        //            requestPermissionsForLocation();
        Log.d("fujunwei", "======All null ");
    }
}

From source file:org.jacorb.JacorbActivator.java

/**
 * This method ensures that if the Java logging properties weren't properly installed by the IDE's feature
 * into the configuration directory that we'll load a backup. This is primarily important for debugging the IDE
 * within Eclipse where this is the situation.
 * /*w  w w  .  j  a va2 s  .c o  m*/
 * @param context
 */
private void configureJavaLogger(final BundleContext context) {
    String currentProperty = System.getProperty("java.util.logging.config.file");
    if (currentProperty != null) {
        File propFile = new File(currentProperty);
        if (propFile.exists()) {
            try {
                LogManager.getLogManager().readConfiguration();
                return;
            } catch (SecurityException e) {
                e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE
            } catch (IOException e) {
                e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE
            }
        }
    }

    InputStream test = null;
    InputStream logInputStream = null;
    try {
        test = Platform.getConfigurationLocation().getDataArea("javalogger.properties").openStream();
        LogManager.getLogManager().readConfiguration(test);
    } catch (IOException e) {
        URL javaloggerURL = FileLocator.find(context.getBundle(), new Path("etc/javalogger.properties"), null);
        if (javaloggerURL != null) {
            try {
                logInputStream = javaloggerURL.openStream();
                LogManager.getLogManager().readConfiguration(logInputStream);
            } catch (IOException e2) {
                e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE
            } catch (SecurityException e2) {
                e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE
            }
        }
    } finally {
        if (test != null) {
            try {
                test.close();
            } catch (IOException e) {
                // PASS
            }
        }
        if (logInputStream != null) {
            try {
                logInputStream.close();
            } catch (IOException e) {
                // PASS
            }
        }
    }
}

From source file:org.sakaiproject.kernel.rest.search.RestSearchProvider.java

/**
 * {@inheritDoc}//from   w  w  w  .j av  a 2 s.  c om
 *
 * @see org.sakaiproject.kernel.api.rest.RestProvider#dispatch(java.lang.String[],
 *      javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 */
public void dispatch(String[] elements, HttpServletRequest request, HttpServletResponse response) {
    try {
        Map<String, Object> map = doSearch(request, response);
        if (map != null) {
            String responseBody = beanConverter.convertToString(map);
            response.setContentType(RestProvider.CONTENT_TYPE);
            response.getOutputStream().print(responseBody);
        }
    } catch (SecurityException ex) {
        throw ex;
    } catch (RestServiceFaultException ex) {
        throw ex;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RestServiceFaultException(ex.getMessage(), ex);
    }
}

From source file:com.cubic9.android.droidglove.Main.java

/**
 * detect tethering function is active or not
 * @param manager WiFi manager//  w  w  w  .jav a2 s .  c om
 * @return active or not
 */
private boolean isTethering(final WifiManager manager) {
    Method method = null;
    try {
        method = manager.getClass().getDeclaredMethod("isWifiApEnabled");
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    method.setAccessible(true);
    try {
        return (Boolean) method.invoke(manager);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }

    return false;
}

From source file:com.hellofyc.base.app.activity.BaseActivity.java

@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
    try {/*from  w w  w  . j  a  v  a2s  .c  o m*/
        super.startActivityForResult(intent, requestCode, options);
    } catch (SecurityException e) {
        e.printStackTrace();
    }
}

From source file:fr.cls.atoll.motu.processor.wps.StringList.java

public static void testCreateObject() {
    Class<?> clazz = null;/*  w  ww.j  a  va 2s . co  m*/
    Class<?> clazzTemp = null;
    Constructor<?> ctor = null;
    try {
        Object[] values = { "it's a string", true, new BigDecimal(125489.365),
                DateUtils.stringToDateTime("2007-10-05"), new DateTime(125236636), new Period(6539),
                DateUtils.stringToPeriod("P5Y2M10DT15H"),
                new URI("http://www.w3schools.com/Schema/schema_dtypes_date.asp"), 125639, 4526L, 4253.635,
                (short) 25, 125.36f, (byte) 'a', };

        for (Object value : values) {
            Object object = null;
            String valueString = value.toString();
            clazz = value.getClass();
            clazzTemp = valueString.getClass();
            if (DateTime.class.equals(clazz)) {
                object = DateUtils.stringToDateTime(valueString);

            } else if (Period.class.equals(clazz)) {
                object = DateUtils.stringToPeriod(valueString);
            } else {
                ctor = clazz.getConstructor(clazzTemp);
                object = ctor.newInstance(valueString);
            }

            // System.out.print(value.getClass().getName());
            System.out.print(object.getClass().getName());
            System.out.print(" --> ");
            System.out.println(object);

        }

    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MotuConverterException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:ml.puredark.hviewer.ui.fragments.SettingFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == RESULT_CHOOSE_DIRECTORY) {
            Uri uriTree = data.getData();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                try {
                    getActivity().getContentResolver().takePersistableUriPermission(uriTree,
                            Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                } catch (SecurityException e) {
                    e.printStackTrace();
                }/*from  www . j  a  va  2 s .  c om*/
            }
            String path = uriTree.toString();
            String displayPath = Uri.decode(path);
            SharedPreferencesUtil.saveData(getActivity(), KEY_PREF_DOWNLOAD_PATH, path);
            getPreferenceManager().findPreference(KEY_PREF_DOWNLOAD_PATH).setSummary(displayPath);
        }
    }
}

From source file:org.talend.repository.nosql.ui.common.AbstractNoSQLRetrieveSchemaForm.java

@Override
protected void processWhenDispose() {
    if (retrieveSchemaExecutor != null) {
        try {//from  w ww. jav a 2 s.c om
            retrieveSchemaExecutor.shutdownNow();
            retrieveSchemaExecutor.shutdown();
        } catch (SecurityException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.apache.directory.studio.connection.core.io.jndi.LdifSearchLogger.java

/**
 * Inits the search logger./*ww  w  . j  a  v a 2  s  . co m*/
 */
private void initSearchLogger(Connection connection) {
    Logger logger = Logger.getAnonymousLogger();
    loggers.put(connection.getId(), logger);
    logger.setLevel(Level.ALL);

    String logfileName = ConnectionManager.getSearchLogFileName(connection);
    try {
        FileHandler fileHandler = new FileHandler(logfileName, getFileSizeInKb() * 1000, getFileCount(), true);
        fileHandlers.put(connection.getId(), fileHandler);
        fileHandler.setFormatter(new Formatter() {
            public String format(LogRecord record) {
                return record.getMessage();
            }
        });
        logger.addHandler(fileHandler);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.canappi.connector.yp.yhere.SettingsView.java

public void viewDidLoad() {

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        Set<String> keys = extras.keySet();
        for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
            String key = iter.next();
            Class c = SearchView.class;
            try {
                Field f = c.getDeclaredField(key);
                Object extra = extras.get(key);
                String value = extra.toString();
                f.set(this, extras.getString(value));
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();/*from w  w w. j  av  a2  s .  c o m*/
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else {

    }

    settingsViewIds = new HashMap();
    settingsViewValues = new HashMap();

    isUserDefault = true;

    if (isUserDefault) {
        searchlocEditText.setText(retrieveFromUserDefaultsFor("searchloc"), TextView.BufferType.EDITABLE);
    }

    String updateZipButtonText = "Update";
    String updateZipButtonPressedText = "";

    updateZipButton = (Button) findViewById(R.id.updateZipButton);
    updateZipButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            updateDefaults(v);
        }
    });
    didSelectViewController();

}