[Geoserver-devel] Problem updating shapefile with REST API

HI

I’m trying to upload a shapefile with REST API several times (to update the data of the feature type):

curl -u admin:geoserver -XPUT -H ‘Content-type: application/zip’ --data-binary @buildings.zip http://localhost:8080/geoserver/rest/workspaces/acme/datastores/buildings/file.shp

The first time works ok, but next time I get this exception:

19 ene 13:10:38 ERROR [geoserver.rest] -
org.geoserver.rest.RestletException: java.util.zip.ZipException: error in openin
g zip file
at org.geoserver.catalog.rest.StoreFileResource.handleFileUpload(StoreFi
leResource.java:99)
at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreF
ileResource.java:112)
at org.restlet.Finder.handle(Finder.java:298)
at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet
.java:38)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Router.handle(Router.java:444)

I tried to delete the datastore, removing first the layer and the featuretype so later trying to upload the shapefile again. In this case sometimes it’s working but others getting the before error.

The problem seem that in the data directory the shapefile files are not deleted after the featuretype or datastore are deleted. If the files are deleted manually from the directory then works ok.

Not sure if I’m doing something wrong or it’s a bug of the REST API.

I’m using Windows Vista and Geoserver it’s not installed in Program Files folder.

Regards,
Jose Garcia

Hi Jose,

Sorry for the reply. I know this functionality works on "regular" setup so I assume it is something specific to the vista setup.

I recently acquired a vista virtual machine so I can try this out. To do so can you tell me about the setup. Where is gs installed? And where does the data directory reside. Thanks.

-Justin

jose garcia wrote:

HI

I'm trying to upload a shapefile with REST API several times (to update the data of the feature type):

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @buildings.zip http://localhost:8080/geoserver/rest/workspaces/acme/datastores/buildings/file.shp

The first time works ok, but next time I get this exception:

19 ene 13:10:38 ERROR [geoserver.rest] -
org.geoserver.rest.RestletException: java.util.zip.ZipException: error in openin
g zip file
        at org.geoserver.catalog.rest.StoreFileResource.handleFileUpload(StoreFi
leResource.java:99)
        at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreF
ileResource.java:112)
        at org.restlet.Finder.handle(Finder.java:298)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet
.java:38)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)

I tried to delete the datastore, removing first the layer and the featuretype so later trying to upload the shapefile again. In this case sometimes it's working but others getting the before error.

The problem seem that in the data directory the shapefile files are not deleted after the featuretype or datastore are deleted. If the files are deleted manually from the directory then works ok.

Not sure if I'm doing something wrong or it's a bug of the REST API.

I'm using Windows Vista and Geoserver it's not installed in Program Files folder.

Regards,
Jose Garcia

------------------------------------------------------------------------

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

------------------------------------------------------------------------

_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hi Justin

GeoServer it’s installed in C:\programs\geoserver-2.0.0 and the shapefiles are stored in C:\programs\geoserver-2.0.0\data_dir\data

I tried to delete the files manually with the Windows Explorer and there’s no problem, so seem not blocked. Seem more that GeoServer have problems when unziping the file, if the files already exists in the folder.

Thanks and regards,
Jose Garcia

On Wed, Jan 20, 2010 at 4:22 PM, Justin Deoliveira <jdeolive@anonymised.com…> wrote:

Hi Jose,

Sorry for the reply. I know this functionality works on “regular” setup so I assume it is something specific to the vista setup.

I recently acquired a vista virtual machine so I can try this out. To do so can you tell me about the setup. Where is gs installed? And where does the data directory reside. Thanks.

-Justin

jose garcia wrote:

HI

I’m trying to upload a shapefile with REST API several times (to update the data of the feature type):

curl -u admin:geoserver -XPUT -H ‘Content-type: application/zip’ --data-binary @buildings.zip http://localhost:8080/geoserver/rest/workspaces/acme/datastores/buildings/file.shp

The first time works ok, but next time I get this exception:

19 ene 13:10:38 ERROR [geoserver.rest] -
org.geoserver.rest.RestletException: java.util.zip.ZipException: error in openin
g zip file
at org.geoserver.catalog.rest.StoreFileResource.handleFileUpload(StoreFi
leResource.java:99)
at org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreF
ileResource.java:112)
at org.restlet.Finder.handle(Finder.java:298)
at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet
.java:38)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Router.handle(Router.java:444)

I tried to delete the datastore, removing first the layer and the featuretype so later trying to upload the shapefile again. In this case sometimes it’s working but others getting the before error.

