[Geoserver-devel] Upgrade Jettison dependency version

Hey gabriel,

Thanks for the detailed explanation. Unfortunately I don’t think it is an option to change the rest API serialization format on the stable branch. There is just too much code out there written against it. I would be OK with doing it on the trunk though. Actually this sort of aligns with another api change I have been thinking about and that is to have then root node of an object dropped in a collection:

http://xstream.codehaus.org/json-tutorial.html#json-dropping-root

So I guess to upgrade on the stable branch if we upgrade we would have to tweak converters to maintain the old format. I know it seems a bit silly to maintain a bug but I think its the safest way forward.

$0.02

-Justin

On Dec 26, 2011 12:00 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

Due to a bug in Jettison 1.0.1, serializing and deserializing
collections is broken <http://jira.codehaus.org/browse/JETTISON-48>

Here’s a test that demonstrates the issue:

package org.geoserver.rest.format;

public class ReflectiveJSONFormatTest extends TestCase {

@anonymised.com({ “unchecked”, “rawtypes” })
public void testFoo() throws Exception {

ReflectiveJSONFormat format = new ReflectiveJSONFormat();

Foo foo = new Foo(“list”, 2, 3.0, new
ArrayList(Arrays.asList(1L, 2.5D)));

ByteArrayOutputStream output = new ByteArrayOutputStream();
format.write(foo, output);

Object read = format.read(new
ByteArrayInputStream(output.toByteArray()));

assertTrue(read instanceof Foo);
Foo foo2 = (Foo) read;
assertEquals(foo.getList(), foo2.getList());
assertEquals(foo.getProp1(), foo2.getProp1());
assertEquals(foo.getProp2(), foo2.getProp2());
assertEquals(foo.getProp3(), foo2.getProp3());
}
}

The test fails at the first assert. (Have added a list property to the
org.geoserver.rest.Foo test object).

The generated JSON with the current Jettison version is
Jettison 1.0.1:
{“org.geoserver.rest.Foo”:{“list”:{“int”:[1],“double”:2.5},“prop1”:“list”,“prop2”:2,“prop3”:3}}

The generated JSON with Jettison 1.3 (latest release) is:
Jettison 1.3:
{“org.geoserver.rest.Foo”:{“list”:[{“int”:1,“double”:2.5}],“prop1”:“list”,“prop2”:2,“prop3”:3}}

As you can see, the currently generated value of the “list” attribute
is not a json array as it should be, whilst the Jettison 1.3 one is.

Upgrading to Jettison 1.3 breaks some restconfig tests though, because
they’re asserting the “incorrect” format is being generated.
For instance:
org.geoserver.catalog.rest.WorkspaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.DataStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.CoverageStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.NamespaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.WMSStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.StyleTest.testGetAllAsJSON

Take for example WorkspaceTest.testGetAllAsJSON
The GET request produces:

{“workspaces”:{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}}

while Jettison 1.3 produces:
{“workspaces”:[{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}]}

In the second case, “workspaces” is in itself an array. And that’s
correct because the object being encoded is a List.

So the question is, is there any chance we can upgrade to Jettison 1.3
and fix those tests? Would it be too risky a REST api breakage?
I would like to upgrade and get rid of that Jettison bug because it is
very much needed in order to work with the gwc configuration that
collection properties are properly encoded and decoded when they
contain polymorphic elements, which currently is impossible.

TIA,
Gabriel


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

On Mon, Dec 26, 2011 at 2:01 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Hey gabriel,

Thanks for the detailed explanation. Unfortunately I don't think it is an
option to change the rest API serialization format on the stable branch.
There is just too much code out there written against it. I would be OK with
doing it on the trunk though. Actually this sort of aligns with another api
change I have been thinking about and that is to have then root node of an
object dropped in a collection:

http://xstream.codehaus.org/json-tutorial.html#json-dropping-root

So I guess to upgrade on the stable branch if we upgrade we would have to
tweak converters to maintain the old format. I know it seems a bit silly to
maintain a bug but I think its the safest way forward.

Yeah I agree on stable it's not an option. Hopefully the rest
collection converter seems to be isolated enough as to make the
backwards compatible change in there, if we had to upgrade jettison on
stable too.
Personally I'm not in a rush, would just need to upgrade jettison when
the time comes to backport the gwc integration improvements. By that
time I'll make sure to propose a patch for review.
Back on to trunk, do you have a timeline for the root element name drop?

