List of usage examples for java.io UnsupportedEncodingException toString
public String toString()
From source file:com.moviejukebox.themoviedb.tools.ApiUrl.java
/** * Create the full URL with the API.//from ww w .j a v a2s .c om * * @param query * @param tmdbId * @param language * @param country * @param page * @return */ private URL getFullUrl(String query, String movieId, String language, String country, int page) { StringBuilder urlString = new StringBuilder(TMDB_API_BASE); // Get the start of the URL urlString.append(method); // Append the search term if required if (StringUtils.isNotBlank(query)) { urlString.append(DELIMITER_FIRST); urlString.append(PARAMETER_QUERY); try { urlString.append(URLEncoder.encode(query, "UTF-8")); } catch (UnsupportedEncodingException ex) { // If we can't encode it, try it raw urlString.append(query); } } // Append the ID if provided if (StringUtils.isNotBlank(movieId)) { urlString.append(movieId); } // Append the suffix of the API URL urlString.append(submethod); // Append the key information if (StringUtils.isBlank(query)) { // This is the first parameter urlString.append(DELIMITER_FIRST); } else { // The first parameter was the query urlString.append(DELIMITER_SUBSEQUENT); } urlString.append(PARAMETER_API_KEY); urlString.append(tmdb.getApiKey()); // Append the language to the URL if (StringUtils.isNotBlank(language)) { urlString.append(PARAMETER_LANGUAGE); urlString.append(language); } // Append the country to the URL if (StringUtils.isNotBlank(country)) { urlString.append(PARAMETER_COUNTRY); urlString.append(country); } // Append the page to the URL if (page > DEFAULT_INT) { urlString.append(PARAMETER_PAGE); urlString.append(page); } try { LOGGER.trace("URL: " + urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { LOGGER.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); return null; } }
From source file:net.cubebeaters.FriendsList.java
/** * * This event listener is used to handle clicking within the FriendsList * Inventory GUI Menu.// ww w . ja v a 2 s .c om * * @param event The Inventory Click Event. */ @EventHandler public void onInventoryClick(InventoryClickEvent event) { Player p = (Player) event.getWhoClicked(); // The player that clicked the item ItemStack clicked = event.getCurrentItem(); // The item that was clicked Inventory inventory = event.getInventory(); // The inventory that was clicked in if (inventory.getName().equals(friendsMenu.getName())) { // The inventory is our custom Inventory if (clicked.getType() == Material.GLASS) { // The item that the player clicked is GLASS friendSlot = event.getSlot(); friend = Bukkit .getPlayer(event.getClickedInventory().getItem(friendSlot).getItemMeta().getDisplayName()); event.setCancelled(true); // Make it so the Glass is back in its original spot p.closeInventory(); // Closes there inventory. try { openFriendMenu(p); // Sets up and opens the Custom Friends menu. } catch (UnsupportedEncodingException ex) { p.sendMessage(MSG_PREFIX + "There was an error opening new Inventory Menu!"); } } } if (inventory.getName().equals(customMenu.getName())) { // Second Menu. if (clicked.getType() == Material.CACTUS) { event.setCancelled(true); p.closeInventory(); try { guiTeleport(p, friend); } catch (UnsupportedEncodingException ex) { p.sendMessage(MSG_PREFIX + "There was an error teleporting you to friends Location."); Logger.getLogger("There was an error telporting " + p.getName()); Logger.getLogger(ex.toString()); } } else if (clicked.getType() == Material.GRASS) { event.setCancelled(true); p.closeInventory(); try { guiGift(p, friend); } catch (UnsupportedEncodingException ex) { p.sendMessage(MSG_PREFIX + "There was an error sending a gift to your friend."); Logger.getLogger("There was an error sending a gift from " + p.getName()); Logger.getLogger(ex.toString()); } } else if (clicked.getType() == Material.BEDROCK) { event.setCancelled(true); p.closeInventory(); try { guiDelFriend(p, friend); } catch (UnsupportedEncodingException ex) { p.sendMessage(MSG_PREFIX + "There was an error removing your friend from your friends list."); Logger.getLogger("There was an error sending a gift from " + p.getName()); Logger.getLogger(ex.toString()); } } } }
From source file:com.piusvelte.sonet.core.SonetComments.java
@Override protected void onListItemClick(ListView list, View view, final int position, long id) { super.onListItemClick(list, view, position, id); final String sid = mComments.get(position).get(Statuses.SID); final String liked = mComments.get(position).get(getString(R.string.like)); // wait for previous attempts to finish if ((liked.length() > 0) && !liked.equals(getString(R.string.loading))) { // parse comment body, as in StatusDialog.java Matcher m = Sonet.getLinksMatcher(mComments.get(position).get(Statuses.MESSAGE)); int count = 0; while (m.find()) { count++;/*from w w w. j a va 2 s . c om*/ } // like comments, the first comment is the post itself switch (mService) { case TWITTER: // retweet items = new String[count + 1]; items[0] = getString(R.string.retweet); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { SonetOAuth sonetOAuth = new SonetOAuth(TWITTER_KEY, TWITTER_SECRET, mToken, mSecret); HttpPost httpPost = new HttpPost( String.format(TWITTER_RETWEET, TWITTER_BASE_URL, sid)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(httpPost)); } @Override protected void onPostExecute(String response) { setCommentStatus(0, getString(R.string.retweet)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString( response != null ? R.string.success : R.string.failure), Toast.LENGTH_LONG)).show(); } }; setCommentStatus(0, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case FACEBOOK: items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { if (liked.equals(getString(R.string.like))) { return SonetHttpClient.httpResponse(mHttpClient, new HttpPost(String.format(FACEBOOK_LIKES, FACEBOOK_BASE_URL, sid, Saccess_token, mToken))); } else { HttpDelete httpDelete = new HttpDelete(String.format(FACEBOOK_LIKES, FACEBOOK_BASE_URL, sid, Saccess_token, mToken)); httpDelete.setHeader("Content-Length", "0"); return SonetHttpClient.httpResponse(mHttpClient, httpDelete); } } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case LINKEDIN: if (position == 0) { items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { SonetOAuth sonetOAuth = new SonetOAuth(LINKEDIN_KEY, LINKEDIN_SECRET, mToken, mSecret); HttpPut httpPut = new HttpPut( String.format(LINKEDIN_IS_LIKED, LINKEDIN_BASE_URL, mSid)); httpPut.addHeader( new BasicHeader("Content-Type", "application/xml")); try { httpPut.setEntity(new StringEntity( String.format(LINKEDIN_LIKE_BODY, Boolean.toString( liked.equals(getString(R.string.like)))))); return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(httpPut)); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } return null; } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } else { // no like option here items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } break; case IDENTICA: // retweet items = new String[count + 1]; items[0] = getString(R.string.repeat); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { SonetOAuth sonetOAuth = new SonetOAuth(IDENTICA_KEY, IDENTICA_SECRET, mToken, mSecret); HttpPost httpPost = new HttpPost( String.format(IDENTICA_RETWEET, IDENTICA_BASE_URL, sid)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(httpPost)); } @Override protected void onPostExecute(String response) { setCommentStatus(0, getString(R.string.repeat)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString( response != null ? R.string.success : R.string.failure), Toast.LENGTH_LONG)).show(); } }; setCommentStatus(0, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case GOOGLEPLUS: //TODO: // plus1 items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case CHATTER: if (position == 0) { items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { HttpUriRequest httpRequest; if (liked.equals(getString(R.string.like))) { httpRequest = new HttpPost(String.format(CHATTER_URL_LIKES, mChatterInstance, mSid)); } else { httpRequest = new HttpDelete(String.format(CHATTER_URL_LIKE, mChatterInstance, mChatterLikeId)); } httpRequest.setHeader("Authorization", "OAuth " + mChatterToken); return SonetHttpClient.httpResponse(mHttpClient, httpRequest); } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } else { // no like option here items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } break; } } }
From source file:com.piusvelte.sonet.SonetComments.java
@Override protected void onListItemClick(ListView list, View view, final int position, long id) { super.onListItemClick(list, view, position, id); final String sid = mComments.get(position).get(Statuses.SID); final String liked = mComments.get(position).get(getString(R.string.like)); // wait for previous attempts to finish if ((liked.length() > 0) && !liked.equals(getString(R.string.loading))) { // parse comment body, as in StatusDialog.java Matcher m = Sonet.getLinksMatcher(mComments.get(position).get(Statuses.MESSAGE)); int count = 0; while (m.find()) { count++;/*w w w.jav a2s .co m*/ } // like comments, the first comment is the post itself switch (mService) { case TWITTER: // retweet items = new String[count + 1]; items[0] = getString(R.string.retweet); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { SonetOAuth sonetOAuth = new SonetOAuth(BuildConfig.TWITTER_KEY, BuildConfig.TWITTER_SECRET, mToken, mSecret); HttpPost httpPost = new HttpPost( String.format(TWITTER_RETWEET, TWITTER_BASE_URL, sid)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(httpPost)); } @Override protected void onPostExecute(String response) { setCommentStatus(0, getString(R.string.retweet)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString( response != null ? R.string.success : R.string.failure), Toast.LENGTH_LONG)).show(); } }; setCommentStatus(0, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case FACEBOOK: items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { if (liked.equals(getString(R.string.like))) { return SonetHttpClient.httpResponse(mHttpClient, new HttpPost(String.format(FACEBOOK_LIKES, FACEBOOK_BASE_URL, sid, Saccess_token, mToken))); } else { HttpDelete httpDelete = new HttpDelete(String.format(FACEBOOK_LIKES, FACEBOOK_BASE_URL, sid, Saccess_token, mToken)); httpDelete.setHeader("Content-Length", "0"); return SonetHttpClient.httpResponse(mHttpClient, httpDelete); } } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case LINKEDIN: if (position == 0) { items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { SonetOAuth sonetOAuth = new SonetOAuth(BuildConfig.LINKEDIN_KEY, BuildConfig.LINKEDIN_SECRET, mToken, mSecret); HttpPut httpPut = new HttpPut( String.format(LINKEDIN_IS_LIKED, LINKEDIN_BASE_URL, mSid)); httpPut.addHeader( new BasicHeader("Content-Type", "application/xml")); try { httpPut.setEntity(new StringEntity( String.format(LINKEDIN_LIKE_BODY, Boolean.toString( liked.equals(getString(R.string.like)))))); return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(httpPut)); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } return null; } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } else { // no like option here items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } break; case IDENTICA: // retweet items = new String[count + 1]; items[0] = getString(R.string.repeat); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { SonetOAuth sonetOAuth = new SonetOAuth(BuildConfig.IDENTICA_KEY, BuildConfig.IDENTICA_SECRET, mToken, mSecret); HttpPost httpPost = new HttpPost( String.format(IDENTICA_RETWEET, IDENTICA_BASE_URL, sid)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(httpPost)); } @Override protected void onPostExecute(String response) { setCommentStatus(0, getString(R.string.repeat)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString( response != null ? R.string.success : R.string.failure), Toast.LENGTH_LONG)).show(); } }; setCommentStatus(0, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case GOOGLEPLUS: //TODO: // plus1 items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case CHATTER: if (position == 0) { items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { HttpUriRequest httpRequest; if (liked.equals(getString(R.string.like))) { httpRequest = new HttpPost(String.format(CHATTER_URL_LIKES, mChatterInstance, mSid)); } else { httpRequest = new HttpDelete(String.format(CHATTER_URL_LIKE, mChatterInstance, mChatterLikeId)); } httpRequest.setHeader("Authorization", "OAuth " + mChatterToken); return SonetHttpClient.httpResponse(mHttpClient, httpRequest); } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(SonetComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } else { // no like option here items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(SonetComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } break; } } }
From source file:com.esprit.lyricsplus.DAO.SongDAO.java
public String getJSONFromUrl(String url) { // Making HTTP request try {/*from ww w .ja v a 2s.c o m*/ // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); // HttpPost httpPost = new HttpPost(url); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NegativeArraySizeException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // return JSON String return json; }
From source file:com.shafiq.myfeedle.core.MyfeedleComments.java
@Override protected void onListItemClick(ListView list, View view, final int position, long id) { super.onListItemClick(list, view, position, id); final String sid = mComments.get(position).get(Statuses.SID); final String liked = mComments.get(position).get(getString(R.string.like)); // wait for previous attempts to finish if ((liked.length() > 0) && !liked.equals(getString(R.string.loading))) { // parse comment body, as in StatusDialog.java Matcher m = Myfeedle.getLinksMatcher(mComments.get(position).get(Statuses.MESSAGE)); int count = 0; while (m.find()) { count++;/*from w w w . jav a2s.c o m*/ } // like comments, the first comment is the post itself switch (mService) { case TWITTER: // retweet items = new String[count + 1]; items[0] = getString(R.string.retweet); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { MyfeedleOAuth myfeedleOAuth = new MyfeedleOAuth(TWITTER_KEY, TWITTER_SECRET, mToken, mSecret); HttpPost httpPost = new HttpPost( String.format(TWITTER_RETWEET, TWITTER_BASE_URL, sid)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); return MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPost)); } @Override protected void onPostExecute(String response) { setCommentStatus(0, getString(R.string.retweet)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString( response != null ? R.string.success : R.string.failure), Toast.LENGTH_LONG)).show(); } }; setCommentStatus(0, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case FACEBOOK: items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { if (liked.equals(getString(R.string.like))) { return MyfeedleHttpClient.httpResponse(mHttpClient, new HttpPost(String.format(FACEBOOK_LIKES, FACEBOOK_BASE_URL, sid, Saccess_token, mToken))); } else { HttpDelete httpDelete = new HttpDelete(String.format(FACEBOOK_LIKES, FACEBOOK_BASE_URL, sid, Saccess_token, mToken)); httpDelete.setHeader("Content-Length", "0"); return MyfeedleHttpClient.httpResponse(mHttpClient, httpDelete); } } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case LINKEDIN: if (position == 0) { items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { MyfeedleOAuth myfeedleOAuth = new MyfeedleOAuth(LINKEDIN_KEY, LINKEDIN_SECRET, mToken, mSecret); HttpPut httpPut = new HttpPut( String.format(LINKEDIN_IS_LIKED, LINKEDIN_BASE_URL, mSid)); httpPut.addHeader( new BasicHeader("Content-Type", "application/xml")); try { httpPut.setEntity(new StringEntity( String.format(LINKEDIN_LIKE_BODY, Boolean.toString( liked.equals(getString(R.string.like)))))); return MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPut)); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } return null; } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } else { // no like option here items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } break; case IDENTICA: // retweet items = new String[count + 1]; items[0] = getString(R.string.repeat); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { MyfeedleOAuth myfeedleOAuth = new MyfeedleOAuth(IDENTICA_KEY, IDENTICA_SECRET, mToken, mSecret); HttpPost httpPost = new HttpPost( String.format(IDENTICA_RETWEET, IDENTICA_BASE_URL, sid)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); return MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPost)); } @Override protected void onPostExecute(String response) { setCommentStatus(0, getString(R.string.repeat)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString( response != null ? R.string.success : R.string.failure), Toast.LENGTH_LONG)).show(); } }; setCommentStatus(0, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case GOOGLEPLUS: //TODO: // plus1 items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); break; case CHATTER: if (position == 0) { items = new String[count + 1]; items[0] = getString( mComments.get(position).get(getString(R.string.like)) == getString(R.string.like) ? R.string.like : R.string.unlike); count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... arg0) { HttpUriRequest httpRequest; if (liked.equals(getString(R.string.like))) { httpRequest = new HttpPost(String.format(CHATTER_URL_LIKES, mChatterInstance, mSid)); } else { httpRequest = new HttpDelete(String.format(CHATTER_URL_LIKE, mChatterInstance, mChatterLikeId)); } httpRequest.setHeader("Authorization", "OAuth " + mChatterToken); return MyfeedleHttpClient.httpResponse(mHttpClient, httpRequest); } @Override protected void onPostExecute(String response) { if (response != null) { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.unlike : R.string.like)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString(R.string.success), Toast.LENGTH_LONG)).show(); } else { setCommentStatus(position, getString(liked.equals(getString(R.string.like)) ? R.string.like : R.string.unlike)); (Toast.makeText(MyfeedleComments.this, mServiceName + " " + getString(R.string.failure), Toast.LENGTH_LONG)).show(); } } }; setCommentStatus(position, getString(R.string.loading)); asyncTask.execute(); } else { if ((which < items.length) && (items[which] != null)) // open link startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } else { // no like option here items = new String[count]; count = 1; m.reset(); while (m.find()) { items[count++] = m.group(); } mDialog = (new AlertDialog.Builder(this)) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if ((which < items.length) && (items[which] != null)) // open link startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(items[which]))); else (Toast.makeText(MyfeedleComments.this, getString(R.string.error_status), Toast.LENGTH_LONG)).show(); } }).setCancelable(true).setOnCancelListener(this).create(); mDialog.show(); } break; } } }
From source file:com.silverpeas.portlets.portal.portletwindow.PortletWindowURL.java
public String toString() { StringBuffer buffer = new StringBuffer(); int index = this.desktopURL.indexOf("?"); String processURL;/*ww w . j a v a 2 s .co m*/ if (index != -1) { processURL = this.desktopURL.substring(index + 1); } else { processURL = this.desktopURL; } StringTokenizer tokens = new StringTokenizer(processURL, "&"); String token, internalKey, internalValue; HashMap keyValueMap = new HashMap(); int equalIndex; while (tokens.hasMoreTokens()) { token = tokens.nextToken(); equalIndex = token.indexOf("="); if (equalIndex != -1) { internalKey = token.substring(0, equalIndex); internalValue = token.substring(equalIndex + 1); keyValueMap.put(internalKey, internalValue); } } buffer.append(this.desktopURL.substring(0, index)); buffer.append("?"); keyValueMap.put(WindowInvokerConstants.PORTLET_ACTION, urlType.toString()); // check if PortletAction is RESOURCE if (urlType.toString().equals(PortletActions.RESOURCE)) keyValueMap.put(WindowInvokerConstants.DRIVER_ACTION, WindowInvokerConstants.RESOURCE); if (this.newWindowState != null) { keyValueMap.put(WindowInvokerConstants.NEW_PORTLET_WINDOW_STATE_KEY, this.newWindowState.toString()); } if (this.newPortletWindowMode != null) { keyValueMap.put(WindowInvokerConstants.NEW_PORTLET_WINDOW_MODE_KEY, this.newPortletWindowMode.toString()); } if (this.resourceID != null) { try { keyValueMap.put(WindowInvokerConstants.RESOURCE_ID_KEY, URLEncoder.encode(this.resourceID, CharEncoding.UTF_8)); } catch (UnsupportedEncodingException uee) { logger.log(Level.WARNING, "PSPCD_CSPPD0049", uee); } } if (this.cacheLevel != null) { keyValueMap.put(WindowInvokerConstants.RESOURCE_URL_CACHE_LEVEL_KEY, cacheLevel); } Iterator itr = keyValueMap.entrySet().iterator(); while (itr.hasNext()) { Map.Entry entry = (Map.Entry) itr.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); buffer.append("&").append(key); buffer.append("=").append(value); } if (this.parametersMap != null) { Set<Map.Entry<String, String[]>> entries = this.parametersMap.entrySet(); for (Map.Entry<String, String[]> mapEntry : entries) { String key = mapEntry.getKey(); String[] values = mapEntry.getValue(); try { if (isEncodingNeeded(key)) { key = URLEncoder.encode(key, CharEncoding.UTF_8); } for (int j = 0; j < values.length; j++) { buffer.append("&").append(key); if (isEncodingNeeded(values[j])) { buffer.append("=").append(URLEncoder.encode(values[j], CharEncoding.UTF_8)); } else { buffer.append("=").append(values[j]); } } } catch (UnsupportedEncodingException uee) { if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, "PSPCD_CSPPD0009", uee.toString()); } } } } if (this.properties != null) { Set<Map.Entry<String, List<String>>> entries = this.properties.entrySet(); for (Map.Entry<String, List<String>> mapEntry : entries) { String key = mapEntry.getKey(); List<String> values = mapEntry.getValue(); try { if (isEncodingNeeded(key)) { key = URLEncoder.encode(key, CharEncoding.UTF_8); } for (String value : values) { buffer.append("&").append(key); if (isEncodingNeeded(value)) { buffer.append("=").append(URLEncoder.encode(value, CharEncoding.UTF_8)); } else { buffer.append("=").append(value); } } } catch (UnsupportedEncodingException uee) { if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, "PSPCD_CSPPD0009", uee.toString()); } } } } return buffer.toString(); }
From source file:servlets.module.challenge.SessionManagement3ChangePassword.java
/** * Function used by Session Management Challenge Three to change the password of the submitted user name specified in the "Current" cookie * @param current User cookie used to store the current user (encoded twice with base64) * @param newPassword the password which to use to update an accounts password *//*from ww w. j a v a 2 s . co m*/ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Setting IpAddress To Log and taking header for original IP if forwarded from proxy ShepherdLogManager.setRequestIp(request.getRemoteAddr(), request.getHeader("X-Forwarded-For")); HttpSession ses = request.getSession(true); //Translation Stuff Locale locale = new Locale(Validate.validateLanguage(request.getSession())); ResourceBundle errors = ResourceBundle.getBundle("i18n.servlets.errors", locale); ResourceBundle bundle = ResourceBundle .getBundle("i18n.servlets.challenges.sessionManagement.sessionManagement3", locale); if (Validate.validateSession(ses)) { ShepherdLogManager.setRequestIp(request.getRemoteAddr(), request.getHeader("X-Forwarded-For"), ses.getAttribute("userName").toString()); log.debug(levelName + " servlet accessed by: " + ses.getAttribute("userName").toString()); PrintWriter out = response.getWriter(); out.print(getServletInfo()); String htmlOutput = new String(); log.debug(levelName + " - Change Password - Servlet"); try { log.debug("Getting Challenge Parameters"); Cookie userCookies[] = request.getCookies(); int i = 0; Cookie theCookie = null; for (i = 0; i < userCookies.length; i++) { if (userCookies[i].getName().compareTo("current") == 0) { theCookie = userCookies[i]; break; //End Loop, because we found the token } } Object passNewObj = request.getParameter("newPassword"); String subName = new String(); String subNewPass = new String(); if (theCookie != null) subName = theCookie.getValue(); if (passNewObj != null) subNewPass = (String) passNewObj; log.debug("subName = " + subName); //Base 64 Decode try { byte[] decodedName = Base64.decodeBase64(subName); subName = new String(decodedName, "UTF-8"); decodedName = Base64.decodeBase64(subName); subName = new String(decodedName, "UTF-8"); } catch (UnsupportedEncodingException e) { log.debug("Could not decode username"); subName = new String(); } log.debug("subName Decoded = " + subName); log.debug("subPass = " + subNewPass); if (subNewPass.length() >= 6) { log.debug("Getting ApplicationRoot"); String ApplicationRoot = getServletContext().getRealPath(""); Connection conn = Database.getChallengeConnection(ApplicationRoot, "BrokenAuthAndSessMangChalThree"); log.debug("Changing password for user: " + subName); log.debug("Changing password to: " + subNewPass); PreparedStatement callstmt; callstmt = conn.prepareStatement("UPDATE users SET userPassword = SHA(?) WHERE userName = ?"); callstmt.setString(1, subNewPass); callstmt.setString(2, subName); log.debug("Executing changePassword"); callstmt.execute(); log.debug("Committing changes made to database"); callstmt = conn.prepareStatement("COMMIT"); callstmt.execute(); log.debug("Changes committed."); htmlOutput = "<p>" + bundle.getString("reset.password") + "</p>"; } else { log.debug("invalid password submitted: " + subNewPass); htmlOutput = "<p>" + bundle.getString("reset.failed") + "</p>"; } log.debug("Outputting HTML"); out.write(htmlOutput); } catch (Exception e) { out.write(errors.getString("error.funky")); log.fatal(levelName + " - Change Password - " + e.toString()); } } else { log.error(levelName + " servlet accessed with no session"); } }
From source file:com.oakesville.mythling.MediaActivity.java
protected void setPathFromIntent() { try {/* w ww . j ava 2 s .co m*/ String newPath = getIntent().getDataString(); setPath(newPath == null ? "" : URLDecoder.decode(newPath, "UTF-8")); } catch (UnsupportedEncodingException ex) { Log.e(TAG, ex.getMessage(), ex); if (getAppSettings().isErrorReportingEnabled()) new Reporter(ex).send(); Toast.makeText(getApplicationContext(), getString(R.string.error_) + ex.toString(), Toast.LENGTH_LONG) .show(); setPath(""); // TODO correct? } }