001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.main;
029
030/**
031 * Implement this interface in case your class has to react
032 * to CmsEvents that are thrown by system.<p>
033 *
034 * In order to receive system events, your class must register with
035 * the OpenCms event mechanism. This can be done in the constructor of a class
036 * like this:
037 * <pre>
038 * org.opencms.main.OpenCms.addCmsEventListener(this);
039 * </pre>
040 *
041 * A typical implementation might look like this:
042 * <pre>
043 * public void cmsEvent(org.opencms.main.CmsEvent event) {
044 *     switch (event.getType()) {
045 *         case org.opencms.main.I_CmsEventListener.EVENT_PUBLISH_PROJECT:
046 *         case org.opencms.main.I_CmsEventListener.EVENT_CLEAR_CACHES:
047 *             // do something
048 *             break;
049 *         case org.opencms.main.I_CmsEventListener.EVENT_LOGIN_USER:
050 *            // do something else
051 *             break;
052 *         }
053 * }
054 * </pre>
055 *
056 * @since 6.0.0
057 *
058 * @see CmsEvent
059 * @see org.opencms.main.OpenCms#addCmsEventListener(I_CmsEventListener)
060 * @see org.opencms.main.OpenCms#addCmsEventListener(I_CmsEventListener, int[])
061 */
062public interface I_CmsEventListener {
063
064    /**
065     * Event "a project is to published" (but has not yet been published).<p>
066     *
067     * Event data:
068     * <ul>
069     * <li><code>{@link #KEY_REPORT}</code>: a <code>{@link org.opencms.report.I_CmsReport}</code> to print output messages to</li>
070     * <li><code>{@link #KEY_PUBLISHLIST}</code>: a <code>{@link org.opencms.db.CmsPublishList}</code> that contains the resources that are to be published</li>
071     * <li><code>{@link #KEY_PROJECTID}</code>: the ID of the project that is to be published</li>
072     * <li><code>{@link #KEY_DBCONTEXT}</code>: the current users database context</li>
073     * </ul>
074     *
075     * @see org.opencms.publish.CmsPublishManager#publishProject(org.opencms.file.CmsObject)
076     * @see #EVENT_PUBLISH_PROJECT
077     */
078    int EVENT_BEFORE_PUBLISH_PROJECT = 3;
079
080    /**
081     * Event "all caches must be cleared".<p>
082     *
083     * Not thrown by the core classes, but might be used in modules.
084     */
085    int EVENT_CLEAR_CACHES = 5;
086
087    /**
088     * Event "clear all offline caches".<p>
089     *
090     * Event data: none
091     */
092    int EVENT_CLEAR_OFFLINE_CACHES = 16;
093
094    /**
095     * Event "clear all online caches".<p>
096     *
097     * Event data: none
098     */
099    int EVENT_CLEAR_ONLINE_CACHES = 17;
100
101    /**
102     * Event "all caches related to user and groups must be cleared".<p>
103     *
104     * Not thrown by the core classes, but might be used in modules.
105     */
106    int EVENT_CLEAR_PRINCIPAL_CACHES = 6;
107
108    /**
109     * Event "the FlexCache must be cleared".<p>
110     *
111     * This is thrown on the "FlexCache Administration" page if you press
112     * one ot the "Clear cache" buttons, or if you use the <code>_flex=clearcache</code>
113     * request parameter.
114     */
115    int EVENT_FLEX_CACHE_CLEAR = 9;
116
117    /**
118     * Event "delete all JSP pages in the "real" file system
119     * (so they will be rebuild next time the JSP is requested)".<p>
120     *
121     * This is thrown on the "FlexCache Administration" page if you press
122     * the button "Purge JSP repository", or if you use the <code>_flex=purge</code>
123     * request parameter.
124     */
125    int EVENT_FLEX_PURGE_JSP_REPOSITORY = 8;
126
127    /**
128     * Event "full static export".<p>
129     *
130     * This is thrown in {@link org.opencms.staticexport.CmsStaticExportManager}.
131     *
132     * Event data:
133     * <ul>
134     * <li>key "purge": the boolean value to purge the export folders first</li>
135     * <li><code>{@link #KEY_REPORT}</code>:  a <code>{@link org.opencms.report.I_CmsReport}</code> to print output messages to</li>
136     * </ul>
137     */
138    int EVENT_FULLSTATIC_EXPORT = 4;
139
140    /**
141     * Event "group modified".<p>
142     *
143     * Includes create, write and delete group.<p>
144     *
145     * Event data:
146     * <ul>
147     * <li>key "id": the uuid of the modified group</li>
148     * <li>key "groupname": the name of the modified group</li>
149     * <li>key "useraction": the name of the action to do on the replicated server</li>
150     * <ul>
151     * <li>createGroup</li>
152     * <li>writeGroup</li>
153     * <li>deleteGroup</li>
154     * </ul>
155     * </ul>
156     */
157    int EVENT_GROUP_MODIFIED = 31;
158
159    /**
160     * Event "user has logged in".<p>
161     *
162     * Event data:
163     * <ul>
164     * <li>key "data" (mandatory): the user who was logged in</li>
165     * </ul>
166     *
167     * @see org.opencms.file.CmsObject#loginUser(String, String)
168     */
169    int EVENT_LOGIN_USER = 1;
170
171    /**
172     * Event "ou modified".<p>
173     *
174     * Includes create OU and delete OU.<p>
175     *
176     * Event data:
177     * <ul>
178     * <li>key "id": the uuid of the modified ou</li>
179     * <li>key "ouname": the name of the modified ou</li>
180     * <li>key "useraction": the name of the action to do on the replicated server</li>
181     * <ul>
182     * <li>createOu</li>
183     * <li>deleteOu</li>
184     * </ul>
185     * </ul>
186     */
187    int EVENT_OU_MODIFIED = 30;
188
189    /**
190     * Event "a project was modified" (e.g. a project has been deleted,
191     * or the project resources have been changed).<p>
192     *
193     * Event data:
194     * <ul>
195     * <li>key "project" (mandatory): the deleted CmsProject</li>
196     * </ul>
197     */
198    int EVENT_PROJECT_MODIFIED = 18;
199
200    /**
201     * Event "a property definition has been created".<p>
202     *
203     * Event data:
204     * <ul>
205     * <li>key "propertyDefinition" (mandatory): the modified property definition</li>
206     * </ul>
207     */
208    int EVENT_PROPERTY_DEFINITION_CREATED = 28;
209
210    /**
211     * Event "a property definition has been modified".<p>
212     *
213     * Event data:
214     * <ul>
215     * <li>key "propertyDefinition" (mandatory): the modified property definition</li>
216     * </ul>
217     */
218    int EVENT_PROPERTY_DEFINITION_MODIFIED = 26;
219
220    /**
221     * Event "a single property (and so the resource itself, too) have been modified".<p>
222     *
223     * Event data:
224     * <ul>
225     * <li>key "resource" (mandatory): the CmsResource that has the modified property attached</li>
226     * <li>key "property" (mandatory): the modified property</li>
227     * </ul>
228     */
229    int EVENT_PROPERTY_MODIFIED = 14;
230
231    /**
232     * Event "a project was published".<p>
233     *
234     * Event data:
235     * <ul>
236     * <li><code>{@link #KEY_REPORT}</code>: a <code>{@link org.opencms.report.I_CmsReport}</code> to print output messages to</li>
237     * <li><code>{@link #KEY_PUBLISHID}</code>: the ID of the publish task in the publish history</li>
238     * <li><code>{@link #KEY_PROJECTID}</code>: the ID of the project that has been published</li>
239     * <li><code>{@link #KEY_DBCONTEXT}</code>: the current users database context</li>
240     * </ul>
241     *
242     * @see org.opencms.publish.CmsPublishManager#publishProject(org.opencms.file.CmsObject)
243     * @see #EVENT_BEFORE_PUBLISH_PROJECT
244     */
245    int EVENT_PUBLISH_PROJECT = 2;
246
247    /**
248     * Event "rebuild search indexes".<p>
249     *
250     * Event data:
251     * <ul>
252     * <li><code>{@link #KEY_REPORT}</code>: a <code>{@link org.opencms.report.I_CmsReport}</code> to print output messages to</li>
253     * <li><code>{@link #KEY_INDEX_NAMES}</code>: a comma separated list of names of the search indexes to rebuild, empty for all indexes</li>
254     * </ul>
255     */
256    int EVENT_REBUILD_SEARCHINDEXES = 32;
257
258    /**
259     * Event "all properties (and so the resource itself, too) have been modified".<p>
260     *
261     * Event data:
262     * <ul>
263     * <li>key "resource" (mandatory): the CmsResource that has the modified properties attached</li>
264     * </ul>
265     */
266    int EVENT_RESOURCE_AND_PROPERTIES_MODIFIED = 15;
267
268    /**
269     * @see #EVENT_RESOURCES_MODIFIED
270     */
271    int EVENT_RESOURCE_COPIED = 24;
272
273    /**
274     * @see #EVENT_RESOURCE_AND_PROPERTIES_MODIFIED
275     */
276    int EVENT_RESOURCE_CREATED = 23;
277
278    /**
279     * @see #EVENT_RESOURCES_MODIFIED
280     */
281    int EVENT_RESOURCE_DELETED = 25;
282
283    /**
284     * Event "a single resource has been modified".<p>
285     *
286     * Event data:
287     * <ul>
288     * <li>key "resource" (mandatory): the modified CmsResource</li>
289     * </ul>
290     */
291    int EVENT_RESOURCE_MODIFIED = 11;
292
293    /**
294     * @see #EVENT_RESOURCE_CREATED
295     * @see #EVENT_RESOURCE_COPIED
296     * @see #EVENT_RESOURCE_DELETED
297     */
298    int EVENT_RESOURCE_MOVED = 22;
299
300    /**
301     * Event "a list of resources and their properties have been modified".<p>
302     *
303     * Event data:
304     * <ul>
305     * <li>key "resources" (mandatory): a List of modified CmsResources</li>
306     * </ul>
307     */
308    int EVENT_RESOURCES_AND_PROPERTIES_MODIFIED = 27;
309
310    /**
311     * Event "a bunch of resources has been modified".<p>
312     *
313     * Event data:
314     * <ul>
315     * <li>key "resources" (mandatory): a List of modified CmsResources</li>
316     * </ul>
317     */
318    int EVENT_RESOURCES_MODIFIED = 12;
319
320    /**
321     * Event "a sitemap has been modified".<p>
322     *
323     * Event data:
324     * <ul>
325     * <li>key "resources" (mandatory): a List of modified sitemap entries identified by their root path</li>
326     * </ul>
327     */
328    int EVENT_SITEMAP_CHANGED = 33;
329
330    /**
331     * Event "update exported resources".<p>
332     *
333     * This event updates all export points, deletes the content
334     * of the "export" folder, purges the JSP repository, and clears
335     * all caches.<p>
336     *
337     * This event is for internal use.<p>
338     */
339    int EVENT_UPDATE_EXPORTS = 19;
340
341    /**
342     * Event "user modified".<p>
343     *
344     * Event data:
345     * <ul>
346     * <li>key "id": the uuid of the modified user</li>
347     * <li>key "username": the name of the modified user</li>
348     * <li>key "groupname": the name of the group which is effected</li>
349     * <li>key "useraction": the name of the action to do on the replicated server</li>
350     * <ul>
351     * <li>createUser</li>
352     * <li>writeUser</li>
353     * <li>deleteUser</li>
354     * <li>setOu</li>
355     * <li>addUserToGroup</li>
356     * <li>removeUserFromGroup</li>
357     * <li>resetPassword</li>
358     * </ul>
359     * </ul>
360     */
361    int EVENT_USER_MODIFIED = 29;
362
363    /** Key name for passing a change int in the data map - see the <code>CHANGED_XXX</code> constants in {@link org.opencms.db.CmsDriverManager}. */
364    String KEY_CHANGE = "change";
365
366    /** Key name for passing a database context in the data map. */
367    String KEY_DBCONTEXT = "dbContext";
368
369    /** Key name for passing a group ID. */
370    String KEY_GROUP_ID = "groupId";
371
372    /** Key name for passing a group name. */
373    String KEY_GROUP_NAME = "groupName";
374
375    /** Key name for passing a comma separated list of search index names in the data map. */
376    String KEY_INDEX_NAMES = "indexNames";
377
378    /** Key name for passing an OU ID. */
379    String KEY_OU_ID = "ouId";
380
381    /** Key name for passing a group name. */
382    String KEY_OU_NAME = "ouName";
383
384    /** Key name for passing a project id in the data map. */
385    String KEY_PROJECTID = "projectId";
386
387    /** Key name for passing a publish history id in the data map. */
388    String KEY_PUBLISHID = "publishHistoryId";
389
390    /** Key name for passing a publish list in the data map. */
391    String KEY_PUBLISHLIST = "publishList";
392
393    /** Key name for passing a report in the data map. */
394    String KEY_REPORT = "report";
395
396    /** Key name for passing a {@link org.opencms.file.CmsResource} in the data map. */
397    String KEY_RESOURCE = "resource";
398
399    /** Key name for passing a List of {@link org.opencms.file.CmsResource} in the data map. */
400    String KEY_RESOURCES = "resources";
401
402    /** Key name for skipping searchindexing. */
403    String KEY_SKIPINDEX = "skipindex";
404
405    /** Key name for passing a user action. */
406    String KEY_USER_ACTION = "userAction";
407
408    /** Key name for passing user changes flag. */
409    String KEY_USER_CHANGES = "userChanges";
410
411    /** Key name for passing an user ID. */
412    String KEY_USER_ID = "userId";
413
414    /** Key name for passing a user name. */
415    String KEY_USER_NAME = "userName";
416
417    /** Marker for "all events". */
418    Integer LISTENERS_FOR_ALL_EVENTS = new Integer(-1);
419
420    /** Value for the "group modified" action. */
421    String VALUE_GROUP_MODIFIED_ACTION_CREATE = "createGroup";
422
423    /** Value for the "group modified" action. */
424    String VALUE_GROUP_MODIFIED_ACTION_DELETE = "deleteGroup";
425
426    /** Value for the "group modified" action. */
427    String VALUE_GROUP_MODIFIED_ACTION_WRITE = "writeGroup";
428
429    /** Value for the "ou modified" action. */
430    String VALUE_OU_MODIFIED_ACTION_CREATE = "createOu";
431
432    /** Value for the "ou modified" action. */
433    String VALUE_OU_MODIFIED_ACTION_DELETE = "deleteOu";
434
435    /** Value for the "user modified" action. */
436    String VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP = "addUserToGroup";
437
438    /** Value for the "user modified" action. */
439    String VALUE_USER_MODIFIED_ACTION_CREATE_USER = "createUser";
440
441    /** Value for the "user modified" action. */
442    String VALUE_USER_MODIFIED_ACTION_DELETE_USER = "deleteUser";
443
444    /** Value for the "user modified" action. */
445    String VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP = "removeUserFromGroup";
446
447    /** Value for the "user modified" action. */
448    String VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD = "resetPassword";
449
450    /** Value for the "user modified" action. */
451    String VALUE_USER_MODIFIED_ACTION_SET_OU = "setOu";
452
453    /** Value for the "user modified" action. */
454    String VALUE_USER_MODIFIED_ACTION_WRITE_USER = "writeUser";
455
456    /**
457     * Acknowledge the occurrence of the specified event, implement this
458     * method to check for CmsEvents in your class.
459     *
460     * @param event CmsEvent that has occurred
461     */
462    void cmsEvent(CmsEvent event);
463}