List of usage examples for java.lang NullPointerException toString
public String toString()
From source file:net.longfalcon.newsj.TVRageService.java
private long getTraktIdFromTraktResultsSafe(TraktResult traktResult) { try {//from ww w. j av a 2s . c om if (traktResult == null) { return -2; } TraktShowResult showResult = traktResult.getShowResult(); if (showResult == null) { return -2; } TraktIdSet traktIdSet = showResult.getIds(); if (traktIdSet == null) { return -2; } long traktId = traktIdSet.getTrakt(); _log.info("found trakt id: " + traktId); return traktId; } catch (NullPointerException e) { _log.error(e.toString(), e); return -2; } }
From source file:com.hortonworks.amstore.view.AmbariStoreServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); // very important, used throughout writer = response.getWriter();/* ww w .ja va 2 s .co m*/ // Reload all settings in case they changed mainStoreApplication.reloadConfiguration(); bootstrapjs(response); writer.println("<h2>Ambari Store</h2>"); displayExceptions(latestExceptions); latestExceptions = new LinkedList<StoreException>(); try { // TODO: remove use of global variable endpointIssues if (endpointIssues) { displayChecks(request, response); // If we still have issues after the checks if (endpointIssues) return; } if (request.getParameter("app_id") != null) { displayApplicationDetails(request.getParameter("app_id"), response); return; } displayAllApplications(request, response); // displayInstalledServicesInformation(); } catch (NullPointerException e) { writer.println("NullPointerException caught.<br>"); writer.println(GenericException.prettyTrace(e)); } catch (Exception e) { writer.println("Catch All Exception: " + e.toString() + "<br/>"); writer.println(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); } }
From source file:info.guardianproject.pixelknot.PixelKnotActivity.java
@Override public void onEmbedded(final File out_file) { h.post(new Runnable() { @Override//from w ww .ja v a2s . c o m public void run() { hasSuccessfullyEmbed = true; pixel_knot.setOutFile(out_file); ((ImageButton) options_holder.getChildAt(0)).setEnabled(true); try { progress_dialog.dismiss(); } catch (NullPointerException e) { Log.e(Logger.UI, e.toString()); e.printStackTrace(); } ((ActivityListener) pk_pager.getItem(view_pager.getCurrentItem())).updateUi(); } }); }
From source file:com.jimplush.goose.ContentExtractor.java
/** * attemps to grab titles from the html pages, lots of sites use different delimiters * for titles so we'll try and do our best guess. * * * @param doc// w w w . j a va2 s. co m * @return */ private String getTitle(Document doc) { String title = string.empty; try { Elements titleElem = doc.getElementsByTag("title"); if (titleElem == null || titleElem.isEmpty()) return string.empty; String titleText = titleElem.first().text(); if (string.isNullOrEmpty(titleText)) return string.empty; boolean usedDelimeter = false; if (titleText.contains("|")) { titleText = doTitleSplits(titleText, PIPE_SPLITTER); usedDelimeter = true; } if (!usedDelimeter && titleText.contains("-")) { titleText = doTitleSplits(titleText, DASH_SPLITTER); usedDelimeter = true; } if (!usedDelimeter && titleText.contains("")) { titleText = doTitleSplits(titleText, ARROWS_SPLITTER); usedDelimeter = true; } if (!usedDelimeter && titleText.contains(":")) { titleText = doTitleSplits(titleText, COLON_SPLITTER); } // encode unicode charz title = StringEscapeUtils.escapeHtml(titleText); // todo this is a hack until I can fix this.. weird motely crue error with // http://money.cnn.com/2010/10/25/news/companies/motley_crue_bp.fortune/index.htm?section=money_latest title = MOTLEY_REPLACEMENT.replaceAll(title); if (logger.isDebugEnabled()) { logger.debug("Page title is: " + title); } } catch (NullPointerException e) { logger.error(e.toString()); } return title; }
From source file:net.cubebeaters.FriendsList.java
/** * * This method is the same as the teleportFriend method but is used when the * GUI item 'teleport' is clicked.//w ww .j a va2s . co m * * @param player The player to be Teleported. * @param friend The player to be Teleported to. * @throws UnsupportedEncodingException if UTF-8 Encoding is not used. */ public void guiTeleport(Player player, Player friend) throws UnsupportedEncodingException { // Error casting to Player.. Player p = player; try { if (Bukkit.getPlayer(friend.getName()) == null) { p.sendMessage(MSG_PREFIX + "Sorry, your friend is not currently online."); } else { p.teleport(friend); p.sendMessage(MSG_PREFIX + "Teleported to " + friend.getName()); friend.sendMessage(MSG_PREFIX + p.getName() + " has teleported to you."); } } catch (NullPointerException ex) { p.sendMessage(MSG_PREFIX + "It seems that friend is currently offline."); Logger.getLogger(ex.toString()); } }
From source file:org.catechis.Stats.java
private void addErrorToLog(java.lang.NullPointerException npe) { log.add("toString : " + npe.toString()); log.add("getMessage : " + npe.getMessage()); log.add("getLocalziedMessage:" + npe.getLocalizedMessage()); Throwable throwup = npe.getCause(); Throwable init_cause = npe.initCause(throwup); log.add("thowable.msg :" + init_cause.toString()); StackTraceElement[] ste = npe.getStackTrace(); for (int j = 0; j < ste.length; j++) { log.add(j + " - " + ste[j].toString()); if (j > 6) { log.add(" ..."); break; }// w w w.j a va 2s . c om } }
From source file:org.hfoss.posit.android.RegisterActivity.java
/** * Handles server registration by decoding the JSON Object that the barcode * reader gets from the server site containing the server address and the * authentication key. These two pieces of information are stored as shared * preferences. The user is then prompted to choose a project from the * server to work on and sync with.//ww w .j a va2 s . co m */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i(TAG, "Requestcode = " + requestCode + "Result code = " + resultCode); super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case LOGIN_BY_BARCODE_READER: String value = data.getStringExtra("SCAN_RESULT"); Log.i(TAG, "Bar code scanner result " + value); // Hack to remove extra escape characters from JSON text. StringBuffer sb = new StringBuffer(""); for (int k = 0; k < value.length(); k++) { char ch = value.charAt(k); if (ch != '\\') { sb.append(ch); } else if (value.charAt(k + 1) == '\\') { sb.append(ch); } } value = sb.toString(); // Valid JSON encoded string // End of Hack JSONObject object; try { Log.i(TAG, "JSON=" + value); object = new JSONObject(value); String server = object.getString("server"); String authKey = object.getString("authKey"); if (Utils.debug) Log.i(TAG, "server= " + server + ", authKey= " + authKey); TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); String imei = manager.getDeviceId(); Communicator communicator = new Communicator(this); mProgressDialog = ProgressDialog.show(this, "Registering device", "Please wait.", true, true); try { String registered = communicator.registerDevice(server, authKey, imei); Log.d(TAG, "onActivityResult, registered = " + registered); if (registered != null) { Log.i(TAG, "registered"); Editor spEditor = mSharedPrefs.edit(); spEditor.putString("SERVER_ADDRESS", server); spEditor.putString("AUTHKEY", authKey); spEditor.putInt("PROJECT_ID", 0); spEditor.putString("PROJECT_NAME", ""); spEditor.commit(); Intent intent = new Intent(this, ShowProjectsActivity.class); startActivity(intent); } } catch (NullPointerException e) { Utils.showToast(this, "Registration Error"); } finally { mProgressDialog.dismiss(); } mProgressDialog.dismiss(); int projectId = mSharedPrefs.getInt("PROJECT_ID", 0); if (projectId == 0) { Intent intent = new Intent(this, ShowProjectsActivity.class); startActivity(intent); } finish(); } catch (JSONException e) { if (Utils.debug) Log.e(TAG, e.toString()); } break; } }
From source file:se.lu.nateko.edca.svc.GeoHelper.java
/** * Forms a single string containing the Insert XML elements of a WFS Transaction Insert request. * @return A string with the Insert elements of a WFS-T Insert XML. */// ww w. j a va2s.co m private String formInsertElements() { // Log.d(TAG, "formInsertElements() called."); /* The parts of the Insert statements to form. */ // TODO Make static parts static final instance variables so they don't need to be instantiated for each GeoHelper. String inserts = ""; // The total, combined, result. String wfsStart = ""; String geomFieldStart = ""; String geomStart = ""; String coords = ""; String geomEnd = ""; String geomFieldEnd = ""; String atts = ""; String wfsEnd = ""; Set<Long> keyset = (mGeoLayer.getTypeMode() == GeographyLayer.TYPE_POINT) ? mGeoLayer.getGeometry().keySet() : mGeoLayer.getPointSequence().keySet(); // Fetch the set of keys pertaining to the relevant geometry type. for (Long featureId : keyset) { /* Form the WFS Insert element starters and enders. */ wfsStart = " <wfs:Insert>" + " <" + mNamespace + ":" + Utilities.dropColons(mGeoLayer.getName(), Utilities.RETURN_LAST) + ">"; wfsEnd = " </" + mNamespace + ":" + Utilities.dropColons(mGeoLayer.getName(), Utilities.RETURN_LAST) + ">" + " </wfs:Insert>"; /* Form the Geometry field element starter and ender. */ geomFieldStart = " <" + mNamespace + ":" + mGeoLayer.getGeomColumnKey() + ">"; geomFieldEnd = " </" + mNamespace + ":" + mGeoLayer.getGeomColumnKey() + ">"; /* Form the element starters and enders required by the corresponding geometry type before the coordinates. */ if (mGeoLayer.getType().equalsIgnoreCase("gml:PointPropertyType")) { geomStart = " <gml:Point " + SRS + ">"; geomEnd = " </gml:Point>"; } else if (mGeoLayer.getType().equalsIgnoreCase("gml:MultiPointPropertyType")) { geomStart = " <gml:MultiPoint " + SRS + ">" + " <gml:pointMember>" + " <gml:Point>"; geomEnd = " </gml:Point>" + " </gml:pointMember>" + " </gml:MultiPoint>"; } else if (mGeoLayer.getType().equalsIgnoreCase("gml:LineStringPropertyType")) { geomStart = " <gml:LineString " + SRS + ">"; geomEnd = " </gml:LineString>"; } else if (mGeoLayer.getType().equalsIgnoreCase("gml:MultiLineStringPropertyType")) { geomStart = " <gml:MultiLineString " + SRS + ">" + " <gml:lineStringMember>" + " <gml:LineString>"; geomEnd = " </gml:LineString>" + " </gml:lineStringMember>" + " </gml:MultiLineString>"; } else if (mGeoLayer.getType().equalsIgnoreCase("gml:PolygonPropertyType") || mGeoLayer.getType().equalsIgnoreCase("gml:SurfacePropertyType")) { geomStart = " <gml:Polygon " + SRS + ">" + " <gml:outerBoundaryIs>" + " <gml:LinearRing>"; geomEnd = " </gml:LinearRing>" + " </gml:outerBoundaryIs>" + " </gml:Polygon>"; } else if (mGeoLayer.getType().equalsIgnoreCase("gml:MultiPolygonPropertyType") || mGeoLayer.getType().equalsIgnoreCase("gml:MultiSurfacePropertyType")) { geomStart = " <gml:MultiPolygon " + SRS + ">" + " <gml:polygonMember>" + " <gml:Polygon>" + " <gml:outerBoundaryIs>" + " <gml:LinearRing>"; geomEnd = " </gml:LinearRing>" + " </gml:outerBoundaryIs>" + " </gml:Polygon>" + " </gml:polygonMember>" + " </gml:MultiPolygon>"; } /* Form the coordinates elements. */ if (mGeoLayer.getTypeMode() == GeographyLayer.TYPE_POINT) { // Form Point Coordinates GML. coords = " <gml:coordinates decimal=\".\" cs=\",\" ts=\" \">" + String.valueOf(mGeoLayer.getGeometry().get(featureId).longitude) + "," + String.valueOf(mGeoLayer.getGeometry().get(featureId).latitude) + "</gml:coordinates>"; } else { // Form the sequence Coordinates GML. coords = " <gml:coordinates decimal=\".\" cs=\",\" ts=\" \">"; for (int i = 0; i < mGeoLayer.getPointSequence().get(featureId).size(); i++) { // For each point in this point sequence: if (i != 0) coords = coords + " "; // Insert spaces between coordinates. coords = coords + String.valueOf(mGeoLayer.getGeometry() .get(mGeoLayer.getPointSequence().get(featureId).get(i)).longitude) + "," + String.valueOf(mGeoLayer.getGeometry() .get(mGeoLayer.getPointSequence().get(featureId).get(i)).latitude); } coords = coords + "</gml:coordinates>"; } /* Form the non-geometry fields and attributes, but only those with input. */ try { atts = ""; // Reset the attributes string. for (LayerField field : mGeoLayer.getNonGeomFields()) { if (!mGeoLayer.getAttributes().get(featureId).get(field.getName()).equalsIgnoreCase("")) { atts = atts + " <" + mNamespace + ":" + field.getName() + ">" + mGeoLayer.getAttributes().get(featureId).get(field.getName()) + "</" + mNamespace + ":" + field.getName() + ">"; } } } catch (NullPointerException e) { Log.e(TAG, "Didn't add attributes: " + e.toString()); } /* Combine all parts into a complete WFS Insert statement. */ inserts = inserts + wfsStart + geomFieldStart + geomStart + coords + geomEnd + geomFieldEnd + atts + wfsEnd; } return inserts; }
From source file:fsi_admin.JFsiTareas.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public synchronized void actualizarSaldos() { // Primero recopila la informacion de las bases de datos. Vector BASES = new Vector(); JBDRegistradasSet bdr = new JBDRegistradasSet(null); bdr.ConCat(true);/*www . j ava 2s . c o m*/ bdr.Open(); for (int i = 0; i < bdr.getNumRows(); i++) { String nombre = bdr.getAbsRow(i).getNombre(); BASES.addElement(nombre); } short res = 0; String mensaje = ""; Connection con; try { Calendar fecha = GregorianCalendar.getInstance(); FileWriter filewri = new FileWriter( "/usr/local/forseti/log/SLDS-" + JUtil.obtFechaTxt(fecha, "yyyy-MM-dd-hh-mm") + ".log", true); PrintWriter pw = new PrintWriter(filewri); for (int i = 0; i < BASES.size(); i++) { String nombre = (String) BASES.get(i); pw.println("----------------------------------------------------------------------------"); pw.println(" " + "ACTUALIZANDO LA BASE DE DATOS: " + nombre + " " + JUtil.obtFechaTxt(new Date(), "HH:mm:ss")); pw.println("----------------------------------------------------------------------------"); pw.flush(); System.out.println("ACTUALIZANDO LA BASE DE DATOS: " + nombre + " " + JUtil.obtFechaTxt(new Date(), "HH:mm:ss")); //Empieza por la de saldos con = JAccesoBD.getConexion(nombre); String sql[] = { "select * from sp_invserv_actualizar_existencias() as ( err integer, res varchar ) ", "select * from sp_prod_formulas_actualizar_niveles() as ( err integer, res varchar ) ", "select * from sp_invserv_actualizar_sdos() as ( err integer, res varchar ) ", "select * from sp_invserv_actualizar_polcant() as ( err integer, res varchar ) ", "select * from sp_cont_catalogo_actualizar_sdos() as ( err integer, res varchar ) ", "select * from sp_bancos_actualizar_sdos() as ( err integer, res varchar ) ", "select * from sp_provee_actualizar_sdos() as ( err integer, res varchar ) ", "select * from sp_client_actualizar_sdos() as ( err integer, res varchar ) " }; try { Statement s = con.createStatement(); for (int j = 0; j < sql.length; j++) { System.out.println("EJECUTANDO: " + sql[j]); pw.println("EJECUTANDO: " + sql[j] + "\n"); pw.flush(); ResultSet rs = s.executeQuery(sql[j]); if (rs.next()) { res = rs.getShort("ERR"); mensaje = rs.getString("RES"); } //outprintln("REGRESO: ERR: " + res + " RES: " + mensaje + " " + JUtil.obtFechaTxt(new Date(), "hh:mm:ss")); pw.println("REGRESO: ERR: " + res + " RES: " + mensaje + " " + JUtil.obtFechaTxt(new Date(), "HH:mm:ss")); pw.flush(); } s.close(); } catch (NullPointerException e) //Se captura cuando no existe una base de datos fsica pero el cabecero general de tbl_bd contiene una { System.out.println(e.toString()); pw.println(e.toString() + "\n"); pw.flush(); } catch (SQLException e) { System.out.println(e.toString()); pw.println(e.toString() + "\n"); pw.flush(); } finally { JAccesoBD.liberarConexion(con); } } // Fin for BA>SES pw.println("----------------------------- FIN DE LA ACTUALIZACION ----------------------------------"); pw.flush(); idsalida = 0; } catch (IOException e) { idsalida = 3; salida += "OCURRIERON ERRORES AL ABRIR O COPIAR ARCHIVOS... REVISA EL REGISTRO DE ACTUALIZACIONES<br>"; e.printStackTrace(); } }
From source file:org.webguitoolkit.ui.controls.form.fileupload.FileUploadServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int eventId = 0; Hashtable parameters = new Hashtable(); String cssId = ""; List eventParameters = null;//from www .j ava 2s. com try { cssId = request.getQueryString().replaceAll("cssId=", ""); UploadListener listener = new UploadListener(request, cssId, 30); // Create a factory for disk-based file items FileItemFactory factory = new MonitoredDiskFileItemFactory(listener); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); upload.setHeaderEncoding("UTF-8"); // currently only one file is uploaded List fileItems = new ArrayList(); // process uploads .. int contentlength = request.getContentLength(); if (contentlength > maxFileSize) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head><title></title></head>"); out.println("<body onLoad=\"window.parent.eventParam('" + cssId + "', new Array('File to large','" + contentlength + "'));window.parent.fireWGTEvent('" + cssId + "','" + FileUpload.EVENT_FILE_TO_LARGE + "');\">"); out.println("</body>"); out.println("</html>"); request.getSession().setAttribute("uploadInfo", new UploadInfo(1, 1, 1, 1, "error")); return; } // parsing request and generate tmp files List items = upload.parseRequest(request); for (Iterator iter = items.iterator(); iter.hasNext();) { FileItem item = (FileItem) iter.next(); // if file item is a parameter, add to parameter map // eles add filename to parameter map and store fileitem in the // fileitem list String name = item.getFieldName(); if (item.isFormField()) { parameters.put(name, item.getString()); } else { parameters.put(name, item.getName()); fileItems.add(item); } } IFileHandler fileHandler = null; // filehandler class specified in the fileupload tag. String fileHandlerClass = (String) parameters.get("fileHandler"); // of the filehandler (rather than for a Classname) cssId = (String) parameters.get("cssId"); if (StringUtils.isNotEmpty(cssId) && fileHandler == null) { // get access through component event mechanism FileUpload fu = null; try { fu = (FileUpload) DWRController.getInstance().getComponentById(cssId); } catch (NullPointerException e) { // not instance found, probably not the GuiSessionController // filter configured // to catch the requests for this Servlet } // this is only possible if the GuiSessionFilter is enabled for // this servlet if (fu != null) { fileHandler = fu.getFileHandler(); } } else if (StringUtils.isNotEmpty(fileHandlerClass)) fileHandler = (IFileHandler) Class.forName(fileHandlerClass).newInstance(); if (fileItems == null || fileItems.isEmpty() || StringUtils.isEmpty(((FileItem) fileItems.get(0)).getName())) { eventId = FileUpload.EVENT_NO_FILE; eventParameters = new ArrayList(); eventParameters.add("error.fileupload.nofile@No file specified!"); } else if (fileHandler != null) { fileHandler.init(fileItems, parameters, request); // method to process the Upload fileHandler.processUpload(); // get returnparameter of the filehandler to send them bag to // the fileupload action listener. eventParameters = fileHandler.getEventParameters(); } else { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head><title></title></head>"); out.println("<body onLoad=\"window.parent.eventParam('" + cssId + "', new Array('No File Handler found'));window.parent.fireWGTEvent('" + cssId + "','" + FileUpload.EVENT_UPLOAD_ERROR + "');\">"); out.println("</body>"); out.println("</html>"); request.getSession().setAttribute("uploadInfo", new UploadInfo(1, 1, 1, 1, "error")); return; } } catch (Exception e) { // event Id for errors eventId = FileUpload.EVENT_UPLOAD_ERROR; eventParameters = new ArrayList(); eventParameters.add(cssId); eventParameters.add(e.toString()); // e.printStackTrace(); // To change page of catch statement use // File | Settings | File Templates. } finally { // try to get cssId to send an event about the result of the upload // to the server cssId = (String) parameters.get("cssId"); } // put the return parameters in a js array for sending them back to the // fileupload's action listener String eventParameterArray = "new Array("; if (eventParameters != null) { for (Iterator iter = eventParameters.iterator(); iter.hasNext();) { eventParameterArray += "'" + StringEscapeUtils.escapeJavaScript((String) iter.next()) + "'"; if (iter.hasNext()) eventParameterArray += ","; } } eventParameterArray += ")"; // tell parrent page to do fire the event response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head><title></title></head>"); out.println("<body onLoad=\"window.parent.eventParam('" + cssId + "', " + eventParameterArray + ");window.parent.fireWGTEvent('" + cssId + "','" + eventId + "');\">"); out.println("</body>"); out.println("</html>"); }