Cheers,
Gabriel

$0.02

-Justin

On Dec 26, 2011 12:00 AM, "Gabriel Roldan" <groldan@anonymised.com> wrote:

Due to a bug in Jettison 1.0.1, serializing and deserializing
collections is broken <http://jira.codehaus.org/browse/JETTISON-48&gt;

Here's a test that demonstrates the issue:

package org.geoserver.rest.format;
...
public class ReflectiveJSONFormatTest extends TestCase {

@anonymised.com({ "unchecked", "rawtypes" })
public void testFoo() throws Exception {

   ReflectiveJSONFormat format = new ReflectiveJSONFormat\(\);

   Foo foo = new Foo\(&quot;list&quot;, 2, 3\.0, new

ArrayList(Arrays.asList(1L, 2.5D)));

   ByteArrayOutputStream output = new ByteArrayOutputStream\(\);
   format\.write\(foo, output\);

   Object read = format\.read\(new

ByteArrayInputStream(output.toByteArray()));

   assertTrue\(read instanceof Foo\);
   Foo foo2 = \(Foo\) read;
   assertEquals\(foo\.getList\(\), foo2\.getList\(\)\);
   assertEquals\(foo\.getProp1\(\), foo2\.getProp1\(\)\);
   assertEquals\(foo\.getProp2\(\), foo2\.getProp2\(\)\);
   assertEquals\(foo\.getProp3\(\), foo2\.getProp3\(\)\);

}
}

The test fails at the first assert. (Have added a list property to the
org.geoserver.rest.Foo test object).

The generated JSON with the current Jettison version is
Jettison 1.0.1:

{"org.geoserver.rest.Foo":{"list":{"int":[1],"double":2.5},"prop1":"list","prop2":2,"prop3":3}}

The generated JSON with Jettison 1.3 (latest release) is:
Jettison 1.3:

{"org.geoserver.rest.Foo":{"list":[{"int":1,"double":2.5}],"prop1":"list","prop2":2,"prop3":3}}

As you can see, the currently generated value of the "list" attribute
is not a json array as it should be, whilst the Jettison 1.3 one is.

Upgrading to Jettison 1.3 breaks some restconfig tests though, because
they're asserting the "incorrect" format is being generated.
For instance:
org.geoserver.catalog.rest.WorkspaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.DataStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.CoverageStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.NamespaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.WMSStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.StyleTest.testGetAllAsJSON

Take for example WorkspaceTest.testGetAllAsJSON
The GET request produces:

{"workspaces":{"workspace":[{"name":"cite","..."},{"name":"cgf","..."},{"name":"sf","..."},{"name":"gs","..."},{"name":"cdf","..."}]}}

while Jettison 1.3 produces:

{"workspaces":[{"workspace":[{"name":"cite","..."},{"name":"cgf","..."},{"name":"sf","..."},{"name":"gs","..."},{"name":"cdf","..."}]}]}

In the second case, "workspaces" is in itself an array. And that's
correct because the object being encoded is a List<WorkspaceInfo>.

So the question is, is there any chance we can upgrade to Jettison 1.3
and fix those tests? Would it be too risky a REST api breakage?
I would like to upgrade and get rid of that Jettison bug because it is
very much needed in order to work with the gwc configuration that
collection properties are properly encoded and decoded when they
contain polymorphic elements, which currently is impossible.

TIA,
Gabriel

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

btw, it just occurred to me whether versioning the rest api somehow
would be a good thing and feasible.
Google's first answer is at
<http://stackoverflow.com/questions/389169/best-practices-for-api-versioning&gt;

In an ideal world geoserver version X would support REST api verson Z
and Z-1, and there would be a document explaining the api changes
between Z and Z-1.

Do you think that's something worth pursuing?

Cheers,
Gabriel

On Mon, Dec 26, 2011 at 2:42 PM, Gabriel Roldan <groldan@anonymised.com> wrote:

On Mon, Dec 26, 2011 at 2:01 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Hey gabriel,

Thanks for the detailed explanation. Unfortunately I don't think it is an
option to change the rest API serialization format on the stable branch.
There is just too much code out there written against it. I would be OK with
doing it on the trunk though. Actually this sort of aligns with another api
change I have been thinking about and that is to have then root node of an
object dropped in a collection:

