/** * Sets the list of compiled browser patterns.<p> * * @param pattern the list of compiled browser patterns */ private void setBrowserPattern(List<Pattern> pattern) { if ((pattern == null) || (pattern.size() == 0)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_PATTERN_0)); } m_browserPattern = pattern; }
/** * Sets the valid user agents regular expressions of the editor.<p> * * @param agents the valid user agents regular expressions of the editor */ private void setUserAgentsRegEx(List<String> agents) { if ((agents == null) || (agents.size() == 0)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_USER_AGENTS_0)); } m_userAgentsRegEx = agents; }
/** * Sets the valid resource types of the editor.<p> * * @param types the valid resource types of the editor */ private void setResourceTypes(Map types) { if ((types == null) || (types.size() == 0)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_RESOURCE_TYPES_0)); } m_resTypes = types; }
/** * Sets the valid resource types of the editor.<p> * * @param types the valid resource types of the editor */ private void setResourceTypes(Map<String, String[]> types) { if ((types == null) || (types.size() == 0)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_RESOURCE_TYPES_0)); } m_resTypes = types; }
/** * Sets the valid user agents regular expressions of the editor.<p> * * @param agents the valid user agents regular expressions of the editor */ private void setUserAgentsRegEx(List agents) { if ((agents == null) || (agents.size() == 0)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_USER_AGENTS_0)); } m_userAgentsRegEx = agents; }
/** * Sets the list of compiled browser patterns.<p> * * @param pattern the list of compiled browser patterns */ private void setBrowserPattern(List pattern) { if ((pattern == null) || (pattern.size() == 0)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_PATTERN_0)); } m_browserPattern = pattern; }
/** * Logs configuration errors and invalidates the current configuration.<p> * * @param message the message specifying the configuration error * @param t the Throwable object or null */ private void logConfigurationError(String message, Throwable t) { setValidConfiguration(false); if (LOG.isErrorEnabled()) { if (t == null) { LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_ERROR_1, message)); } else { LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_ERROR_1, message), t); } } }
/** * Logs configuration errors and invalidates the current configuration.<p> * * @param message the message specifying the configuration error * @param t the Throwable object or null */ private void logConfigurationError(String message, Throwable t) { setValidConfiguration(false); if (LOG.isErrorEnabled()) { if (t == null) { LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_ERROR_1, message)); } else { LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_ERROR_1, message), t); } } }
/** * Tests if the current browser is matching the configuration.<p> * * @param currentBrowser the users browser String to test * @return true if the browser matches the configuration, otherwise false */ public boolean matchesBrowser(String currentBrowser) { if (currentBrowser == null) { return false; } for (int i = 0; i < getBrowserPattern().size(); i++) { boolean matches = getBrowserPattern().get(i).matcher(currentBrowser.trim()).matches(); if (matches) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_BROWSER_MATCHES_CONFIG_1, currentBrowser)); } return true; } } return false; }
/** * Tests if the current browser is matching the configuration.<p> * * @param currentBrowser the users browser String to test * @return true if the browser matches the configuration, otherwise false */ public boolean matchesBrowser(String currentBrowser) { if (currentBrowser == null) { return false; } for (int i = 0; i < getBrowserPattern().size(); i++) { boolean matches = ((Pattern)getBrowserPattern().get(i)).matcher(currentBrowser.trim()).matches(); if (matches) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_BROWSER_MATCHES_CONFIG_1, currentBrowser)); } return true; } } return false; }
/** * Sets the editor workplace URI.<p> * @param uri the editor workplace URI */ private void setEditorUri(String uri) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(uri)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_URI_0)); } m_editorUri = uri; }
/** * Sets the editor label key used for the localized nice name.<p> * * @param label the editor label key used for the localized nice name */ private void setEditorLabel(String label) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(label)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_LABEL_0)); } m_editorLabel = label; }
/** * Sets the editor label key used for the localized nice name.<p> * * @param label the editor label key used for the localized nice name */ private void setEditorLabel(String label) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(label)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_LABEL_0)); } m_editorLabel = label; }
/** * Sets the editor workplace URI.<p> * @param uri the editor workplace URI */ private void setEditorUri(String uri) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(uri)) { setValidConfiguration(false); LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_URI_0)); } m_editorUri = uri; }
/** * @see org.opencms.workplace.editors.I_CmsEditorCssHandler#matches(org.opencms.file.CmsObject, java.lang.String) */ public boolean matches(CmsObject cms, String editedResourcePath) { // determine the path of the template String templatePath = ""; try { templatePath = cms.readPropertyObject(editedResourcePath, CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue( ""); } catch (CmsException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_FAILED_0), e); } } if (CmsStringUtil.isNotEmpty(templatePath)) { // found the template path, check if it is the template one template return CmsTemplateLayout.VFS_PATH_TEMPLATE.equals(templatePath); } return false; }
/** * @see org.opencms.workplace.editors.I_CmsEditorCssHandler#matches(org.opencms.file.CmsObject, java.lang.String) */ public boolean matches(CmsObject cms, String editedResourcePath) { // determine the path of the template String templatePath = ""; try { templatePath = cms.readPropertyObject(editedResourcePath, CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue( ""); } catch (CmsException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_FAILED_0), e); } } if (CmsStringUtil.isNotEmpty(templatePath)) { // found the template path, check if it is the template one template return VFS_PATH_TEMPLATE.equals(templatePath); } return false; }
/** * @see org.opencms.workplace.editors.I_CmsEditorCssHandler#getUriStyleSheet(org.opencms.file.CmsObject, java.lang.String) */ public String getUriStyleSheet(CmsObject cms, String editedResourcePath) { String result = ""; try { // determine the path of the template String templatePath = ""; try { templatePath = cms.readPropertyObject(editedResourcePath, CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue( ""); } catch (CmsException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_FAILED_0), e); } } if (CmsStringUtil.isNotEmpty(templatePath)) { // read the template property value from the template file where the absolute CSS path is (or should be) stored result = cms.readPropertyObject(templatePath, CmsPropertyDefinition.PROPERTY_TEMPLATE, false).getValue( ""); } } catch (CmsException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_STYLESHEET_FAILED_0), e); } } return result; }
/** * @see org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider#init(org.opencms.file.CmsObject, org.opencms.workplace.editors.directedit.CmsDirectEditMode, java.lang.String) */ public void init(CmsObject cms, CmsDirectEditMode mode, String fileName) { m_cms = cms; m_fileName = fileName; if (CmsStringUtil.isEmpty(m_fileName)) { m_fileName = INCLUDE_FILE_DEFAULT; } m_mode = mode != null ? mode : CmsDirectEditMode.AUTO; m_rnd = new Random(); CmsUserSettings settings = new CmsUserSettings(cms); m_messages = new CmsMessages(Messages.get().getBundleName(), settings.getLocale()); m_editButtonStyle = settings.getEditorButtonStyle(); }
/** * Creates a list of possible elements of a template from the template property "template-elements" * and the elements available in the provided resource file.<p> * * @param cms the CmsObject * @param xmlPageUri the resource to read the elements from * @param locale the current element locale * @return the list of elements in a String array with element name, nice name (if present) and mandatory flag */ public static List computeElements(CmsObject cms, String xmlPageUri, Locale locale) { CmsXmlPage page = null; try { // read the xmlpage file CmsFile pageFile = cms.readFile(xmlPageUri, CmsResourceFilter.IGNORE_EXPIRATION); page = CmsXmlPageFactory.unmarshal(cms, pageFile); } catch (CmsException e) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_XMLPAGE_FAILED_1, xmlPageUri), e); // xmlpage will be null, only "template-elements" property on template will be checked } return computeElements(cms, page, xmlPageUri, locale); }
} else { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, getParamResource()));