List of usage examples for org.xml.sax ErrorHandler ErrorHandler
ErrorHandler
From source file:XmlUtils.java
public static void createIgnoreErrorHandler(SAXReader reader) { reader.setValidation(false);//from www .ja v a 2s . c o m reader.setErrorHandler(new ErrorHandler() { public void warning(SAXParseException exception) throws SAXException { //System.out.println(exception); } public void error(SAXParseException exception) throws SAXException { //System.out.println(exception); } public void fatalError(SAXParseException exception) throws SAXException { //System.out.println(exception); } }); }
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.util.QCliveXMLSchemaValidator.java
protected Boolean validateSchema(final List<Source> schemaSourceList, final Document document, final File xmlFile, final QcContext context) throws SAXException, IOException { final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // instantiate the schema Schema schema = factory.newSchema(schemaSourceList.toArray(new Source[] {})); // now validate the file against the schema // note: supposedly there is a way to just let the XML document figure // out its own schema based on what is referred to, but // I could not get that to work, which is why I am looking for the // schema in the attribute final DOMSource source = new DOMSource(document); final Validator validator = schema.newValidator(); // wow this looks dumb, but isValid has to be final to be accessed from // within an inner class // and this was IDEA's solution to the problem: make it an array and set // the first element of the array final boolean[] isValid = new boolean[] { true }; // add error handler that will add validation errors and warnings // directly to the QcContext object validator.setErrorHandler(new ErrorHandler() { public void warning(final SAXParseException exception) { context.addWarning(new StringBuilder().append(xmlFile.getName()).append(": ") .append(exception.getMessage()).toString()); }// w w w.ja va 2 s . c o m public void error(final SAXParseException exception) { context.addError(MessageFormat.format(MessagePropertyType.XML_FILE_PROCESSING_ERROR, xmlFile.getName(), new StringBuilder().append(xmlFile.getName()).append(": ") .append(exception.getMessage()).toString())); isValid[0] = false; } public void fatalError(final SAXParseException exception) throws SAXException { context.getArchive().setDeployStatus(Archive.STATUS_INVALID); throw exception; } }); validator.validate(source); return isValid[0]; }
From source file:de.hsos.ecs.richwps.wpsmonitor.communication.wpsclient.simple.SimpleWpsClient.java
private DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(true); DocumentBuilder newDocumentBuilder = docBuilderFactory.newDocumentBuilder(); // Configure error handler newDocumentBuilder.setErrorHandler(new ErrorHandler() { @Override/*from w ww . jav a 2 s .c om*/ public void error(SAXParseException saxpe) throws SAXException { LOG.warn(saxpe); } @Override public void fatalError(SAXParseException saxpe) throws SAXException { LOG.warn(saxpe); } @Override public void warning(SAXParseException saxpe) throws SAXException { LOG.warn(saxpe); } }); return newDocumentBuilder; }
From source file:module.signature.util.XAdESValidator.java
/** * @author joantune//from w w w. jav a 2 s . c o m * * Makes sure that the document which was signed is equal to the one * that was sent. It also checks to see if the signers are the * correct persons or not NOTE: It does note validate the validity * of the signature itself, only that what was sent was the same * that was receveived. * * To validate, see: * * @see XAdESValidator#validateXMLSignature(byte[]) * @param receivedContent * the received signature * @param originalContent * the byte array of what was sent to the signer * @param usersPermitted * Users that are permitted to be on the signature * @param usersExcluded * Users which must not be on the list of signers, or null/empty * list if none is excluded * @param allUsersPermittedShouldBeThere * if true, all of the users of <i>usersPermitted</i> must be on * the list of signers * @throws SignatureDataException * if any error has been observed, thus the validation fails */ public static void validateSentAndReceivedContent(String receivedContent, byte[] originalContent, Set<User> usersPermitted, Set<User> usersExcluded, boolean allUsersPermittedShouldBeThere) throws SignatureDataException { //let's validate the content. That is, what we received against what we sent and make sure it hasn't changed if (schemaXSD == null) { loadXAdESSchemas(); } //we know that we are receiving a XaDES-T signature boolean validSignature = false; try { //let's extract the signatureContent and compare it against what we sent //let's decode and interpret the XML file //making the objects to interpret the XML document DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder parser = dbf.newDocumentBuilder(); ErrorHandler eh = new ErrorHandler() { @Override public void warning(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } @Override public void error(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } @Override public void fatalError(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } }; //let's decode the document byte[] signatureDecoded = Base64.decode(receivedContent); ByteArrayInputStream bais = new ByteArrayInputStream(signatureDecoded); // let's parse the document parser.setErrorHandler(eh); Document document = parser.parse(bais); NodeList fileContentNodeList = document.getElementsByTagName("FileContent"); //Even if we have more than one signature, we should only have one file content!! if not, let's throw an exception here if (fileContentNodeList.getLength() > 1) { throw new SignatureDataException("too.many.file.content.nodes.malformed.signature.document", true, null); } if (fileContentNodeList.getLength() < 1) { throw new SignatureDataException("no.file.content.nodes.in.received.signature", true, null); } Node fileContentNode = fileContentNodeList.item(0).getFirstChild(); //now finally, we can compare the content of this node with the one that we generated //debug lines: byte[] receivedDecodedByteContent = Base64.decode(fileContentNode.getNodeValue()); //ok, so let's parse this again to strings and then we can better compare them and maybe know exactly why they are different String originalEncodedContent = Base64.encodeBytes(originalContent); String originalDecodedContent = new String(Base64.decode(originalEncodedContent), Charset.forName("UTF-8")); String receivedDecodedContent = new String(receivedDecodedByteContent, Charset.forName("UTF-8")); //now let's //make sure the signature is from the right person //TODO uncomment the following line: // validateSigner(document, usersPermitted, usersExcluded, allUsersPermittedShouldBeThere); if (!StringUtils.equals(StringUtils.trimToEmpty(originalDecodedContent), StringUtils.trimToEmpty(receivedDecodedContent))) { // } throw new SignatureDataException("signature.content.sent.and.received.are.different"); } else { validSignature = true; } //TODO FENIX-196 assert if one should be notified of these errors } catch (IOException e1) { // e1.printStackTrace(); throw new SignatureDataException("error.decoding.base64.sig", e1); } catch (SAXException e) { // e.printStackTrace(); throw new SignatureDataException("error.parsing.received.signature.file", e); } catch (ParserConfigurationException e) { // e.printStackTrace(); throw new SignatureDataException("error.parsing.received.signature.file.parser.configuration", e); } if (!validSignature) { throw new SignatureDataException("invalid.signature.content"); } }
From source file:jp.ikedam.jenkins.plugins.viewcopy_builder.ViewcopyBuilder.java
/** * Returns the configuration XML document of a view * //from w w w. j a v a 2 s .co m * @param view * @param logger * @return * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ private Document getViewConfigXmlDocument(View view, final PrintStream logger) throws IOException, SAXException, ParserConfigurationException { XStream2 xStream2 = new XStream2(new DomDriver("UTF-8")); xStream2.omitField(View.class, "owner"); xStream2.omitField(View.class, "name"); // this field causes disaster when overwriting. PipedOutputStream sout = new PipedOutputStream(); PipedInputStream sin = new PipedInputStream(sout); xStream2.toXML(view, sout); sout.close(); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = domFactory.newDocumentBuilder(); builder.setErrorHandler(new ErrorHandler() { @Override public void warning(SAXParseException exception) throws SAXException { exception.printStackTrace(logger); } @Override public void error(SAXParseException exception) throws SAXException { exception.printStackTrace(logger); } @Override public void fatalError(SAXParseException exception) throws SAXException { exception.printStackTrace(logger); } }); return builder.parse(sin); }
From source file:com.meidusa.amoeba.context.ProxyRuntimeContext.java
private ProxyServerConfig loadConfig(String configFileName) { DocumentBuilder db;// w w w . ja va2 s . com try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); dbf.setNamespaceAware(false); db = dbf.newDocumentBuilder(); db.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) { if (systemId.endsWith("amoeba.dtd")) { InputStream in = ProxyRuntimeContext.class .getResourceAsStream("/com/meidusa/amoeba/xml/amoeba.dtd"); if (in == null) { LogLog.error("Could not find [amoeba.dtd]. Used [" + ProxyRuntimeContext.class.getClassLoader() + "] class loader in the search."); return null; } else { return new InputSource(in); } } else { return null; } } }); db.setErrorHandler(new ErrorHandler() { public void warning(SAXParseException exception) { } public void error(SAXParseException exception) throws SAXException { logger.error(exception.getMessage() + " at (" + exception.getLineNumber() + ":" + exception.getColumnNumber() + ")"); throw exception; } public void fatalError(SAXParseException exception) throws SAXException { logger.fatal(exception.getMessage() + " at (" + exception.getLineNumber() + ":" + exception.getColumnNumber() + ")"); throw exception; } }); return loadConfigurationFile(configFileName, db); } catch (Exception e) { logger.fatal("Could not load configuration file, failing", e); throw new ConfigurationException("Error loading configuration file " + configFileName, e); } }
From source file:module.signature.util.XAdESValidator.java
/** * @author joao.antunes@tagus.ist.utl.pt adapted it from {@link #validateXMLSignature(String)} * @param streamWithSignature// ww w. j a v a2 s. co m * the {@link InputStream} that has the signature content * @return true if it's valid, false otherwise */ public boolean validateXMLSignature(InputStream streamWithSignature) { try { // get the xsd schema Validator validator = schemaXSD.newValidator(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder parser = dbf.newDocumentBuilder(); ErrorHandler eh = new ErrorHandler() { @Override public void warning(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } @Override public void error(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } @Override public void fatalError(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } }; // parse the document parser.setErrorHandler(eh); Document document = parser.parse(streamWithSignature); // XAdES extension NodeList nlObject = document.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#", "Object"); // XMLDSIG NodeList nlSignature = document.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#", "Signature"); if (checkSchema) { if (nlObject.getLength() < 1) { return false; } if (nlSignature.getLength() < 1) { return false; } // parse the XML DOM tree againts the XSD schema validator.validate(new DOMSource(nlSignature.item(0))); } if (checkSignature) { // Validate Every Signature Element (including CounterSignatures) for (int i = 0; i < nlSignature.getLength(); i++) { Element signature = (Element) nlSignature.item(i); // String baseURI = fileToValidate.toURL().toString(); XMLSignature xmlSig = new XMLSignature(signature, null); KeyInfo ki = xmlSig.getKeyInfo(); // If signature contains X509Data if (ki.containsX509Data()) { NodeList nlSigningTime = signature.getElementsByTagNameNS(xadesNS, "SigningTime"); Date signingDate = null; if (nlSigningTime.item(0) != null) { StringBuilder xmlDate = new StringBuilder(nlSigningTime.item(0).getTextContent()) .deleteCharAt(22); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); signingDate = simpleDateFormat.parse(xmlDate.toString()); } //verificao OCSP //TODO FENIX-189 joantune: na realidade acho que isto no verifica mesmo a revocao.. a no ser que a keystore indicada seja actualizada regularmente. if (checkRevocation) { //keystore certs cc, raiz estado Security.setProperty("ocsp.enable", "true"); //System.setProperty("com.sun.security.enableCRLDP", "true"); CertificateFactory cf = CertificateFactory.getInstance("X.509"); CertPath certPath = cf .generateCertPath(Collections.singletonList(ki.getX509Certificate())); // TrustAnchor trustA = new TrustAnchor(ki.getX509Certificate(), null); // Set trustAnchors = Collections.singleton(trustA); PKIXParameters params = new PKIXParameters(cartaoCidadaoKeyStore); params.setRevocationEnabled(true); // validar o estado na data da assinatura if (nlSigningTime.item(0) != null) { params.setDate(signingDate); } try { CertPathValidator cpValidator = CertPathValidator.getInstance("PKIX"); CertPathValidatorResult result = cpValidator.validate(certPath, params); //TODO FENIX-196 probably one would want to send a notification here } catch (CertPathValidatorException ex) { return false; } catch (InvalidAlgorithmParameterException ex) { return false; } } // verifica a validade do certificado no momento da assinatura if (checkValidity) { if (nlSigningTime.item(0) != null) { // continue if there is no SigningTime, if CounterSignature isn't XAdES try { ki.getX509Certificate().checkValidity(signingDate); } catch (CertificateExpiredException ex) { return false; } catch (CertificateNotYetValidException ex) { return false; } } } // validate against Certificate Public Key boolean validSignature = xmlSig.checkSignatureValue(ki.getX509Certificate().getPublicKey()); if (!validSignature) { return false; } } // if signature includes KeyInfo KeyValue, also check against it if (ki.containsKeyValue()) { boolean validSignature = xmlSig.checkSignatureValue(ki.getPublicKey()); if (!validSignature) { return false; } } //let's check the SignatureTimeStamp(s) joantune NodeList signatureTimeStamps = signature.getElementsByTagNameNS("*", "SignatureTimeStamp"); Element signatureValue = null; if (signatureTimeStamps.getLength() > 0) { signatureValue = (Element) signature.getElementsByTagNameNS("*", "SignatureValue").item(0); } for (int j = 0; j < signatureTimeStamps.getLength(); j++) { logger.debug("Found a SignatureTimeStamp"); Element signatureTimeStamp = (Element) signatureTimeStamps.item(j); //for now we are ignoring the XMLTimeStamp element, let's iterate through all of the EncapsulatedTimeStamp that we find NodeList encapsulatedTimeStamps = signatureTimeStamp.getElementsByTagNameNS("*", "EncapsulatedTimeStamp"); for (int k = 0; k < encapsulatedTimeStamps.getLength(); k++) { logger.debug("Found an EncapsulatedTimeStamp"); Element encapsulatedTimeStamp = (Element) encapsulatedTimeStamps.item(k); //let's check it // note, we have the timestamptoken, not the whole response, that is, we don't have the status field ASN1Sequence signedTimeStampToken = ASN1Sequence .getInstance(Base64.decode(encapsulatedTimeStamp.getTextContent())); CMSSignedData cmsSignedData = new CMSSignedData( Base64.decode(encapsulatedTimeStamp.getTextContent())); TimeStampToken timeStampToken = new TimeStampToken(cmsSignedData); //let's construct the Request to make sure this is a valid response //let's generate the digest MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] digest = sha1.digest(signatureValue.getTextContent().getBytes("UTF-8")); //let's make sure the digests are the same if (!Arrays.equals(digest, timeStampToken.getTimeStampInfo().getMessageImprintDigest())) { //TODO probably want to send an e-mail if this happens, as it's clearly a sign of tampering //FENIX-196 logger.debug("Found a different digest in the timestamp!"); return false; } try { //TODO for now we won't use the provided certificates that came with the TST // X509Store certificateStore = (X509Store) timeStampToken.getCertificates(); // JcaDigestCalculatorProviderBuilder builder = new JcaDigestCalculatorProviderBuilder(); // timeStampToken.validate(tsaCert, "BC"); // timeStampToken.validate(new SignerInformationVerifier(new JcaContentVerifierProviderBuilder() // .build(tsaCert), builder.build())); timeStampToken.validate(new SignerInformationVerifier( new JcaContentVerifierProviderBuilder().build(tsaCert), new BcDigestCalculatorProvider())); //let's just verify that the timestamp was done in the past :) - let's give a tolerance of 5 mins :) Date currentDatePlus5Minutes = new Date(); //let's make it go 5 minutes ahead currentDatePlus5Minutes.setMinutes(currentDatePlus5Minutes.getMinutes() + 5); if (!timeStampToken.getTimeStampInfo().getGenTime() .before(currentDatePlus5Minutes)) { //FENIX-196 probably we want to log this! //what the heck, timestamp is done in the future!! (clocks might be out of sync) logger.warn("Found a timestamp in the future!"); return false; } logger.debug("Found a valid TimeStamp!"); //as we have no other timestamp elements in this signature, this means all is ok! :) //(point 5) of g.2.2.16.1.3 on the specs } catch (TSPException exception) { logger.debug("TimeStamp response did not validate", exception); return false; } } } } } } catch (IOException ex) { Logger.getLogger(XAdESValidator.class.getName()).log(Level.SEVERE, null, ex); return false; } catch (ParserConfigurationException ex) { Logger.getLogger(XAdESValidator.class.getName()).log(Level.SEVERE, null, ex); return false; } catch (SAXException ex) { Logger.getLogger(XAdESValidator.class.getName()).log(Level.SEVERE, null, ex); return false; } catch (Exception ex) { Logger.getLogger(XAdESValidator.class.getName()).log(Level.SEVERE, null, ex); return false; } return true; }
From source file:de.uzk.hki.da.sb.Cli.java
/** * Copies the files listed in a SIP list to a single directory * //from ww w . j av a 2 s .c o m * @param fileListFile The SIP list file * @return The path to the directory containing the files */ private String copySipListContentToFolder(File sipListFile) { CliProgressManager progressManager = new CliProgressManager(); String tempFolderName = getTempFolderName(); XMLReader xmlReader = null; SAXParserFactory spf = SAXParserFactory.newInstance(); try { xmlReader = spf.newSAXParser().getXMLReader(); } catch (Exception e) { logger.log("ERROR: Failed to create SAX parser", e); System.out.println("Fehler beim Einlesen der SIP-Liste: SAX-Parser konnte nicht erstellt werden."); return ""; } xmlReader.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException e) throws SAXException { throw new SAXException("Beim Einlesen der SIP-Liste ist ein Fehler aufgetreten.", e); } @Override public void fatalError(SAXParseException e) throws SAXException { throw new SAXException("Beim Einlesen der SIP-Liste ist ein schwerer Fehler aufgetreten.", e); } @Override public void warning(SAXParseException e) throws SAXException { logger.log("WARNING: Warning while parsing siplist", e); System.out.println("\nWarnung:\n" + e.getMessage()); } }); InputStream inputStream; try { inputStream = new FileInputStream(sipListFile); Reader reader = new InputStreamReader(inputStream, "UTF-8"); Builder parser = new Builder(xmlReader); Document doc = parser.build(reader); reader.close(); Element root = doc.getRootElement(); Elements sipElements = root.getChildElements("sip"); long files = 0; for (int i = 0; i < sipElements.size(); i++) { Elements fileElements = sipElements.get(i).getChildElements("file"); if (fileElements != null) files += fileElements.size(); } progressManager.setTotalSize(files); for (int i = 0; i < sipElements.size(); i++) { Element sipElement = sipElements.get(i); String sipName = sipElement.getAttributeValue("name"); File tempDirectory = new File(tempFolderName + File.separator + sipName); if (tempDirectory.exists()) { FileUtils.deleteQuietly(new File(tempFolderName)); System.out.println("\nDie SIP-Liste enthlt mehrere SIPs mit dem Namen " + sipName + ". " + "Bitte vergeben Sie fr jedes SIP einen eigenen Namen."); return ""; } tempDirectory.mkdirs(); Elements fileElements = sipElement.getChildElements("file"); for (int j = 0; j < fileElements.size(); j++) { Element fileElement = fileElements.get(j); String filepath = fileElement.getValue(); File file = new File(filepath); if (!file.exists()) { logger.log("ERROR: File " + file.getAbsolutePath() + " is referenced in siplist, " + "but does not exist"); System.out.println("\nDie in der SIP-Liste angegebene Datei " + file.getAbsolutePath() + " existiert nicht."); FileUtils.deleteQuietly(new File(tempFolderName)); return ""; } try { if (file.isDirectory()) FileUtils.copyDirectoryToDirectory(file, tempDirectory); else FileUtils.copyFileToDirectory(file, tempDirectory); progressManager.copyFilesFromListProgress(); } catch (IOException e) { logger.log("ERROR: Failed to copy file " + file.getAbsolutePath() + " to folder " + tempDirectory.getAbsolutePath(), e); System.out.println("\nDie in der SIP-Liste angegebene Datei " + file.getAbsolutePath() + " konnte nicht kopiert werden."); FileUtils.deleteQuietly(new File(tempFolderName)); return ""; } } } } catch (Exception e) { logger.log("ERROR: Failed to read siplist " + sipListFile.getAbsolutePath(), e); System.out.println("\nBeim Lesen der SIP-Liste ist ein Fehler aufgetreten. "); return ""; } return (new File(tempFolderName).getAbsolutePath()); }
From source file:de.uzk.hki.da.cli.Cli.java
/** * Copies the files listed in a SIP list to a single directory * /*from w w w. ja va 2 s. c o m*/ * @param fileListFile The SIP list file * @return The path to the directory containing the files */ private String copySipListContentToFolder(File sipListFile) { CliProgressManager progressManager = new CliProgressManager(); String tempFolderName = getTempFolderName(); XMLReader xmlReader = null; SAXParserFactory spf = SAXParserFactory.newInstance(); try { xmlReader = spf.newSAXParser().getXMLReader(); } catch (Exception e) { logger.error("Failed to create SAX parser", e); System.out.println("Fehler beim Einlesen der SIP-Liste: SAX-Parser konnte nicht erstellt werden."); return ""; } xmlReader.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException e) throws SAXException { throw new SAXException("Beim Einlesen der SIP-Liste ist ein Fehler aufgetreten.", e); } @Override public void fatalError(SAXParseException e) throws SAXException { throw new SAXException("Beim Einlesen der SIP-Liste ist ein schwerer Fehler aufgetreten.", e); } @Override public void warning(SAXParseException e) throws SAXException { logger.warn("Warning while parsing siplist", e); System.out.println("\nWarnung:\n" + e.getMessage()); } }); InputStream inputStream; try { inputStream = new FileInputStream(sipListFile); Reader reader = new InputStreamReader(inputStream, "UTF-8"); Builder parser = new Builder(xmlReader); Document doc = parser.build(reader); reader.close(); Element root = doc.getRootElement(); Elements sipElements = root.getChildElements("sip"); long files = 0; for (int i = 0; i < sipElements.size(); i++) { Elements fileElements = sipElements.get(i).getChildElements("file"); if (fileElements != null) files += fileElements.size(); } progressManager.setTotalSize(files); for (int i = 0; i < sipElements.size(); i++) { Element sipElement = sipElements.get(i); String sipName = sipElement.getAttributeValue("name"); File tempDirectory = new File(tempFolderName + File.separator + sipName); if (tempDirectory.exists()) { FolderUtils.deleteQuietlySafe(new File(tempFolderName)); System.out.println("\nDie SIP-Liste enthlt mehrere SIPs mit dem Namen " + sipName + ". " + "Bitte vergeben Sie fr jedes SIP einen eigenen Namen."); return ""; } tempDirectory.mkdirs(); Elements fileElements = sipElement.getChildElements("file"); for (int j = 0; j < fileElements.size(); j++) { Element fileElement = fileElements.get(j); String filepath = fileElement.getValue(); File file = new File(filepath); if (!file.exists()) { logger.error("File " + file.getAbsolutePath() + " is referenced in siplist, " + "but does not exist"); System.out.println("\nDie in der SIP-Liste angegebene Datei " + file.getAbsolutePath() + " existiert nicht."); FolderUtils.deleteQuietlySafe(new File(tempFolderName)); return ""; } try { if (file.isDirectory()) FileUtils.copyDirectoryToDirectory(file, tempDirectory); else FileUtils.copyFileToDirectory(file, tempDirectory); progressManager.copyFilesFromListProgress(); } catch (IOException e) { logger.error("Failed to copy file " + file.getAbsolutePath() + " to folder " + tempDirectory.getAbsolutePath(), e); System.out.println("\nDie in der SIP-Liste angegebene Datei " + file.getAbsolutePath() + " konnte nicht kopiert werden."); FolderUtils.deleteQuietlySafe(new File(tempFolderName)); return ""; } } } } catch (Exception e) { logger.error("Failed to read siplist " + sipListFile.getAbsolutePath(), e); System.out.println("\nBeim Lesen der SIP-Liste ist ein Fehler aufgetreten. "); return ""; } return (new File(tempFolderName).getAbsolutePath()); }
From source file:it.cnr.icar.eric.server.profile.ws.wsdl.cataloger.WSDLCatalogerEngine.java
private Document parseXML(InputSource source) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); builderFactory.setValidating(false); DocumentBuilder builder = builderFactory.newDocumentBuilder(); builder.setErrorHandler(new ErrorHandler() { public void error(SAXParseException e) throws SAXParseException { throw e; }/* www. ja v a 2 s . co m*/ public void fatalError(SAXParseException e) throws SAXParseException { throw e; } public void warning(SAXParseException err) throws SAXParseException { // do nothing } }); return builder.parse(source); }