Example usage for java.lang IllegalStateException printStackTrace

List of usage examples for java.lang IllegalStateException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.example.android.camera2basic.Camera2VideoFragment.java

private void startRecordingVideo() {
    try {//from  w w w .j  av a 2  s.c  o m
        // UI
        //mButtonVideo.setText(R.string.stop);
        mIsRecordingVideo = true;
        Log.d(TAG, "start recording...");
        // Start recording
        mMediaRecorder.start();

    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:net.geant.edugain.filter.EduGAINFilter.java

private void fromHome(HttpServletRequest request, HttpServletResponse response) {
    String target = request.getParameter("TARGET");
    AuthenticationResponse eduGAINresponse = null;
    try {//from   ww  w  .  java 2s  .  c om
        eduGAINresponse = getSAMLResponse(request.getParameter("SAMLResponse").getBytes());
    } catch (Exception e) {
        e.printStackTrace();
        try {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unable to parse eduGAIN response");
            return;
        } catch (IOException e1) {
            this.log.error("Invalid eduGAIN response; unable to forward user to error page");
        }
    }

    if ((eduGAINresponse != null)
            && eduGAINresponse.getResult().equals(AuthenticationResponse.EDUGAIN_NAMESPACE_RESULT_ACCEPTED)) {
        try {
            Cookie lcook = getCookie(request, response, "statecook");
            HashMap attrs = validateCookie(lcook, "statecook");
            if ((attrs != null) && (attrs.containsKey("KEY"))) {
                String key = (String) attrs.get("KEY");
                HashMap<String, String> oldRequest = (HashMap<String, String>) this.loadRequest(key);
                String oldURL = reconstructRequest(oldRequest, response);

                attrs = parseAttrs(eduGAINresponse);

                request.getSession().setAttribute("SAMLResponse", eduGAINresponse.toSAML());
                attachCookies("lcook", attrs, response, false);
                attachCookies("statecook", null, response, true);
                //addAttributes(attrs,request.getSession());
                if (!(oldURL.equals("")) && (oldRequest != null) && !(response.isCommitted()))
                    response.sendRedirect(oldURL);
                else
                    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unable to load old request");

            } else
                response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Connection timed out");
        } catch (IOException ioe) {
            try {
                response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "State cookie not found");
            } catch (IOException e) {
                this.log.error("State cookie not found");
                ioe.printStackTrace();
            }

        } catch (Exception e) {
            try {
                e.printStackTrace();
                response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT, "Process timed out");
            } catch (IOException e1) {
                this.log.error("Process timed out");
                e1.printStackTrace();
            }
        }

    } else
        try {
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid authentication at home domain");
        } catch (IOException e) {
            this.log.error("Invalid authentication at home domain");
            e.printStackTrace();
        } catch (IllegalStateException ex) {
            this.log.error("Unable to forward user to error page");
            ex.printStackTrace();
        }

}

From source file:org.apache.jackrabbit.oak.explorer.NodeStoreTree.java

@Override
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    if (node == null) {
        return;// w w  w . j  a  va2s .c  o  m
    }
    // load child nodes:
    try {
        addChildren(node);
        updateStats(node);
    } catch (IllegalStateException ex) {
        ex.printStackTrace();

        StringBuilder sb = new StringBuilder();
        sb.append(ex.getMessage());
        sb.append(newline);

        NamePathModel model = (NamePathModel) node.getUserObject();
        NodeState state = model.getState();
        String recordId = backend.getRecordId(state);
        if (recordId != null) {
            sb.append("Record ");
            sb.append(recordId);
            sb.append(newline);
        }
        setText(sb.toString());
    }
}

From source file:com.intel.xdk.player.Player.java

public void stopAudio() {
    if (mediaPlayer != null) {
        try {/* w  w w. j av a2 s .c  om*/
            mediaPlayer.stop();
            mediaPlayer = null;
            injectJS(
                    "javascript:var ev = document.createEvent('Events');ev.initEvent('intel.xdk.player.audio.stop',true,true);document.dispatchEvent(ev);");
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    }
    setPlayingAudio(false);
}

From source file:com.ghkjgod.lightnovel.component.PagerSlidingTabStrip.java

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    if (pager != null) {
        if (adapterObserver.isAttached()) {
            try {
                pager.getAdapter().unregisterDataSetObserver(adapterObserver);
            } catch (IllegalStateException e) {
                e.printStackTrace();
            }/*  ww w  . ja  v a  2 s .c  om*/
            adapterObserver.setAttached(false);
        }
    }
}

From source file:uk.bowdlerize.service.CensorCensusService.java

