[Yanel-dev] Moving toward the node based repository interface
Josias Thöny
josias.thoeny at wyona.com
Mon Feb 19 18:08:24 CET 2007
Andreas Wuest wrote:
> Hi
>
> Here's a short summary of what we've discussed today with regard to the
> node based repository interface.
Thanks a lot for this summary.
>
> In the long and medium term, we would like to move to a node interface
> which contains typed properties (we already have that), and a default
> property (which we don't have yet). On those properties, getType() can
> be called to enquire for the property's type. If the type is e.g.
> binary, then getInputStream() should be called to retrieve its value, if
> the type is character, then getReader(), etc.
>
> The default property marks one of the properties as kind of "main". A
> node would also implement the Property interface, whose methods would be
> used as a shortcut to access the node's default property.
>
> When creating new nodes, not only should the creation method be
> parametrised with the distinction between collection and resource, but
> also with the content type (in case it is a resource). Subsequently, the
> correct method should be called to set the content of the default
> property, e.g. getOutputStream() for binary resources, getWriter() for
> character resources, etc.
>
> Since this would require some refactoring, we decided to just implement
> an isBinary() method on the node, in order to be able to decide if
> getInputStream() or getReader() should be called to read the content's
> of the resource.
I'm currently thinking about how to tell the repository whether a new
node is binary or not. I guess we have to inform the repository right at
creation time of a new node.
Would it be ok to pass and use the mime-type? The repository would have
to decide whether a certain mime-type is binary or textual.
Maybe we could enhance the addNode() method as follows:
public Node addNode(String name, int type, String mimeType);
(type would be either collection or resource)
Or should the caller specify explicitely whether it's binary or not:
public Node addNode(String name, int type, boolean isBinary);
Or would it be better to have dedicated methods:
public Node addCollectionNode(String name);
public Node addResourceNode(String name, String mimeType or boolean
isBinary);
To use the mime-type instead of a boolean isBinary might have some
advantages. The repository could e.g. store a text/plain document in a
different way than application/xml.
Moreoever it could be used to index binary documents like pdf or doc
(although this would not require to specify the mime-type at creation time).
But I'm not sure if it's easy to decide whether a given mime-type is
binary or textual.
WDYT?
Josias
> The downside of this is that we can only distinguish
> between character data and binary data, and therefore lose type
> information, if the repo back-end had provided some (e.g. using an SQL
> resource, whose values sport much finer-grained type information than
> only character and binary).
>
More information about the Yanel-development
mailing list