public void execute() { try { this.saxBeanWriter.write(this.bean); } catch (IOException e) { throw new ProcessingException("Fatal protocol violation", e); } catch (SAXException e) { throw new ProcessingException("Fatal XML error", e); } catch (IntrospectionException e) { throw new ProcessingException("Impossible to analyze input bean", e); } }
private URLConnection getUrlConnection() { if (this.servletConnection == null) { try { this.servletConnection = this.service.openConnection(); } catch (IOException e) { throw new ProcessingException("Can't use connected servlet service: " + this.service, e); } } return this.servletConnection; } }
private URLConnection getUrlConnection() { if (this.servletConnection == null) { try { this.servletConnection = this.service.openConnection(); } catch (IOException e) { throw new ProcessingException("Can't use connected servlet service: " + this.service, e); } } return this.servletConnection; }
private URLConnection getURLConnection() { if (this.urlConnection == null) { try { this.urlConnection = new URL(this.uri).openConnection(); } catch (IOException e) { throw new ProcessingException("Can't connect to the URI " + this.uri, e); } } return this.urlConnection; }
@Override public void setConfiguration(Map<String, ? extends Object> configuration) { try { this.service = new URL((String) configuration.get("service")); } catch (MalformedURLException e) { throw new ProcessingException(("Can't create an URL for " + configuration.get("service") + "."), e); } } }
public void execute() { if ("GET".equalsIgnoreCase(this.request.getMethod()) || "POST".equalsIgnoreCase(this.request.getMethod())) { try { wicketFilter.doGet(this.request, this.response); } catch (ServletException e) { throw new ProcessingException(e); } catch (IOException e) { throw new ProcessingException(e); } } }
private URL createSource(String sourceAtt) { try { URL source = null; if (sourceAtt.contains(":")) { source = new URL(sourceAtt); } else { source = new URL(this.baseUrl, sourceAtt); } if (this.logger.isDebugEnabled()) { this.logger.debug("Including source: " + source); } return source; } catch (MalformedURLException e) { throw new ProcessingException(("Can't parse URL " + sourceAtt), e); } }
/** * {@inheritDoc} * * @see org.apache.cocoon.pipeline.Pipeline#execute() */ public void execute() throws Exception { if (!this.setupDone) { throw new ProcessingException(new IllegalStateException( "The pipeline wasn't setup correctly. Call #setup() first.")); } this.invokeStarter(); }
public void execute() { if (XMLGenerator.this.logger.isDebugEnabled()) { XMLGenerator.this.logger.debug("Using a SAXBuffer to produce SAX events."); } try { this.saxBuffer.toSAX(XMLGenerator.this.getSAXConsumer()); } catch (SAXException e) { throw new ProcessingException("Can't stream " + this + " into the content handler.", e); } }
public void execute() { try { if (XMLGenerator.this.logger.isDebugEnabled()) { XMLGenerator.this.logger.debug("Using input stream " + this.inputStream + " as source to produce SAX events."); } XMLUtils.toSax(this.inputStream, XMLGenerator.this.getSAXConsumer()); } catch (PipelineException e) { throw e; } catch (Exception e) { throw new ProcessingException("Can't read or parse file " + this.inputStream, e); } }
public static XMLReader createXMLReader(final ContentHandler contentHandler) { XMLReader xmlReader; try { xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setContentHandler(contentHandler); if ( contentHandler instanceof LexicalHandler ) { xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", contentHandler); } xmlReader.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return new InputSource(new ByteArrayInputStream("".getBytes())); } }); } catch (SAXException e) { throw new ProcessingException("Cannot create and prepare an XMLReader.", e); } return xmlReader; } }
/** * {@inheritDoc} * * @see org.apache.cocoon.pipeline.component.Starter#execute() */ public void execute() { if (this.source == null) { throw new ProcessingException(this.getClass().getSimpleName() + " has no source."); } if (XMLGenerator.this.logger.isDebugEnabled()) { XMLGenerator.this.logger.debug("Using the URL " + this.source + " to produce SAX events."); } try { XMLUtils.toSax(this.source.openConnection(), XMLGenerator.this.getSAXConsumer()); } catch (IOException e) { throw new ProcessingException("Can't open connection to " + this.source, e); } }
public void execute() { try { if (XMLGenerator.this.logger.isDebugEnabled()) { XMLGenerator.this.logger.debug("Using file " + this.file.getAbsolutePath() + " as source to produce SAX events."); } XMLUtils.toSax(new FileInputStream(this.file), XMLGenerator.this.getSAXConsumer()); } catch (PipelineException e) { throw e; } catch (Exception e) { throw new ProcessingException("Can't read or parse file " + this.file.getAbsolutePath(), e); } }
/** * {@inheritDoc} * * @see org.apache.cocoon.pipeline.component.Starter#execute() */ public void execute() { try { if (XMLGenerator.this.logger.isDebugEnabled()) { XMLGenerator.this.logger.debug("Using a string to produce SAX events."); } XMLUtils.toSax(new ByteArrayInputStream(this.xmlString.getBytes()), XMLGenerator.this.getSAXConsumer()); } catch (PipelineException e) { throw e; } catch (Exception e) { throw new ProcessingException("Can't parse the XML string.", e); } }
public void execute() { try { if (XMLGenerator.this.logger.isDebugEnabled()) { XMLGenerator.this.logger.debug("Using a byte array as source to produce SAX events."); } if (this.encoding == null) { XMLUtils.toSax(new ByteArrayInputStream(this.bytes), XMLGenerator.this.getSAXConsumer()); } else { XMLUtils.toSax(new String(this.bytes, this.encoding), XMLGenerator.this.getSAXConsumer()); } } catch (PipelineException e) { throw e; } catch (UnsupportedEncodingException e) { throw new ProcessingException("The encoding " + this.encoding + " is not supported.", e); } catch (Exception e) { throw new ProcessingException("Can't parse byte array " + this.bytes, e); } }
/** * Creates a url from a string. * * @param sourceAtt The url represented as a string. * @return The url of the specified string. */ private URL createSource(String sourceAtt) { try { URL source = null; if (sourceAtt.contains(":")) { source = new URL(sourceAtt); } else { source = new URL(this.baseUrl, sourceAtt); } if (this.logger.isDebugEnabled()) { this.logger.debug("Including source: " + source); } return source; } catch (MalformedURLException e) { String message = "Can't parse URL " + sourceAtt; this.logger.error(message, e); throw new ProcessingException(message, e); } }
public void execute() { this.saxParser.setContentHandler(this.getSAXConsumer()); try { this.saxParser.parse(this.htmlSource.toExternalForm()); } catch (SAXException e) { throw new ProcessingException("Fatal XML error", e); } catch (IOException e) { throw new ProcessingException("Fatal protocol violation", e); } }
/** * * @param sourceAtt * @return */ private URL createSource(final String sourceAtt) { try { URL source = null; if (sourceAtt.contains(":")) { source = new URL(sourceAtt); } else { source = new URL(this.baseUrl, sourceAtt); } if (this.logger.isDebugEnabled()) { this.logger.debug("Including source: " + source); } return source; } catch (MalformedURLException e) { String message = "Can't parse URL " + sourceAtt; if (this.logger.isErrorEnabled()) { this.logger.error(message, e); } throw new ProcessingException(message, e); } }
/** * {@inheritDoc} * * @see org.apache.cocoon.pipeline.component.Finisher#getContentType() */ public String getContentType() { if (this.mimeType != null) { return this.mimeType; } URLConnection connection = null; try { connection = this.source.openConnection(); return connection.getContentType(); } catch (IOException e) { throw new ProcessingException(e); } finally { URLConnectionUtils.closeQuietly(connection); } }
public void execute() { HttpServletRequest request = HttpContextHelper.getRequest(this.inputParameters); if (!"POST".equals(request.getMethod())) { throw new ProcessingException("Cannot create consumer source for request that is not POST."); } InputStream inputStream = null; try { inputStream = request.getInputStream(); } catch (IOException e) { throw new ProcessingException("Can't open inputStream on request."); } try { XMLUtils.toSax(inputStream, this.getSAXConsumer()); } catch (PipelineException e) { throw e; } catch (Exception e) { throw new ProcessingException("Can't parse inputStream.", e); } }