The problem seem that in the data directory the shapefile files are not deleted after the featuretype or datastore are deleted. If the files are deleted manually from the directory then works ok.

Not sure if I’m doing something wrong or it’s a bug of the REST API.

I’m using Windows Vista and Geoserver it’s not installed in Program Files folder.

Regards,
Jose Garcia



Throughout its 18-year history, RSA Conference consistently attracts the
world’s best and brightest in the field, creating opportunities for Conference
attendees to learn about information security’s most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev



Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel


Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hi Jose,

Thanks for supplying all the information for this. I spent a couple of hours today looking at this and I don't have a great explanation. Here is what I found.

There is a bug in the code where the uploaded zip file can overwrite the original files. This will happen when the store name is equal to the file name. And in this case it is. One thing to try would be to try it with the file names different. For instance, create a store named "buildings" but rename the shapefile to buildings_foo.shp or something. See if that works.

As for being able to replicate the issue I could not with any repeatability. My current guess is that there is some file locking going on. Ie a datastore is holding onto the shapefiles you are trying to overwrite. Again I was not able to affirm this was any repeatability. We could have the code dispose the existing datastore manually before updating. This should ensure nothing else is holding onto the files when overwriting them.

However can you try the renaming thing first since that one is much easier to fix.

Thanks.

-Justin

On 1/20/10 11:09 AM, jose garcia wrote:

Hi Justin

GeoServer it's installed in C:\programs\geoserver-2.0.0 and the
shapefiles are stored in C:\programs\geoserver-2.0.0\data_dir\data

I tried to delete the files manually with the Windows Explorer and
there's no problem, so seem not blocked. Seem more that GeoServer have
problems when unziping the file, if the files already exists in the folder.

Thanks and regards,
Jose Garcia

On Wed, Jan 20, 2010 at 4:22 PM, Justin Deoliveira <jdeolive@anonymised.com
<mailto:jdeolive@anonymised.com>> wrote:

    Hi Jose,

    Sorry for the reply. I know this functionality works on "regular"
    setup so I assume it is something specific to the vista setup.

    I recently acquired a vista virtual machine so I can try this out.
    To do so can you tell me about the setup. Where is gs installed? And
    where does the data directory reside. Thanks.

    -Justin

    jose garcia wrote:

        HI

        I'm trying to upload a shapefile with REST API several times (to
        update the data of the feature type):

        curl -u admin:geoserver -XPUT -H 'Content-type: application/zip'
        --data-binary @buildings.zip
        http://localhost:8080/geoserver/rest/workspaces/acme/datastores/buildings/file.shp

        The first time works ok, but next time I get this exception:

        19 ene 13:10:38 ERROR [geoserver.rest] -
        org.geoserver.rest.RestletException: java.util.zip.ZipException:
        error in openin
        g zip file
                at
        org.geoserver.catalog.rest.StoreFileResource.handleFileUpload(StoreFi
        leResource.java:99)
                at
        org.geoserver.catalog.rest.DataStoreFileResource.handlePut(DataStoreF
        ileResource.java:112)
                at org.restlet.Finder.handle(Finder.java:298)
                at
        org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet
        .java:38)
                at org.restlet.Filter.doHandle(Filter.java:105)
                at org.restlet.Filter.handle(Filter.java:134)
                at org.restlet.Router.handle(Router.java:444)

        I tried to delete the datastore, removing first the layer and
        the featuretype so later trying to upload the shapefile again.
        In this case sometimes it's working but others getting the
        before error.

        The problem seem that in the data directory the shapefile files
        are not deleted after the featuretype or datastore are deleted.
        If the files are deleted manually from the directory then works ok.

        Not sure if I'm doing something wrong or it's a bug of the REST API.

        I'm using Windows Vista and Geoserver it's not installed in
        Program Files folder.

        Regards,
        Jose Garcia

        ------------------------------------------------------------------------

        ------------------------------------------------------------------------------
        Throughout its 18-year history, RSA Conference consistently
        attracts the
        world's best and brightest in the field, creating opportunities
        for Conference
        attendees to learn about information security's most important
        issues through
        interactions with peers, luminaries and emerging and established
        companies.
        http://p.sf.net/sfu/rsaconf-dev2dev

        ------------------------------------------------------------------------

        _______________________________________________
        Geoserver-devel mailing list
        Geoserver-devel@lists.sourceforge.net
        <mailto:Geoserver-devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/geoserver-devel

    --
    Justin Deoliveira
    OpenGeo - http://opengeo.org
    Enterprise support for open source geospatial.

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.