1 31 32 package org.opencms.workplace; 33 34 import org.opencms.configuration.CmsDefaultUserSettings; 35 import org.opencms.db.CmsExportPoint; 36 import org.opencms.db.CmsUserSettings; 37 import org.opencms.db.I_CmsProjectDriver; 38 import org.opencms.file.CmsFolder; 39 import org.opencms.file.CmsObject; 40 import org.opencms.file.CmsProject; 41 import org.opencms.file.CmsPropertyDefinition; 42 import org.opencms.file.CmsUser; 43 import org.opencms.file.types.CmsResourceTypeFolderExtended; 44 import org.opencms.file.types.I_CmsResourceType; 45 import org.opencms.i18n.CmsAcceptLanguageHeaderParser; 46 import org.opencms.i18n.CmsEncoder; 47 import org.opencms.i18n.CmsI18nInfo; 48 import org.opencms.i18n.CmsLocaleComparator; 49 import org.opencms.i18n.CmsLocaleManager; 50 import org.opencms.i18n.I_CmsLocaleHandler; 51 import org.opencms.main.CmsEvent; 52 import org.opencms.main.CmsException; 53 import org.opencms.main.CmsLog; 54 import org.opencms.main.I_CmsEventListener; 55 import org.opencms.main.OpenCms; 56 import org.opencms.module.CmsModule; 57 import org.opencms.module.CmsModuleManager; 58 import org.opencms.security.CmsRole; 59 import org.opencms.security.CmsRoleViolationException; 60 import org.opencms.util.CmsRfsFileViewer; 61 import org.opencms.util.CmsStringUtil; 62 import org.opencms.workplace.editors.CmsEditorDisplayOptions; 63 import org.opencms.workplace.editors.CmsEditorHandler; 64 import org.opencms.workplace.editors.CmsWorkplaceEditorManager; 65 import org.opencms.workplace.editors.I_CmsEditorActionHandler; 66 import org.opencms.workplace.editors.I_CmsEditorHandler; 67 import org.opencms.workplace.editors.directedit.CmsDirectEditDefaultProvider; 68 import org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider; 69 import org.opencms.workplace.explorer.CmsExplorerContextMenu; 70 import org.opencms.workplace.explorer.CmsExplorerTypeAccess; 71 import org.opencms.workplace.explorer.CmsExplorerTypeSettings; 72 import org.opencms.workplace.galleries.A_CmsGallery; 73 import org.opencms.workplace.tools.CmsToolManager; 74 75 import java.io.UnsupportedEncodingException ; 76 import java.util.ArrayList ; 77 import java.util.Collections ; 78 import java.util.HashMap ; 79 import java.util.HashSet ; 80 import java.util.Iterator ; 81 import java.util.List ; 82 import java.util.Locale ; 83 import java.util.Map ; 84 import java.util.Set ; 85 86 import javax.servlet.http.HttpServletRequest ; 87 import javax.servlet.http.HttpSession ; 88 89 import org.apache.commons.logging.Log; 90 91 103 public final class CmsWorkplaceManager implements I_CmsLocaleHandler, I_CmsEventListener { 104 105 106 public static final String DEFAULT_WORKPLACE_ENCODING = CmsEncoder.ENCODING_UTF_8; 107 108 109 public static final String PARAM_LOGIN_REQUESTED_RESOURCE = "requestedResource"; 110 111 112 public static final String SESSION_WORKPLACE_SETTINGS = "__CmsWorkplace.WORKPLACE_SETTINGS"; 113 114 115 private static final Log LOG = CmsLog.getLog(CmsWorkplaceManager.class); 116 117 118 private boolean m_autoLockResources; 119 120 121 private CmsExplorerTypeAccess m_defaultAccess; 122 123 124 private Locale m_defaultLocale; 125 126 127 private boolean m_defaultPropertiesOnStructure; 128 129 130 private CmsDefaultUserSettings m_defaultUserSettings; 131 132 133 private Map m_dialogHandler; 134 135 136 private I_CmsDirectEditProvider m_directEditProvider; 137 138 139 private I_CmsEditorActionHandler m_editorAction; 140 141 142 private CmsEditorDisplayOptions m_editorDisplayOptions; 143 144 145 private I_CmsEditorHandler m_editorHandler; 146 147 148 private CmsWorkplaceEditorManager m_editorManager; 149 150 151 private boolean m_enableAdvancedPropertyTabs; 152 153 154 private String m_encoding; 155 156 157 private List m_explorerTypeSettings; 158 159 160 private List m_explorerTypeSettingsFromModules; 161 162 163 private List m_explorerTypeSettingsFromXml; 164 165 166 private Map m_explorerTypeSettingsMap; 167 168 169 private Set m_exportPoints; 170 171 172 private int m_fileMaxUploadSize; 173 174 175 private CmsRfsFileViewer m_fileViewSettings; 176 177 178 private Map m_galleries; 179 180 181 private List m_labelSiteFolders; 182 183 184 private List m_locales; 185 186 187 private List m_localizedFolders; 188 189 190 private Map m_messages; 191 192 193 private CmsExplorerContextMenu m_multiContextMenu; 194 195 196 private boolean m_showUserGroupIcon; 197 198 199 private CmsProject m_tempFileProject; 200 201 202 private CmsToolManager m_toolManager; 203 204 205 private List m_views; 206 207 208 private boolean m_workflowMessage; 209 210 213 public CmsWorkplaceManager() { 214 215 if (CmsLog.INIT.isInfoEnabled()) { 216 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_INITIALIZE_START_0)); 217 } 218 m_locales = new ArrayList (); 219 m_labelSiteFolders = new ArrayList (); 220 m_localizedFolders = new ArrayList (); 221 m_autoLockResources = true; 222 m_showUserGroupIcon = true; 223 m_dialogHandler = new HashMap (); 224 m_views = new ArrayList (); 225 m_exportPoints = new HashSet (); 226 m_editorHandler = new CmsEditorHandler(); 227 m_fileMaxUploadSize = -1; 228 m_fileViewSettings = new CmsRfsFileViewer(); 229 m_explorerTypeSettingsFromXml = new ArrayList (); 230 m_explorerTypeSettingsFromModules = new ArrayList (); 231 m_defaultPropertiesOnStructure = true; 232 m_enableAdvancedPropertyTabs = true; 233 m_defaultUserSettings = new CmsDefaultUserSettings(); 234 m_defaultAccess = new CmsExplorerTypeAccess(); 235 m_galleries = new HashMap (); 236 m_messages = new HashMap (); 237 m_workflowMessage = false; 238 m_multiContextMenu = new CmsExplorerContextMenu(); 239 m_multiContextMenu.setMultiMenu(true); 240 241 m_explorerTypeSettings = null; 243 } 244 245 251 public static boolean isWorkplaceUser(HttpServletRequest req) { 252 253 HttpSession session = req.getSession(false); 254 if (session != null) { 255 return null != session.getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS); 257 } 258 return false; 260 } 261 262 267 public void addDialogHandler(I_CmsDialogHandler clazz) { 268 269 m_dialogHandler.put(clazz.getDialogHandler(), clazz); 270 if (CmsLog.INIT.isInfoEnabled()) { 271 CmsLog.INIT.info(Messages.get().getBundle().key( 272 Messages.INIT_ADD_DIALOG_HANDLER_2, 273 clazz.getDialogHandler(), 274 clazz.getClass().getName())); 275 } 276 } 277 278 283 public void addExplorerTypeSetting(CmsExplorerTypeSettings settings) { 284 285 m_explorerTypeSettingsFromXml.add(settings); 286 if (CmsLog.INIT.isInfoEnabled()) { 287 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_ADD_TYPE_SETTING_1, settings.getName())); 288 } 289 if (m_explorerTypeSettings != null) { 290 initExplorerTypeSettings(); 292 } 293 } 294 295 300 public void addExplorerTypeSettings(CmsModule module) { 301 302 List explorerTypes = module.getExplorerTypes(); 303 if ((explorerTypes != null) && (explorerTypes.size() > 0)) { 304 Iterator i = explorerTypes.iterator(); 305 while (i.hasNext()) { 306 CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)i.next(); 307 m_explorerTypeSettingsFromModules.add(settings); 308 if (CmsLog.INIT.isInfoEnabled()) { 309 CmsLog.INIT.info(Messages.get().getBundle().key( 310 Messages.INIT_ADD_TYPE_SETTING_1, 311 settings.getName())); 312 } 313 } 314 initExplorerTypeSettings(); 316 } 317 } 318 319 325 public void addExportPoint(String uri, String destination) { 326 327 CmsExportPoint point = new CmsExportPoint(uri, destination); 328 m_exportPoints.add(point); 329 if (CmsLog.INIT.isInfoEnabled() && (point.getDestinationPath() != null)) { 330 CmsLog.INIT.info(Messages.get().getBundle().key( 331 Messages.INIT_ADD_EXPORT_POINT_2, 332 point.getUri(), 333 point.getDestinationPath())); 334 } 335 } 336 337 342 public void addLabeledFolder(String uri) { 343 344 m_labelSiteFolders.add(uri); 345 if (CmsLog.INIT.isInfoEnabled()) { 346 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LABEL_LINKS_IN_FOLDER_1, uri)); 347 } 348 } 349 350 355 public void addLocalizedFolder(String uri) { 356 357 m_localizedFolders.add(uri); 358 if (CmsLog.INIT.isInfoEnabled()) { 359 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_LOCALIZED_1, uri)); 360 } 361 } 362 363 368 public boolean autoLockResources() { 369 370 return m_autoLockResources; 371 } 372 373 378 public void cmsEvent(CmsEvent event) { 379 380 switch (event.getType()) { 381 case I_CmsEventListener.EVENT_CLEAR_CACHES: 382 m_messages = new HashMap (); 384 if (LOG.isDebugEnabled()) { 385 LOG.debug(Messages.get().getBundle().key(Messages.LOG_EVENT_CLEAR_CACHES_0)); 386 } 387 break; 388 default: } 390 } 391 392 397 public CmsExplorerTypeAccess getDefaultAccess() { 398 399 return m_defaultAccess; 400 } 401 402 407 public Locale getDefaultLocale() { 408 409 return m_defaultLocale; 410 } 411 412 417 public CmsDefaultUserSettings getDefaultUserSettings() { 418 419 return m_defaultUserSettings; 420 } 421 422 427 public Map getDialogHandler() { 428 429 return m_dialogHandler; 430 } 431 432 438 public Object getDialogHandler(String key) { 439 440 return m_dialogHandler.get(key); 441 } 442 443 448 public I_CmsDirectEditProvider getDirectEditProvider() { 449 450 return m_directEditProvider.newInstance(); 451 } 452 453 458 public I_CmsEditorActionHandler getEditorActionHandler() { 459 460 return m_editorAction; 461 } 462 463 468 public CmsEditorDisplayOptions getEditorDisplayOptions() { 469 470 return m_editorDisplayOptions; 471 } 472 473 478 public I_CmsEditorHandler getEditorHandler() { 479 480 return m_editorHandler; 481 } 482 483 488 public String getEncoding() { 489 490 return m_encoding; 491 } 492 493 499 public CmsExplorerTypeSettings getExplorerTypeSetting(String type) { 500 501 return (CmsExplorerTypeSettings)m_explorerTypeSettingsMap.get(type); 502 } 503 504 511 public List getExplorerTypeSettings() { 512 513 if (m_explorerTypeSettings == null) { 514 initExplorerTypeSettings(); 516 } 517 518 return m_explorerTypeSettings; 519 } 520 521 526 public Set getExportPoints() { 527 528 return m_exportPoints; 529 } 530 531 537 public long getFileBytesMaxUploadSize(CmsObject cms) { 538 539 int maxFileSize = getFileMaxUploadSize(); 540 long maxFileSizeBytes = maxFileSize * 1024; 541 if ((maxFileSize <= 0) || cms.hasRole(CmsRole.VFS_MANAGER)) { 543 maxFileSizeBytes = -1; 544 } 545 return maxFileSizeBytes; 546 } 547 548 553 public int getFileMaxUploadSize() { 554 555 return m_fileMaxUploadSize; 556 } 557 558 568 public CmsRfsFileViewer getFileViewSettings() { 569 570 return m_fileViewSettings; 571 } 572 573 580 public Map getGalleries() { 581 582 return m_galleries; 583 } 584 585 588 public CmsI18nInfo getI18nInfo(HttpServletRequest req, CmsUser user, CmsProject project, String resource) { 589 590 Locale locale = null; 591 if (req != null) { 593 try { 595 req.setCharacterEncoding(m_encoding); 596 } catch (UnsupportedEncodingException e) { 597 LOG.error(Messages.get().getBundle().key(Messages.LOG_UNSUPPORTED_ENCODING_SET_1, m_encoding), e); 599 } 600 HttpSession session = req.getSession(false); 602 if (session != null) { 603 CmsWorkplaceSettings settings = (CmsWorkplaceSettings)session.getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS); 604 if (settings != null) { 605 locale = settings.getUserSettings().getLocale(); 606 } 607 } 608 } 609 610 if (locale == null) { 611 if (!user.isGuestUser()) { 613 CmsUserSettings settings = new CmsUserSettings(user); 615 locale = settings.getLocale(); 616 617 } 618 if (req != null) { 619 List acceptedLocales = (new CmsAcceptLanguageHeaderParser(req, getDefaultLocale())).getAcceptedLocales(); 620 if ((locale != null) && (!acceptedLocales.contains(locale))) { 621 acceptedLocales.add(0, locale); 622 } 623 locale = OpenCms.getLocaleManager().getFirstMatchingLocale(acceptedLocales, m_locales); 624 } 625 626 if (locale == null) { 628 locale = getDefaultLocale(); 629 } 630 } 631 632 return new CmsI18nInfo(locale, m_encoding); 633 } 634 635 640 public List getLabelSiteFolders() { 641 642 return m_labelSiteFolders; 643 } 644 645 652 public List getLocales() { 653 654 return m_locales; 655 } 656 657 662 public List getLocalizedFolders() { 663 664 return m_localizedFolders; 665 } 666 667 680 public CmsWorkplaceMessages getMessages(Locale locale) { 681 682 CmsWorkplaceMessages result = (CmsWorkplaceMessages)m_messages.get(locale); 683 if (result != null) { 684 return result; 686 } 687 688 synchronized (this) { 690 result = new CmsWorkplaceMessages(locale); 691 m_messages.put(locale, result); 692 } 693 return result; 694 } 695 696 701 public CmsExplorerContextMenu getMultiContextMenu() { 702 703 return m_multiContextMenu; 704 } 705 706 711 public int getTempFileProjectId() { 712 713 if (m_tempFileProject != null) { 714 return m_tempFileProject.getId(); 715 } else { 716 return -1; 717 } 718 } 719 720 725 public CmsToolManager getToolManager() { 726 727 if (m_toolManager == null) { 728 m_toolManager = new CmsToolManager(); 729 } 730 return m_toolManager; 731 } 732 733 738 public List getViews() { 739 740 return m_views; 741 } 742 743 748 public CmsWorkplaceEditorManager getWorkplaceEditorManager() { 749 750 return m_editorManager; 751 } 752 753 756 public void initHandler(CmsObject cms) { 757 758 m_locales = initWorkplaceLocales(cms); 760 } 761 762 771 public synchronized void initialize(CmsObject cms) throws CmsException, CmsRoleViolationException { 772 773 try { 774 cms.checkRole(CmsRole.WORKPLACE_MANAGER); 776 777 m_encoding = OpenCms.getSystemInfo().getDefaultEncoding(); 779 780 if (m_directEditProvider == null) { 782 m_directEditProvider = new CmsDirectEditDefaultProvider(); 783 } 784 785 m_explorerTypeSettingsFromModules.clear(); 787 CmsModuleManager moduleManager = OpenCms.getModuleManager(); 789 Iterator j = moduleManager.getModuleNames().iterator(); 790 while (j.hasNext()) { 791 CmsModule module = moduleManager.getModule((String )j.next()); 792 if (module != null) { 793 addExplorerTypeSettings(module); 794 } 795 } 796 initExplorerTypeSettings(); 798 initWorkplaceViews(cms); 800 m_editorManager = new CmsWorkplaceEditorManager(cms); 802 initHandler(cms); 804 805 if (CmsLog.INIT.isInfoEnabled()) { 806 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_VFS_ACCESS_INITIALIZED_0)); 807 } 808 try { 809 m_tempFileProject = cms.readProject(I_CmsProjectDriver.TEMP_FILE_PROJECT_NAME); 811 } catch (CmsException e) { 812 LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_TEMP_FILE_PROJECT_0)); 814 } 815 m_editorDisplayOptions = new CmsEditorDisplayOptions(); 817 818 m_galleries.clear(); 820 j = OpenCms.getResourceManager().getResourceTypes().iterator(); 822 while (j.hasNext()) { 823 I_CmsResourceType resourceType = (I_CmsResourceType)j.next(); 824 if (resourceType instanceof CmsResourceTypeFolderExtended) { 825 CmsResourceTypeFolderExtended galleryType = (CmsResourceTypeFolderExtended)resourceType; 827 String folderClassName = galleryType.getFolderClassName(); 828 if (CmsStringUtil.isNotEmpty(folderClassName)) { 829 try { 831 if (A_CmsGallery.class.isAssignableFrom(Class.forName(folderClassName))) { 833 A_CmsGallery galleryInstance = (A_CmsGallery)Class.forName(folderClassName).newInstance(); 835 galleryInstance.setResourceType(galleryType); 837 m_galleries.put(galleryType.getTypeName(), galleryInstance); 839 } 840 } catch (ClassNotFoundException e) { 841 LOG.error(e.getLocalizedMessage()); 842 } catch (InstantiationException e) { 843 LOG.error(e.getLocalizedMessage()); 844 } catch (IllegalAccessException e) { 845 LOG.error(e.getLocalizedMessage()); 846 } 847 } 848 } 849 } 850 851 getToolManager().configure(cms); 853 854 m_messages = new HashMap (); 856 857 OpenCms.addCmsEventListener(this, new int[] {I_CmsEventListener.EVENT_CLEAR_CACHES}); 859 860 } catch (CmsException e) { 861 throw new CmsException(Messages.get().container(Messages.ERR_INITIALIZE_WORKPLACE_0)); 862 } 863 } 864 865 870 public boolean isDefaultPropertiesOnStructure() { 871 872 return m_defaultPropertiesOnStructure; 873 } 874 875 880 public boolean isEnableAdvancedPropertyTabs() { 881 882 return m_enableAdvancedPropertyTabs; 883 } 884 885 890 public boolean isEnableWorkflowMessages() { 891 892 return m_workflowMessage; 893 } 894 895 900 public void removeExplorerTypeSettings(CmsModule module) { 901 902 List explorerTypes = module.getExplorerTypes(); 903 if ((explorerTypes != null) && (explorerTypes.size() > 0)) { 904 Iterator i = explorerTypes.iterator(); 905 while (i.hasNext()) { 906 CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)i.next(); 907 if (m_explorerTypeSettingsFromModules.contains(settings)) { 908 m_explorerTypeSettingsFromModules.remove(settings); 909 if (CmsLog.INIT.isInfoEnabled()) { 910 CmsLog.INIT.info(Messages.get().getBundle().key( 911 Messages.INIT_REMOVE_EXPLORER_TYPE_SETTING_1, 912 settings.getName())); 913 } 914 } 915 } 916 initExplorerTypeSettings(); 918 } 919 } 920 921 926 public void setAutoLock(String value) { 927 928 m_autoLockResources = Boolean.valueOf(value).booleanValue(); 929 if (CmsLog.INIT.isInfoEnabled()) { 930 CmsLog.INIT.info(Messages.get().getBundle().key( 931 m_autoLockResources ? Messages.INIT_AUTO_LOCK_ENABLED_0 : Messages.INIT_AUTO_LOCK_DISABLED_0)); 932 } 933 } 934 935 940 public void setDefaultAccess(CmsExplorerTypeAccess access) { 941 942 m_defaultAccess = access; 943 } 944 945 950 public void setDefaultLocale(String locale) { 951 952 try { 953 m_defaultLocale = CmsLocaleManager.getLocale(locale); 954 } catch (Exception e) { 955 if (CmsLog.INIT.isWarnEnabled()) { 956 CmsLog.INIT.warn(Messages.get().getBundle().key(Messages.INIT_NONCRIT_ERROR_0), e); 957 } 958 } 959 if (CmsLog.INIT.isInfoEnabled()) { 960 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DEFAULT_LOCALE_1, m_defaultLocale)); 961 } 962 } 963 964 969 public void setDefaultPropertiesOnStructure(String defaultPropertiesOnStructure) { 970 971 m_defaultPropertiesOnStructure = Boolean.valueOf(defaultPropertiesOnStructure).booleanValue(); 972 if (CmsLog.INIT.isInfoEnabled()) { 973 CmsLog.INIT.info(Messages.get().getBundle().key( 974 m_defaultPropertiesOnStructure ? Messages.INIT_PROP_ON_STRUCT_TRUE_0 975 : Messages.INIT_PROP_ON_STRUCT_FALSE_0)); 976 } 977 } 978 979 984 public void setDefaultUserSettings(CmsDefaultUserSettings defaultUserSettings) { 985 986 m_defaultUserSettings = defaultUserSettings; 987 988 if (CmsLog.INIT.isInfoEnabled()) { 989 CmsLog.INIT.info(Messages.get().getBundle().key( 990 Messages.INIT_DEFAULT_USER_SETTINGS_1, 991 m_defaultUserSettings)); 992 } 993 } 994 995 1000 public void setDirectEditProvider(I_CmsDirectEditProvider clazz) { 1001 1002 m_directEditProvider = clazz; 1003 if (CmsLog.INIT.isInfoEnabled()) { 1004 CmsLog.INIT.info(Messages.get().getBundle().key( 1005 Messages.INIT_DIRECT_EDIT_PROVIDER_1, 1006 m_directEditProvider.getClass().getName())); 1007 } 1008 } 1009 1010 1015 public void setEditorAction(I_CmsEditorActionHandler clazz) { 1016 1017 m_editorAction = clazz; 1018 if (CmsLog.INIT.isInfoEnabled()) { 1019 CmsLog.INIT.info(Messages.get().getBundle().key( 1020 Messages.INIT_EDITOR_ACTION_CLASS_1, 1021 m_editorAction.getClass().getName())); 1022 } 1023 } 1024 1025 1030 public void setEditorDisplayOptions(CmsEditorDisplayOptions clazz) { 1031 1032 m_editorDisplayOptions = clazz; 1033 if (CmsLog.INIT.isInfoEnabled()) { 1034 CmsLog.INIT.info(Messages.get().getBundle().key( 1035 Messages.INIT_EDITOR_DISPLAY_OPTS_1, 1036 m_editorAction.getClass().getName())); 1037 } 1038 } 1039 1040 1045 public void setEditorHandler(I_CmsEditorHandler clazz) { 1046 1047 m_editorHandler = clazz; 1048 if (CmsLog.INIT.isInfoEnabled()) { 1049 CmsLog.INIT.info(Messages.get().getBundle().key( 1050 Messages.INIT_EDITOR_HANDLER_CLASS_1, 1051 m_editorHandler.getClass().getName())); 1052 } 1053 } 1054 1055 1060 public void setEnableAdvancedPropertyTabs(String enableAdvancedPropertyTabs) { 1061 1062 m_enableAdvancedPropertyTabs = Boolean.valueOf(enableAdvancedPropertyTabs).booleanValue(); 1063 if (CmsLog.INIT.isInfoEnabled()) { 1064 CmsLog.INIT.info(Messages.get().getBundle().key( 1065 m_enableAdvancedPropertyTabs ? Messages.INIT_ADV_PROP_DIALOG_SHOW_TABS_0 1066 : Messages.INIT_ADV_PROP_DIALOG_HIDE_TABS_0)); 1067 } 1068 } 1069 1070 1075 public void setFileMaxUploadSize(String value) { 1076 1077 try { 1078 m_fileMaxUploadSize = Integer.valueOf(value).intValue(); 1079 } catch (NumberFormatException e) { 1080 if (LOG.isInfoEnabled()) { 1082 LOG.info(e.getLocalizedMessage()); 1083 } 1084 m_fileMaxUploadSize = -1; 1085 } 1086 if (CmsLog.INIT.isInfoEnabled()) { 1087 if (m_fileMaxUploadSize > 0) { 1088 CmsLog.INIT.info(Messages.get().getBundle().key( 1089 Messages.INIT_MAX_FILE_UPLOAD_SIZE_1, 1090 new Integer (m_fileMaxUploadSize))); 1091 } else { 1092 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_MAX_FILE_UPLOAD_SIZE_UNLIMITED_0)); 1093 } 1094 1095 } 1096 } 1097 1098 1106 public void setFileViewSettings(CmsObject cms, CmsRfsFileViewer fileViewSettings) throws CmsRoleViolationException { 1107 1108 if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { 1109 cms.checkRole(CmsRole.ADMINISTRATOR); 1110 } 1111 m_fileViewSettings = fileViewSettings; 1112 m_fileViewSettings.setFrozen(true); 1114 } 1115 1116 1121 public void setMultiContextMenu(CmsExplorerContextMenu multiContextMenu) { 1122 1123 multiContextMenu.setMultiMenu(true); 1124 m_multiContextMenu = multiContextMenu; 1125 } 1126 1127 1132 public void setToolManager(CmsToolManager toolManager) { 1133 1134 m_toolManager = toolManager; 1135 } 1136 1137 1142 public void setUserManagementEnabled(String value) { 1143 1144 m_showUserGroupIcon = Boolean.valueOf(value).booleanValue(); 1145 if (CmsLog.INIT.isInfoEnabled()) { 1146 if (m_showUserGroupIcon) { 1147 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_USER_MANAGEMENT_ICON_ENABLED_0)); 1148 } else { 1149 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_USER_MANAGEMENT_ICON_DISABLED_0)); 1150 } 1151 } 1152 } 1153 1154 1159 public void setWorkflowMessage(String workflowMessage) { 1160 1161 m_workflowMessage = Boolean.valueOf(workflowMessage).booleanValue(); 1162 if (CmsLog.INIT.isInfoEnabled()) { 1163 CmsLog.INIT.info(Messages.get().getBundle().key( 1164 m_workflowMessage ? Messages.INIT_WORKFLOW_MESSAGES_SHOW_MESSAGE_0 1165 : Messages.INIT_WORKFLOW_MESSAGES_HIDE_MESSAGE_0)); 1166 } 1167 } 1168 1169 1174 public boolean showUserGroupIcon() { 1175 1176 return m_showUserGroupIcon; 1177 } 1178 1179 1182 private synchronized void initExplorerTypeSettings() { 1183 1184 Map explorerTypeSettingsMap = new HashMap (); 1185 List explorerTypeSettings = new ArrayList (); 1186 1187 explorerTypeSettings.addAll(m_explorerTypeSettingsFromXml); 1188 explorerTypeSettings.addAll(m_explorerTypeSettingsFromModules); 1189 1190 for (int i = 0; i < explorerTypeSettings.size(); i++) { 1191 CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)explorerTypeSettings.get(i); 1192 explorerTypeSettingsMap.put(settings.getName(), settings); 1194 try { 1195 settings.getAccess().createAccessControlList(); 1197 } catch (CmsException e) { 1198 if (CmsLog.INIT.isInfoEnabled()) { 1199 CmsLog.INIT.info(Messages.get().getBundle().key( 1200 Messages.INIT_ADD_TYPE_SETTING_FAILED_1, 1201 settings.getName()), e); 1202 } 1203 } 1204 } 1205 Collections.sort(explorerTypeSettings); 1207 m_explorerTypeSettings = Collections.unmodifiableList(explorerTypeSettings); 1209 m_explorerTypeSettingsMap = Collections.unmodifiableMap(explorerTypeSettingsMap); 1210 } 1211 1212 1222 private List initWorkplaceLocales(CmsObject cms) { 1223 1224 Set locales = new HashSet (); 1225 List localeFolders; 1226 try { 1227 localeFolders = cms.getSubFolders(CmsWorkplace.VFS_PATH_LOCALES); 1228 } catch (CmsException e) { 1229 LOG.error(Messages.get().getBundle().key( 1230 Messages.LOG_WORKPLACE_INIT_NO_LOCALES_1, 1231 CmsWorkplace.VFS_PATH_LOCALES)); 1232 localeFolders = new ArrayList (); 1234 } 1235 Iterator i = localeFolders.iterator(); 1236 while (i.hasNext()) { 1237 CmsFolder folder = (CmsFolder)i.next(); 1238 Locale locale = CmsLocaleManager.getLocale(folder.getName()); 1239 locales.add(locale); 1241 locales.add(new Locale (locale.getLanguage(), locale.getCountry())); 1243 locales.add(new Locale (locale.getLanguage())); 1245 } 1246 1247 ArrayList result = new ArrayList (); 1249 result.addAll(locales); 1250 Collections.sort(result, CmsLocaleComparator.getComparator()); 1251 return result; 1252 } 1253 1254 1264 private List initWorkplaceViews(CmsObject cms) { 1265 1266 List viewFolders = new ArrayList (); 1267 try { 1268 viewFolders = cms.getSubFolders(CmsWorkplace.VFS_PATH_VIEWS); 1270 } catch (CmsException e) { 1271 if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING && LOG.isErrorEnabled()) { 1272 LOG.error(Messages.get().getBundle().key( 1273 Messages.LOG_WORKPLACE_INIT_NO_VIEWS_1, 1274 CmsWorkplace.VFS_PATH_VIEWS), e); 1275 } 1276 viewFolders = new ArrayList (); 1278 } 1279 m_views = new ArrayList (viewFolders.size()); 1280 for (int i = 0; i < viewFolders.size(); i++) { 1281 CmsFolder folder = (CmsFolder)viewFolders.get(i); 1283 String folderPath = cms.getSitePath(folder); 1284 try { 1285 String order = cms.readPropertyObject(folderPath, CmsPropertyDefinition.PROPERTY_NAVPOS, false).getValue(); 1287 String key = cms.readPropertyObject(folderPath, CmsPropertyDefinition.PROPERTY_NAVTEXT, false).getValue(); 1288 String viewUri = cms.readPropertyObject(folderPath, CmsPropertyDefinition.PROPERTY_DEFAULT_FILE, false).getValue(); 1289 if (viewUri == null) { 1290 viewUri = folderPath; 1292 } else if (!viewUri.startsWith("/")) { 1293 viewUri = folderPath + viewUri; 1295 } 1296 if (order == null) { 1297 order = "" + i; 1299 } 1300 Float orderValue; 1301 try { 1302 orderValue = Float.valueOf(order); 1304 } catch (NumberFormatException e) { 1305 orderValue = Float.valueOf("" + i); 1307 } 1308 if (key == null) { 1309 key = "View " + i; 1311 continue; 1313 } 1314 CmsWorkplaceView view = new CmsWorkplaceView(key, viewUri, orderValue); 1316 m_views.add(view); 1317 if (CmsLog.INIT.isInfoEnabled()) { 1319 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_VIEW_1, view.getUri())); 1320 } 1321 } catch (CmsException e) { 1322 LOG.error(Messages.get().getBundle().key(Messages.LOG_READING_VIEW_FOLDER_FAILED_1, folderPath), e); 1324 } 1325 } 1326 Collections.sort(m_views); 1328 return m_views; 1329 } 1330} | Popular Tags |