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]>
----------------------------------------------------------------

Reply via email to