/** * Converts a property object to a field value for one of the boolean selection widgets.<p> * * @param prop the property to convert * @return the field value */ private String convertPropertyToFieldValue(CmsProperty prop) { if (prop == null) { return ""; } return "" + Boolean.valueOf(prop.getValue()); }
/** * Determines if the title property of the default file should be changed.<p> * * @param properties the current default file properties * @param folderNavtext the 'NavText' property of the folder * * @return <code>true</code> if the title property should be changed */ private boolean shouldChangeDefaultFileTitle(Map<String, CmsProperty> properties, CmsProperty folderNavtext) { return (properties == null) || (properties.get(CmsPropertyDefinition.PROPERTY_TITLE) == null) || (properties.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue() == null) || ((folderNavtext != null) && properties.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue().equals(folderNavtext.getValue())); }
/** * Determines if the title property should be changed in case of a 'NavText' change.<p> * * @param properties the current resource properties * * @return <code>true</code> if the title property should be changed in case of a 'NavText' change */ private boolean shouldChangeTitle(Map<String, CmsProperty> properties) { return (properties == null) || (properties.get(CmsPropertyDefinition.PROPERTY_TITLE) == null) || (properties.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue() == null) || ((properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT) != null) && properties.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue().equals( properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT).getValue())); }
/** * Determines if the title property should be changed in case of a 'NavText' change.<p> * * @param properties the current resource properties * * @return <code>true</code> if the title property should be changed in case of a 'NavText' change */ private boolean shouldChangeTitle(Map<String, CmsProperty> properties) { return (properties == null) || (properties.get(CmsPropertyDefinition.PROPERTY_TITLE) == null) || (properties.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue() == null) || ((properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT) != null) && properties.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue().equals( properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT).getValue())); }
/** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String result; try { // read the requested property result = m_cms.readPropertyObject(m_res, String.valueOf(input), m_search, m_locale).getValue(); } catch (@SuppressWarnings("unused") CmsException e) { // unable to read property, return null result = null; } return result; } }
/** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String result; try { // read the properties of the requested resource result = getCmsObject().readPropertyObject(m_resource, String.valueOf(input), m_search).getValue(); } catch (CmsException e) { // in case of any error we assume the property does not exist result = null; } return result; } }
/** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String result; try { // read the properties of the requested resource result = getCmsObject().readPropertyObject(m_resource, String.valueOf(input), m_search).getValue(); } catch (CmsException e) { // in case of any error we assume the property does not exist result = null; } return result; } }
/** * Unmarshals the descriptor content. * * @throws CmsXmlException thrown if the XML structure of the descriptor is wrong. * @throws CmsException thrown if reading the descriptor file fails. */ private void unmarshalDescriptor() throws CmsXmlException, CmsException { if (null != m_desc) { // unmarshal descriptor m_descContent = CmsXmlContentFactory.unmarshal(m_cms, m_cms.readFile(m_desc)); // configure messages if wanted CmsProperty bundleProp = m_cms.readPropertyObject(m_desc, PROPERTY_BUNDLE_DESCRIPTOR_LOCALIZATION, true); if (!(bundleProp.isNullProperty() || bundleProp.getValue().trim().isEmpty())) { m_configuredBundle = bundleProp.getValue(); } } }
/** * @see org.opencms.loader.I_CmsTemplateContextProvider#readCommonProperty(org.opencms.file.CmsObject, java.lang.String, java.lang.String) */ public String readCommonProperty(CmsObject cms, String propertyName, String fallbackValue) throws CmsException { String templatePath = getAllContexts().get("desktop").getTemplatePath(); return cms.readPropertyObject(templatePath, propertyName, false).getValue(fallbackValue); }
/** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String result; try { // read the requested history property result = CmsProperty.get( String.valueOf(input), getCmsObject().readHistoryPropertyObjects(m_res)).getValue(); } catch (@SuppressWarnings("unused") CmsException e) { // unable to read history property, return null result = null; } return result; } }
/** * Initializes the user object.<p> */ protected void initFileInfo() { try { // edit an existing user, get the user object from db m_path = getParamResource(); m_title = getCms().readPropertyObject(m_path, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue("-"); } catch (CmsException e) { // should never happen } } }
/** * Initializes the user object.<p> */ protected void initFileInfo() { try { // edit an existing user, get the user object from db m_path = getParamResource(); m_title = getCms().readPropertyObject(m_path, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue("-"); } catch (CmsException e) { // should never happen } } }
/** * @see org.opencms.loader.I_CmsTemplateContextProvider#getEditorStyleSheet(org.opencms.file.CmsObject, java.lang.String) */ public String getEditorStyleSheet(CmsObject cms, String editedResourcePath) { String templatePath = getAllContexts().get("desktop").getTemplatePath(); String result = null; try { CmsProperty property = cms.readPropertyObject(templatePath, CmsPropertyDefinition.PROPERTY_TEMPLATE, true); if (!property.isNullProperty()) { result = property.getValue(); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } return result; }
/** * Returns the appropriate locale for the given destination.<p> * * @param destination the destination path (parent must exist) * @param properties the properties to check at first * * @return the locale */ protected Locale getLocale(String destination, List<CmsProperty> properties) { String localeName = CmsProperty.get(CmsPropertyDefinition.PROPERTY_LOCALE, properties).getValue(); if (localeName != null) { // locale was already set on the files properties return OpenCms.getLocaleManager().getAvailableLocales(localeName).get(0); } // locale not set in properties, read default locales return OpenCms.getLocaleManager().getDefaultLocales(m_cms, CmsResource.getParentFolder(destination)).get(0); }
@Override protected CmsVfsEntryBean createEntry(CmsObject innerCms, CmsResource innerResource) throws CmsException { String title = innerCms.readPropertyObject( innerResource, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue(); return internalCreateVfsEntryBean( getCmsObject(), innerResource, title, true, isEditable(innerCms, innerResource), null, false); } };
/** * 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; }
/** * Helper method to convert the content of a resource to a string.<p> * * @param file the file * @return the file content as a string * * @throws CmsException if something goes wrong */ protected String getContentAsString(CmsFile file) throws CmsException { CmsProperty p = m_cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true); String e = p.getValue(); if (e == null) { e = OpenCms.getSystemInfo().getDefaultEncoding(); } return CmsEncoder.createString(file.getContents(), e); }
/** * Helper method to determine the encoding of the given file in the VFS, * which must be set using the "content-encoding" property.<p> * * @param cms the CmsObject * @param filename the name of the file which is to be checked * @return the encoding for the file */ protected String getFileEncoding(CmsObject cms, String filename) { try { return cms.readPropertyObject(filename, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue( OpenCms.getSystemInfo().getDefaultEncoding()); } catch (CmsException e) { return OpenCms.getSystemInfo().getDefaultEncoding(); } }
/** * Helper method to determine the encoding of the given file in the VFS, * which must be set using the "content-encoding" property.<p> * * @param cms the CmsObject * @param filename the name of the file which is to be checked * @return the encoding for the file */ protected String getFileEncoding(CmsObject cms, String filename) { try { return cms.readPropertyObject(filename, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue( OpenCms.getSystemInfo().getDefaultEncoding()); } catch (CmsException e) { return OpenCms.getSystemInfo().getDefaultEncoding(); } }