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 "reindex" in the online project.<p> 260 * 261 * Note we split offline/online in two events since only for the online project, the event has to be forwarded in a cluster.<p> 262 * 263 * Event data: 264 * <ul> 265 * <li><code>{@link #KEY_RESOURCES}</code>: a list of {@link org.opencms.file.CmsResource}.</li> 266 * <li><code>{@link #KEY_REPORT}</code>: a <code>{@link org.opencms.report.I_CmsReport}</code> to print output messages to</li> 267 * <li><code>{@link #KEY_USER_ID}</code>: id of the user triggering the action. Used to show a message on success/failure.</li> 268 * <li><code>{@link #KEY_REINDEX_RELATED}</code>: flag, indicating if related resources should be reindexed as well.</li> 269 * </ul> 270 */ 271 int EVENT_REINDEX_ONLINE = 34; 272 273 /** 274 * Event "reindex" in an offline project.<p> 275 * 276 * Note we split offline/online in two events since only for the online project, the event has to be forwarded in a cluster.<p> 277 * 278 * Event data: 279 * <ul> 280 * <li><code>{@link #KEY_RESOURCES}</code>: a list of {@link org.opencms.file.CmsResource}.</li> 281 * <li><code>{@link #KEY_PROJECTID}</code>: the id of the project re-indexing is triggered in.</li> 282 * <li><code>{@link #KEY_REPORT}</code>: a <code>{@link org.opencms.report.I_CmsReport}</code> to print output messages to</li> 283 * <li><code>{@link #KEY_USER_ID}</code>: id of the user triggering the action. Used to show a message on success/failure.</li> 284 * <li><code>{@link #KEY_REINDEX_RELATED}</code>: flag, indicating if related resources should be reindexed as well.</li> 285 * </ul> 286 */ 287 int EVENT_REINDEX_OFFLINE = 35; 288 289 /** 290 * Event "all properties (and so the resource itself, too) have been modified".<p> 291 * 292 * Event data: 293 * <ul> 294 * <li>key "resource" (mandatory): the CmsResource that has the modified properties attached</li> 295 * </ul> 296 */ 297 int EVENT_RESOURCE_AND_PROPERTIES_MODIFIED = 15; 298 299 /** 300 * @see #EVENT_RESOURCES_MODIFIED 301 */ 302 int EVENT_RESOURCE_COPIED = 24; 303 304 /** 305 * @see #EVENT_RESOURCE_AND_PROPERTIES_MODIFIED 306 */ 307 int EVENT_RESOURCE_CREATED = 23; 308 309 /** 310 * @see #EVENT_RESOURCES_MODIFIED 311 */ 312 int EVENT_RESOURCE_DELETED = 25; 313 314 /** 315 * Event "a single resource has been modified".<p> 316 * 317 * Event data: 318 * <ul> 319 * <li>key "resource" (mandatory): the modified CmsResource</li> 320 * </ul> 321 */ 322 int EVENT_RESOURCE_MODIFIED = 11; 323 324 /** 325 * @see #EVENT_RESOURCE_CREATED 326 * @see #EVENT_RESOURCE_COPIED 327 * @see #EVENT_RESOURCE_DELETED 328 */ 329 int EVENT_RESOURCE_MOVED = 22; 330 331 /** 332 * Event "a list of resources and their properties have been modified".<p> 333 * 334 * Event data: 335 * <ul> 336 * <li>key "resources" (mandatory): a List of modified CmsResources</li> 337 * </ul> 338 */ 339 int EVENT_RESOURCES_AND_PROPERTIES_MODIFIED = 27; 340 341 /** 342 * Event "a bunch of resources has been modified".<p> 343 * 344 * Event data: 345 * <ul> 346 * <li>key "resources" (mandatory): a List of modified CmsResources</li> 347 * </ul> 348 */ 349 int EVENT_RESOURCES_MODIFIED = 12; 350 351 /** 352 * Event "a sitemap has been modified".<p> 353 * 354 * Event data: 355 * <ul> 356 * <li>key "resources" (mandatory): a List of modified sitemap entries identified by their root path</li> 357 * </ul> 358 */ 359 int EVENT_SITEMAP_CHANGED = 33; 360 361 /** 362 * Event "update exported resources".<p> 363 * 364 * This event updates all export points, deletes the content 365 * of the "export" folder, purges the JSP repository, and clears 366 * all caches.<p> 367 * 368 * This event is for internal use.<p> 369 */ 370 int EVENT_UPDATE_EXPORTS = 19; 371 372 /** 373 * Event "user modified".<p> 374 * 375 * Event data: 376 * <ul> 377 * <li>key "id": the uuid of the modified user</li> 378 * <li>key "username": the name of the modified user</li> 379 * <li>key "groupname": the name of the group which is effected</li> 380 * <li>key "useraction": the name of the action to do on the replicated server</li> 381 * <ul> 382 * <li>createUser</li> 383 * <li>writeUser</li> 384 * <li>deleteUser</li> 385 * <li>setOu</li> 386 * <li>addUserToGroup</li> 387 * <li>removeUserFromGroup</li> 388 * <li>resetPassword</li> 389 * </ul> 390 * </ul> 391 */ 392 int EVENT_USER_MODIFIED = 29; 393 394 /** Key name for passing a change int in the data map - see the <code>CHANGED_XXX</code> constants in {@link org.opencms.db.CmsDriverManager}. */ 395 String KEY_CHANGE = "change"; 396 397 /** Key name for passing a database context in the data map. */ 398 String KEY_DBCONTEXT = "dbContext"; 399 400 /** Key name for passing a group ID. */ 401 String KEY_GROUP_ID = "groupId"; 402 403 /** Key name for passing a group name. */ 404 String KEY_GROUP_NAME = "groupName"; 405 406 /** Key name for passing a comma separated list of search index names in the data map. */ 407 String KEY_INDEX_NAMES = "indexNames"; 408 409 /** Key name for passing a flag, indicating if we are in the online project. */ 410 String KEY_IS_ONLINE = "isOnline"; 411 412 /** Key name for passing an OU ID. */ 413 String KEY_OU_ID = "ouId"; 414 415 /** Key name for passing a group name. */ 416 String KEY_OU_NAME = "ouName"; 417 418 /** Key name for passing a project id in the data map. */ 419 String KEY_PROJECTID = "projectId"; 420 421 /** Key name for passing a publish history id in the data map. */ 422 String KEY_PUBLISHID = "publishHistoryId"; 423 424 /** Key name for passing a publish list in the data map. */ 425 String KEY_PUBLISHLIST = "publishList"; 426 427 /** Key name for passing a flag, indicating if related resources should be taken into account in the data map. */ 428 String KEY_REINDEX_RELATED = "related"; 429 430 /** Key name for passing a report in the data map. */ 431 String KEY_REPORT = "report"; 432 433 /** Key name for passing a {@link org.opencms.file.CmsResource} in the data map. */ 434 String KEY_RESOURCE = "resource"; 435 436 /** Key name for passing a List of {@link org.opencms.file.CmsResource} in the data map. */ 437 String KEY_RESOURCES = "resources"; 438 439 /** Key name for skipping searchindexing. */ 440 String KEY_SKIPINDEX = "skipindex"; 441 442 /** Key name for passing a user action. */ 443 String KEY_USER_ACTION = "userAction"; 444 445 /** Key name for passing user changes flag. */ 446 String KEY_USER_CHANGES = "userChanges"; 447 448 /** Key name for passing an user ID. */ 449 String KEY_USER_ID = "userId"; 450 451 /** Key name for passing a user name. */ 452 String KEY_USER_NAME = "userName"; 453 454 /** Marker for "all events". */ 455 Integer LISTENERS_FOR_ALL_EVENTS = new Integer(-1); 456 457 /** Value for the "group modified" action. */ 458 String VALUE_GROUP_MODIFIED_ACTION_CREATE = "createGroup"; 459 460 /** Value for the "group modified" action. */ 461 String VALUE_GROUP_MODIFIED_ACTION_DELETE = "deleteGroup"; 462 463 /** Value for the "group modified" action. */ 464 String VALUE_GROUP_MODIFIED_ACTION_WRITE = "writeGroup"; 465 466 /** Value for the "ou modified" action. */ 467 String VALUE_OU_MODIFIED_ACTION_CREATE = "createOu"; 468 469 /** Value for the "ou modified" action. */ 470 String VALUE_OU_MODIFIED_ACTION_DELETE = "deleteOu"; 471 472 /** Value for the "user modified" action. */ 473 String VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP = "addUserToGroup"; 474 475 /** Value for the "user modified" action. */ 476 String VALUE_USER_MODIFIED_ACTION_CREATE_USER = "createUser"; 477 478 /** Value for the "user modified" action. */ 479 String VALUE_USER_MODIFIED_ACTION_DELETE_USER = "deleteUser"; 480 481 /** Value for the "user modified" action. */ 482 String VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP = "removeUserFromGroup"; 483 484 /** Value for the "user modified" action. */ 485 String VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD = "resetPassword"; 486 487 /** Value for the "user modified" action. */ 488 String VALUE_USER_MODIFIED_ACTION_SET_OU = "setOu"; 489 490 /** Value for the "user modified" action. */ 491 String VALUE_USER_MODIFIED_ACTION_WRITE_USER = "writeUser"; 492 493 /** Value to mark modification events from sibling creation. */ 494 String VALUE_CREATE_SIBLING = "createSibling"; 495 496 /** 497 * Acknowledge the occurrence of the specified event, implement this 498 * method to check for CmsEvents in your class. 499 * 500 * @param event CmsEvent that has occurred 501 */ 502 void cmsEvent(CmsEvent event); 503}