---------- Forwarded message ----------
From: Asiri Rathnayake <[EMAIL PROTECTED]>
Date: Thu, Oct 9, 2008 at 2:09 PM
Subject: Re: [xwiki-notifications] r13428 - in sandbox/xwiki-webdav/src:
main/java/com/xpn/xwiki/plugin/webdav/resources/views
main/java/com/xpn/xwiki/plugin/webdav/resources/views/pages
test/java/com/xpn/xwiki/plugin/webdav/tests
To: XWiki Notifications <[EMAIL PROTECTED]>


Hi Vincent, Sergiu and all,

I will try to explain the need to componetize xwiki-webdav. May be we
shouldn't componetize xwiki-webdav after all ;)

Following is the way we lookup for a base-view (a particular view of an
xwiki-repository). Basically, when a request comes for a particular url, we
take the corresponding segment of the url (nextToken here), append
"-baseview" and lookup for a component with that ROLE_HINT. If found, we'll
handover the job to that component.


> +            XWikiDavResource resource = null;
> +            try {
> +                resource =
> +                    (XWikiDavResource) getComponentManager()
> +                        .lookup(ROLE, nextToken + "-baseview");
> +                resource.init(this, nextToken, "/" + nextToken);
> +                stack.push(resource);
> +                resource.decode(stack, tokens, next + 1);
> +            } catch (ComponentLookupException e) {
> +                throw new
> DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e);
>


Bellow is where we list the set of possible views. for this i need to filter
out only those views which has the "-baseview" id appended to their role
hint. This is why i added the getRoleHint() method into the component
interface.

The use of this approach is, if someone need to add a new view, he simply
have to extend the XWikiDavResource interface and have the ROLE_HINT ending
like "-baseview", nothing else.

The other approach is to manually load each base view using lookup("role",
"role-hint") but in this case, the developer of the new view will have to
change the RootView's code to load his view along with the rest of base
views.


>
> +            List<XWikiDavResource> viewsList =
> getComponentManager().lookupList(ROLE);
> +            for (XWikiDavResource view : viewsList) {
> +                String componentHint = view.getRoleHint();
> +                int dash = componentHint.lastIndexOf('-');
> +                if (componentHint.endsWith("-baseview")) {
> +                    String name = componentHint.substring(0, dash);
> +                    view.init(this, name, "/" + name);
> +                    children.add(view);
> +                }
> +            }
> +        } catch (ComponentLookupException e) {
> +            LOG.error("Unexpected Error : ", e);
>


May be this is a wrong approach. And yes, XWikiDavResource is not a business
interface. But I think this increases the extensibility / flexibility of
xwiki-webdav. To add a new view, (as i said before) extend XWikiDavResourve
and end your ROLE_HINT with "-baseview". To remove an existing view, simply
remove the "-baseview" part from your components.xml configuration file,
that's it.

I would like to know your thoughts. And i can revert these changes if
necessary.

Thanks.

- Asiri
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to