[opencms-dev] Java Action class for checking content changed/created

gsriman gsriman at gmail.com
Tue Jan 15 22:59:23 CET 2008


Hi Alessio,
   I am trying to unlock the Resource(files) in one folder and also unlock
all the files in Offline project. Do you know How can I do that in my class.

Thanks in advance
Sriman

Alessio Zurleni wrote:
> 
> Sriman,
> 
> you cast the "resource" key from event data this way  (in case of event
> resource modified) :
> 
> CmsResource  res = (CmsResource)<event object>.getData().get("resource");
> 
> U can access all resource informations with CmsResource methods.
> 
> Pay attention to the fact that getData method and keys are event
> dependents, so have a
> look at the org.opencms.main.I_CmsEventListener class.
> 
> 
> Regards,
> 
> Alessio
> 
> gsriman wrote:
>> Hi Alessio  & Sylvain ,
>>   Thanks a lot for your response. As you told I wrote a action class and
>> registered in my module. It's listening to my action class . I am trying
>> to
>> get mofified or created Resouce path and resouce name only but the
>> function
>> event.getData() is giving lot of info which I don't need it.  Can you
>> tell
>> me what shoould I do to get only Resource path and name.
>>
>> Thanks in advance
>> Sriman
>>
>> Alessio Zurleni wrote:
>>   
>>> Hi,
>>>
>>> Once your module class set up (classe must implement I_CmsModuleAction
>>> as specified by Sylvain), use the CmsEvent method to check for the
>>> wished event.
>>> For a complete events list look at the 
>>> org.opencms.main.I_CmsEventListener class. Once the event detected you
>>> can grab resource(s) from event contextual data.
>>> For instance, when a ressource is modified a 
>>> I_CmsEventListener.EVENT_RESOURCE_MODIFIED event is fired and the event
>>> data map will contain a key named "resource" (CmsResource object).
>>>
>>> Regards,
>>>
>>>
>>> Alessio Zurleni
>>>
>>>
>>>
>>> Sylvain Courcelle wrote:
>>>     
>>>> Hi,
>>>> Concerning Action classes, you have to respect only 3 steps :
>>>> 1) declaring the action class ( full package name without ".class"
>>>> termination ) in the module configuration
>>>> 2) developing your own Java class as Action Class : this action class
>>>> must implement I_CmsModuleAction ( an OpenCMS API interface ).
>>>> 3) place the brand new class in the Classes directory of your module.
>>>>
>>>> NB: ActionClasses are always used in a Module context. If you don't
>>>> have
>>>> one, you should create it.
>>>>
>>>> Then, concerning events capture ...
>>>> The I_CmsModuleAction interface defines many methods :
>>>> - initialize
>>>> - moduleUninstall
>>>> - publishProject
>>>> And a more important one :
>>>> cmsEvent(CmsEvent event)
>>>>
>>>> in this method's body, you can analyse the type of the "event" param to
>>>> trigger your own actions.
>>>>
>>>> Nevertheless, I don't have a precise idea concerning the manner you
>>>> could
>>>> detect changes on a precise Ressource of VFS. Maybe You'll have to
>>>> declare your own CmsEvent, and make the system listen to it ( look at
>>>> method AddCmsEventListener of class CmsEventManager, reachable via
>>>> OpenCms.getEventManager() ).
>>>>
>>>> Hope it will help,
>>>> Regards,
>>>> Sylvain Courcelle
>>>> EURELIS
>>>>
>>>>
>>>>
>>>>
>>>> -----Message d'origine-----
>>>> De : opencms-dev-bounces at opencms.org
>>>> [mailto:opencms-dev-bounces at opencms.org] De la part de gsriman
>>>> Envoyé : mardi 11 décembre 2007 05:37
>>>> À : opencms-dev at opencms.org
>>>> Objet : [opencms-dev] Java Action class for checking content
>>>> changed/created
>>>>
>>>>
>>>> Hi All,
>>>>   I am new to Opencms and Java. I am trying to write a java class as
>>>> event
>>>> listener that triggers wheneever the file/content in opencms is changed
>>>> or
>>>> created and send an email to the project manager that file has been
>>>> changed.
>>>> Could anybody help me the steps needed to create java class for this
>>>> and
>>>> necessary steps required to make this happen.
>>>>
>>>> Thanks in advance
>>>> Sriman
>>>>   
>>>>       
>>> _______________________________________________
>>> This mail is sent to you from the opencms-dev mailing list
>>> To change your list options, or to unsubscribe from the list, please
>>> visit
>>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>>>
>>>
>>>     
>>
>>   
> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Java-Action-class-for-checking-content-changed-created-tp14270583p14848818.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.




More information about the opencms-dev mailing list