List of usage examples for java.lang Throwable getLocalizedMessage
public String getLocalizedMessage()
From source file:com.is.rest.cache.CacheAwareCallback.java
@Override public void onFailure(final int statusCode, final Header[] headers, final Throwable e, final String responseBody, final Result errorResponse) { Logger.d("onFailure: status" + statusCode + " rawResponse: " + responseBody); ExecutionUtils.execute(new AsyncTask<Void, Void, Result>() { @Override/*from w w w . j ava2 s . c om*/ protected Result doInBackground(Void... voids) { Result cachedResponse = null; boolean loadFromCache = false; switch (cacheInfo.getPolicy()) { case LOAD_IF_TIMEOUT: if (e != null && (ConnectTimeoutException.class.isAssignableFrom(e.getClass()) || SocketTimeoutException.class.isAssignableFrom(e.getClass()))) { loadFromCache = true; } break; case LOAD_ON_ERROR: loadFromCache = true; break; default: break; } if (loadFromCache) { try { cachedResponse = cacheManager.get(cacheInfo.getKey(), cacheInfo); } catch (IOException e1) { Logger.e("cache error", e); } catch (ClassNotFoundException e1) { Logger.e("cache error", e); } } return cachedResponse; } @Override public void onPostExecute(Result result) { if (result != null) { String errorMsg = e != null ? e.getLocalizedMessage() : "n/a"; Logger.d("CacheAwareCallback. Loading from cache after response error: " + errorMsg + " result with cached result: " + result); cacheInfo.setLoadedFromCache(true); } Response<Result> httpResponse = new Response<Result>(statusCode, headers, responseBody, errorResponse, e, getCacheInfo()); if (proceedWithResponse()) { timesProcessed++; onResponse(httpResponse); } } }); }
From source file:org.deegree.services.controller.OGCFrontController.java
/** * Handles HTTP POST requests.//from w w w .j av a 2 s . c om * <p> * An HTTP POST request specifies parameters in the request body. OGC service specifications use three different * ways to encode the parameters: * <ul> * <li><b>KVP</b>: Parameters are given as <code>key=value</code> pairs which are separated using the & * character. This is equivalent to standard HTTP GET requests, except that the parameters are not part of the query * string, but the POST body. In this case, the <code>content-type</code> field in the header must be * <code>application/x-www-form-urlencoded</code>.</li> * <li><b>XML</b>: The POST body contains an XML document. In this case, the <code>content-type</code> field in the * header has to be <code>text/xml</code>, but the implementation does not rely on this in order to be more tolerant * to clients.</li> * <li><b>SOAP</b>: TODO</li> * <li><b>Multipart</b>: TODO</li> * </ul> */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpResponseBuffer responseBuffer = createHttpResponseBuffer(request, response); try { logHeaders(request); addHeaders(responseBuffer); responseBuffer = handleCompression(responseBuffer); LOG.debug("doPost(), contentType: '" + request.getContentType() + "'"); long entryTime = System.currentTimeMillis(); try { // check if content-type implies that it's a KVP request String contentType = request.getContentType(); boolean isKVP = false; if (contentType != null) { isKVP = request.getContentType().startsWith("application/x-www-form-urlencoded"); } List<FileItem> multiParts = checkAndRetrieveMultiparts(request); InputStream is = request.getInputStream(); if (isKVP) { String queryString = readPostBodyAsString(is); LOG.debug("Treating POST input stream as KVP parameters. Raw input: '" + queryString + "'."); Map<String, String> normalizedKVPParams = null; String encoding = request.getCharacterEncoding(); if (encoding == null) { LOG.debug("Request has no further encoding information. Defaulting to '" + DEFAULT_ENCODING + "'."); normalizedKVPParams = KVPUtils.getNormalizedKVPMap(queryString, DEFAULT_ENCODING); } else { LOG.debug("Client encoding information :" + encoding); normalizedKVPParams = KVPUtils.getNormalizedKVPMap(queryString, encoding); } dispatchKVPRequest(normalizedKVPParams, request, responseBuffer, multiParts, entryTime); } else { // if( handle multiparts, get first body from multipart (?) // body->requestDoc InputStream requestInputStream = null; if (multiParts != null && multiParts.size() > 0) { for (int i = 0; i < multiParts.size() && requestInputStream == null; ++i) { FileItem item = multiParts.get(i); if (item != null) { LOG.debug("Using multipart item: " + i + " with contenttype: " + item.getContentType() + " as the request."); requestInputStream = item.getInputStream(); } } } else { requestInputStream = is; } if (requestInputStream == null) { String msg = "Could not create a valid inputstream from request " + ((multiParts != null && multiParts.size() > 0) ? "without" : "with") + " multiparts."; LOG.error(msg); throw new IOException(msg); } String dummySystemId = "HTTP Post request from " + request.getRemoteAddr() + ":" + request.getRemotePort(); XMLStreamReader xmlStream = XMLInputFactoryUtils.newSafeInstance() .createXMLStreamReader(dummySystemId, requestInputStream); // skip to start tag of root element XMLStreamUtils.nextElement(xmlStream); if (isSOAPRequest(xmlStream)) { dispatchSOAPRequest(xmlStream, request, responseBuffer, multiParts); } else { dispatchXMLRequest(xmlStream, request, responseBuffer, multiParts); } } } catch (Throwable e) { LOG.debug("Handling HTTP-POST request took: " + (System.currentTimeMillis() - entryTime) + " ms before sending exception."); LOG.debug(e.getMessage(), e); OWSException ex = new OWSException(e.getLocalizedMessage(), "InvalidRequest"); OWS ows = null; try { ows = determineOWSByPath(request); } catch (OWSException e2) { sendException(ows, e2, responseBuffer, null); return; } sendException(ows, ex, responseBuffer, null); } LOG.debug("Handling HTTP-POST request with status 'success' took: " + (System.currentTimeMillis() - entryTime) + " ms."); } finally { instance.CONTEXT.remove(); responseBuffer.flushBuffer(); if (mainConfig.isValidateResponses() != null && mainConfig.isValidateResponses()) { validateResponse(responseBuffer); } } }
From source file:org.nuxeo.ecm.platform.web.common.exceptionhandling.DefaultNuxeoExceptionHandler.java
@Override public void handleException(HttpServletRequest request, HttpServletResponse response, Throwable t) throws IOException, ServletException { Throwable unwrappedException = ExceptionHelper.unwrapException(t); // check for Anonymous case if (ExceptionHelper.isSecurityError(unwrappedException)) { Principal principal = request.getUserPrincipal(); if (principal instanceof NuxeoPrincipal) { NuxeoPrincipal nuxeoPrincipal = (NuxeoPrincipal) principal; if (nuxeoPrincipal.isAnonymous()) { // redirect to login than to requested page if (handleAnonymousException(request, response)) { return; }/* www .j ava 2s . c om*/ } } } startHandlingException(request, response, t); try { ErrorHandler handler = getHandler(t); Integer code = handler.getCode(); int status = code == null ? HttpServletResponse.SC_INTERNAL_SERVER_ERROR : code.intValue(); parameters.getListener().startHandling(t, request, response); StringWriter swriter = new StringWriter(); PrintWriter pwriter = new PrintWriter(swriter); t.printStackTrace(pwriter); String stackTrace = swriter.getBuffer().toString(); if (status < HttpServletResponse.SC_INTERNAL_SERVER_ERROR) { // 500 log.debug(t.getMessage(), t); } else { log.error(stackTrace); parameters.getLogger().error(stackTrace); } parameters.getListener().beforeSetErrorPageAttribute(unwrappedException, request, response); request.setAttribute("exception_message", unwrappedException.getLocalizedMessage()); request.setAttribute("user_message", getUserMessage(handler.getMessage(), request.getLocale())); request.setAttribute("securityError", ExceptionHelper.isSecurityError(unwrappedException)); request.setAttribute("messageBundle", ResourceBundle.getBundle(parameters.getBundleName(), request.getLocale(), Thread.currentThread().getContextClassLoader())); String dumpedRequest = parameters.getRequestDumper().getDump(request); if (status >= HttpServletResponse.SC_INTERNAL_SERVER_ERROR) { // 500 parameters.getLogger().error(dumpedRequest); } request.setAttribute("isDevModeSet", Framework.isDevModeSet()); if (Framework.isDevModeSet()) { request.setAttribute("stackTrace", stackTrace); request.setAttribute("request_dump", dumpedRequest); } parameters.getListener().beforeForwardToErrorPage(unwrappedException, request, response); if (!response.isCommitted()) { response.setStatus(status); String errorPage = handler.getPage(); errorPage = (errorPage == null) ? parameters.getDefaultErrorPage() : errorPage; RequestDispatcher requestDispatcher = request.getRequestDispatcher(errorPage); if (requestDispatcher != null) { requestDispatcher.forward(request, response); } else { log.error("Cannot forward to error page, " + "no RequestDispatcher found for errorPage=" + errorPage + " handler=" + handler); } parameters.getListener().responseComplete(); } else { // do not throw an error, just log it: afterDispatch needs to // be called, and sometimes the initial error is a // ClientAbortException log.error("Cannot forward to error page: " + "response is already committed"); } parameters.getListener().afterDispatch(unwrappedException, request, response); } catch (ServletException e) { throw e; } catch (RuntimeException | IOException e) { throw new ServletException(e); } }
From source file:org.geotools.utils.imageoverviews.OverviewsEmbedder.java
public void run() { // did we create a local private tile cache or not? boolean localTileCache = false; ////from w w w . j a v a2 s . c o m // creating the image to use for the successive // subsampling // TileCache baseTC = JAI.getDefaultInstance().getTileCache(); if (baseTC == null) { localTileCache = true; final long tilecacheSize = super.getTileCacheSize(); baseTC = JAI.createTileCache(); baseTC.setMemoryCapacity(tilecacheSize); baseTC.setMemoryThreshold(0.75f); } // // CHECK INPUT DIRECTORIES/FILES // if (sourcePath == null) { fireEvent("Provided sourcePath is null", overallProgress); return; } // getting an image input stream to the file final File file = new File(sourcePath); final File[] files; int numFiles = 1; StringBuilder message; if (!file.canRead() || !file.exists()) { fireEvent("Provided file " + file.getAbsolutePath() + " cannot be read or does not exist", 100); return; } if (file.isDirectory()) { if (wildcardString == null) { fireEvent("Provided wildcardString is null", 100); return; } final FileFilter fileFilter = new WildcardFileFilter(wildcardString); files = file.listFiles(fileFilter); numFiles = files.length; if (numFiles <= 0) { message = new StringBuilder("No files to process!"); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), 100); } } else files = new File[] { file }; if (files == null || files.length == 0) { fireEvent("Unable to find input files for the provided wildcard " + wildcardString + " and input path " + sourcePath, 100); return; } // setting step overallProgressStep = 100 * 1.0 / numFiles; // // ADDING OVERVIEWS TO ALL FOUND FILES // for (fileBeingProcessed = 0; fileBeingProcessed < numFiles; fileBeingProcessed++) { message = new StringBuilder("Managing file ").append(fileBeingProcessed).append(" of ") .append(files[fileBeingProcessed]).append(" files"); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } overallProgress = overallProgressStep * fileBeingProcessed; fireEvent(message.toString(), overallProgress); if (getStopThread()) { message = new StringBuilder("Stopping requested at file ").append(fileBeingProcessed) .append(" of ").append(numFiles).append(" files"); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), overallProgress); return; } ImageInputStream stream = null; ImageWriter writer = null; ImageOutputStream streamOut = null; RenderedOp currentImage = null; RenderedOp newImage = null; try { File localFile = files[fileBeingProcessed]; // // get a stream // stream = ImageIO.createImageInputStream(localFile); if (stream == null) { message = new StringBuilder("Unable to create an input stream for file") .append(files[fileBeingProcessed]); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(message.toString()); } fireEvent(message.toString(), overallProgress); break; } stream.mark(); // // get a reader // final Iterator<ImageReader> it = ImageIO.getImageReaders(stream); if (!it.hasNext()) { message = new StringBuilder("Unable to find a reader for file") .append(files[fileBeingProcessed]); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(message.toString()); } fireEvent(message.toString(), overallProgress); break; } final ImageReader reader = (ImageReader) it.next(); stream.reset(); stream.mark(); // is it a geotiff reader or not? if (!reader.getFormatName().toLowerCase().startsWith("tif")) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Discarding input file " + files[fileBeingProcessed] + " since it is not a proper tif file."); } continue; } // // set input // reader.setInput(stream); ImageLayout layout = null; // tiling the image if needed int actualTileW = reader.getTileWidth(0); int actualTileH = reader.getTileHeight(0); if (!reader.isImageTiled(0) || (reader.isImageTiled(0) && (actualTileH != tileH && tileH != -1) || (actualTileW != tileW && tileW != -1))) { message = new StringBuilder("Retiling image ").append(fileBeingProcessed); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), overallProgress); layout = Utils.createTiledLayout(tileW, tileH, 0, 0); } stream.reset(); reader.reset(); reader.dispose(); // // output image stream // if (externalOverviews) { // create a sibling file localFile = new File(localFile.getParent(), FilenameUtils.getBaseName(localFile.getAbsolutePath()) + ".tif.ovr"); } streamOut = ImageIOExt.createImageOutputStream(null, localFile); if (streamOut == null) { message = new StringBuilder("Unable to acquire an ImageOutputStream for the file ") .append(files[fileBeingProcessed].toString()); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(message.toString()); } fireEvent(message.toString(), 100); break; } // // Preparing to write the set of images. First of all I write // the first image ` // // getting a writer for this reader writer = TIFF_IMAGE_WRITER_SPI.createWriterInstance(); writer.setOutput(streamOut); writer.addIIOWriteProgressListener(writeProgressListener); writer.addIIOWriteWarningListener(writeProgressListener); ImageWriteParam param = writer.getDefaultWriteParam(); // // setting tiling on the first image using writing parameters // if (tileH != -1 & tileW != -1) { param.setTilingMode(ImageWriteParam.MODE_EXPLICIT); param.setTiling(tileW, tileH, 0, 0); } else { param.setTilingMode(ImageWriteParam.MODE_EXPLICIT); param.setTiling(actualTileW, actualTileH, 0, 0); } if (this.compressionScheme != null && !Double.isNaN(compressionRatio)) { param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionType(compressionScheme); param.setCompressionQuality((float) this.compressionRatio); } final RenderingHints newHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout); newHints.add(new RenderingHints(JAI.KEY_TILE_CACHE, baseTC)); // read base image ParameterBlock pbjRead = new ParameterBlock(); pbjRead.add(stream); pbjRead.add(Integer.valueOf(0)); pbjRead.add(Boolean.FALSE); pbjRead.add(Boolean.FALSE); pbjRead.add(Boolean.FALSE); pbjRead.add(null); pbjRead.add(null); pbjRead.add(null); pbjRead.add(null); currentImage = JAI.create("ImageRead", pbjRead, newHints); message = new StringBuilder("Read original image ").append(fileBeingProcessed); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), overallProgress); int i = 0; // // OVERVIEWS CYLE // for (overviewInProcess = 0; overviewInProcess < numSteps; overviewInProcess++) { message = new StringBuilder("Subsampling step ").append(overviewInProcess + 1) .append(" of image ").append(fileBeingProcessed); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), overallProgress); // paranoiac check if (currentImage.getWidth() / downsampleStep <= 0 || currentImage.getHeight() / downsampleStep <= 0) break; // SCALE // subsampling the input image using the chosen algorithm final SubsampleAlgorithm algorithm = SubsampleAlgorithm.valueOf(scaleAlgorithm); switch (algorithm) { case Average: newImage = Utils.scaleAverage(currentImage, baseTC, downsampleStep, borderExtender); break; case Filtered: newImage = Utils.filteredSubsample(currentImage, baseTC, downsampleStep, lowPassFilter); break; case Bilinear: newImage = Utils.subsample(currentImage, baseTC, new InterpolationBilinear(), downsampleStep, borderExtender); break; case Bicubic: newImage = Utils.subsample(currentImage, baseTC, new InterpolationBicubic(2), downsampleStep, borderExtender); break; case Nearest: newImage = Utils.subsample(currentImage, baseTC, new InterpolationNearest(), downsampleStep, borderExtender); break; default: throw new IllegalArgumentException("Invalid scaling algorithm " + scaleAlgorithm);//cannot get here } //set relevant metadata IIOMetadata imageMetadata = null; if (writer instanceof TIFFImageWriter) { imageMetadata = writer.getDefaultImageMetadata(new ImageTypeSpecifier(newImage), param); if (imageMetadata != null) ((TIFFImageMetadata) imageMetadata).addShortOrLongField( BaselineTIFFTagSet.TAG_NEW_SUBFILE_TYPE, BaselineTIFFTagSet.NEW_SUBFILE_TYPE_REDUCED_RESOLUTION); } // write out if (!externalOverviews || i > 0) writer.writeInsert(-1, new IIOImage(newImage, null, imageMetadata), param); else writer.write(null, new IIOImage(newImage, null, imageMetadata), param); message = new StringBuilder("Step ").append(overviewInProcess + 1).append(" of image ") .append(fileBeingProcessed).append(" done!"); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), overallProgress); // switching images currentImage.dispose(); //dispose old image currentImage = newImage; i++; } overallProgress = 100; // close message message = new StringBuilder("Done with image ").append(fileBeingProcessed); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), overallProgress); } catch (Throwable e) { fireException(e); } finally { // clean up // clean caches if they are local if (localTileCache && baseTC != null) try { baseTC.flush(); } catch (Exception e) { } // // free everything try { if (streamOut != null) streamOut.close(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } try { if (writer != null) writer.dispose(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } try { if (currentImage != null) currentImage.dispose(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } try { if (newImage != null) newImage.dispose(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } try { if (stream != null) stream.close(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } } } if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Done!!!"); }
From source file:com.microsoft.tfs.client.common.ui.controls.teamexplorer.TeamExplorerBaseControl.java
protected Composite createExceptionComposite(final Composite parent, final String itemName, final Throwable e) { if (context == null || !context.isConnected()) { return createOfflineComposite(parent); }//from w ww. j av a 2 s.c o m log.warn("Caught exception creating TE UI component", e); //$NON-NLS-1$ // Make sure to use a non-disposed parent composite if (parent == null || parent.isDisposed()) { return parent; } final Composite composite = toolkit.createComposite(parent); // Form-style border painting not enabled (0 pixel margins OK) because // no applicable controls in this composite SWTUtil.gridLayout(composite); final Composite border = toolkit.createComposite(composite, SWT.BORDER); SWTUtil.gridLayout(border, 2); GridDataBuilder.newInstance().hAlignFill().hGrab().applyTo(border); final ImageHelper imageHelper = new ImageHelper(TFSCommonUIClientPlugin.PLUGIN_ID); final Image image = imageHelper.getImage("/images/common/team_explorer_exception.gif"); //$NON-NLS-1$ final Label imageLabel = toolkit.createLabel(border, "", SWT.NONE); //$NON-NLS-1$ imageLabel.setImage(image); GridDataBuilder.newInstance().applyTo(imageLabel); final String format = Messages.getString("TeamExplorerControl.ExceptionCreatingContributionFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(format, itemName, e.getLocalizedMessage() != null ? e.getLocalizedMessage() : Messages.getString("TeamExplorerControl.NoMessageAvailable")); //$NON-NLS-1$ final Label textLabel = toolkit.createLabel(border, message, SWT.WRAP); GridDataBuilder.newInstance().hAlignFill().hGrab().applyTo(textLabel); return composite; }
From source file:org.apache.synapse.message.store.impl.rabbitmq.RabbitMQProducer.java
public boolean storeMessage(MessageContext synCtx) { if (synCtx == null) { return false; }//from www . j a v a2s .c o m if (connection == null) { if (logger.isDebugEnabled()) { logger.error(getId() + " cannot proceed. RabbitMQ Connection is null."); } logger.warn(getId() + ". Ignored MessageID : " + synCtx.getMessageID()); return false; } StorableMessage message = MessageConverter.toStorableMessage(synCtx); boolean error = false; Throwable throwable = null; Channel channel = null; try { //Serializing message ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutput objOut = new ObjectOutputStream(os); objOut.writeObject(message); byte[] byteForm = os.toByteArray(); objOut.close(); os.close(); //building AMQP message AMQP.BasicProperties.Builder builder = new AMQP.BasicProperties().builder(); builder.messageId(synCtx.getMessageID()); builder.deliveryMode(MessageProperties.MINIMAL_PERSISTENT_BASIC.getDeliveryMode()); builder.priority(message.getPriority(DEFAULT_PRIORITY)); channel = connection.createChannel(); if (exchangeName == null) { channel.basicPublish("", queueName, builder.build(), byteForm); } else { channel.basicPublish(exchangeName, queueName, builder.build(), byteForm); } } catch (IOException e) { throwable = e; error = true; isConnectionError = true; } catch (Throwable t) { throwable = t; error = true; } finally { if (channel != null && channel.isOpen()) try { channel.close(); } catch (IOException e) { logger.error("Error when closing connection" + synCtx.getMessageID() + ". " + e); } } if (error) { String errorMsg = getId() + ". Ignored MessageID : " + synCtx.getMessageID() + ". Could not store message to store [" + store.getName() + "]. Error:" + throwable.getLocalizedMessage(); logger.error(errorMsg, throwable); store.closeProducerConnection(); connection = null; if (logger.isDebugEnabled()) { logger.debug(getId() + ". Ignored MessageID : " + synCtx.getMessageID()); } return false; } if (logger.isDebugEnabled()) { logger.debug(getId() + ". Stored MessageID : " + synCtx.getMessageID()); } store.enqueued(); return true; }
From source file:org.omegat.core.data.RealProject.java
/** * Set up and execute the user-specified external command. * @param command Command to execute/*from w ww . ja v a2 s .com*/ */ private void doExternalCommand(String command) { if (StringUtil.isEmpty(command)) { return; } Core.getMainWindow().showStatusMessageRB("CT_START_EXTERNAL_CMD"); CommandVarExpansion expander = new CommandVarExpansion(command); command = expander.expandVariables(m_config); Log.log("Executing command: " + command); try { Process p = Runtime.getRuntime().exec(StaticUtils.parseCLICommand(command)); processCache.push(p); CommandMonitor stdout = CommandMonitor.newStdoutMonitor(p); CommandMonitor stderr = CommandMonitor.newStderrMonitor(p); stdout.start(); stderr.start(); } catch (IOException e) { String message; Throwable cause = e.getCause(); if (cause == null) { message = e.getLocalizedMessage(); } else { message = cause.getLocalizedMessage(); } Core.getMainWindow().showStatusMessageRB("CT_ERROR_STARTING_EXTERNAL_CMD", message); } }
From source file:org.nightlabs.jfire.trade.Article.java
public void setReleaseException(Throwable t) { if (t == null) { this.releaseExceptionClass = null; this.releaseExceptionMessage = null; this.releaseExceptionStackTrace = null; return;/* ww w . j a v a 2 s .c om*/ } Throwable root = ExceptionUtils.getRootCause(t); if (root == null) root = t; StackTraceElement ste = root.getStackTrace()[0]; this.releaseExceptionClass = root.getClass().getName(); this.releaseExceptionMessage = root.getLocalizedMessage(); this.releaseExceptionStackTrace = ste.toString(); }
From source file:org.nightlabs.jfire.trade.Article.java
public void setAllocationException(Throwable t) { if (t == null) { this.allocationExceptionClass = null; this.allocationExceptionMessage = null; this.allocationExceptionStackTrace = null; return;/*from w w w.j a v a 2 s. co m*/ } Throwable root = ExceptionUtils.getRootCause(t); if (root == null) root = t; // StackTraceElement ste = root.getStackTrace()[0]; this.allocationExceptionClass = root.getClass().getName(); this.allocationExceptionMessage = root.getLocalizedMessage(); // this.allocationExceptionStackTrace = ste.toString(); this.allocationExceptionStackTrace = Util.getStackTraceAsString(root); }
From source file:org.opencms.workplace.CmsWidgetDialog.java
/** * Creates the dialog HTML for all occurrences of one widget parameter.<p> * /*w w w. j a v a2 s . c o m*/ * @param base the widget parameter base * @return the dialog HTML for one widget parameter */ protected String createDialogRowHtml(CmsWidgetDialogParameter base) { StringBuffer result = new StringBuffer(256); List<CmsWidgetDialogParameter> sequence = getParameters().get(base.getName()); int count = sequence.size(); // check if value is optional or multiple boolean addValue = false; if (count < base.getMaxOccurs()) { addValue = true; } boolean removeValue = false; if (count > base.getMinOccurs()) { removeValue = true; } // check if value is present boolean disabledElement = false; if (count < 1) { // no parameter with the value present, but also not optional: use base as parameter sequence = new ArrayList<CmsWidgetDialogParameter>(); sequence.add(base); count = 1; if (base.getMinOccurs() == 0) { disabledElement = true; } } // loop through multiple elements for (int j = 0; j < count; j++) { // get the parameter and the widget CmsWidgetDialogParameter p = sequence.get(j); I_CmsWidget widget = p.getWidget(); // check for an error in this row if (p.hasError()) { // show error message result.append("<tr><td></td><td><img src=\""); result.append(getSkinUri()).append("editors/xmlcontent/"); result.append("error.png"); result.append("\" border=\"0\" alt=\"\"></td><td class=\"xmlTdError\">"); Throwable t = p.getError(); while (t != null) { if (t instanceof I_CmsThrowable) { result.append(CmsEncoder.escapeXml(((I_CmsThrowable) t).getLocalizedMessage(getLocale()))); } else { result.append(CmsEncoder.escapeXml(t.getLocalizedMessage())); } t = t.getCause(); if (t != null) { result.append("<br>"); } } result.append("</td><td colspan=\"2\"></td></tr>\n"); } // create label and help bubble cells result.append("<tr>"); result.append("<td class=\"xmlLabel"); if (disabledElement) { // element is disabled, mark it with css result.append("Disabled"); } result.append("\">"); result.append(keyDefault(A_CmsWidget.getLabelKey(p), p.getName())); if (count > 1) { result.append(" [").append(p.getIndex() + 1).append("]"); } result.append(": </td>"); if (p.getIndex() == 0) { // show help bubble only on first element of each content definition result.append(p.getWidget().getHelpBubble(getCms(), this, p)); } else { // create empty cell for all following elements result.append(dialogHorizontalSpacer(16)); } // append individual widget html cell if element is enabled if (!disabledElement) { // this is a simple type, display widget result.append(widget.getDialogWidget(getCms(), this, p)); } else { // disabled element, show message for optional element result.append("<td class=\"xmlTdDisabled maxwidth\">"); result.append(key(Messages.GUI_EDITOR_WIDGET_OPTIONALELEMENT_0)); result.append("</td>"); } // append add and remove element buttons if required result.append(dialogHorizontalSpacer(5)); result.append("<td>"); if (addValue || removeValue) { result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>"); if (!addValue) { result.append(dialogHorizontalSpacer(25)); } else { result.append( "<td><table class=\"editorbuttonbackground\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>"); result.append(buildAddElement(base.getName(), p.getIndex(), addValue)); } if (removeValue) { if (!addValue) { result.append( "<td><table class=\"editorbuttonbackground\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>"); } result.append(buildRemoveElement(base.getName(), p.getIndex(), removeValue)); } result.append("</tr></table></td>"); result.append("</tr></table>"); } result.append("</td>"); // close row result.append("</tr>\n"); } return result.toString(); }