Hi Ernst,
sorry, there's no ActivationUtil at present. So far nobody really tried to
invoke activation on their own, but only via workflow or via context menu.
However there is a class called CommandManager that should give you
preconfigured command based on the command configuration in config repo.
Also please if you instantiate and execute commands manually, make sure you
call release() in the finally block after the execution ... not a big deal if
you throw away instance of the command after the execution, but it would be a
problem if you try to reuse it later.
HTH,
Jan
On Mar 29, 2011, at 11:17 AM, Ernst Bunders wrote:
> hello
>
> this topic has been visited a number of times on this list. But still I
> couldn't quite find the info that i was looking for, so here goes.
>
> We are using the simpleMedia module to manager our images, and we thought it
> would be a nice usability enhancement if images would auto-activate after
> uploading. We achieved this by using module life cycle management to register
> an observer on the media workspace (later we discovered the observer module
> that would have allowed us to do (some of) this in repository configuration).
> This was pretty straight forward. What we did find a bit daunting was the way
> we could figure out to activate content pro grammatically.
>
> We did this by creating our own ActivationCommand instance. We did it like so:
>
> ActivationCommand command = new ActivationCommand();
> command.setRepository("media");
> command.setRecursive(true);
> command.setUuid(node.getUUID());
> command.setRule(RULE);
>
> Syndicator syndicator =
> Components.getComponentProvider().newInstance(Syndicator.class);
> syndicator.init(
> MgnlContext.getUser(),
> command.getRepository(),
> ContentRepository.getDefaultWorkspace(command.getRepository()),
> RULE);
> command.setSyndicator(syndicator);
> command.execute(MgnlContext.getInstance());
>
> First we had to do something like
> MgnlContext.setInstance(MgnlContext.getSystemContext());
>
> As it turned out that the context was not set on the thread local. We created
> a Rule instance with no filters and 'reverse' to 'true'.
> Non of this was problematic, but we had the feeling that this was all a bit
> low level. It would seem that a lot of system knowledge goes into the above
> code, and i was actually surprised it was not easier than this.
>
> So i actually expect there to be a more high level way to do this. I sort of
> expected something like ActivationUtil, but no dice. Could anybody point me
> in the right direction on this one?
>
> regards,
>
> Ernst
> --
> Ernst Bunders
> Ontwikkelaar VPRO
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------