private CensorPayload checkURL(String checkURL) throws IllegalArgumentException, URISyntaxException {
    if (!checkURL.startsWith("http"))
        checkURL = "http://" + checkURL;

    CensorPayload censorPayload = new CensorPayload(checkURL);

    Uri mUri = Uri.parse(checkURL);/*from  w  w w .  ja  va 2  s.c  om*/

    if (null == mUri.getEncodedQuery()) {
        checkURL = mUri.getScheme() + "://" + mUri.getHost() + mUri.getPath();
    } else {
        checkURL = mUri.getScheme() + "://" + mUri.getHost() + mUri.getPath() + "?"
                + URLEncoder.encode(mUri.getEncodedQuery());
    }

    Log.e("Checking url", checkURL);

    client = new DefaultHttpClient();

    /*headRequest = new HttpHead(checkURL);
    headRequest.setHeader("User-Agent", "OONI Android Probe");*/

    httpGet = new HttpGet(checkURL);
    httpGet.setHeader("User-Agent", "OONI Android Probe");

    try {
        //response = client.execute(headRequest);
        client.addResponseInterceptor(new HttpResponseInterceptor() {
            @Override
            public void process(HttpResponse httpResponse, HttpContext httpContext)
                    throws HttpException, IOException {
                if (httpResponse.getStatusLine().getStatusCode() == 302
                        || httpResponse.getStatusLine().getStatusCode() == 301) {
                    for (Header hdr : httpResponse.getAllHeaders()) {
                        if (hdr.getName().equals("Location")) {
                            /*if (hdr.getValue().equals("http://ee-outage.s3.amazonaws.com/content-blocked/content-blocked-v1.html") ||
                            hdr.getValue().contains("http://ee-outage.s3.amazonaws.com"))
                            {
                            Log.e("Blocked", "Blocked by EE");
                            throw new CensoredException("Blocked by EE", "EE", 100);
                            }
                            else if (hdr.getValue().contains("http://www.t-mobile.co.uk/service/wnw-mig/entry/") ||
                                 hdr.getValue().contains("http://tmobile.ee.co.uk/common/system_error_pages/outage_wnw.html"))
                            {
                            Log.e("Blocked", "Blocked by TMobile");
                            throw new CensoredException("Blocked by TMobile", "TMobile", 100);
                            }
                            else if (hdr.getValue().contains("http://online.vodafone.co.uk/dispatch/Portal/ContentControlServlet?type=restricted"))
                            {
                            Log.e("Blocked", "Blocked by Vodafone");
                            throw new CensoredException("Blocked by Vodafone", "Vodafone", 100);
                            }
                            else if (hdr.getValue().contains("http://blockpage.bt.com/pcstaticpage/blocked.html"))
                            {
                            Log.e("Blocked", "Blocked by BT");
                            throw new CensoredException("Blocked by BT", "BT", 100);
                            }
                            else if (hdr.getValue().contains("http://www.talktalk.co.uk/notice/parental-controls?accessurl"))
                            {
                            Log.e("Blocked", "Blocked by TalkTalk");
                            throw new CensoredException("Blocked by TalkTalk", "TalkTalk", 100);
                            }
                            else if (hdr.getValue().contains("http://www.plus.net/support/security/abuse/blocked.shtml"))
                            {
                            Log.e("Blocked", "Blocked by PlusNet");
                            throw new CensoredException("Blocked by PlusNet", "PlusNet", 100);
                            }
                            else if (hdr.getValue().contains("http://mobile.three.co.uk/pc/Live/pcreator/live/100004/pin/blocked?"))
                            {
                            Log.e("Blocked", "Blocked by Three");
                            throw new CensoredException("Blocked by Three", "Three", 100);
                            }
                            else if (hdr.getValue().contains("http://m.virginmedia.com/MiscPages/AdultWarning.aspx"))
                            {
                            Log.e("Blocked", "Blocked by VirginMobile");
                            throw new CensoredException("Blocked by VirginMobile", "VirginMobile", 100);
                            }
                            else if (hdr.getValue().contains("http://assets.o2.co.uk/18plusaccess/"))
                            {
                            Log.e("Blocked", "Blocked by O2");
                            throw new CensoredException("Blocked by O2", "O2", 100);
                            }*/
                            api.checkHeader(hdr);
                        }
                    }
                }

                /*Log.e("intercepted return code",httpResponse.getStatusLine().toString());
                        
                for(Header hdr : httpResponse.getAllHeaders())
                {
                Log.e("intercepted header",hdr.getName().toString() + " / " + hdr.getValue().toString());
                }
                Log.e("intercepted header","------------------\r\n------------------\r\n------------------\r\n------------------\r\n------------------\r\n");*/

            }
        });
        response = client.execute(httpGet);
    }
    //This is the best case scenario!
    catch (CensoredException CE) {
        censorPayload.consumeCensoredException(CE);
        return censorPayload;
    } catch (UnknownHostException uhe) {
        uhe.printStackTrace();
        censorPayload.consumeError(uhe.getMessage());
        return censorPayload;
    } catch (ConnectTimeoutException CTE) {
        CTE.printStackTrace();
        censorPayload.consumeError(CTE.getMessage());
        return censorPayload;
    } catch (NoHttpResponseException NHRE) {
        NHRE.printStackTrace();
        censorPayload.consumeError(NHRE.getMessage());
        return censorPayload;
    } catch (IOException ioe) {
        ioe.printStackTrace();
        censorPayload.consumeError(ioe.getMessage());
        return censorPayload;
    } catch (IllegalStateException ise) {
        ise.printStackTrace();
        censorPayload.setCensored(false);
        censorPayload.setConfidence(0);
        return censorPayload;
    } catch (Exception e) {
        e.printStackTrace();
        censorPayload.setCensored(false);
        censorPayload.setConfidence(0);
        return censorPayload;
    }

    int statusCode = response.getStatusLine().getStatusCode();

    censorPayload.setReturnCode(statusCode);

    Log.e("checkURL code", Integer.toString(statusCode));
    if (statusCode == 403 || statusCode == 404) {
        censorPayload.setCensored(true);
        censorPayload.setConfidence(25);
        return censorPayload;
    } else if (statusCode == 504 || statusCode == 503 || statusCode == 500) {
        censorPayload.consumeError("Server Issue " + Integer.toString(statusCode));
        return censorPayload;
    }

    String phrase = response.getStatusLine().getReasonPhrase();

    Log.e("checkURL phrase", phrase);

    if (phrase.contains("orbidden")) {
        censorPayload.setCensored(true);
        censorPayload.setConfidence(50);
        return censorPayload;
    }

    if (phrase.contains("blocked")) {
        censorPayload.setCensored(true);
        censorPayload.setConfidence(100);
        return censorPayload;
    }

    for (Header hdr : response.getAllHeaders()) {
        Log.e("checkURL header", hdr.getName() + " / " + hdr.getValue());
    }

    censorPayload.setCensored(false);
    censorPayload.setConfidence(1);
    return censorPayload;
}

