KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > data > viewhelper > sitemap > SiteMapEventListener


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13

14 /*
15  * ----- BEGIN LICENSE BLOCK -----
16  * Version: JCSL 1.0
17  *
18  * The contents of this file are subject to the Jahia Community Source License
19  * 1.0 or later (the "License"); you may not use this file except in
20  * compliance with the License. You may obtain a copy of the License at
21  * http://www.jahia.org/license
22  *
23  * Software distributed under the License is distributed on an "AS IS" basis,
24  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
25  * for the rights, obligations and limitations governing use of the contents
26  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
27  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
28  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
29  *
30  * The Shared Modifications are Jahia View Helper.
31  *
32  * The Developer of the Shared Modifications is Jahia Solution Sàrl.
33  * Portions created by the Initial Developer are Copyright (C) 2002 by the
34  * Initial Developer. All Rights Reserved.
35  *
36  * Contributor(s):
37  * Oct 17 2002 Jahia Solutions Sàrl: MAP Initial release.
38  *
39  * ----- END LICENSE BLOCK -----
40  */

41
42 package org.jahia.data.viewhelper.sitemap;
43
44 import org.jahia.data.events.JahiaEvent;
45 import org.jahia.data.events.JahiaEventListener;
46 import org.jahia.data.fields.FieldTypes;
47 import org.jahia.data.fields.JahiaField;
48 import org.jahia.registries.ServicesRegistry;
49 import org.jahia.services.usermanager.JahiaUser;
50
51 /**
52  * <p>Title: Jahia View Helper</p>
53  * <p>Description:
54  * Listen if a Jahia page was added or if the user logout from CMS. In these
55  * cases the appropriate actions are made in particular the invalidation of the
56  * view helper.
57  * </p>
58  * <p>Copyright: MAP (Jahia Solutions Sàrl 2002)</p>
59  * <p>Company: Jahia Solutions Sàrl</p>
60  * @author MAP
61  * @version 1.0
62  */

63 public class SiteMapEventListener extends JahiaEventListener {
64
65     public SiteMapEventListener() {
66     }
67
68     /**
69      * Reset engines that implement the site map view helper if a page was added.
70      * Called when a page is added to Jahia CMS.
71      *
72      * @param je The Jahia event in question
73      */

74     public void pageAdded(JahiaEvent je) {
75         ServicesRegistry.getInstance().getJahiaSiteMapService().resetSiteMap();
76     }
77
78     /**
79      * Reset engines that implement the site map view helper if a page was
80      * removed.
81      * Called when a field is removed to Jahia CMS.
82      *
83      * @param je The Jahia event in question
84      */

85     public void fieldDeleted(JahiaEvent je) {
86         JahiaField theField = (JahiaField)je.getObject();
87         if (theField.getType() == FieldTypes.PAGE) {
88             ServicesRegistry.getInstance().getJahiaSiteMapService().resetSiteMap();
89         }
90     }
91
92     public void fieldUpdated(JahiaEvent je) {
93         fieldDeleted(je);
94     }
95
96     /**
97      * Remove the user from the site map created in the engine.
98      * Called when a user logout.
99      *
100      * @param je The Jahia event in question. C'est fou ce qu'on peut se marrer
101      * a repeter les memes aneries.
102      */

103     public void userLoggedOut(JahiaEvent je) {
104         JahiaUser theUser = (JahiaUser)je.getObject();
105         ServicesRegistry.getInstance().getJahiaSiteMapService().
106                 removeUserSiteMap(theUser.getUserKey());
107     }
108
109 }
110
Popular Tags