throw new MagicParseException("unable to instantiate parser", e2); //$NON-NLS-1$ throw new MagicParseException("couldn't load '" + magicURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$ throw new MagicParseException("Parse error occurred: " + e); //$NON-NLS-1$
private String getMimeType(ExternalReferenceSPI externalReference, InvocationContext context) { if (!mimeTypes.containsKey(externalReference)) { InputStream inputStream = externalReference.openStream(context); try { byte[] bytes = new byte[64]; inputStream.read(bytes); mimeTypes.put(externalReference, Magic.getMagicMatch(bytes, true).getMimeType()); } catch (IOException e) { e.printStackTrace(); logger.debug("Failed to read from stream to determine mimetype", e); } catch (MagicParseException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } catch (MagicMatchNotFoundException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } catch (MagicException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } finally { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); logger.debug("Failed to close stream after determining mimetype", e); } } } return mimeTypes.get(externalReference); }
logger.debug("Failed to read from stream to determine mimetype", e); } catch (MagicParseException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } catch (MagicMatchNotFoundException e) {
parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME); } catch (Exception ee) { throw new MagicParseException("unable to instantiate parser"); throw new MagicParseException("couldn't load '" + magicURL + "'"); throw new MagicParseException("parse error occurred - " + e.getMessage());
logger.debug("Failed to read from stream to determine mimetype", e); } catch (MagicParseException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } catch (MagicMatchNotFoundException e) {
parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME); } catch (Exception ee) { throw new MagicParseException("unable to instantiate parser"); throw new MagicParseException("couldn't load '" + magicURL + "'"); throw new MagicParseException("parse error occurred - " + e.getMessage());
} catch (MagicParseException e1) { e1.printStackTrace(); } catch (MagicMatchNotFoundException e1) {
/** * return the parsed MagicMatch objects that were created from the magic.xml * definitions * * @return the parsed MagicMatch objects * * @throws MagicParseException DOCUMENT ME! */ public static Collection<MagicMatcher> getMatchers() throws MagicParseException { log.debug("getMatchers()"); if (!initialized) { initialize(); } Iterator<MagicMatcher> i = magicParser.getMatchers().iterator(); List<MagicMatcher> m = new ArrayList<MagicMatcher>(); while (i.hasNext()) { MagicMatcher matcher = (MagicMatcher) i.next(); try { m.add(matcher.clone()); } catch (CloneNotSupportedException e) { log.error("failed to clone matchers"); throw new MagicParseException("failed to clone matchers"); } } return m; }
/** * return the parsed MagicMatch objects that were created from the magic.xml * definitions * * @return the parsed MagicMatch objects * * @throws MagicParseException DOCUMENT ME! */ public static Collection getMatchers() throws MagicParseException { log.debug("getMatchers()"); if (!initialized) { initialize(); } Iterator i = magicParser.getMatchers().iterator(); ArrayList m = new ArrayList(); while (i.hasNext()) { MagicMatcher matcher = (MagicMatcher) i.next(); try { m.add(matcher.clone()); } catch (CloneNotSupportedException e) { log.error("failed to clone matchers"); throw new MagicParseException("failed to clone matchers"); } } return m; }