/** * Return the XMIHeader for the specified File or null if the file does not represent a MetaMatrix * model file. * * @param resource The file of a metamatrix model file. * @return The XMIHeader for the model file */ public static XMIHeader getXmiHeader(final File resource) { if (resource != null && resource.isFile() && resource.exists() && resource.canRead()) { // check cache if (CACHE != null) { XMIHeader header = CACHE.getCachedXmiHeader(resource); if (header != null) { return header; } } try { XMIHeader header = XMIHeaderReader.readHeader(resource); // add to cache if (CACHE != null) { CACHE.setXmiHeaderToCache(resource, header); } return header; } catch (TeiidException e) { LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage()); } catch (IllegalArgumentException iae) { // Swallowing this exception because we're doing all three checks that would produce it. // If this exception is caught, it's because the files really were closed/deleted in another // thread and this // thread didn't know about it. // Fixes Defect 22117 } } return null; }
/** * Return the XMIHeader for the specified inputstream of a model file. * * @param resourceStream The inputStream of a metamatrix model file. * @return The XMIHeader for the model file */ public static XMIHeader getXmiHeader(final InputStream resourceStream) { if (resourceStream != null) { try { return XMIHeaderReader.readHeader(resourceStream); } catch (TeiidException e) { LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage()); } } return null; }