http://xstream.codehaus.org/json-tutorial.html#json-dropping-root

So I guess to upgrade on the stable branch if we upgrade we would have to
tweak converters to maintain the old format. I know it seems a bit silly to
maintain a bug but I think its the safest way forward.

Yeah I agree on stable it's not an option. Hopefully the rest
collection converter seems to be isolated enough as to make the
backwards compatible change in there, if we had to upgrade jettison on
stable too.
Personally I'm not in a rush, would just need to upgrade jettison when
the time comes to backport the gwc integration improvements. By that
time I'll make sure to propose a patch for review.
Back on to trunk, do you have a timeline for the root element name drop?

Cheers,
Gabriel

$0.02

-Justin

On Dec 26, 2011 12:00 AM, "Gabriel Roldan" <groldan@anonymised.com> wrote:

Due to a bug in Jettison 1.0.1, serializing and deserializing
collections is broken <http://jira.codehaus.org/browse/JETTISON-48&gt;

Here's a test that demonstrates the issue:

package org.geoserver.rest.format;
...
public class ReflectiveJSONFormatTest extends TestCase {

@anonymised.com({ "unchecked", "rawtypes" })
public void testFoo() throws Exception {

   ReflectiveJSONFormat format = new ReflectiveJSONFormat\(\);

   Foo foo = new Foo\(&quot;list&quot;, 2, 3\.0, new

ArrayList(Arrays.asList(1L, 2.5D)));

   ByteArrayOutputStream output = new ByteArrayOutputStream\(\);
   format\.write\(foo, output\);

   Object read = format\.read\(new

ByteArrayInputStream(output.toByteArray()));

   assertTrue\(read instanceof Foo\);
   Foo foo2 = \(Foo\) read;
   assertEquals\(foo\.getList\(\), foo2\.getList\(\)\);
   assertEquals\(foo\.getProp1\(\), foo2\.getProp1\(\)\);
   assertEquals\(foo\.getProp2\(\), foo2\.getProp2\(\)\);
   assertEquals\(foo\.getProp3\(\), foo2\.getProp3\(\)\);

}
}

The test fails at the first assert. (Have added a list property to the
org.geoserver.rest.Foo test object).

The generated JSON with the current Jettison version is
Jettison 1.0.1:

{"org.geoserver.rest.Foo":{"list":{"int":[1],"double":2.5},"prop1":"list","prop2":2,"prop3":3}}

The generated JSON with Jettison 1.3 (latest release) is:
Jettison 1.3:

{"org.geoserver.rest.Foo":{"list":[{"int":1,"double":2.5}],"prop1":"list","prop2":2,"prop3":3}}

As you can see, the currently generated value of the "list" attribute
is not a json array as it should be, whilst the Jettison 1.3 one is.

Upgrading to Jettison 1.3 breaks some restconfig tests though, because
they're asserting the "incorrect" format is being generated.
For instance:
org.geoserver.catalog.rest.WorkspaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.DataStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.CoverageStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.NamespaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.WMSStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.StyleTest.testGetAllAsJSON

Take for example WorkspaceTest.testGetAllAsJSON
The GET request produces:

{"workspaces":{"workspace":[{"name":"cite","..."},{"name":"cgf","..."},{"name":"sf","..."},{"name":"gs","..."},{"name":"cdf","..."}]}}

while Jettison 1.3 produces:

{"workspaces":[{"workspace":[{"name":"cite","..."},{"name":"cgf","..."},{"name":"sf","..."},{"name":"gs","..."},{"name":"cdf","..."}]}]}

In the second case, "workspaces" is in itself an array. And that's
correct because the object being encoded is a List<WorkspaceInfo>.

So the question is, is there any chance we can upgrade to Jettison 1.3
and fix those tests? Would it be too risky a REST api breakage?
I would like to upgrade and get rid of that Jettison bug because it is
very much needed in order to work with the gwc configuration that
collection properties are properly encoded and decoded when they
contain polymorphic elements, which currently is impossible.

TIA,
Gabriel

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

No time line really but if you plan to push on this I would be more inclined to push on this.

On Dec 26, 2011 10:42 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

