public void closeTransaction() { transaction.close(); }
protected void finalize() throws Throwable { if (stateLookup != null) { LOGGER.severe( "There's code leaving transaction unclosed. " + "Call Transaction.close() after using them to ensure they do not hold state " + "such as JDBC connections or file handles"); LOGGER.severe("Unclosed transaction handle is '" + handle + "'"); close(); } super.finalize(); } }
public void purge(Filter filter) throws IOException { DefaultTransaction transaction = null; try { transaction = new DefaultTransaction("CleanupTransaction" + System.nanoTime()); for (String typeName : typeNames) { removeGranules(typeName, filter, transaction); } transaction.commit(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Rollback"); } if (transaction != null) { transaction.rollback(); } throw new IOException(e); } finally { try { if (transaction != null) { transaction.close(); } } catch (Throwable t) { } } } }
try { if (transaction != null) { transaction.close();
protected void finalize() throws Throwable { if (stateLookup != null) { LOGGER.severe("There's code leaving transaction unclosed. " + "Call Transaction.close() after using them to ensure they do not hold state " + "such as JDCB connections or file handles"); LOGGER.severe("Unclosed transaction handle is '" + handle + "'"); close(); } super.finalize(); } }
protected void finalize() throws Throwable { if (stateLookup != null) { LOGGER.severe("There's code leaving transaction unclosed. " + "Call Transaction.close() after using them to ensure they do not hold state " + "such as JDCB connections or file handles"); LOGGER.severe("Unclosed transaction handle is '" + handle + "'"); close(); } super.finalize(); } }
public void purge(Filter filter) throws IOException { DefaultTransaction transaction = null; try { transaction = new DefaultTransaction("CleanupTransaction" + System.nanoTime()); for (String typeName : typeNames) { removeGranules(typeName, filter, transaction); } transaction.commit(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Rollback"); } if (transaction != null) { transaction.rollback(); } throw new IOException(e); } finally { try { if (transaction != null) { transaction.close(); } } catch (Throwable t) { } } } }
} finally { try { transaction.close(); } catch (Exception e) { final String message = "Unable to close indexing" + e.getLocalizedMessage();
static void write(List<SimpleFeature> features, File file) throws IOException { String basename = file.getName(); if (basename.endsWith(FILE_EXTENSION_SHAPEFILE)) { basename = basename.substring(0, basename.length() - 4); } File shapefile = new File(file.getParentFile(), basename + FILE_EXTENSION_SHAPEFILE); ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory(); Map map = Collections.singletonMap("url", shapefile.toURI().toURL()); DataStore dataStore = factory.createNewDataStore(map); SimpleFeature simpleFeature = features.get(0); SimpleFeatureType simpleFeatureType = simpleFeature.getType(); final String typeName = simpleFeatureType.getName().getLocalPart(); dataStore.createSchema(simpleFeatureType); FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(typeName); DefaultTransaction transaction = new DefaultTransaction("X"); featureStore.setTransaction(transaction); final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = DataUtilities.collection(features); featureStore.addFeatures(featureCollection); try { transaction.commit(); } catch (Exception e) { transaction.rollback(); throw new IOException("Cannot write shapefile. Error:\n" + e.getMessage(), e); } finally { dataStore.dispose(); transaction.close(); } } }
throw e; } finally { transaction.close();
throw new IOException(problem); } finally { transaction.close();
try { if (transaction != null) { transaction.close();
try { if (transaction != null) { transaction.close();
transaction.close();
transaction.close();
@Test public void testTransactionCommitMessage() throws Exception { FeatureCollection<SimpleFeatureType, SimpleFeature> collection; collection = DataUtilities.collection(Arrays.asList((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3)); DefaultTransaction tx = new DefaultTransaction(); points.setTransaction(tx); assertSame(tx, points.getTransaction()); try { points.addFeatures(collection); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_AUTHOR, "John Doe"); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_MESSAGE, "test message"); tx.commit(); assertEquals(3, dataStore.getFeatureSource(pointsName).getFeatures().size()); } catch (Exception e) { tx.rollback(); throw e; } finally { tx.close(); } List<RevCommit> commits = toList(geogig.command(LogOp.class).call()); assertFalse(commits.isEmpty()); assertTrue(commits.get(0).getAuthor().getName().isPresent()); assertEquals("John Doe", commits.get(0).getAuthor().getName().get()); assertEquals("test message", commits.get(0).getMessage()); }
@Test public void testTransactionCommitMessage() throws Exception { FeatureCollection<SimpleFeatureType, SimpleFeature> collection; collection = DataUtilities.collection(Arrays.asList((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3)); DefaultTransaction tx = new DefaultTransaction(); points.setTransaction(tx); assertSame(tx, points.getTransaction()); try { points.addFeatures(collection); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_AUTHOR, "John Doe"); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_MESSAGE, "test message"); tx.commit(); assertEquals(3, dataStore.getFeatureSource(pointsName).getFeatures().size()); } catch (Exception e) { tx.rollback(); throw e; } finally { tx.close(); } List<RevCommit> commits = toList(geogig.command(LogOp.class).call()); assertFalse(commits.isEmpty()); assertTrue(commits.get(0).getAuthor().getName().isPresent()); assertEquals("John Doe", commits.get(0).getAuthor().getName().get()); assertEquals("test message", commits.get(0).getMessage()); }
@Test public void testTransactionCommitAuthorAndEmail() throws Exception { FeatureCollection<SimpleFeatureType, SimpleFeature> collection; collection = DataUtilities.collection(Arrays.asList((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3)); DefaultTransaction tx = new DefaultTransaction(); points.setTransaction(tx); assertSame(tx, points.getTransaction()); try { points.addFeatures(collection); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_AUTHOR, "john"); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_MESSAGE, "test message"); tx.putProperty("fullname", "John Doe"); tx.putProperty("email", "jd@example.com"); tx.commit(); assertEquals(3, dataStore.getFeatureSource(pointsName).getFeatures().size()); } catch (Exception e) { tx.rollback(); throw e; } finally { tx.close(); } List<RevCommit> commits = toList(geogig.command(LogOp.class).call()); assertFalse(commits.isEmpty()); assertTrue(commits.get(0).getAuthor().getName().isPresent()); assertEquals("John Doe", commits.get(0).getAuthor().getName().orNull()); assertEquals("jd@example.com", commits.get(0).getAuthor().getEmail().orNull()); }
@Test public void testTransactionCommitAuthorAndEmail() throws Exception { FeatureCollection<SimpleFeatureType, SimpleFeature> collection; collection = DataUtilities.collection(Arrays.asList((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3)); DefaultTransaction tx = new DefaultTransaction(); points.setTransaction(tx); assertSame(tx, points.getTransaction()); try { points.addFeatures(collection); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_AUTHOR, "john"); tx.putProperty(GeogigTransactionState.VERSIONING_COMMIT_MESSAGE, "test message"); tx.putProperty("fullname", "John Doe"); tx.putProperty("email", "jd@example.com"); tx.commit(); assertEquals(3, dataStore.getFeatureSource(pointsName).getFeatures().size()); } catch (Exception e) { tx.rollback(); throw e; } finally { tx.close(); } List<RevCommit> commits = toList(geogig.command(LogOp.class).call()); assertFalse(commits.isEmpty()); assertTrue(commits.get(0).getAuthor().getName().isPresent()); assertEquals("John Doe", commits.get(0).getAuthor().getName().orNull()); assertEquals("jd@example.com", commits.get(0).getAuthor().getEmail().orNull()); }