Search in sources :

Example 1 with Resource

use of org.apache.sis.storage.Resource in project sis by apache.

the class StoreTest method verifyContent.

/**
 * Verifies that the given metadata contains one of the given identifiers.
 * The identifiers that are found are removed from the given set.
 */
private static void verifyContent(final Aggregate store, final Set<String> identifiers) throws DataStoreException {
    for (final Resource resource : store.components()) {
        assertNotNull("resource", resource);
        for (Identification info : resource.getMetadata().getIdentificationInfo()) {
            final String id = Citations.getIdentifier(info.getCitation());
            assertTrue(id, identifiers.remove(id));
            if (resource instanceof Aggregate) {
                verifyContent((Aggregate) resource, identifiers);
            }
        }
    }
}
Also used : Resource(org.apache.sis.storage.Resource) Identification(org.opengis.metadata.identification.Identification) Aggregate(org.apache.sis.storage.Aggregate)

Example 2 with Resource

use of org.apache.sis.storage.Resource in project sis by apache.

the class Store method close.

/**
 * Closes all children resources.
 */
@Override
public synchronized void close() throws DataStoreException {
    final Collection<Resource> resources = components;
    if (resources != null) {
        // Clear first in case of failure.
        components = null;
        DataStoreException failure = null;
        for (final Resource r : resources) {
            if (r instanceof DataStore)
                try {
                    ((DataStore) r).close();
                } catch (DataStoreException ex) {
                    if (failure == null) {
                        failure = ex;
                    } else {
                        failure.addSuppressed(ex);
                    }
                }
        }
        if (failure != null) {
            throw failure;
        }
    }
}
Also used : DataStoreException(org.apache.sis.storage.DataStoreException) DataStore(org.apache.sis.storage.DataStore) Resource(org.apache.sis.storage.Resource)

Aggregations

Resource (org.apache.sis.storage.Resource)2 Aggregate (org.apache.sis.storage.Aggregate)1 DataStore (org.apache.sis.storage.DataStore)1 DataStoreException (org.apache.sis.storage.DataStoreException)1 Identification (org.opengis.metadata.identification.Identification)1