use of org.geotoolkit.storage.feature.FeatureStoreRuntimeException in project geotoolkit by Geomatys.
the class DefaultJDBCFeatureStore method handleRemoveWithFeatureWriter.
/**
* Convenient method to handle adding features operation by using the
* FeatureWriter.
*/
protected void handleRemoveWithFeatureWriter(final String groupName, final Filter filter, Connection cnx) throws DataStoreException {
try (FeatureWriter writer = getFeatureWriterInternal(groupName, filter, EditMode.UPDATE, cnx, null)) {
while (writer.hasNext()) {
writer.next();
writer.remove();
}
} catch (FeatureStoreRuntimeException | IOException ex) {
throw new DataStoreException(ex);
}
}
use of org.geotoolkit.storage.feature.FeatureStoreRuntimeException in project geotoolkit by Geomatys.
the class ShapefileFeatureReader method close.
/**
* {@inheritDoc }
*/
@Override
public void close() throws FeatureStoreRuntimeException {
if (closed)
return;
closed = true;
Exception ex = null;
try {
fidReader.close();
} catch (DataStoreException e) {
ex = e;
}
try {
attributeReader.close();
} catch (IOException e) {
if (ex == null) {
ex = e;
} else {
// we tryed to close both and both failed
// return the first exception
}
}
if (ex != null) {
throw new FeatureStoreRuntimeException(ex);
}
}
use of org.geotoolkit.storage.feature.FeatureStoreRuntimeException in project geotoolkit by Geomatys.
the class ShapefileFeatureWriter method doClose.
protected void doClose() throws FeatureStoreRuntimeException {
// close reader, flush headers, and copy temp files, if any
try {
featureReader.close();
} finally {
try {
flush();
} catch (IOException ex) {
throw new FeatureStoreRuntimeException(ex);
} finally {
try {
shpWriter.close();
dbfWriter.close();
} catch (IOException ex) {
throw new FeatureStoreRuntimeException(ex);
}
}
featureReader = null;
shpWriter = null;
dbfWriter = null;
}
}
use of org.geotoolkit.storage.feature.FeatureStoreRuntimeException in project geotoolkit by Geomatys.
the class IndexedShapefileFeatureWriter method next.
@Override
public Feature next() throws FeatureStoreRuntimeException {
// closed already, error!
if (featureReader == null) {
throw new FeatureStoreRuntimeException("Writer closed");
}
// we have to write the current feature back into the stream
if (currentFeature != null) {
write();
}
final long next;
try {
next = fidWriter.next();
} catch (IOException ex) {
throw new FeatureStoreRuntimeException(ex);
}
currentFid = getFeatureType().getName().tip() + "." + next;
Feature feature = super.next();
return feature;
}
use of org.geotoolkit.storage.feature.FeatureStoreRuntimeException in project geotoolkit by Geomatys.
the class IndexedFidReader method hasNext.
@Override
public boolean hasNext() throws FeatureStoreRuntimeException {
if (done) {
return false;
}
if (((Buffer) buffer).position() == ((Buffer) buffer).limit()) {
((Buffer) buffer).position(0);
final FileChannel fc = (FileChannel) readChannel;
final int read;
try {
bufferStart = fc.position();
read = ShapefileReader.fill(buffer, readChannel);
} catch (IOException ex) {
throw new FeatureStoreRuntimeException(ex);
}
if (read != 0) {
((Buffer) buffer).position(0);
}
}
return buffer.remaining() != 0;
}
Aggregations