On Mon, Dec 26, 2011 at 2:01 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Hey gabriel,

Thanks for the detailed explanation. Unfortunately I don’t think it is an
option to change the rest API serialization format on the stable branch.
There is just too much code out there written against it. I would be OK with
doing it on the trunk though. Actually this sort of aligns with another api
change I have been thinking about and that is to have then root node of an
object dropped in a collection:

http://xstream.codehaus.org/json-tutorial.html#json-dropping-root

So I guess to upgrade on the stable branch if we upgrade we would have to
tweak converters to maintain the old format. I know it seems a bit silly to
maintain a bug but I think its the safest way forward.

Yeah I agree on stable it’s not an option. Hopefully the rest
collection converter seems to be isolated enough as to make the
backwards compatible change in there, if we had to upgrade jettison on
stable too.
Personally I’m not in a rush, would just need to upgrade jettison when
the time comes to backport the gwc integration improvements. By that
time I’ll make sure to propose a patch for review.
Back on to trunk, do you have a timeline for the root element name drop?

Cheers,
Gabriel

$0.02

-Justin

On Dec 26, 2011 12:00 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

Due to a bug in Jettison 1.0.1, serializing and deserializing
collections is broken <http://jira.codehaus.org/browse/JETTISON-48>

Here’s a test that demonstrates the issue:

package org.geoserver.rest.format;

public class ReflectiveJSONFormatTest extends TestCase {

@anonymised.com({ “unchecked”, “rawtypes” })
public void testFoo() throws Exception {

ReflectiveJSONFormat format = new ReflectiveJSONFormat();

Foo foo = new Foo(“list”, 2, 3.0, new
ArrayList(Arrays.asList(1L, 2.5D)));

ByteArrayOutputStream output = new ByteArrayOutputStream();
format.write(foo, output);

Object read = format.read(new
ByteArrayInputStream(output.toByteArray()));

assertTrue(read instanceof Foo);
Foo foo2 = (Foo) read;
assertEquals(foo.getList(), foo2.getList());
assertEquals(foo.getProp1(), foo2.getProp1());
assertEquals(foo.getProp2(), foo2.getProp2());
assertEquals(foo.getProp3(), foo2.getProp3());
}
}

The test fails at the first assert. (Have added a list property to the
org.geoserver.rest.Foo test object).

The generated JSON with the current Jettison version is
Jettison 1.0.1:

{“org.geoserver.rest.Foo”:{“list”:{“int”:[1],“double”:2.5},“prop1”:“list”,“prop2”:2,“prop3”:3}}

The generated JSON with Jettison 1.3 (latest release) is:
Jettison 1.3:

{“org.geoserver.rest.Foo”:{“list”:[{“int”:1,“double”:2.5}],“prop1”:“list”,“prop2”:2,“prop3”:3}}

As you can see, the currently generated value of the “list” attribute
is not a json array as it should be, whilst the Jettison 1.3 one is.

Upgrading to Jettison 1.3 breaks some restconfig tests though, because
they’re asserting the “incorrect” format is being generated.
For instance:
org.geoserver.catalog.rest.WorkspaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.DataStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.CoverageStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.NamespaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.WMSStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.StyleTest.testGetAllAsJSON

Take for example WorkspaceTest.testGetAllAsJSON
The GET request produces:

{“workspaces”:{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}}

while Jettison 1.3 produces:

{“workspaces”:[{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}]}

In the second case, “workspaces” is in itself an array. And that’s
correct because the object being encoded is a List.

So the question is, is there any chance we can upgrade to Jettison 1.3
and fix those tests? Would it be too risky a REST api breakage?
I would like to upgrade and get rid of that Jettison bug because it is
very much needed in order to work with the gwc configuration that
collection properties are properly encoded and decoded when they
contain polymorphic elements, which currently is impossible.

TIA,
Gabriel


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Yeah I like the idea of versioning the rest API since at some point we will have to undoubetly make non backward compatible changes. So yeah I guess we could call this api version 1 and then if we want to make breaking changes on the trunk push it to 2. It would be nice to have at least one release of a deprecation cycle though.

On Dec 26, 2011 11:13 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

btw, it just occurred to me whether versioning the rest api somehow
would be a good thing and feasible.
Google’s first answer is at
<http://stackoverflow.com/questions/389169/best-practices-for-api-versioning>

