@Override public void run() { try { XMLStreamWriter writer = outFac.createXMLStreamWriter( pout ); copyXML( reader, writer, request.getRequestURL().toString() ); pout.close(); } catch ( IOException e ) { LOG.debug( "IO-error occurred while proxying: '{}'", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } catch ( XMLStreamException e ) { LOG.debug( "IO-error occurred while proxying: '{}'", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } } };
public void export( StringBuilder sb, List<ICRS> crsToExport ) { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter( out ); XMLOutputFactory factory = XMLOutputFactory.newInstance(); factory.setProperty( "javax.xml.stream.isRepairingNamespaces", Boolean.TRUE ); try { XMLStreamWriter xmlWriter = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); export( crsToExport, xmlWriter ); sb.append( out.toString( Charset.defaultCharset().displayName() ) ); } catch ( UnsupportedEncodingException e ) { LOG.error( e.getLocalizedMessage(), e ); } catch ( XMLStreamException e ) { LOG.error( "Error while exporting the coordinates: " + e.getLocalizedMessage(), e ); } }
private String naturalizeXMLStreamExceptionMessage(final XMLStreamException xse) { String naturalized = xse.getLocalizedMessage(); final Matcher m = XML_STREAM_EXCEPTION_MESSAGE_PATTERN.matcher(naturalized); if (m.find()) { final String errorInfo = m.group(2); if (StringUtils.isNotEmpty(errorInfo)) { final String [] tokens = StringUtils.split(errorInfo, "#?&"); if (!ArrayUtils.isEmpty(tokens)) { final Location location = xse.getLocation(); final StringBuilder sbTemp = new StringBuilder().append("XML Stream Error at (L") .append(location.getLineNumber()) .append(":C").append(location.getColumnNumber()) .append("). Cause: ").append(StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(tokens[0]), " ")); if (tokens.length > 1) { sbTemp.append(" (").append(StringUtils.join(tokens, ", ", 1, tokens.length)).append(")"); } naturalized = sbTemp.toString(); } } } return naturalized; }
Style loadNoImport( String layerName, File file, boolean legend ) { XMLInputFactory fac = XMLInputFactory.newInstance(); FileInputStream in = null; try { LOG.debug( "Trying to load{} style from '{}'", legend ? "" : " legend", file ); in = new FileInputStream( file ); Style sty = SymbologyParser.INSTANCE.parse( fac.createXMLStreamReader( file.toString(), in ) ); if ( legend ) { monitoredLegendFiles.put( file, new Pair<Long, String>( file.lastModified(), layerName ) ); } else { monitoredFiles.put( file, new Pair<Long, String>( file.lastModified(), layerName ) ); } return sty; } catch ( FileNotFoundException e ) { LOG.info( "Style file '{}' for layer '{}' could not be found: '{}'", new Object[] { file, layerName, e.getLocalizedMessage() } ); } catch ( XMLStreamException e ) { LOG.trace( "Stack trace:", e ); LOG.info( "Style file '{}' for layer '{}' could not be loaded: '{}'", new Object[] { file, layerName, e.getLocalizedMessage() } ); } finally { closeQuietly( in ); } return null; }
/** * Converts a JSON input stream to its XML representation. * * @param jsonStream JSON input stream * @param pIs Whether or not to add XML processing instructions to the output XML.<br/> * This property is useful when converting JSON payloads with array objects. * @return OMElement that is the XML representation of the input JSON data. */ public static OMElement toXml(InputStream jsonStream, boolean pIs) throws AxisFault { if (jsonStream == null) { logger.error("#toXml. Could not convert JSON Stream to XML. JSON input stream is null."); return null; } try { XMLStreamReader streamReader = getReader(jsonStream, pIs); return new StAXOMBuilder(streamReader).getDocumentElement(); } catch (XMLStreamException e) {//invalid JSON? logger.error("#toXml. Could not convert JSON Stream to XML. Cannot handle JSON input. Error>>> " + e.getLocalizedMessage()); throw new AxisFault("Could not convert JSON Stream to XML. Cannot handle JSON input.", e); } }
private void openReader() { try { synchronized ( LOCK ) { configStream = ProxySettings.openURLConnection( configURL ).getInputStream(); this.configReader = XMLInputFactory.newInstance().createXMLStreamReader( configURL.toExternalForm(), this.configStream ); // move from start document. XMLStreamUtils.nextElement( configReader ); if ( !expectedRootName().equals( configReader.getName() ) ) { LOG.error( "The root element of the crs configuration at location: " + configURL + " is not the expected: " + expectedRootName() + " is your configuration correct?" ); } } } catch ( XMLStreamException e ) { LOG.debug( "Could not read config file from url: " + configURL + ", stack trace.", e ); LOG.error( "Could not read config file from url: " + configURL + " because: " + e.getLocalizedMessage() ); } catch ( FactoryConfigurationError e ) { LOG.debug( "Could not read config file from url: " + configURL + ", stack trace.", e ); LOG.error( "Could not read config file from url: " + configURL + " because: " + e.getLocalizedMessage() ); } catch ( IOException e ) { LOG.debug( "Could not read config file from url: " + configURL + ", stack trace.", e ); LOG.error( "Could not read config file from url: " + configURL + " because: " + e.getLocalizedMessage() ); } }
.append(e.getLocalizedMessage()); throw new SystemException(error.toString());
@Override public Representation get(ReferenceParametersType ref) { String uuid = getUUID(ref); if (!storage.containsKey(uuid)) { throw new UnknownResource(); } String resource = storage.get(uuid); if (resource.isEmpty()) { return new Representation(); } Document doc = null; try { doc = StaxUtils.read(new StringReader(storage.get(uuid))); } catch (XMLStreamException e) { LOG.severe(e.getLocalizedMessage()); throw new SoapFault("Internal Error", getSoapVersion().getReceiver()); } Representation representation = new Representation(); representation.setAny(doc.getDocumentElement()); return representation; }
throw new IOException(e.getLocalizedMessage(), e);
@Override public Representation get(ReferenceParametersType ref) { String uuid = getUUID(ref); if (!storage.containsKey(uuid)) { throw new UnknownResource(); } String resource = storage.get(uuid); if (resource.isEmpty()) { return new Representation(); } Document doc = null; try { doc = StaxUtils.read(new StringReader(storage.get(uuid))); } catch (XMLStreamException e) { LOG.severe(e.getLocalizedMessage()); throw new SoapFault("Internal Error", getSoapVersion().getReceiver()); } Representation representation = new Representation(); representation.setAny(doc.getDocumentElement()); return representation; }
public FeatureCollection getFeatures() throws OWSException, OWSExceptionReport { try { return FeatureInfoParser.parseAsFeatureCollection( rawResponse.getAsXMLStream(), request.getLayer() ); } catch ( XMLStreamException e ) { throw new OWSException( "Remote WMTS response was not recognized as feature collection: " + e.getLocalizedMessage(), e, OWSException.NO_APPLICABLE_CODE ); } }
LOG.trace( "Stack trace:", e ); } catch ( XMLStreamException e ) { LOG.debug( "Error while writing 'not authorized' response: '{}'", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e );
@Override public void flushBuffer() throws IOException { if ( wrappee instanceof LoggingHttpResponseWrapper ) { ( (LoggingHttpResponseWrapper) wrappee ).finalizeLogging(); } if ( xmlWriter != null ) { try { xmlWriter.flush(); } catch ( XMLStreamException e ) { LOG.debug( e.getLocalizedMessage(), e ); throw new IOException( e ); } } if ( buffer != null ) { buffer.flush(); buffer.writeTo( super.getOutputStream() ); buffer.reset(); } super.flushBuffer(); }
+ messageContext.getMessageID() + ". Error>>> " + e.getLocalizedMessage()); throw new AxisFault("Could not Write JSON message.", e);
LOG.debug( "Exception message: " + e.getMessage(), e ); throw new ProcessletException( new OWSException( e.getLocalizedMessage(), OWSException.INVALID_PARAMETER_VALUE ) ); } catch ( UnknownCRSException e ) {
+ e.getLocalizedMessage() ); } catch ( FactoryConfigurationError e ) { throw new CRSConfigurationException( "Could not instantiate crs definitions because: "
throw new IOException(e.getLocalizedMessage(), e);
throw new IOException(e.getLocalizedMessage(), e);
throw new IOException(e.getLocalizedMessage(), e);
response.flushBuffer(); } catch ( XMLStreamException e ) { throw new IOException( e.getLocalizedMessage(), e );