Example usage for java.lang SecurityException getStackTrace

List of usage examples for java.lang SecurityException getStackTrace

Introduction

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

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:org.csploit.android.core.UpdateService.java

@Override
protected void onHandleIntent(Intent intent) {
    action what_to_do = (action) intent.getSerializableExtra(ACTION);
    boolean exitForError = true;

    if (what_to_do == null) {
        Logger.error("received null action");
        return;//from w  w  w  .j av a 2 s  .c om
    }

    mRunning = true;

    switch (what_to_do) {
    case apk_update:
        mCurrentTask = mApkInfo;
        break;
    case core_update:
        mCurrentTask = mCoreInfo;
        break;
    case ruby_update:
        mCurrentTask = mRubyInfo;
        break;
    case msf_update:
        mCurrentTask = mMsfInfo;
        break;
    case gems_update:
        mCurrentTask = new ArchiveMetadata();
        break;
    }

    try {
        setupNotification();

        synchronized (mCurrentTask) {
            mCurrentTask.errorOccurred = true;
            if (!haveLocalFile())
                downloadFile();

            if (what_to_do == action.core_update)
                System.shutdownCoreDaemon();

            extract();

            if (what_to_do == action.msf_update)
                installGems();
            else if (what_to_do == action.gems_update)
                updateGems();
            else if (what_to_do == action.core_update)
                System.initCore();

            deleteTemporaryFiles();
            createVersionFile();

            mCurrentTask.errorOccurred = exitForError = false;
        }

        sendDone(what_to_do);
    } catch (SecurityException e) {
        sendError(what_to_do, R.string.bad_permissions);
        Logger.warning(e.getClass().getName() + ": " + e.getMessage());
    } catch (KeyException e) {
        sendError(what_to_do, R.string.checksum_failed);
        Logger.warning(e.getClass().getName() + ": " + e.getMessage());
    } catch (NoSuchAlgorithmException e) {
        sendError(what_to_do, R.string.error_occured);
        System.errorLogging(e);
    } catch (CancellationException e) {
        sendError(what_to_do, R.string.update_cancelled);
        Logger.warning(e.getClass().getName() + ": " + e.getMessage());
    } catch (IOException e) {
        sendError(what_to_do, R.string.error_occured);
        System.errorLogging(e);
    } catch (RuntimeException e) {
        sendError(what_to_do, R.string.error_occured);

        StackTraceElement[] stack = e.getStackTrace();
        StackTraceElement frame = e.getStackTrace()[0];

        for (StackTraceElement f : stack) {
            if (f.getClassName().startsWith("org.csploit.android")) {
                frame = f;
                break;
            }
        }

        Logger.error(String.format("%s: %s [%s:%d]", e.getClass().getName(), e.getMessage(),
                frame.getFileName(), frame.getLineNumber()));
    } catch (InterruptedException e) {
        sendError(what_to_do, R.string.error_occured);
        System.errorLogging(e);
    } catch (ChildManager.ChildNotStartedException e) {
        sendError(what_to_do, R.string.error_occured);
        System.errorLogging(e);
    } catch (ChildManager.ChildDiedException e) {
        sendError(what_to_do, R.string.error_occured);
        System.errorLogging(e);
    } catch (System.SuException e) {
        sendError(what_to_do, R.string.only_4_root);
    } catch (System.DaemonException e) {
        sendError(what_to_do, R.string.heart_attack);
        Logger.error(e.getMessage());
    } finally {
        if (exitForError) {
            if (what_to_do == action.msf_update || what_to_do == action.gems_update)
                clearGemsCache();
            if (what_to_do != action.core_update)
                wipe();
        }
        stopSelf();
        mRunning = false;
    }
}

From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java

@Override
public void handleRemoveEdition(Integer editionId) {
    EditionHbm edition = getEditionHbmDao().load(editionId);
    if (log.isInfoEnabled())
        log.info("Deleting edition and attachments: " + edition.getEditionId());
    if (edition.getEditionFileName() != null) {
        File f = new File(edition.getEditionFileName());
        try {/*w  ww.  jav a 2s  . co  m*/
            f.delete();
        } catch (SecurityException se) {
            log.warn("Could not delete file: " + f.getAbsolutePath() + " " + se.getStackTrace());
        }
    }
    //getEditionHbmDao().remove(edition);
}