planetfederal / geodroid-server

Apache License 2.0
3 stars 4 forks source link

Ignore zip file when reading data #39

Closed sbalasub closed 10 years ago

sbalasub commented 10 years ago

When loading a layer preview, the geodroid server looks for data from the geodata directory. Currently if the directory contains the zip file of the data along with the extracted data, an exception is thrown and layer is not loaded. The error from the log:

W/GeodroidServer(21057): Error loading workspace: objects W/GeodroidServer(21057): java.lang.IllegalArgumentException: file does not exist or is not a directory: /mnt/sdcard/Geodata/objects.zip W/GeodroidServer(21057): at com.google.common.base.Preconditions.checkArgument(Preconditions.java:92) W/GeodroidServer(21057): at org.geogit.api.DefaultPlatform.setWorkingDir(DefaultPlatform.java:36) W/GeodroidServer(21057): at org.geogit.api.GeoGIT.(GeoGIT.java:75) W/GeodroidServer(21057): at org.jeo.geogit.GeoGit.newGeoGIT(GeoGit.java:129) W/GeodroidServer(21057): at org.jeo.geogit.GeoGit.open(GeoGit.java:98) W/GeodroidServer(21057): at org.jeo.geogit.GeoGit.open(GeoGit.java:40) W/GeodroidServer(21057): at org.jeo.data.FileDriver.open(FileDriver.java:95) W/GeodroidServer(21057): at org.jeo.data.DirectoryRepository.objOrNull(DirectoryRepository.java:278) W/GeodroidServer(21057): at org.jeo.data.DirectoryRepository.get(DirectoryRepository.java:180) W/GeodroidServer(21057): at org.jeo.data.Handle$1.doResolve(Handle.java:252) W/GeodroidServer(21057): at org.jeo.data.Handle.resolve(Handle.java:227) W/GeodroidServer(21057): at org.geodroid.server.LayersPage$DatasetVisitor.process(LayersPage.java:321) W/GeodroidServer(21057): at org.geodroid.server.LayersPage$LoadLayers.doInBackground(LayersPage.java:206)

So the zip file should be ignored when reading data

ischneider commented 10 years ago

This is an annoying aspect of geogit - the use of Preconditions for error handling. As IllegalArgumentException is thrown from many different libraries, it is not acceptable to catch this and assume it's because the core geogit can't understand it.

In the meantime, org.jeo.geogit.GeoGit.open should test if it's a directory. I also wonder what would happen if an empty directory is present.

FWIW, this is technically a jeo issue

jdeolive commented 10 years ago

@ischneider What do you think about simply filtering out archived files from the directory listing? ".zip", ".tgz", etc...

ischneider commented 10 years ago

@jdeolive makes sense but also wonder about what happens if a non-geogit directory is passed in.

jdeolive commented 10 years ago

Right the issue here is the .jeo file. When the DirectoryRepostiory hits world.tgz it looks for the associated .jeo file, which it finds. The .jeo file tells it to use the GeoGit driver and that is GeoGit is trying to open it. In the normal case of a non GeoGit directory it should simply be ignored.

So really what I think we should probably do long term is change the processing in DirectoryRepository so that it groups all files by the base name.

jdeolive commented 10 years ago

See jeo/jeo#42