poke object graph through the REST API #54

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@cbeer
Member

cbeer commented May 3, 2013

This is just a thought exercise to poke SPARQL/UPDATE queries through the REST API and have them modify object properties. Obviously a lot of things wrong with this, but hey, it actually seems to (mostly) work.

cc: @ajs6f

+import static org.slf4j.LoggerFactory.getLogger;
+
+@Component
+@Path("/rest/{path: .*}/fcr:graph")

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

@ajs6f I couldn't get this to play nice as a part of the FedoraNodes routing.. it seemed like some of the IT requests were hitting the rdf-producing endpoints instead of the object profile one..

@cbeer

cbeer May 8, 2013

Member

@ajs6f I couldn't get this to play nice as a part of the FedoraNodes routing.. it seemed like some of the IT requests were hitting the rdf-producing endpoints instead of the object profile one..

This comment has been minimized.

@ajs6f

ajs6f May 8, 2013

Member

I have no idea what FedoraNodes is/does, so I'll start there. More soon.

@ajs6f

ajs6f May 8, 2013

Member

I have no idea what FedoraNodes is/does, so I'll start there. More soon.

This comment has been minimized.

@ajs6f

ajs6f May 8, 2013

Member

Okay, FedoraNodes seems to be the endpoint formerly known as "fcr:describe". It's not clear to me why there's any difficulty-- you're not doing anything that plenty of other working endpoints aren't doing. What exactly are the paths that are failing?

@ajs6f

ajs6f May 8, 2013

Member

Okay, FedoraNodes seems to be the endpoint formerly known as "fcr:describe". It's not clear to me why there's any difficulty-- you're not doing anything that plenty of other working endpoints aren't doing. What exactly are the paths that are failing?

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

Maybe this is a question for @barmintor then..

When I tried to put this method in FedoraNodes, several of the integration tests (perhaps all of them?) that tried to get the ObjectProfile or DatastreamProfile XML/JSON responses were getting this response instead. I assume in the absence of an Accept header, JAX-RS magically chooses a response, and ended up choosing wrong.

Maybe this isn't a problem in the long term (if we kill of those profile responses), but was more than I wanted to bite off..

@cbeer

cbeer May 8, 2013

Member

Maybe this is a question for @barmintor then..

When I tried to put this method in FedoraNodes, several of the integration tests (perhaps all of them?) that tried to get the ObjectProfile or DatastreamProfile XML/JSON responses were getting this response instead. I assume in the absence of an Accept header, JAX-RS magically chooses a response, and ended up choosing wrong.

Maybe this isn't a problem in the long term (if we kill of those profile responses), but was more than I wanted to bite off..

+
+
+
+ List<Variant> possibleResponseVariants =

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

Yuck. Help?

@cbeer

cbeer May 8, 2013

Member

Yuck. Help?

This comment has been minimized.

@barmintor

barmintor May 8, 2013

Member

Are you trying to avoid reproducing the array of contentType strings? I could push a kind of goofy bit of reflection that pulls the values out of the Produces annotation.

@barmintor

barmintor May 8, 2013

Member

Are you trying to avoid reproducing the array of contentType strings? I could push a kind of goofy bit of reflection that pulls the values out of the Produces annotation.

This comment has been minimized.

@ajs6f

ajs6f May 8, 2013

Member

Ditto Ben's question, and if these two guys should always be the same, might we not define them somewhere else and just use the definition twice?

@ajs6f

ajs6f May 8, 2013

Member

Ditto Ben's question, and if these two guys should always be the same, might we not define them somewhere else and just use the definition twice?

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

Well:

  • is there a better way to just ask JAX-RS "what accept header made you choose this route anyway?"
  • is there some standard way to just say "just take this string and make a media type out of it?"

Maybe I've missed something in Jena too that'd make this less annoying..

@cbeer

cbeer May 8, 2013

Member

Well:

  • is there a better way to just ask JAX-RS "what accept header made you choose this route anyway?"
  • is there some standard way to just say "just take this string and make a media type out of it?"

Maybe I've missed something in Jena too that'd make this less annoying..

This comment has been minimized.

