public DirectoryDataStore(File directory, FileStoreFactory dialect) throws IOException { cache = new DirectoryTypeCache(directory, dialect); }
public void dispose() { cache.dispose(); }
/** * Returns the native store for a specified type name * * @param typeName * @return * @throws IOException */ public DataStore getDataStore(String typeName) throws IOException { // grab the store for a specific feature type, making sure it's actually there DataStore store = cache.getDataStore(typeName, true); if (store == null) throw new IOException("Feature type " + typeName + " is unknown"); return store; }
public boolean exists(String authID) { List<DataStore> stores = cache.getDataStores(); for (DataStore store : stores) { if ((store.getLockingManager() != null) && store.getLockingManager().exists(authID)) { return true; } } return false; }
/** * Returns all the type names known * * @return */ Set<String> getTypeNames() throws IOException { lock.readLock().lock(); try { updateCache(); return ftCache.keySet(); } finally { lock.readLock().unlock(); } }
/** * Checks if the feature type cache contents needs updating, does so in case. The code assumes * the caller already owns a read only lock that needs upgrading in case the information is * stale. */ private void updateCache() throws IOException { if (watcher.isStale()) { // upgrade lock so that we have exclusive access to ftCache lock.readLock().unlock(); lock.writeLock().lock(); try { // still stale? if (watcher.isStale()) { watcher.mark(); refreshCacheContents(); } } finally { // downgrade lock lock.readLock().lock(); lock.writeLock().unlock(); } } }
public String[] getTypeNames() throws IOException { Set<String> typeNames = cache.getTypeNames(); return typeNames.toArray(new String[typeNames.size()]); }
List<FactoryAdapter> factories = lookupFileDataStores(); LOGGER.log(Level.FINE, "Found the following file capable factories: {0}", factories);
public boolean release(String authID, Transaction transaction) throws IOException { List<DataStore> stores = cache.getDataStores(); for (DataStore store : stores) { if ((store.getLockingManager() != null) && store.getLockingManager().exists(authID)) { return store.getLockingManager().release(authID, transaction); } } return false; }
/** * Returns the data store containing a specific feature type, or null if not found * * @param typeName * @param forceUpdate If true, it will force the update * @return */ DataStore getDataStore(String typeName, boolean forceUpdate) throws IOException { lock.readLock().lock(); try { if (forceUpdate) updateCache(); // TODO: check about re-creating the datastore when the cache // is turned into a soft map FileEntry fileEntry = ftCache.get(typeName); if (fileEntry == null) { throw new IOException("Not available: " + typeName); } return fileEntry.getStore(true); } finally { lock.readLock().unlock(); } }
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName() + ".shp"); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("url", URLs.fileToUrl(f)); params.put("filetype", "shapefile"); DataStore ds = null; try { ds = DataStoreFinder.getDataStore(params); if (ds != null) { ds.createSchema(featureType); ds.dispose(); cache.refreshCacheContents(); } } catch (Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } if (ds == null) { throw new IOException("Could not find the shapefile data store in the classpath"); } }
public String[] getTypeNames() throws IOException { Set<String> typeNames = cache.getTypeNames(); return typeNames.toArray(new String[typeNames.size()]); }
public void lockFeatureID( String typeName, String authID, Transaction transaction, FeatureLock featureLock) throws IOException { DataStore store = cache.getDataStore(typeName, false); if ((store != null) && (store.getLockingManager() != null)) { store.getLockingManager().lockFeatureID(typeName, authID, transaction, featureLock); } } }
public boolean refresh(String authID, Transaction transaction) throws IOException { List<DataStore> stores = cache.getDataStores(); for (DataStore store : stores) { if ((store.getLockingManager() != null) && store.getLockingManager().exists(authID)) { return store.getLockingManager().refresh(authID, transaction); } } return false; }
/** * Returns all the type names known * @return */ Set<String> getTypeNames() throws IOException { lock.readLock().lock(); try { updateCache(); return ftCache.keySet(); } finally { lock.readLock().unlock(); } }
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName()+".shp"); String shpDataStoreClassName = "org.geotools.data.shapefile.ShapefileDataStore"; DataStore ds = null; try { ds = (DataStore) Class.forName(shpDataStoreClassName).getConstructor(URL.class) .newInstance(f.toURL()); ds.createSchema(featureType); cache.refreshCacheContents(); } catch(Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } }
public void dispose() { cache.dispose(); }
public String[] getTypeNames() throws IOException { Set<String> typeNames = cache.getTypeNames(); return typeNames.toArray(new String[typeNames.size()]); }
public DirectoryDataStore(File directory, FileStoreFactory dialect) throws IOException { cache = new DirectoryTypeCache(directory, dialect); }
public void unLockFeatureID( String typeName, String authID, Transaction transaction, FeatureLock featureLock) throws IOException { DataStore store = cache.getDataStore(typeName, false); if ((store != null) && (store.getLockingManager() != null)) { store.getLockingManager().unLockFeatureID(typeName, authID, transaction, featureLock); } }