Fórum

After deploy event?

thumbnail
Florencia Gadea, modificado 11 Anos atrás.

After deploy event?

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
Hi Everyone!

I would like to run some code after a portlet is deployed.

Is there something like an after deploy event?

If not, how can I achieve this?

Regards,

Flor.
thumbnail
Jan Geißler, modificado 11 Anos atrás.

RE: After deploy event?

Liferay Master Postagens: 735 Data de Entrada: 05/07/11 Postagens Recentes
http://www.liferay.com/de/documentation/liferay-portal/6.1/user-guide/-/ai/startup-even-1

application.startup.events=*.*.*.StartupHook



public class StartupHook extends SimpleAction
@Override
	public void run(String[] companyIds) throws ActionException



This should get you on track.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: After deploy event? (Resposta)

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
There is no 'after deploy event'. However, as Jan pointed out you can use the startup event. To get it to be one time only, you should do some sort of query to check whether you've already completed the actions previously.
thumbnail
Florencia Gadea, modificado 11 Anos atrás.

RE: After deploy event?

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
That is a great idea David. Any idea about how to check if the action has been executed previously? Should I store a property in the database? Is there a specific table to do that? Or should I create my own entity?

Regards,

Flor.
thumbnail
Jan Geißler, modificado 11 Anos atrás.

RE: After deploy event? (Resposta)

Liferay Master Postagens: 735 Data de Entrada: 05/07/11 Postagens Recentes
Even if I am not David ;)

EG. If you want to add some USers in your StratupAction, you could check if the Users already exist in the Database, and stop executing the if the user is already there.

Regards
thumbnail
Florencia Gadea, modificado 11 Anos atrás.

RE: After deploy event?

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
Thanks Jan, that will do!
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: After deploy event?

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
Liferay does have a Release object and corresponding ReleaseLocalServiceUtil that you can use... It's not as rigid as the parameters would tend to indicate...

You could use:

Release release = ReleaseLocalServiceUtil.getRelease("my-plugin", 1);


to see if your release is there. If not, you'd do:

release = ReleaseLocalServiceUtil.addRelease("my-plugin", 1);

and then invoke your startup code.

You could even handle upgrades in a similar way. If you're checking for ("my-plugin", 5) but don't find it, you can step backwards to see if there was a previous release already deployed, then handle upgrades from the previous version up to 5, then use:

release = ReleaseLocalServiceUtil.updateRelease(release.getReleaseId(), 5, buildDate, true);


so that your one release entry is updated to be build 5...

Liferay uses a 4 digit release value, i.e. 6012 to indicate it is 6.0 sp 12 or 6.0 EE...
thumbnail
Florencia Gadea, modificado 11 Anos atrás.

RE: After deploy event?

Regular Member Postagens: 146 Data de Entrada: 27/03/12 Postagens Recentes
Thanks David, really useful information.
thumbnail
Jan Geißler, modificado 11 Anos atrás.

RE: After deploy event?

Liferay Master Postagens: 735 Data de Entrada: 05/07/11 Postagens Recentes
Hey. I didn't think of that till now. Thanks for this valuable information ;)
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: After deploy event?

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
Most devs aren't really aware that they can use the release stuff also...