In an ideal world geoserver version X would support REST api verson Z
and Z-1, and there would be a document explaining the api changes
between Z and Z-1.

Do you think that’s something worth pursuing?

Cheers,
Gabriel

On Mon, Dec 26, 2011 at 2:42 PM, Gabriel Roldan <groldan@anonymised.com> wrote:

On Mon, Dec 26, 2011 at 2:01 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Hey gabriel,

Thanks for the detailed explanation. Unfortunately I don’t think it is an
option to change the rest API serialization format on the stable branch.
There is just too much code out there written against it. I would be OK with
doing it on the trunk though. Actually this sort of aligns with another api
change I have been thinking about and that is to have then root node of an
object dropped in a collection:

http://xstream.codehaus.org/json-tutorial.html#json-dropping-root

So I guess to upgrade on the stable branch if we upgrade we would have to
tweak converters to maintain the old format. I know it seems a bit silly to
maintain a bug but I think its the safest way forward.

Yeah I agree on stable it’s not an option. Hopefully the rest
collection converter seems to be isolated enough as to make the
backwards compatible change in there, if we had to upgrade jettison on
stable too.
Personally I’m not in a rush, would just need to upgrade jettison when
the time comes to backport the gwc integration improvements. By that
time I’ll make sure to propose a patch for review.
Back on to trunk, do you have a timeline for the root element name drop?

Cheers,
Gabriel

$0.02

-Justin

On Dec 26, 2011 12:00 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

Due to a bug in Jettison 1.0.1, serializing and deserializing
collections is broken <http://jira.codehaus.org/browse/JETTISON-48>

Here’s a test that demonstrates the issue:

package org.geoserver.rest.format;

public class ReflectiveJSONFormatTest extends TestCase {

@anonymised.com({ “unchecked”, “rawtypes” })
public void testFoo() throws Exception {

ReflectiveJSONFormat format = new ReflectiveJSONFormat();

Foo foo = new Foo(“list”, 2, 3.0, new
ArrayList(Arrays.asList(1L, 2.5D)));

ByteArrayOutputStream output = new ByteArrayOutputStream();
format.write(foo, output);

Object read = format.read(new
ByteArrayInputStream(output.toByteArray()));

assertTrue(read instanceof Foo);
Foo foo2 = (Foo) read;
assertEquals(foo.getList(), foo2.getList());
assertEquals(foo.getProp1(), foo2.getProp1());
assertEquals(foo.getProp2(), foo2.getProp2());
assertEquals(foo.getProp3(), foo2.getProp3());
}
}

The test fails at the first assert. (Have added a list property to the
org.geoserver.rest.Foo test object).

The generated JSON with the current Jettison version is
Jettison 1.0.1:

{“org.geoserver.rest.Foo”:{“list”:{“int”:[1],“double”:2.5},“prop1”:“list”,“prop2”:2,“prop3”:3}}

The generated JSON with Jettison 1.3 (latest release) is:
Jettison 1.3:

{“org.geoserver.rest.Foo”:{“list”:[{“int”:1,“double”:2.5}],“prop1”:“list”,“prop2”:2,“prop3”:3}}

As you can see, the currently generated value of the “list” attribute
is not a json array as it should be, whilst the Jettison 1.3 one is.

Upgrading to Jettison 1.3 breaks some restconfig tests though, because
they’re asserting the “incorrect” format is being generated.
For instance:
org.geoserver.catalog.rest.WorkspaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.DataStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.CoverageStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.NamespaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.WMSStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.StyleTest.testGetAllAsJSON

Take for example WorkspaceTest.testGetAllAsJSON
The GET request produces:

{“workspaces”:{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}}

while Jettison 1.3 produces:

{“workspaces”:[{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}]}

In the second case, “workspaces” is in itself an array. And that’s
correct because the object being encoded is a List.

So the question is, is there any chance we can upgrade to Jettison 1.3
and fix those tests? Would it be too risky a REST api breakage?
I would like to upgrade and get rid of that Jettison bug because it is
very much needed in order to work with the gwc configuration that
collection properties are properly encoded and decoded when they
contain polymorphic elements, which currently is impossible.

TIA,
Gabriel


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Resurrecting this old thread a bit...

