Skip to content

Commit

Permalink
Log errors creating GeoGig index
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Merkle committed Mar 16, 2017
1 parent e66d2ec commit faa97c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Expand Up @@ -4,13 +4,13 @@
*/
package org.geogig.geoserver.wms;

import java.io.IOException;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;

import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogException;
import org.geoserver.catalog.CatalogVisitor;
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.CoverageStoreInfo;
Expand Down Expand Up @@ -97,9 +97,14 @@ public void visit(LayerInfo layer) {
final StoreInfo store = resource.getStore();
if (GeoGigDataStoreFactory.DISPLAY_NAME.equals(store.getType())) {
// it's a GeoGig dataStore
GeoGigDataStore geogigDataStore = null;
try {
final GeoGigDataStore geogigDataStore = GeoGigDataStore.class.cast(
geogigDataStore = GeoGigDataStore.class.cast(
((DataStoreInfo) store).getDataStore(null));
} catch (Exception ex) {
throw new CatalogException("Error accessing GeoGig DataStore", ex);
}
try {
if (!geogigDataStore.getAutoIndexing()) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(String.format("GeoGig DataStore is not configured for automatic indexing."));
Expand All @@ -114,9 +119,11 @@ public void visit(LayerInfo layer) {
String[] dimensions = Stream.concat(Arrays.stream(timeAttr), Arrays.stream(elevationAttr))
.toArray(String[]::new);
// create the indexes
geogigDataStore.createOrUpdateIndex(resource.getNativeName(), dimensions);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
geogigDataStore.createOrUpdateIndex(resource.getName(), dimensions);
} catch (Exception ex) {
// Something went wrong creating the index, log it and move on
LOGGER.log(Level.WARNING, "Index could not be created or updated on Layer: " +
resource.getNativeName(), ex);
}
}
}
Expand Down
Expand Up @@ -68,7 +68,7 @@ public void after() {
}

@Test
public void testGetAttribute3() throws Exception {
public void testGetAttribute_SapitalIndexOnly() throws Exception {
addAvailableGeogigLayers();
Catalog catalog = getCatalog();
GeoGigTestData.CatalogBuilder catalogBuilder = geogigData.newCatalogBuilder(catalog);
Expand All @@ -87,7 +87,7 @@ public void testGetAttribute3() throws Exception {
}

@Test
public void testGetAttribute2() throws Exception {
public void testGetAttribute_SpatialIndexWithExtraAttributes() throws Exception {
addAvailableGeogigLayers();
Catalog catalog = getCatalog();
GeoGigTestData.CatalogBuilder catalogBuilder = geogigData.newCatalogBuilder(catalog);
Expand Down
Expand Up @@ -7,7 +7,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.locationtech.geogig.geotools.data.GeoGigDataStoreFactory.REPOSITORY;
import static org.locationtech.geogig.model.impl.RevObjectTestSupport.hashString;

import java.io.Serializable;
import java.util.List;
Expand Down Expand Up @@ -60,6 +59,9 @@ protected void onSetUp(SystemTestData testData) throws Exception {
"l2=geom:LINESTRING(0 0, 180 0)");

geogigData.add().commit("Added test features");

// add a branch for the explicit HEAD test
geogigData.branch("fakeBranch");
// need to instantiate the listerner so it can register with the test GeoServer instance
new GeogigLayerIntegrationListener(getGeoServer());

Expand Down Expand Up @@ -128,9 +130,7 @@ public void testAddGeogigLayerAddsLayerIdentifierWithExplicitHead() {
CatalogBuilder catalogBuilder = geogigData.newCatalogBuilder(catalog);
DataStoreInfo store = catalog.getDataStoreByName(catalogBuilder.storeName());

final String fakeHead = hashString("something").toString();

store.getConnectionParameters().put(GeoGigDataStoreFactory.HEAD.key, fakeHead);
store.getConnectionParameters().put(GeoGigDataStoreFactory.HEAD.key, "fakeBranch");
catalog.save(store);

String layerName = catalogBuilder.workspaceName() + ":points";
Expand Down

0 comments on commit faa97c1

Please sign in to comment.