Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Lior Hadaya
Hook that runs once
13 août 2012 23:41
Réponse

Lior Hadaya

Rang: Regular Member

Publications: 138

Date d'inscription: 24 janvier 2012

Publications Récentes

Hi,

Is it possible to create a hook that runs only once? the closest thing I know is to create a hook that implements a startup action and runs each time the server starts up, but I wonder if there's a way to create a hook that will run just once upon deployment and that's it.
I want to write a hook that creates a few layouts and run it on newly installed servers.
(I'm using Liferay EE 6.1.10)

Thanks,
Lior
Bart Simpson
RE: Hook that runs once
14 août 2012 00:14
Réponse

Bart Simpson

Rang: Liferay Master

Publications: 524

Date d'inscription: 29 août 2011

Publications Récentes

I am not sure if there is a direct way to achieve this, may be check for certain values in db and then decide to continue execution in your hook. Something like the SevenCogs hook available from liferay itself. A cool idea would be to run the hook once, and then execute what is done via Control Panel -- Update plugins -- uninstall of a certain plugin.
David H Nebinger
RE: Hook that runs once
14 août 2012 06:25
Réponse

David H Nebinger

Community Moderator

Rang: Liferay Legend

Publications: 11770

Date d'inscription: 1 septembre 2006

Publications Récentes

Lior Hadaya:
the closest thing I know is to create a hook that implements a startup action and runs each time the server starts up, but I wonder if there's a way to create a hook that will run just once upon deployment and that's it. I want to write a hook that creates a few layouts and run it on newly installed servers.


That's going to be it. Your hook should check to see if the layouts are already installed; if they are, you do nothing. If they're not, then create them.
Hitoshi Ozawa
RE: Hook that runs once
14 août 2012 06:30
Réponse

Hitoshi Ozawa

Rang: Liferay Legend

Publications: 7949

Date d'inscription: 23 mars 2010

Publications Récentes

Use startup action event to check for layout as David said.

http://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins#section-Portal+Hook+Plugins-Event+Handlers
Lior Hadaya
RE: Hook that runs once
14 août 2012 06:31
Réponse

Lior Hadaya

Rang: Regular Member

Publications: 138

Date d'inscription: 24 janvier 2012

Publications Récentes

Alright, thanks guys.
Dominique Ebert
RE: Hook that runs once
17 juillet 2013 01:37
Réponse

Dominique Ebert

Rang: Junior Member

Publications: 29

Date d'inscription: 1 février 2013

Publications Récentes

Hi everyone!
As this thread is pretty close to what I'm currently trying to achieve I decided to revive this thread instead of creating a new one.

I'm trying to create a Hook that runs only once. I know how to create a Hook that runs when the Portal starts, and I know that I need to ensure somehow (e.g. database values) that the hook hasnt been run previously at this point.
My problem is, as im importing private-messages (dharma pm-portlet) into the privatemessaging portlet of the social office, that I dont have any reliable database value that I could check for. Such as "has Layout XY already been created". What would you guys recommend in this case, to ensure that the hook runs only once? What could I possibly check for, or do you know other approaches to ensure that the hook doesnt run twice?


thanks in advance and best regards
Dominique Ebert
RE: Hook that runs once
17 juillet 2013 04:03
Réponse

Dominique Ebert

Rang: Junior Member

Publications: 29

Date d'inscription: 1 février 2013

Publications Récentes

Solved the problem by using an upgrade action


Click


Works fine emoticon