@Override public void parse(InputStream inputStream, ContentHandler contentHandler, Metadata metadata, ParseContext parseContext) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE,geoInfoType); DataStore dataStore= null; DefaultMetadata defaultMetadata=null; XHTMLContentHandler xhtmlContentHandler=new XHTMLContentHandler(contentHandler,metadata); TemporaryResources tmp = TikaInputStream.isTikaInputStream(inputStream) ? null : new TemporaryResources(); try { TikaInputStream tikaInputStream = TikaInputStream.get(inputStream,tmp); File file= tikaInputStream.getFile(); dataStore = DataStores.open(file); defaultMetadata=new DefaultMetadata(dataStore.getMetadata()); if(defaultMetadata!=null) extract(xhtmlContentHandler, metadata, defaultMetadata); } catch (UnsupportedStorageException e) { throw new TikaException("UnsupportedStorageException",e); } catch (DataStoreException e) { throw new TikaException("DataStoreException", e); } finally { if (tmp != null) { tmp.dispose(); } } }
/** * If the given argument seems to be an authority code ("URN", "EPSG", "CRS", "AUTO", <i>etc.</i>), * delegates to {@link CRS#forCode(String)}. Otherwise reads the metadata using a datastore. * The input format is detected automatically (this is <strong>not</strong> {@link #outputFormat}). * * @return a {@link Metadata} or {@link CoordinateReferenceSystem} instance, or {@code null} if none. * @throws DataStoreException if an error occurred while reading the file. * @throws FactoryException if an error occurred while looking for a CRS identifier. */ final Object readMetadataOrCRS() throws DataStoreException, FactoryException { if (useStandardInput()) { try (DataStore store = DataStores.open(System.in)) { return store.getMetadata(); } } else if (hasUnexpectedFileCount(1, 1)) { hasUnexpectedFileCount = true; return null; } else { final String file = files.get(0); if (CodeType.guess(file).isCRS) { return CRS.forCode(file); } else { try (DataStore store = DataStores.open(file)) { return store.getMetadata(); } } } }
/** * Tests {@link DataStores#open(Object)}. * * @throws DataStoreException Should never happen. */ @Test public void testOpen() throws DataStoreException { final DataStore store = DataStores.open(new StringReader(StoreTest.XML)); assertFalse(store.getMetadata().getContacts().isEmpty()); } }
final Metadata metadata = getMetadata(); if (metadata != null) { Citation citation = null;
final Metadata metadata; try (DataStore store = DataStores.open(identifier)) { metadata = store.getMetadata();
@Override public void parse(InputStream inputStream, ContentHandler contentHandler, Metadata metadata, ParseContext parseContext) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE,geoInfoType); DataStore dataStore= null; DefaultMetadata defaultMetadata=null; XHTMLContentHandler xhtmlContentHandler=new XHTMLContentHandler(contentHandler,metadata); TemporaryResources tmp = TikaInputStream.isTikaInputStream(inputStream) ? null : new TemporaryResources(); try { TikaInputStream tikaInputStream = TikaInputStream.get(inputStream,tmp); File file= tikaInputStream.getFile(); dataStore = DataStores.open(file); defaultMetadata=new DefaultMetadata(dataStore.getMetadata()); if(defaultMetadata!=null) extract(xhtmlContentHandler, metadata, defaultMetadata); } catch (UnsupportedStorageException e) { throw new TikaException("UnsupportedStorageException",e); } catch (DataStoreException e) { throw new TikaException("DataStoreException", e); } finally { if (tmp != null) { tmp.dispose(); } } }
@Override public void parse(InputStream inputStream, ContentHandler contentHandler, Metadata metadata, ParseContext parseContext) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE,geoInfoType); DataStore dataStore= null; DefaultMetadata defaultMetadata=null; XHTMLContentHandler xhtmlContentHandler=new XHTMLContentHandler(contentHandler,metadata); TemporaryResources tmp = TikaInputStream.isTikaInputStream(inputStream) ? null : new TemporaryResources(); try { TikaInputStream tikaInputStream = TikaInputStream.get(inputStream,tmp); File file= tikaInputStream.getFile(); dataStore = DataStores.open(file); defaultMetadata=new DefaultMetadata(dataStore.getMetadata()); if(defaultMetadata!=null) extract(xhtmlContentHandler, metadata, defaultMetadata); } catch (UnsupportedStorageException e) { throw new TikaException("UnsupportedStorageException",e); } catch (DataStoreException e) { throw new TikaException("DataStoreException",e); } finally { if (tmp != null) { tmp.dispose(); } } }