AnsweredAssumed Answered

Prefill data, rules and/or execute actions on Site Creation

Question asked by iblanco on Aug 17, 2010
Latest reply on Sep 25, 2010 by iblanco
I'm developing a custom Site preset. I've already defined the preset and the "placeholders" for the future custom components and dashlets, as well as the "out of the box" ones required in the site. So far so good.

Now I would like some data and some behaviour or rules automatically applied to some of the folders in the Site when it is created. I've a couple of approaches on mind for solving the problem but I don't feel very confortable with them, and they do have some caveats. I wonder if there isn't a cleaner way to do it.

First approach
Site's main folders have property "{http://www.alfresco.org/model/site/1.0}sitePreset" so I could make a rule for /Company Home/Sites folder that fires when a folder with the id of my preset is created. Other different but similar approach would be defining a Behaviour that is attached to "{http://www.alfresco.org/model/site/1.0}site" type's creation. The former seems easier if the action to be executed is a script and the later seems easier if yout intend to fire heavy "Java" actions. The second approach also seems easier to "install" as I don't know a easy way to bootstrap a rule to an already existing folder (is it possible at all?).

Once the Java action or Javascript launches we could just copy the required data. Each component's folder does not exist until it is first time accesed, so we would probably have to create them, but not like normal folders but using the Site's service API, other ways the Site might become corrupt.
But… what about the content ? AFAIK there is not such a thing as the "Site Discussion API" or the "Site Blog API".

Copying normal cm:content to the document library is said to work, but what about discussions, blogs or wikis ? Would it be possible just to have a "template" and copy it in place ?

In order to make this right we could call the same API's that Share calls. Does it make any sense ? Could the repository itself "call itself" ?

Second approach
The second approach would be making an "invisible" dashlet appear in the Site's dashboard. The only use of the dashlet would be executing the required actions to prefill the Site's content as soon as it is executed. The main "advantage" here is that we are requesting at the "Share" site so we could use the "remote" object to call the required APIs and generate all the content.
This idea has severarl tricks or gotchats:

    We have to control if it is the first executio, maybe with an aspect set in the site folder or even better, if it is possible, by taking out the dashlet by itself after execution.
    The dashlet would probably appear as an option to the person customizing the site.
    This smells like a really really really nasty hack
Buff, it's been a long post…. So… What do you think ? Does any of those approaches sound reasonable to you ?

Outcomes