Dan Hankins
Dan Hankins

Reputation: 193

Can I run code at Alfresco startup?

I have an Alfresco module that I would like to have do some cleanup when a new version of it is installed.

In the current situation, an older version of the module created a folder node with custom properties at the root of the repository. We've since decided to have multiple such nodes, and none of them at that location. I'd like to put into the next version of the module code that would run at Alfresco startup, check for the existence of the old node, copy its properties into the appropriate new nodes, and delete the old node.

Is such a thing possible? I've looked at the Bootstrap configuration file, but that appears to only allow one to add things to the repository, not modify or delete them.

Upvotes: 1

Views: 541

Answers (3)

Vikash Patel
Vikash Patel

Reputation: 1346

You can use patches. When alfresco server starts it applies patches and executes database updates etc.

Definition :

A patch is a piece of Java code that executes once when Alfresco Content Services starts. Custom patches can be implemented.

Documentation Link

Upvotes: 1

billerby
billerby

Reputation: 1978

My suggestion is that you write a patch. That is a class that implements org.alfresco.repo.admin.patch.AbstractPatch

Then you can do pretty much anything you want on bootstrap (except executing searches against solr since it wont be available).

Add some spring configuration, take a look at the file patch-services-context.xml for inspiration.

Upvotes: 3

Teqnology
Teqnology

Reputation: 1298

Yes you can do that, probably you missed the correct place in the documentation about that:

If you open Import Strategy you'll find a section Per BootstrapView, you should be using something like REPLACE_EXISTING or UPDATE_EXISTING for your ACP packaged content (if you're using ACPs as your bootstrap importing strategy).

Here is a more detailed description of the UUID Bindings values.

Hope that helps.

Upvotes: 2

Related Questions