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.recordvoice.service.RecordService.java

private void stopAndReleaseRecorder() {
    if (recorder == null)
        return;//from   w  w  w.java  2s.  c  o m
    Log.d(Constants.TAG, "RecordService stopAndReleaseRecorder");
    boolean recorderStopped = false;
    boolean exception = false;

    try {
        recorder.stop();
        recorderStopped = true;
    } catch (IllegalStateException e) {
        Log.e(Constants.TAG, "IllegalStateException");
        e.printStackTrace();
        exception = true;
    } catch (RuntimeException e) {
        Log.e(Constants.TAG, "RuntimeException");
        exception = true;
    } catch (Exception e) {
        Log.e(Constants.TAG, "Exception");
        e.printStackTrace();
        exception = true;
    }
    try {
        recorder.reset();
    } catch (Exception e) {
        Log.e(Constants.TAG, "Exception");
        e.printStackTrace();
        exception = true;
    }
    try {
        recorder.release();
    } catch (Exception e) {
        Log.e(Constants.TAG, "Exception");
        e.printStackTrace();
        exception = true;
    }

    recorder = null;
    if (exception) {
        deleteFile();
    } else {
        DatabaseHandle databaseHandle = new DatabaseHandle(this);
        RecordCall recordCall = FileHelper.getRecordCall();
        if (recordCall != null) {
            databaseHandle.addHistory(recordCall);
        }
    }
    if (recorderStopped) {
        Toast toast = Toast.makeText(this, this.getString(R.string.receiver_end_call), Toast.LENGTH_SHORT);
        toast.show();
        showNoti();
    }
}

From source file:com.cattle.fragments.UserPhotosFragment.java

private void loadBucketId(String id) {
    if (isAdded()) {
        Bundle bundle = new Bundle();
        if (null != id) {
            bundle.putString(LOADER_PHOTOS_BUCKETS_PARAM, id);
        }//  ww  w  .  j  a  v a  2 s . c om
        try {
            getLoaderManager().restartLoader(LOADER_USER_PHOTOS_EXTERNAL, bundle, this);
        } catch (IllegalStateException e) {
            e.printStackTrace();
            // Can sometimes catch with: Fragment not attached to Activity.
            // Not much we can do to recover
        }
    }
}

From source file:com.android.server.MaybeDatabaseHelper.java