On Mon, Dec 26, 2011 at 3:36 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Yeah I like the idea of versioning the rest API since at some point we will
have to undoubetly make non backward compatible changes. So yeah I guess we
could call this api version 1 and then if we want to make breaking changes
on the trunk push it to 2. It would be nice to have at least one release of
a deprecation cycle though.

Yeah, by versioning the REST API I mean if GeoServer release N
supports rest api version M, GeoServer N+1 should support at least
rest api M _and_ M+1.
Is that what you mean?

Back to the original topic, if I wanted to upgrade the Jettison
version on trunk, would we also need a patch that preserves the old
collections encoding behavior, or would you be up to "fixing" it right
now?

Cheers,
Gabriel

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

On Tue, Jan 24, 2012 at 1:25 PM, Gabriel Roldan <groldan@anonymised.com> wrote:

Resurrecting this old thread a bit…

On Mon, Dec 26, 2011 at 3:36 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Yeah I like the idea of versioning the rest API since at some point we will
have to undoubetly make non backward compatible changes. So yeah I guess we
could call this api version 1 and then if we want to make breaking changes
on the trunk push it to 2. It would be nice to have at least one release of
a deprecation cycle though.

Yeah, by versioning the REST API I mean if GeoServer release N
supports rest api version M, GeoServer N+1 should support at least
rest api M and M+1.
Is that what you mean?

Yes, more or less.

Back to the original topic, if I wanted to upgrade the Jettison
version on trunk, would we also need a patch that preserves the old
collections encoding behavior, or would you be up to “fixing” it right
now?

Well this is not set in stone but I think we should first “deprecate” the old structure in a stable release. So yes on trunk I would like to see the upgrade happen with a patch that preserves the old structure via a flag that is enabled by default.

In the documentation we should deprecate the old collection representations as well.

-Justin

Cheers,

Gabriel


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


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

On Tue, Jan 24, 2012 at 7:28 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

On Tue, Jan 24, 2012 at 1:25 PM, Gabriel Roldan <groldan@anonymised.com> wrote:

Resurrecting this old thread a bit...

On Mon, Dec 26, 2011 at 3:36 PM, Justin Deoliveira <jdeolive@anonymised.com>
wrote:
> Yeah I like the idea of versioning the rest API since at some point we
> will
> have to undoubetly make non backward compatible changes. So yeah I guess
> we
> could call this api version 1 and then if we want to make breaking
> changes
> on the trunk push it to 2. It would be nice to have at least one release
> of
> a deprecation cycle though.
Yeah, by versioning the REST API I mean if GeoServer release N
supports rest api version M, GeoServer N+1 should support at least
rest api M _and_ M+1.
Is that what you mean?

Yes, more or less.

Back to the original topic, if I wanted to upgrade the Jettison
version on trunk, would we also need a patch that preserves the old
collections encoding behavior, or would you be up to "fixing" it right
now?

Well this is not set in stone but I think we should first "deprecate" the
old structure in a stable release. So yes on trunk I would like to see the
upgrade happen with a patch that preserves the old structure via a flag that
is enabled by default.

yeah, that's what I thought as well. Cool then, will make sure to
provide a patch that preserves the current encoding.

Cheers,
Gabriel

In the documentation we should deprecate the old collection representations
as well.

-Justin

Only just seeing this, but a big +1 to versioning our REST API interface. It’d be good for people to know what they’re working against, and to have us commit to things being very stable, but have us able to upgrade when we do want to make changes.

On Mon, Dec 26, 2011 at 1:36 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Yeah I like the idea of versioning the rest API since at some point we will have to undoubetly make non backward compatible changes. So yeah I guess we could call this api version 1 and then if we want to make breaking changes on the trunk push it to 2. It would be nice to have at least one release of a deprecation cycle though.

On Dec 26, 2011 11:13 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

btw, it just occurred to me whether versioning the rest api somehow
would be a good thing and feasible.
Google’s first answer is at
<http://stackoverflow.com/questions/389169/best-practices-for-api-versioning>

In an ideal world geoserver version X would support REST api verson Z
and Z-1, and there would be a document explaining the api changes
between Z and Z-1.

Do you think that’s something worth pursuing?

Cheers,
Gabriel

On Mon, Dec 26, 2011 at 2:42 PM, Gabriel Roldan <groldan@anonymised.com> wrote:

