/** * 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); } } }
/** * 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.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(); }
/** * Returns the OpenCms VFS uri of the template of the current page.<p> * * @return the OpenCms VFS uri of the template of the current page */ public String getUriTemplate() { String result = ""; try { result = getCms().readPropertyObject(getParamTempfile(), CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue( ""); } catch (CmsException e) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_FAILED_0), e); } return result; }
/** * Returns the OpenCms VFS uri of the template of the current page.<p> * * @return the OpenCms VFS uri of the template of the current page */ public String getUriTemplate() { String result = ""; try { result = getCms().readPropertyObject( getParamTempfile(), CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue(""); } catch (CmsException e) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_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( org.opencms.workplace.editors.Messages.get().getBundleName(), settings.getLocale()); m_editButtonStyle = settings.getEditorButtonStyle(); }
/** * Constructor with xml data String.<p> * * @param xmlData the XML data String containing the information about the editor * @param editorUri the editor workplace URI */ public CmsWorkplaceEditorConfiguration(byte[] xmlData, String editorUri) { setValidConfiguration(true); try { initialize(CmsXmlUtils.unmarshalHelper(xmlData, null), editorUri); } catch (CmsXmlException e) { // xml String could not be parsed logConfigurationError(Messages.get().getBundle().key(Messages.ERR_XML_PARSE_0), e); } }
/** * Constructor with xml data String.<p> * * @param xmlData the XML data String containing the information about the editor * @param editorUri the editor workplace URI * @param name the editor configuration name */ public CmsWorkplaceEditorConfiguration(byte[] xmlData, String editorUri, String name) { setValidConfiguration(true); try { m_name = name; initialize(CmsXmlUtils.unmarshalHelper(xmlData, null), editorUri); } catch (CmsXmlException e) { // xml String could not be parsed logConfigurationError(Messages.get().getBundle().key(Messages.ERR_XML_PARSE_0), e); } }
/** * Writes the xml content to the vfs and re-initializes the member variables.<p> * * @throws CmsException if writing the file fails */ private void writeContent() throws CmsException { String decodedContent = m_content.toString(); try { m_file.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException(Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); } // the file content might have been modified during the write operation m_file = getCloneCms().writeFile(m_file); m_content = CmsXmlContentFactory.unmarshal(getCloneCms(), m_file); } }
/** * Shows the error dialog when no valid editor is found and returns null for the editor URI.<p> * * @param jsp the instantiated CmsJspActionElement * @param t a throwable object, can be null */ private static void showErrorDialog(CmsJspActionElement jsp, Throwable t) { CmsDialog wp = new CmsDialog(jsp); wp.setParamMessage(Messages.get().getBundle(wp.getLocale()).key(Messages.ERR_NO_EDITOR_FOUND_0)); wp.fillParamValues(jsp.getRequest()); try { wp.includeErrorpage(wp, t); } catch (JspException e) { LOG.debug(org.opencms.workplace.commons.Messages.get().getBundle().key( org.opencms.workplace.commons.Messages.LOG_ERROR_INCLUDE_FAILED_1, CmsWorkplace.FILE_DIALOG_SCREEN_ERRORPAGE), e); } }