abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Abley" <james.ab...@gmail.com>
Subject Feedback from implementing an AtomPub(-like!) server on top of JCR
Date Wed, 30 Jul 2008 21:03:06 GMT
Hi,

I've got my first version up and running. It does POST of media assets
to a collection, GET of entries and PUT of the same entries.

Just some observations which most likely are due to my lack of
experience with the code base. I extended
AbstractEntityCollectionAdapter, so all of my comments relate to this
class.

1. I overrode getHref(RequestContext) like so:

    /
     * {@inheritDoc}
     */
    @Override
    public String getHref(RequestContext request) {

        /*
         * FIXME We override the default implementation to ensure that
variables bound for parameter substitution are
         * available for URI Templates / Routes.
         */
        Map<String, String> params = new HashMap<String, String>();

        Target target = request.getTarget();

        for (String param : target.getParameterNames()) {
            params.put(param, target.getParameter(param));
        }

        return request.urlFor("feed", params);
    }

Otherwise I was getting back links like

/contextpath/base//

rather than

/contextpath/base/workspace/collection-name

I'm not sure what I'm missing here. I should be able to submit a test
case and maybe patch if it is a genuine problem, although I used JMock
rather than EasyMock.

2. When I GET an Media Link Entry, I'm getting a <source/> element in
the output document.

I had to override the following methods to get this to work happily.

    /**
     * {@inheritDoc}
     */
    @Override
    public String getAuthor(RequestContext request) throws
ResponseContextException {

        /* FIXME this is called when a <source/> is set during a GET request. */
        return "author-goes-here";
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getId(RequestContext request) {

        /* FIXME this is called when a <source/> is set during a GET request. */
        return "id-goes-here";
    }

    /**
     * {@inheritDoc}
     */
    public String getTitle(RequestContext request) {

        /* FIXME this is called when a <source/> is set during a GET request. */
        return "title-goes-here";
    }


For my use case, I'm not that bothered about a <source/> and I'm not
completely sure why it only happens on a GET to that resource, but the
POST of the media entity to the collection does not contain the
<source/> in the response body.

3.     public void putEntry(T entry, String title, Date updated,
List<Person> authors, String summary,
            Content content, RequestContext request) throws
ResponseContextException {

This method does not get passed the FOMEntry, so I wasn't sure how to
get hold of the extension XML in the request body. In the end, I went
for the following:

    /**
     * {@inheritDoc}
     */
    @Override
    protected Entry getEntryFromRequest(RequestContext request) throws
ResponseContextException {
        /* FIXME the Entry isn't passed into putEntry, so stick it in
the request context for now. */

        Entry result = super.getEntryFromRequest(request);

        request.setAttribute(Entry.class.getName(), result);

        return result;
    }

I think that reading and writing extension elements could do with
documenting on the wiki. I found stuff from the example code and
google, but it seems sensible to put it on the wiki. I don't have
write access (I think) but I'm happy to draft my newbie experiences in
the hope that it will be coherent / correct enough to help others.

Summing up, a really nice library to use. Thanks guys.

Cheers,

James

Mime
View raw message