[Yanel-development] YanelServlet.java and ViewableV2 interface
Paloma Gomez
paloma.gomez at wyona.com
Fri Dec 1 18:01:13 CET 2006
Hi all,
I have to implement a "size" attribute similar to the "last-modified"
attribute (e.g.
http://yanel.wyona.org/mailing-lists.html?yanel.resource.meta).
I was thinking of adding a getSize() method to the ViewableV2 interface.
However, with the current implementation of YanelServlet.java that
wouldn't work.
[code: YanelServlet.java method: getContent()]
[...]
if (ResourceAttributeHelper.hasAttributeImplemented(res, "Viewable", "1")) {
Element viewElement = (Element)resourceElement.appendChild(
doc.createElement("view"));
viewElement.appendChild(doc.createTextNode(
"View Descriptors: " + ((ViewableV1) res).getViewDescriptors()));
String viewId = request.getParameter("yanel.resource.viewid");
try {
view = ((ViewableV1) res).getView(request, viewId);
} catch(org.wyona.yarep.core.NoSuchNodeException e)
[...]
} else if (ResourceAttributeHelper.hasAttributeImplemented(res,
"Viewable", "2")) {
log.error("DEBUG: Resource is viewable V2");
String viewId = request.getParameter("yanel.resource.viewid");
((ViewableV2) res).getView(request, response, viewId);
//In the case of ViewableV2 processing stops here:
return;
} else {
[...]
//If the resource implements ViewableV1, processing continues
//And the meta data is displayed to the user if it has been requested
String meta = request.getParameter("yanel.resource.meta")
if (meta != null) {
if (meta.length() > 0) {
log.error("DEBUG: meta length: " + meta.length());
} else {
log.error("DEBUG: Show all meta");
}
response.setStatus(javax.servlet.http.HttpServletResponse.SC_OK);
setYanelOutput(response, doc);
return;
}
[/code]
My first idea was to modify ViewableV2 part to make it behave similarly to
the ViewableV1 part. However, I'm not sure if it might have side effects
and I don't like this solution very much either. WDYT?
I don't like that solution because I wonder what will happen with this
method in the future, when there might be dozens of versions of different
interfaces.
I know that one of our goals is to maintain backwards compatibility, and I
agree that compatibility is an important issue. However, imho we should
try to find a solution for the future.
Thanks,
Paloma
More information about the Yanel-development
mailing list