@ajs6f

ajs6f May 8, 2013

Member

You can context-inject the request and inspect it. That's a clean two-liner.

And yes, there's MediaType.valueOf(type).

@ajs6f

ajs6f May 8, 2013

Member

You can context-inject the request and inspect it. That's a clean two-liner.

And yes, there's MediaType.valueOf(type).

+ try {
+ Node node = session.getNode(path);
+
+ final FedoraObject object = objectService.getObject(node.getSession(), path);

This comment has been minimized.

@barmintor

barmintor May 8, 2013

Member

Is there a reason to get the node first, and then pass the session in? I think you could just pass the session in and let the objectService find the node, right?

@barmintor

barmintor May 8, 2013

Member

Is there a reason to get the node first, and then pass the session in? I think you could just pass the session in and let the objectService find the node, right?

This comment has been minimized.

@ajs6f

ajs6f May 8, 2013

Member

I think the pattern we're slowly coming to is "inject the Session as a field, then use it with the *Services".

@ajs6f

ajs6f May 8, 2013

Member

I think the pattern we're slowly coming to is "inject the Session as a field, then use it with the *Services".

This comment has been minimized.

@ajs6f

ajs6f May 8, 2013

Member

I'm not totally sure how JAX-RS context injection plays with anonymous classes... I wouldn't think there's any problem, tho'.

@ajs6f

ajs6f May 8, 2013

Member

I'm not totally sure how JAX-RS context injection plays with anonymous classes... I wouldn't think there's any problem, tho'.

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

I cribbed this from FedoraExport. We probably don't need to stream the response, but it was convenient.

@cbeer

cbeer May 8, 2013

Member

I cribbed this from FedoraExport. We probably don't need to stream the response, but it was convenient.

- - dc:title (STRING) COPY
+
+ - fedorarelsext:isPartOf (REFERENCE) multiple COPY
+ - * (STRING) multiple COPY

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

I never figured out how programmatically create new property types (for our nt:folder-type node, at least). Just going this was suggested in something I read... and I guess we'll want to do it for all the types eventually?

@cbeer

cbeer May 8, 2013

Member

I never figured out how programmatically create new property types (for our nt:folder-type node, at least). Just going this was suggested in something I read... and I guess we'll want to do it for all the types eventually?

@@ -23,6 +23,7 @@
*/
<fedora = 'info:fedora/'>
+<fedorarelsext = 'info:fedora/fedora-system:def/relations-external#'>

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

We're limited to valid QNames for prefixes.. Understandable, but kinda annoying.

@cbeer

cbeer May 8, 2013

Member

We're limited to valid QNames for prefixes.. Understandable, but kinda annoying.

@@ -23,6 +23,7 @@
*/

This comment has been minimized.

@cbeer

cbeer May 8, 2013

Member

This isn't in the diff, but earlier in this file we define these namespaces:

<jcr = 'http://www.jcp.org/jcr/1.0'>
<nt = 'http://www.jcp.org/jcr/nt/1.0'>
<mix = 'http://www.jcp.org/jcr/mix/1.0'>

I think the spec writers screwed up when defining the namespace, so we end up with properties (in formats that don't support namespaces, e.g. n-triples) like:

http://www.jcp.org/jcr/1.0versionHistory

@cbeer

cbeer May 8, 2013

Member

This isn't in the diff, but earlier in this file we define these namespaces:

<jcr = 'http://www.jcp.org/jcr/1.0'>
<nt = 'http://www.jcp.org/jcr/nt/1.0'>
<mix = 'http://www.jcp.org/jcr/mix/1.0'>

I think the spec writers screwed up when defining the namespace, so we end up with properties (in formats that don't support namespaces, e.g. n-triples) like:

http://www.jcp.org/jcr/1.0versionHistory

@cbeer

This comment has been minimized.

Show comment
Hide comment
@cbeer

cbeer May 9, 2013

Member

merged separately.

Member

cbeer commented May 9, 2013

merged separately.

@cbeer cbeer closed this May 9, 2013

@cbeer cbeer deleted the rdf-all-the-things branch May 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment