List of usage examples for java.lang IllegalStateException printStackTrace
public void printStackTrace()
From source file:com.commontime.cordova.audio.AudioPlayer.java
/** * Resume recording the specified file.//w ww . jav a 2 s.c o m * * @param file The name of the file * @param channels audio channels, 1 or 2, optional, default value is 1 * @param sampleRate sample rate in hz, 8000 to 48000, optional, default value is 44100 */ public void resumeRecording(String file, Integer channels, Integer sampleRate) { switch (this.mode) { case PLAY: Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode."); sendErrorStatus(MEDIA_ERR_ABORTED); break; case NONE: this.audioFile = file; this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC); this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); this.recorder.setAudioChannels(channels); this.recorder.setAudioSamplingRate(sampleRate); // On Android with MPEG4/AAC, bitRate affects file size, surprisingly, sample rate does not. // So we adjust the bit rate for better compression, based on requested sample rate. Integer bitRate = 32000; // default bit rate if (sampleRate < 30000) { bitRate = 16384; } if (sampleRate < 16000) { bitRate = 8192; } this.recorder.setAudioEncodingBitRate(bitRate); Log.d(LOG_TAG, "MPEG-4 recording started with bit rate of " + bitRate + ", sample rate of " + sampleRate + "hz, " + channels + " audio channel(s)"); 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); } }
From source file:com.commontime.cordova.audio.AudioPlayer.java
/** * Start recording the specified file with compression. * * @param file The name of the file, should use .m4a extension * @param channels audio channels, 1 or 2, optional, default value is 1 * @param sampleRate sample rate in hz, 8000 to 48000, optional, default value is 44100 *//*from w w w. jav a 2s.c o m*/ public void startRecordingWithCompression(String file, Integer channels, Integer sampleRate) { 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); this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); this.recorder.setAudioChannels(channels); this.recorder.setAudioSamplingRate(sampleRate); // On Android with MPEG4/AAC, bitRate affects file size, surprisingly, sample rate does not. // So we adjust the bit rate for better compression, based on requested sample rate. Integer bitRate = 32000; // default bit rate if (sampleRate < 30000) { bitRate = 16384; } if (sampleRate < 16000) { bitRate = 8192; } this.recorder.setAudioEncodingBitRate(bitRate); Log.d(LOG_TAG, "MPEG-4 recording started with bit rate of " + bitRate + ", sample rate of " + sampleRate + "hz, " + channels + " audio channel(s)"); 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); } }
From source file:com.piusvelte.webcaster.MainActivity.java
private void setupCasting() { MediaRouteHelper.registerMinimalMediaRouteProvider(castContext, this); mediaRouter = MediaRouter.getInstance(getApplicationContext()); mediaRouteSelector = MediaRouteHelper.buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST, appId, null); mediaRouterCallback = new MediaRouter.Callback() { @Override// ww w.ja v a 2 s . c om public void onRouteSelected(MediaRouter router, RouteInfo route) { MediaRouteHelper.requestCastDeviceForRoute(route); } @Override public void onRouteUnselected(MediaRouter router, RouteInfo route) { try { 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.insthub.O2OMobile.Activity.C1_PublishOrderActivity.java
/** * /*from ww w. j a v a 2s . c o m*/ */ private void startRecording() { mFileName = newFileName(); // try { mRecorder = new MediaRecorder(); //? mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); //??? mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB); mRecorder.setAudioSamplingRate(8000); mRecorder.setAudioEncodingBitRate(16); //?? mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setOutputFile(mFileName); mRecorder.prepare(); mRecorder.start(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalStateException e2) { e2.printStackTrace(); } mTimer = new Timer(); TimerTask timerTask = new TimerTask() { @Override public void run() { // TODO Auto-generated method stub mMaxTime--; Message msg = new Message(); msg.what = mMaxTime; handler.sendMessage(msg); } }; mTimer.schedule(timerTask, 1000, 1000); }
From source file:com.insthub.O2OMobile.Activity.C1_PublishOrderActivity.java
/** * ?// w ww . ja va2 s . c om */ private void stopRecording() { if (mTimer != null) { mTimer.cancel(); //?? } mTimer = null; if (mRecorder != null) { try { mRecorder.stop(); mRecorder.reset(); mRecorder.release(); } catch (IllegalStateException e) { e.printStackTrace(); } } mRecorder = null; MediaPlayer mp = MediaPlayer.create(this, Uri.parse(mFileName)); if (null != mp) { int duration = mp.getDuration();//? ms if (duration > 3000) { mVoice.setVisibility(View.GONE); mVoicePlay.setVisibility(View.VISIBLE); mVoiceReset.setVisibility(View.VISIBLE); } else { ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.record_time_too_short)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); File file = new File(newFileName()); if (file.exists()) { file.delete(); } } mp.release(); } mVoice.setKeepScreenOn(false); }
From source file:com.piusvelte.webcaster.MainActivity.java
@Override public void onClick(View v) { if (v.getId() == R.id.btn_play) { if (castDevice != null) { if (mediaProtocolMessageStream != null) { String text = ((Button) v).getText().toString(); if (text.startsWith(getString(R.string.play))) { Toast.makeText(this, getString(R.string.play), Toast.LENGTH_SHORT).show(); try { if (seekBar.getProgress() > 0) { mediaProtocolMessageStream.resume(); } else { mediaProtocolMessageStream.play(); }/*w w w .j av a2 s . co m*/ btnPlay.setText(R.string.pause); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast.makeText(this, getString(R.string.pause), Toast.LENGTH_SHORT).show(); try { mediaProtocolMessageStream.stop(); btnPlay.setText(R.string.play); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } else { Toast.makeText(this, getString(R.string.select_cast_device), Toast.LENGTH_SHORT).show(); } } }
From source file:it.geosolutions.opensdi.operations.FileBrowserOperationController.java
@Override public String getJsp(ModelMap model, HttpServletRequest request, List<MultipartFile> files) { registerManager();//from ww w.j av a 2 s . c o m LOGGER.debug("getJSP di FileBrowser"); // update key String update = request.getParameter("update"); HashMap<String, List<Operation>> availableOperations = getAvailableOperations(); String baseDir = getRunTimeDir(); FileBrowser fb = null; if (Boolean.TRUE.equals(this.showRunInformation)) { fb = new ExtendedFileBrowser(); ((ExtendedFileBrowser) fb).setAvailableOperations(availableOperations); ((ExtendedFileBrowser) fb).setGeoBatchClient(geoBatchClient); ((ExtendedFileBrowser) fb).setUpdateStatus(update != null); } else { fb = new FileBrowser(); } Object gotParam = model.get("gotParam"); @SuppressWarnings("unchecked") Map<String, String[]> parameters = request.getParameterMap(); for (String key : parameters.keySet()) { LOGGER.debug(key); // debug String[] vals = parameters.get(key); for (String val : vals) // debug LOGGER.debug(" -> " + val); // debug if (key.equalsIgnoreCase(DIRECTORY_KEY)) { String dirString = parameters.get(key)[0].trim(); dirString = ControllerUtils.preventDirectoryTrasversing(dirString); if (dirString.startsWith(SEPARATOR)) { dirString = dirString.substring(1); } // remove last slash if (dirString.lastIndexOf(SEPARATOR) >= 0 && dirString.lastIndexOf(SEPARATOR) == (dirString.length() - 1)) { LOGGER.debug("stripping last slash"); // debug dirString = dirString.substring(0, dirString.length() - 1); } // second check if (dirString.lastIndexOf(SEPARATOR) >= 0) { model.addAttribute("directoryBack", dirString.substring(0, dirString.lastIndexOf(SEPARATOR))); } else { model.addAttribute("directoryBack", ""); } dirString = dirString.concat(SEPARATOR); baseDir = baseDir + dirString; model.addAttribute("directory", dirString); model.addAttribute("jsDirectory", dirString.replace(SEPARATOR, "/")); } } if (gotParam != null) { LOGGER.debug(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); LOGGER.debug("Deletted " + deleteFileString + ": " + res); // debug } model.addAttribute("operationName", this.operationName); model.addAttribute("operationRESTPath", this.getRESTPath()); fb.setBaseDir(baseDir); fb.setRegex(fileRegex); fb.setScanDiretories(canNavigate); if (null != files && files.size() > 0) { List<String> fileNames = new ArrayList<String>(); for (MultipartFile multipartFile : files) { if (multipartFile == null) continue; String fileName = multipartFile.getOriginalFilename(); if (!"".equalsIgnoreCase(fileName)) { try { multipartFile.transferTo(new File(baseDir + fileName)); } catch (IllegalStateException e) { LOGGER.error(e.getMessage()); } catch (IOException e) { e.printStackTrace(); } fileNames.add(fileName); } LOGGER.debug("filename: " + fileName); // debug } } model.addAttribute("fileBrowser", fb); model.addAttribute("operations", availableOperations); model.addAttribute("canDelete", this.canDelete); model.addAttribute("canUpload", this.canUpload); model.addAttribute("uploadMethod", this.uploadMethod.name()); model.addAttribute("maxFileSize", this.maxFileSize); model.addAttribute("chunkSize", this.chunkSize); model.addAttribute("extensionFilter", this.extensionFilter); model.addAttribute("showRunInformation", this.showRunInformation); model.addAttribute("showRunInformationHistory", this.showRunInformationHistory); model.addAttribute("canManageFolders", this.canManageFolders); model.addAttribute("canDownloadFiles", this.canDownloadFiles); model.addAttribute("containerId", uniqueKey.toString().substring(0, 8)); model.addAttribute("formId", uniqueKey.toString().substring(27, 36)); model.addAttribute("accept", accept); return operationJSP; }
From source file:ca.spencerelliott.mercury.Changesets.java
private synchronized void startThread() { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); //Create the thread that will process the incoming feed load_thread = new Thread() { @Override//from w w w.j a va 2 s . c o m public void run() { changesets_list.clear(); DatabaseHelper db_helper = DatabaseHelper.getInstance(getApplicationContext()); EncryptionHelper encrypt_helper = EncryptionHelper.getInstance("DEADBEEF".toCharArray(), new byte[] { 'L', 'O', 'L' }); //Get the repository information from the local database Beans.RepositoryBean repo_type = db_helper.getRepository(repo_id, encrypt_helper); AtomHandler feed_handler = null; //Detect the type of repository and create a parser based on that switch (repo_type.getType()) { case Mercury.RepositoryTypes.HGSERVE: feed_handler = new HGWebAtomHandler(); break; case Mercury.RepositoryTypes.GOOGLECODE: feed_handler = new GoogleCodeAtomHandler(); break; case Mercury.RepositoryTypes.BITBUCKET: feed_handler = new BitbucketAtomHandler(); break; case Mercury.RepositoryTypes.CODEPLEX: feed_handler = new CodePlexAtomHandler(); break; } HttpURLConnection conn = null; boolean connected = false; try { // XXX We need to use our own factory to make all ssl certs work HttpsURLConnection.setDefaultSSLSocketFactory(NaiveSSLSocketFactory.getSocketFactory()); String repo_url_string = (repo_type.getUrl().endsWith("/") || repo_type.getUrl().endsWith("\\") ? feed_handler .formatURL(repo_type.getUrl().substring(0, repo_type.getUrl().length() - 1)) : feed_handler.formatURL(repo_type.getUrl())); switch (repo_type.getType()) { case Mercury.RepositoryTypes.BITBUCKET: //Only add the token if the user requested it if (repo_type.getAuthentication() == Mercury.AuthenticationTypes.TOKEN) repo_url_string = repo_url_string + "?token=" + repo_type.getSSHKey(); break; } URL repo_url = new URL(repo_url_string); conn = (HttpURLConnection) repo_url.openConnection(); //Check to see if the user enabled HTTP authentication if (repo_type.getAuthentication() == Mercury.AuthenticationTypes.HTTP) { //Get their username and password byte[] decrypted_info = (repo_type.getUsername() + ":" + repo_type.getPassword()) .getBytes(); //Add the header to the http request conn.setRequestProperty("Authorization", "Basic " + Base64.encodeBytes(decrypted_info)); } conn.connect(); connected = true; } catch (ClientProtocolException e2) { AlertDialog.Builder alert = new AlertDialog.Builder(getBaseContext()); alert.setMessage("There was a problem with the HTTP protocol"); alert.setPositiveButton(android.R.string.ok, null); alert.show(); //Do not allow the app to continue with loading connected = false; } catch (IOException e2) { AlertDialog.Builder alert = new AlertDialog.Builder(getBaseContext()); alert.setMessage("Server did not respond with a valid HTTP response"); alert.setPositiveButton(android.R.string.ok, null); alert.show(); //Do not allow the app to continue with loading connected = false; } catch (NullPointerException e3) { } catch (Exception e) { } BufferedReader reader = null; //Create a new reader based on the information retrieved if (connected) { try { reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); } catch (IllegalStateException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } else { list_handler.sendEmptyMessage(CANCELLED); return; } //Make sure both the feed handler and info loaded from the web are not null if (reader != null && feed_handler != null) { try { Xml.parse(reader, feed_handler); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } } else { list_handler.sendEmptyMessage(CANCELLED); return; } //Stored beans in the devices database ArrayList<Beans.ChangesetBean> stored_beans = null; if (prefs.getBoolean("caching", false)) { long last_insert = db_helper.getHighestID(DatabaseHelper.DB_TABLE_CHANGESETS, repo_id); if (last_insert >= 0) { //Get all of the stored changesets stored_beans = db_helper.getAllChangesets(repo_id, null); String rev_id = ""; //Try to find the revision id of the bean that has the id of the last inserted value for (Beans.ChangesetBean b : stored_beans) { if (b.getID() == last_insert) { rev_id = b.getRevisionID(); break; } } //Trim the list starting from this revision feed_handler.trimStartingFromRevision(rev_id); } } //Create a new bundle for the progress Bundle progress_bundle = new Bundle(); //Retreive all the beans from the handler ArrayList<Beans.ChangesetBean> beans = feed_handler.getAllChangesets(); int bean_count = beans.size(); //Store the amount of changesets progress_bundle.putInt("max", bean_count); //Create a new message and store the bundle and what type of message it is Message msg = new Message(); msg.setData(progress_bundle); msg.what = SETUP_COUNT; list_handler.sendMessage(msg); //Add each of the beans to the list for (int i = 0; i < bean_count; i++) { String commit_text = beans.get(i).getTitle(); Date commit_date = new Date(beans.get(i).getUpdated()); changesets_list.add(createChangeset( (commit_text.length() > 30 ? commit_text.substring(0, 30) + "..." : commit_text), beans.get(i).getRevisionID() + " - " + commit_date.toLocaleString())); //Store the current progress of the changeset loading progress_bundle.putInt("progress", i); //Reuse the old message and send an update progress message msg = new Message(); msg.setData(progress_bundle); msg.what = UPDATE_PROGRESS; list_handler.sendMessage(msg); } //Get the current count of changesets and the shared preferences long changeset_count = db_helper.getChangesetCount(repo_id); if (prefs.getBoolean("caching", false)) { //Get all of the stored beans from the device if not already done if (stored_beans == null) stored_beans = db_helper.getAllChangesets(repo_id, null); //Add all the changesets from the device for (Beans.ChangesetBean b : stored_beans) { changesets_list.add(createChangeset( (b.getTitle().length() > 30 ? (b.getTitle().substring(0, 30)) + "..." : b.getTitle()), b.getRevisionID() + " - " + new Date(b.getUpdated()).toLocaleString())); } //Reverse the list so the oldest changesets are stored first Collections.reverse(beans); //Iterate through each bean and add it to the device's database for (Beans.ChangesetBean b : beans) { db_helper.insert(b, repo_id); } //Get the amount of changesets allowed to be stored on the device int max_changes = Integer.parseInt(prefs.getString("max_changesets", "-1")); //Delete the oldest changesets if too many have been stored if (changeset_count > max_changes) { db_helper.deleteNumChangesets(repo_id, (changeset_count - max_changes)); } } else if (changeset_count > 0) { //Since the user does not have caching enabled, delete the changesets db_helper.deleteAllChangesets(repo_id); } //Update the tables to the newest revision if (!beans.isEmpty()) db_helper.updateLastRev(repo_id, beans.get(0).getRevisionID()); //Add all of the data to the changeset list changesets_data.addAll(beans); if (prefs.getBoolean("caching", false)) changesets_data.addAll(stored_beans); //Clean up the sql connection db_helper.cleanup(); db_helper = null; //Notify the handler that the loading of the list was successful list_handler.sendEmptyMessage(SUCCESSFUL); } }; //Start the thread load_thread.start(); }
From source file:com.wit.and.dialog.manage.DialogManager.java
/** * <p>// w w w . ja v a 2 s .c om * Dismiss the given dialog fragment. * </p> * * @param dialog Dialog fragment to dismiss. * @return <code>True</code> if dismissing succeed, <code>false</code> otherwise. * @see #dismissDialog(int) * @see #dismissDialog(String) */ public final boolean dismissDialog(DialogFragment dialog) { // Check dialog. if (dialog != null && dialog.isVisible()) { // Try to dismiss dialog. try { dialog.dismissAllowingStateLoss(); return true; } catch (IllegalStateException e) { e.printStackTrace(); } } return false; }
From source file:com.rakesh.d4ty.YTDownloadThread.java
boolean downloadone(String sURL) { boolean rc = false; boolean rc204 = false; boolean rc302 = false; this.iRecursionCount++; // stop recursion try {/* w ww . j a va2 s .c om*/ if (sURL.equals("")) return (false); } catch (NullPointerException npe) { return (false); } if (JFCMainClient.getbQuitrequested()) return (false); // try to get information about application shutdown debugoutput("start."); // TODO GUI option for proxy? // http://wiki.squid-cache.org/ConfigExamples/DynamicContent/YouTube // using local squid to save download time for tests try { // determine http_proxy environment variable if (!this.getProxy().equals("")) { String sproxy = JFCMainClient.sproxy.toLowerCase().replaceFirst("http://", ""); this.proxy = new HttpHost(sproxy.replaceFirst(":(.*)", ""), Integer.parseInt(sproxy.replaceFirst("(.*):", "")), "http"); SchemeRegistry supportedSchemes = new SchemeRegistry(); supportedSchemes.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); HttpProtocolParams.setUseExpectContinue(params, true); ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, supportedSchemes); // with proxy this.httpclient = new DefaultHttpClient(ccm, params); this.httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, this.proxy); this.httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH); } else { // without proxy this.httpclient = new DefaultHttpClient(); this.httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH); } this.httpget = new HttpGet(getURI(sURL)); if (sURL.toLowerCase().startsWith("https")) this.target = new HttpHost(getHost(sURL), 443, "https"); else this.target = new HttpHost(getHost(sURL), 80, "http"); } catch (Exception e) { debugoutput(e.getMessage()); } debugoutput("executing request: ".concat(this.httpget.getRequestLine().toString())); debugoutput("uri: ".concat(this.httpget.getURI().toString())); debugoutput("host: ".concat(this.target.getHostName())); debugoutput("using proxy: ".concat(this.getProxy())); // we dont need cookies at all because the download runs even without it (like my wget does) - in fact it blocks downloading videos from different webpages, because we do not handle the bcs for every URL (downloading of one video with different resolutions does work) /* this.localContext = new BasicHttpContext(); if (this.bcs == null) this.bcs = new BasicCookieStore(); // make cookies persistent, otherwise they would be stored in a HttpContext but get lost after calling org.apache.http.impl.client.AbstractHttpClient.execute(HttpHost target, HttpRequest request, HttpContext context) ((DefaultHttpClient) httpclient).setCookieStore(this.bcs); // cast to AbstractHttpclient would be best match because DefaultHttpClass is a subclass of AbstractHttpClient */ // TODO maybe we save the video IDs+res that were downloaded to avoid downloading the same video again? try { this.response = this.httpclient.execute(this.target, this.httpget, this.localContext); } catch (ClientProtocolException cpe) { debugoutput(cpe.getMessage()); } catch (UnknownHostException uhe) { output((JFCMainClient.isgerman() ? "Fehler bei der Verbindung zu: " : "error connecting to: ") .concat(uhe.getMessage())); debugoutput(uhe.getMessage()); } catch (IOException ioe) { debugoutput(ioe.getMessage()); } catch (IllegalStateException ise) { debugoutput(ise.getMessage()); } /* CookieOrigin cookieOrigin = (CookieOrigin) localContext.getAttribute( ClientContext.COOKIE_ORIGIN); CookieSpec cookieSpec = (CookieSpec) localContext.getAttribute( ClientContext.COOKIE_SPEC); CookieStore cookieStore = (CookieStore) localContext.getAttribute( ClientContext.COOKIE_STORE) ; try { debugoutput("HTTP Cookie store: ".concat( cookieStore.getCookies().toString( ))); } catch (NullPointerException npe) {} // useless if we don't set our own CookieStore before calling httpclient.execute try { debugoutput("HTTP Cookie origin: ".concat(cookieOrigin.toString())); debugoutput("HTTP Cookie spec used: ".concat(cookieSpec.toString())); debugoutput("HTTP Cookie store (persistent): ".concat(this.bcs.getCookies().toString())); } catch (NullPointerException npe) { } */ try { debugoutput("HTTP response status line:".concat(this.response.getStatusLine().toString())); //for (int i = 0; i < response.getAllHeaders().length; i++) { // debugoutput(response.getAllHeaders()[i].getName().concat("=").concat(response.getAllHeaders()[i].getValue())); //} // abort if HTTP response code is != 200, != 302 and !=204 - wrong URL? if (!(rc = this.response.getStatusLine().toString().toLowerCase().matches("^(http)(.*)200(.*)")) & !(rc204 = this.response.getStatusLine().toString().toLowerCase() .matches("^(http)(.*)204(.*)")) & !(rc302 = this.response.getStatusLine().toString().toLowerCase() .matches("^(http)(.*)302(.*)"))) { debugoutput(this.response.getStatusLine().toString().concat(" ").concat(sURL)); output(this.response.getStatusLine().toString().concat(" \"").concat(this.sTitle).concat("\"")); return (rc & rc204 & rc302); } if (rc204) { debugoutput("last response code==204 - download: ".concat(this.sNextVideoURL.get(0))); rc = downloadone(this.sNextVideoURL.get(0)); return (rc); } if (rc302) debugoutput( "location from HTTP Header: ".concat(this.response.getFirstHeader("Location").toString())); } catch (NullPointerException npe) { // if an IllegalStateException was catched while calling httpclient.execute(httpget) a NPE is caught here because // response.getStatusLine() == null this.sVideoURL = null; } HttpEntity entity = null; try { entity = this.response.getEntity(); } catch (NullPointerException npe) { } // try to read HTTP response body if (entity != null) { try { if (this.response.getFirstHeader("Content-Type").getValue().toLowerCase().matches("^text/html(.*)")) this.textreader = new BufferedReader(new InputStreamReader(entity.getContent())); else this.binaryreader = new BufferedInputStream(entity.getContent()); } catch (IllegalStateException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } try { // test if we got a webpage this.sContentType = this.response.getFirstHeader("Content-Type").getValue().toLowerCase(); if (this.sContentType.matches("^text/html(.*)")) { savetextdata(); // test if we got the binary content } else if (this.sContentType.matches("video/(.)*")) { if (JFCMainClient.getbNODOWNLOAD()) reportheaderinfo(); else savebinarydata(); } else { // content-type is not video/ rc = false; this.sVideoURL = null; } } catch (IOException ex) { try { throw ex; } catch (IOException e) { e.printStackTrace(); } } catch (RuntimeException ex) { try { throw ex; } catch (Exception e) { e.printStackTrace(); } } } //if (entity != null) this.httpclient.getConnectionManager().shutdown(); debugoutput("done: ".concat(sURL)); try { if (!this.sVideoURL.matches(JFCMainClient.szURLREGEX)) { debugoutput("cannot download video - URL does not seem to be valid: ".concat(this.sVideoURL)); output(JFCMainClient.isgerman() ? "es gab ein Problem die Video URL zu finden!" : "there was a problem getting the video URL!"); // deutsch output((JFCMainClient.isgerman() ? "erwge die URL dem Autor mitzuteilen!" : "consider reporting the URL to author! - ").concat(this.sURL)); rc = false; } else { debugoutput("try to download video from URL: ".concat(this.sVideoURL)); rc = downloadone(this.sVideoURL); } this.sVideoURL = null; } catch (NullPointerException npe) { } return (rc); }