use of org.apache.sis.storage.DataStoreException in project sis by apache.
the class Store method close.
/**
* Closes this data store and releases any underlying resources.
*
* @throws DataStoreException if an error occurred while closing this data store.
*/
@Override
public synchronized void close() throws DataStoreException {
final Reader s = source;
// Cleared first in case of failure.
source = null;
objects.clear();
if (s != null)
try {
s.close();
} catch (IOException e) {
throw new DataStoreException(e);
}
}
use of org.apache.sis.storage.DataStoreException in project sis by apache.
the class MimeTypeDetector method probeContent.
/**
* Wraps the call to {@link #getMimeType()} for catching {@link IOException} and for
* instantiating the {@link ProbeResult}.
*/
final ProbeResult probeContent() throws DataStoreException {
boolean isSupported = true;
String mimeType;
try {
mimeType = getMimeType();
} catch (IOException e) {
throw new DataStoreException(e);
}
if (mimeType == null) {
if (insufficientBytes) {
return ProbeResult.INSUFFICIENT_BYTES;
}
isSupported = false;
mimeType = StoreProvider.MIME_TYPE;
}
return new ProbeResult(isSupported, mimeType, null);
}
use of org.apache.sis.storage.DataStoreException in project sis by apache.
the class Store method unmarshal.
/**
* Unmarshal the object, if not already done. Note that {@link #object} may still be null
* if an exception has been thrown at this invocation time or in previous invocation.
*
* @throws DataStoreException if an error occurred during the unmarshalling process.
*/
private void unmarshal() throws DataStoreException {
final StreamSource s = source;
final Closeable in = input(s);
// Cleared first in case of error.
source = null;
if (in != null)
try {
try {
object = XML.unmarshal(s, properties());
} finally {
in.close();
}
} catch (JAXBException | IOException e) {
throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, getDisplayName()), e);
}
if (object instanceof CoordinateReferenceSystem)
try {
final DefinitionVerifier v = DefinitionVerifier.withAuthority((CoordinateReferenceSystem) object, null, false, getLocale());
if (v != null) {
log(v.warning(false));
}
} catch (FactoryException e) {
listeners.warning(e);
}
}
use of org.apache.sis.storage.DataStoreException in project sis by apache.
the class Store method close.
/**
* Closes this data store and releases any underlying resources.
*
* @throws DataStoreException if an error occurred while closing this data store.
*/
@Override
public synchronized void close() throws DataStoreException {
final Reader r = reader;
reader = null;
if (r != null)
try {
r.close();
} catch (Exception e) {
final DataStoreException ds = new DataStoreException(e);
try {
super.close();
} catch (DataStoreException s) {
ds.addSuppressed(s.getCause());
}
throw ds;
}
super.close();
}
Aggregations