public boolean hasEntries(String packagename) {
    if (!checkInitialized()) {
        return false;
    }/*from   w w  w  . j  ava  2  s.c  om*/

    Cursor cursor = null;
    boolean ret = false;

    try {
        /* cursor = sDatabase.query(APP_TABLE_NAME, new String[]{DATA_COL}, PACKAGE_COL+"="+packagename,
           null, null, null, null, null);
         */
        cursor = sDatabase.rawQuery("SELECT count(*) FROM " + APP_TABLE_NAME + " where " + PACKAGE_COL + " = ?",
                new String[] { packagename });
        /*
        if(cursor == null){
          Log.v(DBTAG, "cursor is null");
          return false;
        }
        ret = (cursor.moveToFirst() == true);
        */
        Log.v(DBTAG, "num columns|column" + cursor.getColumnCount() + "|" + cursor.getColumnName(0) + "|");
        cursor.moveToFirst();
        ret = (cursor.getInt(cursor.getColumnIndex("count(*)")) > 0);
        Log.v(DBTAG, "Package exists: Count:" + ret + cursor.getCount());
    } catch (IllegalStateException e) {
        Log.e(DBTAG, "IllegalStateException in hasEntries", e);

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return ret;
}

From source file:org.kalypsodeegree_impl.model.feature.FeatureHelper.java

/**
 * Resolves linked features. Handles XLinks.
 * /*ww  w . java  2s .  c om*/
 * @deprecated Use {@link Feature#getMember(QName)} instead.
 */
@Deprecated
public static Feature resolveLinkedFeature(final GMLWorkspace targetWorkspace, final Object property) {
    if (property == null)
        return null;

    if (property instanceof IXLinkedFeature) {
        try {
            final IXLinkedFeature xLnk = (IXLinkedFeature) property;
            return xLnk.getFeature();
        } catch (final IllegalStateException e) {
            e.printStackTrace();

            return null;
        }
    }

    final Feature result = getFeature(targetWorkspace, property);
    if (result == null)
        return null;
    // throw new IllegalStateException( String.format( "Feature with id %s not found", property.toString() ) );

    return result;
}

From source file:it.geosolutions.operations.FileBrowserOperationController.java

@Override
public String getJsp(ModelMap model, HttpServletRequest request, List<MultipartFile> files) {

    System.out.println("getJSP di FileBrowser");

    String baseDir = getDefaultBaseDir();
    FileBrowser fb = new FileBrowser();

    Object gotParam = model.get("gotParam");

    @SuppressWarnings("unchecked")
    Map<String, String[]> parameters = request.getParameterMap();

    for (String key : parameters.keySet()) {
        System.out.println(key); // debug
        String[] vals = parameters.get(key);
        for (String val : vals) // debug
            System.out.println(" -> " + val); // debug
        if (key.equalsIgnoreCase("d")) {
            String dirString = parameters.get(key)[0].trim();

            // prevent directory traversing
            dirString = dirString.replace("..", "");
            // clean path
            dirString = dirString.replace("/./", "/");
            dirString = dirString.replaceAll("/{2,}", "/");

            if (dirString.startsWith("/")) {
                dirString = dirString.substring(1);
            }/*from  w ww .  j a v  a2  s. c  o  m*/

            //remove last slash

            if (dirString.lastIndexOf("/") >= 0 && dirString.lastIndexOf("/") == (dirString.length() - 1)) {
                System.out.println("stripping last slash"); // debug
                dirString = dirString.substring(0, dirString.length() - 1);
            }

            //second check
            if (dirString.lastIndexOf("/") >= 0) {
                model.addAttribute("directoryBack", dirString.substring(0, dirString.lastIndexOf("/")));
            } else {
                model.addAttribute("directoryBack", "");
            }

            dirString = dirString.concat("/");
            baseDir = baseDir + dirString;
            model.addAttribute("directory", dirString);
        }
    }

    if (gotParam != null) {
        System.out.println(gotParam); // debug
    }
    String gotAction = request.getParameter("action");
    String fileToDel = request.getParameter("toDel");
    if (gotAction != null && gotAction.equalsIgnoreCase("delete") && fileToDel != null) {
        String deleteFileString = baseDir + fileToDel;
        boolean res = deleteFile(deleteFileString);
        System.out.println("Deletted " + deleteFileString + ": " + res); // debug
    }

    model.addAttribute("operationName", this.operationName);
    model.addAttribute("operationRESTPath", this.getRESTPath());

    fb.setBaseDir(baseDir);
    fb.setRegex(null);
    fb.setScanDiretories(canNavigate);

    if (null != files && files.size() > 0) {
        List<String> fileNames = new ArrayList<String>();
        for (MultipartFile multipartFile : files) {

            String fileName = multipartFile.getOriginalFilename();
            if (!"".equalsIgnoreCase(fileName)) {
                try {
                    multipartFile.transferTo(new File(baseDir + fileName));
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                fileNames.add(fileName);
            }
            System.out.println(fileName);
        }
    }

    model.addAttribute("fileBrowser", fb);

    model.addAttribute("operations", getAvailableOperations());

    model.addAttribute("canDelete", this.canDelete);
    model.addAttribute("canUpload", this.canUpload);

    model.addAttribute("containerId", uniqueKey.toString().substring(0, 8));
    model.addAttribute("formId", uniqueKey.toString().substring(27, 36));

    return operationJSP;
}

From source file:edu.auburn.ppl.cyclecolumbus.NoteUploader.java

/******************************************************************************************
 * Uploads the note to the server//from  w  ww.  j  av  a  2 s .  c  o m
 ******************************************************************************************
 * @param currentNoteId Unique note ID to be uploaded
 * @return True if uploaded, false if not
 ******************************************************************************************/
boolean uploadOneNote(long currentNoteId) {
    boolean result = false;
    final String postUrl = "http://FountainCityCycling.org/post/";

    try {

        URL url = new URL(postUrl);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setDoInput(true); // Allow Inputs
        conn.setDoOutput(true); // Allow Outputs
        conn.setUseCaches(false); // Don't use a Cached Copy
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.setRequestProperty("ENCTYPE", "multipart/form-data");
        conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
        conn.setRequestProperty("Cycleatl-Protocol-Version", "4");

        /*
        Change protocol to 2 for Note, and change the point where you zip up the body.  (Dont zip up trip body)
        Since notes don't work either, this may not solve it.
         */

        DataOutputStream dos = new DataOutputStream(conn.getOutputStream());

        JSONObject note = getNoteJSON(currentNoteId);
        deviceId = getDeviceId();

        dos.writeBytes("--cycle*******notedata*******columbus\r\n"
                + "Content-Disposition: form-data; name=\"note\"\r\n\r\n" + note.toString() + "\r\n");
        dos.writeBytes("--cycle*******notedata*******columbus\r\n"
                + "Content-Disposition: form-data; name=\"version\"\r\n\r\n"
                + String.valueOf(kSaveNoteProtocolVersion) + "\r\n");
        dos.writeBytes("--cycle*******notedata*******columbus\r\n"
                + "Content-Disposition: form-data; name=\"device\"\r\n\r\n" + deviceId + "\r\n");

        if (imageDataNull == false) {
            dos.writeBytes("--cycle*******notedata*******columbus\r\n"
                    + "Content-Disposition: form-data; name=\"file\"; filename=\"" + deviceId + ".jpg\"\r\n"
                    + "Content-Type: image/jpeg\r\n\r\n");
            dos.write(imageData);
            dos.writeBytes("\r\n");
        }

        dos.writeBytes("--cycle*******notedata*******columbus--\r\n");

        dos.flush();
        dos.close();

        int serverResponseCode = conn.getResponseCode();
        String serverResponseMessage = conn.getResponseMessage();
        // JSONObject responseData = new JSONObject(serverResponseMessage);
        Log.v("KENNY", "HTTP Response is : " + serverResponseMessage + ": " + serverResponseCode);
        responseMessage = serverResponseMessage;
        responseCode = serverResponseCode;

        // 200 - 202 means successfully went to server and uploaded
        if (serverResponseCode == 200 || serverResponseCode == 201 || serverResponseCode == 202) {
            mDb.open();
            mDb.updateNoteStatus(currentNoteId, NoteData.STATUS_SENT);
            mDb.close();
            result = true;
        }
    } catch (IllegalStateException e) {
        Log.d("KENNY", "Note Catch: Illegal State Exception: " + e);
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        Log.d("KENNY", "Note Catch: IOException: " + e);
        e.printStackTrace();
        return false;
    } catch (JSONException e) {
        Log.d("KENNY", "Note Catch: JSONException: " + e);
        e.printStackTrace();
        return false;
    }
    return result;
}

From source file:net.kevxu.purdueassist.course.CatalogDetail.java

@Override
public void onRequestFinished(HttpResponse httpResponse) {
    try {/*w  ww  .java2s .  c o m*/
        InputStream stream = httpResponse.getEntity().getContent();
        Header encoding = httpResponse.getEntity().getContentEncoding();
        Document document;
        if (encoding == null) {
            document = Jsoup.parse(stream, null, URL_HEAD);
        } else {
            document = Jsoup.parse(stream, encoding.getValue(), URL_HEAD);
        }
        stream.close();
        CatalogDetailEntry entry = parseDocument(document);
        mListener.onCatalogDetailFinished(entry);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        mListener.onCatalogDetailFinished(e);
    } catch (HtmlParseException e) {
        mListener.onCatalogDetailFinished(e);
    } catch (CourseNotFoundException e) {
        mListener.onCatalogDetailFinished(e);
    } catch (Exception e) {
        mListener.onCatalogDetailFinished(e);
    } finally {
        this.requestFinished = true;
    }
}

From source file:at.tomtasche.reader.ui.activity.DocumentActivity.java

private void showProgress(final Loader<Document> loader, final boolean upload) {
    if (progressDialog != null)
        return;//w ww.  j  a  v a2s. co m

    try {
        progressDialog = new ProgressDialogFragment(upload);

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        progressDialog.show(transaction, ProgressDialogFragment.FRAGMENT_TAG);

        if (!upload) {
            final FileLoader fileLoader = (FileLoader) loader;

            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (progressDialog == null)
                        return;

                    progressDialog.setProgress(fileLoader.getProgress());

                    if (loader.isStarted())
                        handler.postDelayed(this, 1000);
                }
            }, 1000);
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();

        progressDialog = null;
    }
}

From source file:net.ausgstecktis.DAL.MigrationProxy.java

private void prepareRestClientAndCallWebService(final String service, int requestType) {
    if (currentRestClient == null)
        currentRestClient = new RestClient(service);
    if (!currentRestClient.getService().equals(service))
        currentRestClient.setService(service);
    try {/*from   w  w  w .j  a v a2 s  . co m*/
        currentRestClient.callWebService(requestType);
    } catch (final IllegalStateException e1) {
        e1.printStackTrace();
    } catch (final ClientProtocolException e1) {
        e1.printStackTrace();
    } catch (final IOException e1) {
        e1.printStackTrace();
    }
}

From source file:com.pemikir.youtubeplus.VideoItemListFragment.java

private void updateList(Vector<VideoInfoItem> list) {
    try {//w  ww  .j  a va2s  .  c  o m
        videoListAdapter.addVideoList(list);
        terminateThreads();
        loadThumbsRunnable = new LoadThumbsRunnable(videoListAdapter.getVideoList(),
                videoListAdapter.getDownloadedThumbnailList(), currentRequestId);
        loadThumbsThread = new Thread(loadThumbsRunnable);
        loadThumbsThread.start();
    } catch (java.lang.IllegalStateException e) {
        Log.w(TAG, "Trying to set value while activity is not existing anymore.");
    } catch (Exception e) {
        e.printStackTrace();
    }
}