On Mon, Dec 26, 2011 at 2:01 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Hey gabriel,

Thanks for the detailed explanation. Unfortunately I don’t think it is an
option to change the rest API serialization format on the stable branch.
There is just too much code out there written against it. I would be OK with
doing it on the trunk though. Actually this sort of aligns with another api
change I have been thinking about and that is to have then root node of an
object dropped in a collection:

http://xstream.codehaus.org/json-tutorial.html#json-dropping-root

So I guess to upgrade on the stable branch if we upgrade we would have to
tweak converters to maintain the old format. I know it seems a bit silly to
maintain a bug but I think its the safest way forward.

Yeah I agree on stable it’s not an option. Hopefully the rest
collection converter seems to be isolated enough as to make the
backwards compatible change in there, if we had to upgrade jettison on
stable too.
Personally I’m not in a rush, would just need to upgrade jettison when
the time comes to backport the gwc integration improvements. By that
time I’ll make sure to propose a patch for review.
Back on to trunk, do you have a timeline for the root element name drop?

Cheers,
Gabriel

$0.02

-Justin

On Dec 26, 2011 12:00 AM, “Gabriel Roldan” <groldan@anonymised.com> wrote:

Due to a bug in Jettison 1.0.1, serializing and deserializing
collections is broken <http://jira.codehaus.org/browse/JETTISON-48>

Here’s a test that demonstrates the issue:

package org.geoserver.rest.format;

public class ReflectiveJSONFormatTest extends TestCase {

@anonymised.com({ “unchecked”, “rawtypes” })
public void testFoo() throws Exception {

ReflectiveJSONFormat format = new ReflectiveJSONFormat();

Foo foo = new Foo(“list”, 2, 3.0, new
ArrayList(Arrays.asList(1L, 2.5D)));

ByteArrayOutputStream output = new ByteArrayOutputStream();
format.write(foo, output);

Object read = format.read(new
ByteArrayInputStream(output.toByteArray()));

assertTrue(read instanceof Foo);
Foo foo2 = (Foo) read;
assertEquals(foo.getList(), foo2.getList());
assertEquals(foo.getProp1(), foo2.getProp1());
assertEquals(foo.getProp2(), foo2.getProp2());
assertEquals(foo.getProp3(), foo2.getProp3());
}
}

The test fails at the first assert. (Have added a list property to the
org.geoserver.rest.Foo test object).

The generated JSON with the current Jettison version is
Jettison 1.0.1:

{“org.geoserver.rest.Foo”:{“list”:{“int”:[1],“double”:2.5},“prop1”:“list”,“prop2”:2,“prop3”:3}}

The generated JSON with Jettison 1.3 (latest release) is:
Jettison 1.3:

{“org.geoserver.rest.Foo”:{“list”:[{“int”:1,“double”:2.5}],“prop1”:“list”,“prop2”:2,“prop3”:3}}

As you can see, the currently generated value of the “list” attribute
is not a json array as it should be, whilst the Jettison 1.3 one is.

Upgrading to Jettison 1.3 breaks some restconfig tests though, because
they’re asserting the “incorrect” format is being generated.
For instance:
org.geoserver.catalog.rest.WorkspaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.DataStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.CoverageStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.NamespaceTest.testGetAllAsJSON
org.geoserver.catalog.rest.WMSStoreTest.testGetAllAsJSON
org.geoserver.catalog.rest.StyleTest.testGetAllAsJSON

Take for example WorkspaceTest.testGetAllAsJSON
The GET request produces:

{“workspaces”:{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}}

while Jettison 1.3 produces:

{“workspaces”:[{“workspace”:[{“name”:“cite”,“…”},{“name”:“cgf”,“…”},{“name”:“sf”,“…”},{“name”:“gs”,“…”},{“name”:“cdf”,“…”}]}]}

In the second case, “workspaces” is in itself an array. And that’s
correct because the object being encoded is a List.

So the question is, is there any chance we can upgrade to Jettison 1.3
and fix those tests? Would it be too risky a REST api breakage?
I would like to upgrade and get rid of that Jettison bug because it is
very much needed in order to work with the gwc configuration that
collection properties are properly encoded and decoded when they
contain polymorphic elements, which currently is impossible.

TIA,
Gabriel


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev


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