List of usage examples for org.xml.sax SAXException SAXException
public SAXException(Exception e)
From source file:org.apache.fop.render.intermediate.extensions.DocumentNavigationHandler.java
/** {@inheritDoc} */ public void endElement(String uri, String localName, String qName) throws SAXException { if (NAMESPACE.equals(uri)) { try {// w ww .j a v a 2 s . c o m if (BOOKMARK_TREE.getLocalName().equals(localName)) { BookmarkTree tree = (BookmarkTree) objectStack.pop(); if (hasNavigation()) { this.navHandler.renderBookmarkTree(tree); } } else if (BOOKMARK.getLocalName().equals(localName)) { if (objectStack.peek() instanceof AbstractAction) { AbstractAction action = (AbstractAction) objectStack.pop(); Bookmark b = (Bookmark) objectStack.pop(); b.setAction(action); } else { objectStack.pop(); } } else if (NAMED_DESTINATION.getLocalName().equals(localName)) { AbstractAction action = (AbstractAction) objectStack.pop(); NamedDestination dest = (NamedDestination) objectStack.pop(); dest.setAction(action); if (hasNavigation()) { this.navHandler.renderNamedDestination(dest); } } else if (LINK.getLocalName().equals(localName)) { AbstractAction action = (AbstractAction) objectStack.pop(); Link link = (Link) objectStack.pop(); link.setAction(action); if (hasNavigation()) { this.navHandler.renderLink(link); } } else if (localName.startsWith("goto-")) { if (objectStack.size() == 1) { //Stand-alone action AbstractAction action = (AbstractAction) objectStack.pop(); if (hasNavigation()) { this.navHandler.addResolvedAction(action); } } } } catch (IFException ife) { throw new SAXException(ife); } } content.setLength(0); // Reset text buffer (see characters()) }
From source file:org.apache.fop.render.mif.MIFHandler.java
/** {@inheritDoc} */ public void startDocument() throws SAXException { log.fatal("The MIF Handler is non-functional at this time. Please help resurrect it!"); mifFile = new MIFFile(); try {//from w w w .ja v a 2 s . c o m mifFile.output(outStream); } catch (IOException ioe) { throw new SAXException(ioe); } }
From source file:org.apache.fop.render.mif.MIFHandler.java
/** {@inheritDoc} */ public void endDocument() throws SAXException { // finish all open elements mifFile.finish(true);//from w w w . j a v a 2 s .c o m try { mifFile.output(outStream); outStream.flush(); } catch (IOException ioe) { throw new SAXException(ioe); } }
From source file:org.apache.fop.render.pdf.extensions.PDFExtensionHandler.java
/** {@inheritDoc} */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { boolean handled = false; if (PDFExtensionAttachment.CATEGORY.equals(uri)) { lastAttributes = new AttributesImpl(attributes); handled = false;//ww w . j av a2s . c o m if (localName.equals(PDFEmbeddedFileExtensionAttachment.ELEMENT)) { //handled in endElement handled = true; } } if (!handled) { if (PDFExtensionAttachment.CATEGORY.equals(uri)) { throw new SAXException("Unhandled element " + localName + " in namespace: " + uri); } else { log.warn("Unhandled element " + localName + " in namespace: " + uri); } } }
From source file:org.apache.fop.render.ps.extensions.PSExtensionHandler.java
/** {@inheritDoc} */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { boolean handled = false; if (PSExtensionAttachment.CATEGORY.equals(uri)) { lastAttributes = new AttributesImpl(attributes); handled = false;/*from w ww . j a v a 2 s . c om*/ if (localName.equals(PSSetupCode.ELEMENT) || localName.equals(PSPageTrailerCodeBefore.ELEMENT) || localName.equals(PSSetPageDevice.ELEMENT) || localName.equals(PSCommentBefore.ELEMENT) || localName.equals(PSCommentAfter.ELEMENT)) { //handled in endElement handled = true; } } if (!handled) { if (PSExtensionAttachment.CATEGORY.equals(uri)) { throw new SAXException("Unhandled element " + localName + " in namespace: " + uri); } else { log.warn("Unhandled element " + localName + " in namespace: " + uri); } } }
From source file:org.apache.fop.render.rtf.RTFHandler.java
/** {@inheritDoc} */ public void startDocument() throws SAXException { // TODO sections should be created try {/* www . j av a 2 s.co m*/ rtfFile = new RtfFile(new OutputStreamWriter(os)); docArea = rtfFile.startDocumentArea(); } catch (IOException ioe) { // TODO could we throw Exception in all FOEventHandler events? throw new SAXException(ioe); } }
From source file:org.apache.fop.render.rtf.RTFHandler.java
/** {@inheritDoc} */ public void endDocument() throws SAXException { try {// w w w.j ava2 s .c om rtfFile.flush(); } catch (IOException ioe) { // TODO could we throw Exception in all FOEventHandler events? throw new SAXException(ioe); } }
From source file:org.apache.hadoop.gateway.services.topology.impl.DefaultTopologyService.java
private void redeployTopology(Topology topology) { File topologyFile = new File(topology.getUri()); try {//from w w w . j a v a 2 s .c om TopologyValidator tv = new TopologyValidator(topology); if (tv.validateTopology()) { throw new SAXException(tv.getErrorString()); } long start = System.currentTimeMillis(); long limit = 1000L; // One second. long elapsed = 1; while (elapsed <= limit) { try { long origTimestamp = topologyFile.lastModified(); long setTimestamp = Math.max(System.currentTimeMillis(), topologyFile.lastModified() + elapsed); if (topologyFile.setLastModified(setTimestamp)) { long newTimstamp = topologyFile.lastModified(); if (newTimstamp > origTimestamp) { break; } else { Thread.sleep(10); elapsed = System.currentTimeMillis() - start; continue; } } else { auditor.audit(Action.REDEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE); log.failedToRedeployTopology(topology.getName()); break; } } catch (InterruptedException e) { auditor.audit(Action.REDEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE); log.failedToRedeployTopology(topology.getName(), e); e.printStackTrace(); } } } catch (SAXException e) { auditor.audit(Action.REDEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE); log.failedToRedeployTopology(topology.getName(), e); } }
From source file:org.apache.hadoop.gateway.services.topology.impl.DefaultTopologyService.java
public void deployTopology(Topology t) { try {//from w w w . j av a 2 s . c o m File temp = new File(directory.getAbsolutePath() + "/" + t.getName() + ".xml.temp"); Package topologyPkg = Topology.class.getPackage(); String pkgName = topologyPkg.getName(); String bindingFile = pkgName.replace(".", "/") + "/topology_binding-xml.xml"; Map<String, Object> properties = new HashMap<>(1); properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, bindingFile); JAXBContext jc = JAXBContext.newInstance(pkgName, Topology.class.getClassLoader(), properties); Marshaller mr = jc.createMarshaller(); mr.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); mr.marshal(t, temp); File topology = new File(directory.getAbsolutePath() + "/" + t.getName() + ".xml"); if (!temp.renameTo(topology)) { FileUtils.forceDelete(temp); throw new IOException("Could not rename temp file"); } // This code will check if the topology is valid, and retrieve the errors if it is not. TopologyValidator validator = new TopologyValidator(topology.getAbsolutePath()); if (!validator.validateTopology()) { throw new SAXException(validator.getErrorString()); } } catch (JAXBException e) { auditor.audit(Action.DEPLOY, t.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE); log.failedToDeployTopology(t.getName(), e); } catch (IOException io) { auditor.audit(Action.DEPLOY, t.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE); log.failedToDeployTopology(t.getName(), io); } catch (SAXException sx) { auditor.audit(Action.DEPLOY, t.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE); log.failedToDeployTopology(t.getName(), sx); } reloadTopologies(); }
From source file:org.apache.hadoop.hdfs.server.namenode.FSEditLogOp.java
private static void appendXAttrsToXml(ContentHandler contentHandler, List<XAttr> xAttrs) throws SAXException { for (XAttr xAttr : xAttrs) { contentHandler.startElement("", "", "XATTR", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "NAMESPACE", xAttr.getNameSpace().toString()); XMLUtils.addSaxString(contentHandler, "NAME", xAttr.getName()); if (xAttr.getValue() != null) { try { XMLUtils.addSaxString(contentHandler, "VALUE", XAttrCodec.encodeValue(xAttr.getValue(), XAttrCodec.HEX)); } catch (IOException e) { throw new SAXException(e); }//from w ww . ja v a 2 s . co m } contentHandler.endElement("", "", "XATTR"); } }