|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Storing extension elements using JCR ProviderHello All,
I have a quick question on the best way to store custom extension elements, using the JCR provider. It seems that the data is exposed as a FOM object at AbstractEntityCollectionAdaptor line 140 (see below) If we have extension elements we wish to store in the feed entry, should we extend the JCR provider and implement our own postEntry method, that retrieves these elements from the FOM and passes it to another method that adds these entries to the JCR node? Also, has anyone had any thoughts on a generic way to do this, it seems like a generic solution of adding any extensions to the node that are present and that have the handler registered might be a good thing, is there any downside anyone knows if we do this? Thanks in advance, Chris <code> public ResponseContext postEntry(RequestContext request) { try { Entry entry = getEntryFromRequest(request); if (entry != null) { if (!ProviderHelper.isValidEntry(entry)) return new EmptyResponseContext(400); entry.setUpdated(new Date()); T entryObj = postEntry(entry.getTitle(), entry.getId(), entry.getSummary(), entry.getUpdated(), entry.getAuthors(), entry.getContentElement(), request); entry.getIdElement().setValue(getId(entryObj)); IRI feedIri = getFeedIRI(entryObj, request); String link = getLink(entryObj, feedIri, request); entry.addLink(link, "edit"); return buildCreateEntryResponse(link, entry); } else { return new EmptyResponseContext(400); } } catch (ResponseContextException e) { return createErrorResponse(e); } } </code> _______________________________________________ Chris Stevenson LDN Cross Derivative Technology RC06 | 8-7051-0148 |
|
|
Re: Storing extension elements using JCR ProviderHi Christopher,
I'd like to extend JcrCollectionAdapter so that we can do this. My idea is that we just loop through ever element in the atom entry and serialize any ones which are not recognized (i.e. your custom extensions). In the mean time you could actually write your own code which looks for your own custom elements by overriding mapEntryToNode. I just realized that it was private though - so I changed the trunk/ code to make it protected. Inerested in helping with a patch to make generic code that does this? Dan On Tue, Jun 24, 2008 at 8:28 PM, Stevenson, Christopher < Christopher.Stevenson@...> wrote: > Hello All, > > > > I have a quick question on the best way to store custom extension > elements, using the JCR provider. > > > > It seems that the data is exposed as a FOM object at > AbstractEntityCollectionAdaptor line 140 (see below) > > > > If we have extension elements we wish to store in the feed entry, should > we extend the JCR provider and implement our own postEntry method, that > retrieves these elements from the FOM and passes it to another method > that adds these entries to the JCR node? > > > > Also, has anyone had any thoughts on a generic way to do this, it seems > like a generic solution of adding any extensions to the node that are > present and that have the handler registered might be a good thing, is > there any downside anyone knows if we do this? > > > > Thanks in advance, > > > > Chris > > > > <code> > > > > public ResponseContext postEntry(RequestContext request) { > > try { > > Entry entry = getEntryFromRequest(request); > > if (entry != null) { > > if (!ProviderHelper.isValidEntry(entry)) > > return new EmptyResponseContext(400); > > > > entry.setUpdated(new Date()); > > > > > > T entryObj = postEntry(entry.getTitle(), > > entry.getId(), > > entry.getSummary(), > > entry.getUpdated(), > > entry.getAuthors(), > > entry.getContentElement(), request); > > entry.getIdElement().setValue(getId(entryObj)); > > > > IRI feedIri = getFeedIRI(entryObj, request); > > String link = getLink(entryObj, feedIri, request); > > > > entry.addLink(link, "edit"); > > > > return buildCreateEntryResponse(link, entry); > > } else { > > return new EmptyResponseContext(400); > > } > > } catch (ResponseContextException e) { > > return createErrorResponse(e); > > } > > } > > </code> > > > > > > _______________________________________________ > Chris Stevenson > LDN Cross Derivative Technology > RC06 | 8-7051-0148 > > -- Dan Diephouse http://mulesource.com | http://netzooid.com/blog |
| Free Forum Powered by Nabble | Forum Help |