/** * DOCUMENT ME! * * @throws IOException DOCUMENT ME! */ public void unLockFeatures() throws IOException { locking().lockFeatures(); }
/** * Description ... * * @param lock * @throws UnsupportedOperationException DOCUMENT ME! * @see * org.vfny.geoserver.global.GeoServerFeatureStore#setFeatureLock(org.geotools.data.FeatureLock) */ public void setFeatureLock(FeatureLock lock) { if (source instanceof FeatureLocking) { ((FeatureLocking<SimpleFeatureType, SimpleFeature>) source).setFeatureLock(lock); } else { throw new UnsupportedOperationException("FeatureTypeConfig does not supports locking"); } }
/** * DOCUMENT ME! * * @param filter DOCUMENT ME! * @throws IOException DOCUMENT ME! */ public void unLockFeatures(Filter filter) throws IOException { filter = makeDefinitionFilter(filter); locking().unLockFeatures(filter); }
public void testUnLockFeatures() throws IOException { FeatureLock lock = FeatureLockFactory.generate("test", LOCK_DURATION); FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(tname("road")); road.setFeatureLock(lock); road.lockFeatures(); try { road.unLockFeatures(); fail("unlock should fail due on AUTO_COMMIT"); } catch (IOException expected) { } try (Transaction t = new DefaultTransaction()) { road.setTransaction(t); try { road.unLockFeatures(); fail("unlock should fail due lack of authorization"); } catch (IOException expected) { } t.addAuthorization(lock.getAuthorization()); road.unLockFeatures(); } }
public void testGetFeatureLockingExpire() throws Exception { FeatureLock lock = new FeatureLock("Timed", 500); @SuppressWarnings("unchecked") FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) data.getFeatureSource("road"); road.setFeatureLock(lock); assertFalse(isLocked("road", "road.rd1")); road.lockFeatures(rd1Filter); assertTrue(isLocked("road", "road.rd1")); long then = System.currentTimeMillis(); do { Thread.sleep(15); } while (then > System.currentTimeMillis() - 515); assertFalse(isLocked("road", "road.rd1")); }
public void setTransaction(Transaction transaction) { locking.setTransaction(transaction); }
public void removeFeatures(Filter filter) throws IOException { // this we can optimize, it's a matter of mass updating the last // revisions (and before that, we have to compute the modified envelope) Filter versionedFilter = (Filter) store.buildVersionedFilter(schema.getTypeName(), filter, new RevisionInfo()); Envelope bounds = locking .getBounds(new DefaultQuery(schema.getTypeName(), versionedFilter)); Transaction t = getTransaction(); boolean autoCommit = false; if (Transaction.AUTO_COMMIT.equals(t)) { t = new DefaultTransaction(); autoCommit = true; } VersionedJdbcTransactionState state = store.wrapped.getVersionedJdbcTransactionState(t); locking.modifyFeatures(locking.getSchema().getAttributeType("expired"), new Long(state .getRevision()), versionedFilter); if (autoCommit) { t.commit(); t.close(); } store.listenerManager.fireFeaturesRemoved(schema.getTypeName(), t, bounds, false); }
/** * A safe cast to SimpleFeatureLocking; that will introduce a wrapper if it has to. * * <p>Please keep the use of this class to a minimum; if you are expecting a * FeatureLocking<SimpleFeatureType,SimpleFeature> please make use of SimpleFeatureLocking if * you possibly can. * * @since 2.7 */ public static SimpleFeatureLocking simple(FeatureLocking locking) { if (locking instanceof SimpleFeatureLocking) { return (SimpleFeatureLocking) locking; } if (locking.getSchema() instanceof SimpleFeatureType) { return new SimpleFeatureLockingBridge(locking); } throw new IllegalArgumentException( "The provided feature store contains complex features, cannot be bridged to a simple one"); } //
public void testUnLockFeatures() throws IOException { FeatureLock lock = new FeatureLock("test", 3600); @SuppressWarnings("unchecked") FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) data.getFeatureSource("road"); road.setFeatureLock(lock); road.lockFeatures(); try { road.unLockFeatures(); fail("unlock should fail due on AUTO_COMMIT"); } catch (IOException expected) { } Transaction t = new DefaultTransaction(); road.setTransaction(t); try { road.unLockFeatures(); fail("unlock should fail due lack of authorization"); } catch (IOException expected) { } t.addAuthorization(lock.getAuthorization()); road.unLockFeatures(); t.close(); }
public void testGetFeatureLockingExpire() throws Exception { FeatureLock lock = FeatureLockFactory.generate("Timed", 1000); FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(tname("road")); road.setFeatureLock(lock); assertFalse(isLocked(tname("road"), tname("road") + "." + (td.initialFidValue))); road.lockFeatures(td.rd1Filter); assertTrue(isLocked(tname("road"), tname("road") + "." + (td.initialFidValue))); long then = System.currentTimeMillis(); do { Thread.sleep(1000); } while (System.currentTimeMillis() - then < 1000); assertFalse(isLocked(tname("road"), tname("road") + "." + (td.initialFidValue))); }
/** * A safe cast to SimpleFeatureLocking; that will introduce a wrapper if it has to. * <p> * Please keep the use of this class to a minimum; if you are expecting a * FeatureLocking<SimpleFeatureType,SimpleFeature> please make use of SimpleFeatureLocking if * you possibly can. * * @since 2.7 */ public static SimpleFeatureLocking simple(FeatureLocking locking) { if (locking instanceof SimpleFeatureLocking) { return (SimpleFeatureLocking) locking; } if (locking.getSchema() instanceof SimpleFeatureType) { return new SimpleFeatureLockingBridge(locking); } throw new IllegalArgumentException( "The provided feature store contains complex features, cannot be bridged to a simple one"); } //
(FeatureLocking<SimpleFeatureType, SimpleFeature>) data.getFeatureSource("road"); road1.setTransaction(t1); road2.setTransaction(t2); road1.setFeatureLock(lockA); road2.setFeatureLock(lockB); road1.lockFeatures(rd1Filter); assertTrue(isLocked("road", "road.rd1")); assertFalse(isLocked("road", "road.rd2")); assertFalse(isLocked("road", "road.rd3")); road2.lockFeatures(rd2Filter); assertTrue(isLocked("road", "road.rd1")); assertTrue(isLocked("road", "road.rd2")); road1.unLockFeatures(rd1Filter); fail("need authorization"); } catch (IOException expected) { road1.unLockFeatures(rd2Filter); fail("need correct authorization"); } catch (IOException expected) { road1.unLockFeatures(rd1Filter); assertFalse(isLocked("road", "road.rd1")); assertTrue(isLocked("road", "road.rd2")); road2.unLockFeatures(rd2Filter);
public void testLockFeatures() throws IOException { FeatureLock lock = FeatureLockFactory.generate("test", LOCK_DURATION); FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(tname("road")); road.setFeatureLock(lock); assertFalse(isLocked(tname("road"), tname("road") + ".1")); assertTrue(road.lockFeatures() > 0); assertTrue(isLocked(tname("road"), tname("road") + ".1")); }
/** * DOCUMENT ME! * * @return DOCUMENT ME! * @throws IOException DOCUMENT ME! */ public int lockFeatures() throws IOException { return locking().lockFeatures(); }
public void unLockFeatures(Query query) throws IOException { Query writeQuery = getWriteQuery(policy); Query mixed = mixQueries(query, writeQuery); final Filter writeFilter = writeQuery.getFilter(); if (writeFilter == Filter.EXCLUDE) { throw unsupportedOperation(); } else if (writeFilter == Filter.INCLUDE) { lockDelegate.unLockFeatures(query); } else { lockDelegate.unLockFeatures(mixed); } } }
public void setFeatureLock(FeatureLock lock) { Query writeQuery = getWriteQuery(policy); if (writeQuery.getFilter() == Filter.EXCLUDE) { throw unsupportedOperation(); } else { lockDelegate.setFeatureLock(lock); } }
public void testUnLockFeatures() throws IOException { FeatureLock lock = FeatureLockFactory.generate("test", 360000); FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) data.getFeatureSource("ROAD"); road.setFeatureLock(lock); road.lockFeatures(); try { road.unLockFeatures(); fail("unlock should fail due on AUTO_COMMIT"); } catch (IOException expected) { } Transaction t = new DefaultTransaction(); road.setTransaction(t); try { road.unLockFeatures(); fail("unlock should fail due lack of authorization"); } catch (IOException expected) { } t.addAuthorization(lock.getAuthorization()); road.unLockFeatures(); }
public void testLockFeatures() throws IOException { FeatureLock lock = FeatureLockFactory.generate("test", 3600); FeatureLocking<SimpleFeatureType, SimpleFeature> road = (FeatureLocking<SimpleFeatureType, SimpleFeature>) data.getFeatureSource("ROAD"); road.setFeatureLock(lock); assertFalse(isLocked("ROAD", roadFeatures[0].getID())); road.lockFeatures(); assertTrue(isLocked("ROAD", roadFeatures[0].getID())); }
public int lockFeatures(Filter filter) throws IOException { return lockDelegate.lockFeatures(new Query(null, filter)); }
public void unLockFeatures(Query query) throws IOException { delegate().unLockFeatures(query); } }