From source file:com.piusvelte.webcaster.MainActivity.java

private void clearCasting() {
    try {/*from w ww.  jav a 2 s  .  com*/
        if (applicationSession != null) {
            applicationSession.setStopApplicationWhenEnding(true);
            applicationSession.endSession();
        } else {
            Log.e(TAG, "onRouteUnselected: mSession is null");
        }
    } catch (IllegalStateException e) {
        Log.e(TAG, "onRouteUnselected:");
        e.printStackTrace();
    } catch (IOException e) {
        Log.e(TAG, "onRouteUnselected:");
        e.printStackTrace();
    }
    mediaProtocolMessageStream = null;
    castDevice = null;
    mediaRouteStateChangeListener = null;
}

From source file:com.piusvelte.webcaster.MainActivity.java

@Override
public void onStartTrackingTouch(SeekBar arg0) {
    synchronized (isSeekingLock) {
        isSeeking = true;//  w w w .  ja va 2s  .co m
    }
    if (mediaProtocolMessageStream != null) {
        try {
            mediaProtocolMessageStream.stop();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:com.piusvelte.webcaster.MainActivity.java

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    synchronized (isSeekingLock) {
        isSeeking = false;/*from w w  w. j a v  a  2  s  .co  m*/
    }
    if (mediaProtocolMessageStream != null) {
        try {
            mediaProtocolMessageStream.playFrom(seekBar.getProgress());
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:com.commontime.cordova.audio.AudioPlayer.java

/**
 * Start recording the specified file.//from  ww w  .  j  a  v a2 s .c om
 *
 * @param file              The name of the file, should use .m4a extension
 */
public void startRecording(String file) {
    switch (this.mode) {
    case PLAY:
        Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
        sendErrorStatus(MEDIA_ERR_ABORTED);
        break;
    case NONE:
        // if file exists, delete it
        // Only new file are created with startRecording

        File f = new File(file);
        f.delete();

        this.audioFile = file;
        this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

        //Modified by REM 06/15/2015 to generate MPEG_4 output
        this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        this.recorder.setAudioChannels(1); // single channel
        this.recorder.setAudioSamplingRate(44100); // 44.1 kHz for decent sound, similar to stock iOS media plugin
        this.recorder.setAudioEncodingBitRate(32000); // low bit rate

        this.recorder.setOutputFile(this.tempFile);
        try {
            this.recorder.prepare();
            this.recorder.start();
            this.setState(STATE.MEDIA_RUNNING);
            return;
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        sendErrorStatus(MEDIA_ERR_ABORTED);
        break;
    case RECORD:
        Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
        sendErrorStatus(MEDIA_ERR_ABORTED);
    }
}