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, 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.gwt.shared; 029 030import org.opencms.util.CmsUUID; 031 032import java.util.Map; 033 034import com.google.gwt.user.client.rpc.IsSerializable; 035 036/** 037 * Runtime data bean for prefetching.<p> 038 * 039 * @since 8.0.0 040 */ 041public class CmsCoreData implements IsSerializable { 042 043 /** A enumeration for the ADE context. */ 044 public enum AdeContext { 045 046 /** Context for classic direct edit provider. */ 047 editprovider, 048 049 /** Context for gallery dialog. */ 050 gallery, 051 052 /** Context for container page. */ 053 pageeditor, 054 055 /** Context for publish dialog. */ 056 publish, 057 058 /** Context for resource info dialog. */ 059 resourceinfo, 060 061 /** Context for sitemap. */ 062 sitemapeditor 063 } 064 065 /** The available client modules. */ 066 public enum ModuleKey { 067 068 /** Container page editor. */ 069 containerpage, 070 071 /** Content editor. */ 072 contenteditor, 073 074 /** Direct edit provider. */ 075 editprovider, 076 077 /** Galleries. */ 078 galleries, 079 080 /** Post upload dialog. */ 081 postupload, 082 083 /** Properties dialog. */ 084 properties, 085 086 /** Publish dialog. */ 087 publish, 088 089 /** Sitemap editor. */ 090 sitemap, 091 092 /** Upload dialog. */ 093 upload 094 } 095 096 /** 097 * Bean class containing info about the current user.<p> 098 */ 099 public static class UserInfo implements IsSerializable { 100 101 /** True if the user is an administrator. */ 102 private boolean m_isAdmin; 103 104 /** True if the user is a category manager. */ 105 private boolean m_isCategoryManager; 106 107 /** True if the user is a template developer. */ 108 private boolean m_isDeveloper; 109 110 /** True if the user is managed. */ 111 private boolean m_isManaged; 112 113 /** True if the user is a workplace user. */ 114 private boolean m_isWorkplaceUser; 115 116 /** The user name. */ 117 private String m_name; 118 119 /** The user icon path. */ 120 private String m_userIcon; 121 122 /** 123 * Creates a new instance.<p> 124 * 125 * @param name the user name 126 * @param userIcon the user icon path 127 * @param isAdmin true if the user is an administrator 128 * @param isDeveloper true if the user is a template developer 129 * @param isCategoryManager true if the user is a category manager 130 * @param isWorkplaceUser true if the user is a workplace user 131 * @param isManaged true if the user is managed 132 */ 133 public UserInfo( 134 String name, 135 String userIcon, 136 boolean isAdmin, 137 boolean isDeveloper, 138 boolean isCategoryManager, 139 boolean isWorkplaceUser, 140 boolean isManaged) { 141 142 m_isDeveloper = isDeveloper; 143 m_isCategoryManager = isCategoryManager; 144 m_isAdmin = isAdmin; 145 m_isManaged = isManaged; 146 m_isWorkplaceUser = isWorkplaceUser; 147 m_name = name; 148 m_userIcon = userIcon; 149 } 150 151 /** 152 * Default constructor, needed for serialization.<p> 153 */ 154 protected UserInfo() { 155 156 // empty 157 } 158 159 /** 160 * Gets the user name.<p> 161 * 162 * @return the user name 163 */ 164 public String getName() { 165 166 return m_name; 167 } 168 169 /** 170 * Returns the user icon path.<p> 171 * 172 * @return the user icon path 173 */ 174 public String getUserIcon() { 175 176 return m_userIcon; 177 } 178 179 /** 180 * Returns true if the user is an administrator.<p> 181 * 182 * @return true if the user is an administrator 183 */ 184 public boolean isAdmin() { 185 186 return m_isAdmin; 187 } 188 189 /** 190 * Returns true if the user is a category manager.<p> 191 * 192 * @return true if the user is a category manager 193 */ 194 public boolean isCategoryManager() { 195 196 return m_isCategoryManager; 197 } 198 199 /** 200 * Returns true if the user is a template developer.<p> 201 * 202 * @return true if the user is a template developer 203 */ 204 public boolean isDeveloper() { 205 206 return m_isDeveloper; 207 } 208 209 /** 210 * Returns if the user is managed.<p> 211 * 212 * @return <code>true</code> if the user is managed 213 */ 214 public boolean isManaged() { 215 216 return m_isManaged; 217 } 218 219 /** 220 * Returns true if the current user is a workplace user.<p> 221 * 222 * @return true if the current user is a workplace user 223 */ 224 public boolean isWorkplaceUser() { 225 226 return m_isWorkplaceUser; 227 } 228 } 229 230 /** Name of the used js variable. */ 231 public static final String DICT_NAME = "org_opencms_gwt"; 232 233 /** The key for the GWT build id property. */ 234 public static final String KEY_GWT_BUILDID = "gwt.buildid"; 235 236 /** The meta element name to the requested module key. */ 237 public static final String META_PARAM_MODULE_KEY = "opencms-module"; 238 239 /** The parameter name for path. */ 240 public static final String PARAM_PATH = "path"; 241 242 /** The parameter name for the return code. */ 243 public static final String PARAM_RETURNCODE = "returncode"; 244 245 /** The time sent from the server when loading the data. */ 246 protected long m_serverTime; 247 248 /** A bean with information about the current user. */ 249 protected UserInfo m_userInfo; 250 251 /** The link to the page displayed in the "about" dialog. */ 252 private String m_aboutLink; 253 254 /** ADE parameters. */ 255 private Map<String, String> m_adeParameters; 256 257 /** The XML content editor back-link URL. */ 258 private String m_contentEditorBacklinkUrl; 259 260 /** The XML content editor URL. */ 261 private String m_contentEditorUrl; 262 263 /** The default link to use for opening the workplace. */ 264 private String m_defaultWorkplaceLink; 265 266 /** The embedded dialogs URL. */ 267 private String m_embeddedDialogsUrl; 268 269 /** The mappings of file extensions to resource types. */ 270 private Map<String, String> m_extensionMapping; 271 272 /** The file explorer link. */ 273 private String m_fileExplorerLink; 274 275 /** The resource icon mapping. */ 276 private Map<String, String> m_iconMapping; 277 278 /** The show editor help flag. */ 279 private boolean m_isShowEditorHelp; 280 281 /** Keep-alive setting. */ 282 private boolean m_keepAlive; 283 284 /** The current request locale. */ 285 private String m_locale; 286 287 /** The login JSP URL. */ 288 private String m_loginURL; 289 290 /** The current navigation URI. */ 291 private String m_navigationUri; 292 293 /** The project id. */ 294 private CmsUUID m_projectId; 295 296 /** The current site root. */ 297 private String m_siteRoot; 298 299 /** The structure id of the resource. */ 300 private CmsUUID m_structureId; 301 302 /** The data for the TinyMCE editor. */ 303 private CmsTinyMCEData m_tinymce; 304 305 /** A flag which indicates whether the toolbar should be shown initially. */ 306 private boolean m_toolbarVisible; 307 308 /** The maximum file size for the upload. */ 309 private long m_uploadFileSizeLimit; 310 311 /** The current uri. */ 312 private String m_uri; 313 314 /** The OpenCms VFS prefix. */ 315 private String m_vfsPrefix; 316 317 /** The workplaces resources path prefix. */ 318 private String m_workplaceResourcesPrefix; 319 320 /** The current workplace locale. */ 321 private String m_wpLocale; 322 323 /** 324 * Constructor.<p> 325 */ 326 public CmsCoreData() { 327 328 // empty 329 } 330 331 /** 332 * Clone constructor.<p> 333 * 334 * @param clone the instance to clone 335 */ 336 public CmsCoreData(CmsCoreData clone) { 337 338 this( 339 clone.getContentEditorUrl(), 340 clone.getContentEditorBacklinkUrl(), 341 clone.getLoginURL(), 342 clone.getVfsPrefix(), 343 clone.getFileExplorerLink(), 344 clone.getWorkplaceResourcesPrefix(), 345 clone.getEmbeddedDialogsUrl(), 346 clone.getSiteRoot(), 347 clone.getProjectId(), 348 clone.getLocale(), 349 clone.getWpLocale(), 350 clone.getUri(), 351 clone.getNavigationUri(), 352 clone.getStructureId(), 353 clone.getExtensionMapping(), 354 clone.getIconMapping(), 355 clone.getServerTime(), 356 clone.isShowEditorHelp(), 357 clone.isToolbarVisible(), 358 clone.getDefaultWorkplaceLink(), 359 clone.getAboutLink(), 360 clone.getUserInfo(), 361 clone.getUploadFileSizeLimit(), 362 clone.isKeepAlive(), 363 clone.m_adeParameters); 364 setTinymce(clone.getTinymce()); 365 } 366 367 /** 368 * Constructor.<p> 369 * 370 * @param contentEditorUrl the XML content editor URL 371 * @param contentEditorBacklinkUrl the XML content editor back-link URL 372 * @param loginUrl the login JSP URL 373 * @param vfsPrefix the OpenCms VFS prefix 374 * @param fileExplorerLink the file explorer link 375 * @param workplaceResourcesPrefix the workplace resources path prefix 376 * @param embeddedDialogsUrl the embedded dialogs URL 377 * @param siteRoot the current site root 378 * @param projectId the project id 379 * @param locale the current request locale 380 * @param wpLocale the workplace locale 381 * @param uri the current uri 382 * @param structureId the structure id of tbe resource 383 * @param navigationUri the current navigation URI 384 * @param extensionMapping the mappings of file extensions to resource types 385 * @param iconMapping the resource icon mapping 386 * @param serverTime the current time 387 * @param isShowEditorHelp the show editor help flag 388 * @param toolbarVisible a flag to indicate whether the toolbar should be visible initially 389 * @param defaultWorkplaceLink the default link to use for opening the workplace 390 * @param aboutLink the link to the "About" page 391 * @param userInfo information about the current user 392 * @param uploadFileSizeLimit the file upload size limit 393 * @param isKeepAlive the keep-alive mode 394 * @param adeParameters the map of ADE configuration parameters 395 */ 396 public CmsCoreData( 397 String contentEditorUrl, 398 String contentEditorBacklinkUrl, 399 String loginUrl, 400 String vfsPrefix, 401 String fileExplorerLink, 402 String workplaceResourcesPrefix, 403 String embeddedDialogsUrl, 404 String siteRoot, 405 CmsUUID projectId, 406 String locale, 407 String wpLocale, 408 String uri, 409 String navigationUri, 410 CmsUUID structureId, 411 Map<String, String> extensionMapping, 412 Map<String, String> iconMapping, 413 long serverTime, 414 boolean isShowEditorHelp, 415 boolean toolbarVisible, 416 String defaultWorkplaceLink, 417 String aboutLink, 418 UserInfo userInfo, 419 long uploadFileSizeLimit, 420 boolean isKeepAlive, 421 Map<String, String> adeParameters) { 422 423 m_contentEditorUrl = contentEditorUrl; 424 m_contentEditorBacklinkUrl = contentEditorBacklinkUrl; 425 m_loginURL = loginUrl; 426 m_vfsPrefix = vfsPrefix; 427 m_workplaceResourcesPrefix = workplaceResourcesPrefix; 428 m_embeddedDialogsUrl = embeddedDialogsUrl; 429 m_siteRoot = siteRoot; 430 m_projectId = projectId; 431 m_locale = locale; 432 m_wpLocale = wpLocale; 433 m_uri = uri; 434 m_navigationUri = navigationUri; 435 m_extensionMapping = extensionMapping; 436 m_iconMapping = iconMapping; 437 m_serverTime = serverTime; 438 m_isShowEditorHelp = isShowEditorHelp; 439 m_toolbarVisible = toolbarVisible; 440 m_structureId = structureId; 441 m_defaultWorkplaceLink = defaultWorkplaceLink; 442 m_aboutLink = aboutLink; 443 m_userInfo = userInfo; 444 m_uploadFileSizeLimit = uploadFileSizeLimit; 445 m_keepAlive = isKeepAlive; 446 m_adeParameters = adeParameters; 447 m_fileExplorerLink = fileExplorerLink; 448 } 449 450 /** 451 * Gets the "About" link.<p> 452 * 453 * @return the "about" link 454 */ 455 public String getAboutLink() { 456 457 return m_aboutLink; 458 } 459 460 /** 461 * Gets the map of ADE configuration parameters.<p> 462 * 463 * @return the ADE configuration parameters 464 */ 465 public Map<String, String> getAdeParameters() { 466 467 return m_adeParameters; 468 } 469 470 /** 471 * Returns the XML content editor back-link URL.<p> 472 * 473 * @return the XML content editor back-link URL 474 */ 475 public String getContentEditorBacklinkUrl() { 476 477 return m_contentEditorBacklinkUrl; 478 } 479 480 /** 481 * Returns the XML content editor URL.<p> 482 * 483 * @return the XML content editor URL 484 */ 485 public String getContentEditorUrl() { 486 487 return m_contentEditorUrl; 488 } 489 490 /** 491 * Gets the default link to use for opening the workplace.<p> 492 * 493 * @return the default workplace link 494 */ 495 public String getDefaultWorkplaceLink() { 496 497 return m_defaultWorkplaceLink; 498 } 499 500 /** 501 * Returns the embeddedDialogsUrl.<p> 502 * 503 * @return the embeddedDialogsUrl 504 */ 505 public String getEmbeddedDialogsUrl() { 506 507 return m_embeddedDialogsUrl; 508 } 509 510 /** 511 * Returns the extensionMapping.<p> 512 * 513 * @return the extensionMapping 514 */ 515 public Map<String, String> getExtensionMapping() { 516 517 return m_extensionMapping; 518 } 519 520 /** 521 * Returns the resource icon mapping.<p> 522 * 523 * @return the resource icon mapping 524 */ 525 public Map<String, String> getIconMapping() { 526 527 return m_iconMapping; 528 } 529 530 /** 531 * Returns the current request locale.<p> 532 * 533 * @return the current request locale 534 */ 535 public String getLocale() { 536 537 return m_locale; 538 } 539 540 /** 541 * Returns the login URL.<p> 542 * 543 * @return the login URL 544 */ 545 public String getLoginURL() { 546 547 return m_loginURL; 548 } 549 550 /** 551 * Returns the current navigation (sitemap) URI.<p> 552 * 553 * @return the current navigation URI 554 */ 555 public String getNavigationUri() { 556 557 return m_navigationUri; 558 } 559 560 /** 561 * Gets the project id. 562 * 563 * @return the project id 564 */ 565 public CmsUUID getProjectId() { 566 567 return m_projectId; 568 } 569 570 /** 571 * Returns the time of the server when the data was loaded.<p> 572 * 573 * @return the time of the server when the data was loaded 574 */ 575 public long getServerTime() { 576 577 return m_serverTime; 578 } 579 580 /** 581 * Returns the current site root.<p> 582 * 583 * @return the current site root 584 */ 585 public String getSiteRoot() { 586 587 return m_siteRoot; 588 } 589 590 /** 591 * Gets the structure id of the current resource.<p> 592 * 593 * @return the structure id of the current resource 594 */ 595 public CmsUUID getStructureId() { 596 597 return m_structureId; 598 } 599 600 /** 601 * Gets the data for the TinyMCE editor.<p> 602 * 603 * @return the data for TinyMCE 604 */ 605 public CmsTinyMCEData getTinymce() { 606 607 // TODO Auto-generated method stub 608 return m_tinymce; 609 } 610 611 /** 612 * Returns the file upload size limit.<p> 613 * 614 * @return the file upload size limit 615 */ 616 public long getUploadFileSizeLimit() { 617 618 return m_uploadFileSizeLimit; 619 } 620 621 /** 622 * Returns the current uri.<p> 623 * 624 * @return the current uri 625 */ 626 public String getUri() { 627 628 return m_uri; 629 } 630 631 /** 632 * Gets the information about the current user.<p> 633 * 634 * @return the information about the current user 635 */ 636 public UserInfo getUserInfo() { 637 638 return m_userInfo; 639 } 640 641 /** 642 * Returns the OpenCms VFS prefix.<p> 643 * 644 * @return the OpenCms VFS prefix 645 */ 646 public String getVfsPrefix() { 647 648 return m_vfsPrefix; 649 } 650 651 /** 652 * Returns the workplace resources path prefix.<p> 653 * 654 * @return the workplace resources path prefix 655 */ 656 public String getWorkplaceResourcesPrefix() { 657 658 return m_workplaceResourcesPrefix; 659 } 660 661 /** 662 * Returns the current workplace locale.<p> 663 * 664 * @return the current workplace locale 665 */ 666 public String getWpLocale() { 667 668 return m_wpLocale; 669 } 670 671 /** 672 * Returns true if the session should be kept alive even without user actions.<p> 673 * 674 * @return true if keep-alive mode is active 675 */ 676 public boolean isKeepAlive() { 677 678 return m_keepAlive; 679 } 680 681 /** 682 * Returns the show editor help flag.<p> 683 * 684 * @return the show editor help flag 685 */ 686 public boolean isShowEditorHelp() { 687 688 return m_isShowEditorHelp; 689 } 690 691 /** 692 * Returns true if the toolbar should be visible initially.<p> 693 * 694 * @return true if the toolbar should be visible initially 695 */ 696 public boolean isToolbarVisible() { 697 698 return m_toolbarVisible; 699 } 700 701 /** 702 * Sets the data for the TinyMCE editor.<p> 703 * 704 * @param tinyMceData the data for TinyMCE 705 */ 706 public void setTinymce(CmsTinyMCEData tinyMceData) { 707 708 m_tinymce = tinyMceData; 709 } 710 711 /** 712 * Returns the file explorer link prefix. Append resource site path for complete link.<p> 713 * 714 * @return the file explorer link prefix 715 */ 716 protected String getFileExplorerLink() { 717 718 return m_fileExplorerLink; 719 } 720 721 /** 722 * Sets the show editor help flag.<p> 723 * 724 * @param show <code>true</code> to show editor help 725 */ 726 protected void setShowEditorHelp(boolean show) { 727 728 m_isShowEditorHelp = show; 729 } 730}