You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Phillip Green <Ph...@mail.wvu.edu> on 2007/06/21 15:26:32 UTC

Overwriting usecases for a particular resource type

I have created a resource type that has a slightly different method of publishing.  In my publication menu, I have the default sitemanagement usecases.  Is there anyway I can overwrite sitemanagement.publish for one particular usecase without having to create a custom menu option?  and not effecting the usecase so other resource types can still use it?

Thanks,
Phillip


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Overwriting usecases for a particular resource type

Posted by Andreas Hartmann <an...@apache.org>.
Hi Phillip,

Phillip Green schrieb:
> I have created a resource type that has a slightly different method
> of publishing.  In my publication menu, I have the default
> sitemanagement usecases.  Is there anyway I can overwrite
> sitemanagement.publish for one particular usecase without having to
> create a custom menu option?  and not effecting the usecase so other
> resource types can still use it?

unfortunately that's not configurable.

Basically there are two approaches:

a) Declare another usecase (sitemanagement.publish.myresourcetype),
   use an if/else statement in the menu.xsp to select the appropriate
   menu item based on the current document's resource type

b) Extract the publishing functionality into separate classes and call
   them from the Publish usecase handler according to the resource
   type of the source document

Maybe option a) requires to change the configuration of the
worlflow.multiWorkflow usecase. Apart from that, you have to update
your usecase-policies.xml.

BTW, I can imagine that your requirement is quite typical, maybe you'd
like to file an enhancement bug?
It could be useful to support generic resource type parameters,
e.g.

  <resource-types>
    <component-instance name="foo" ... >
      <parameter name="publishUsecase"
                 value="sitemanagement.publishFoo"/>
    </component-instance>
  </resource-types>

  interface ResourceType {
      ...
      String[] getParameterNames();
      String getParameter(String name);
      String getParameter(String name, String defaultValue);
  }

And in the menu XSP you could use:

  String usecase = doc.getResourceType().getParameter(
      "publishUsecase", "sitemanagement.publish");
  <menu:item>
    <xsp:attr name="uc:usecase">
      <xsp:expr>usecase</xsp:expr>
    </xsp:attr>
  </menu:item>

If you'd like to implement this, a patch would be very welcome.


HTH,

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org