/** * Delegate method for {@link CmsObject#readPropertyObject(CmsResource, String, boolean)}.<p> * * @see CmsObject#readPropertyObject(CmsResource, String, boolean) * * @param resource the resource where the property is attached to * @param property the property name * @param search if true, the property is searched on all parent folders of the resource, * if it's not found attached directly to the resource * * @return the required property, or <code>{@link CmsProperty#getNullProperty()}</code> if the property was not found * * @throws CmsException if something goes wrong */ public CmsProperty readPropertyObject(CmsResource resource, String property, boolean search) throws CmsException { return m_cms.readPropertyObject(resource, property, search); }
/** * Delegate method for {@link CmsObject#readPropertyObject(CmsResource, String, boolean)}.<p> * * @see CmsObject#readPropertyObject(CmsResource, String, boolean) * * @param resource the resource where the property is attached to * @param property the property name * @param search if true, the property is searched on all parent folders of the resource, * if it's not found attached directly to the resource * * @return the required property, or <code>{@link CmsProperty#getNullProperty()}</code> if the property was not found * * @throws CmsException if something goes wrong */ public CmsProperty readPropertyObject(CmsResource resource, String property, boolean search) throws CmsException { return m_cms.readPropertyObject(resource, property, search); }
/** * @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; } }
/** * @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); }
/** * 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; }
/** * 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(); } } }
@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; }
/** * Returns the encoding of the file. * Encoding is read from the content-encoding property and defaults to the systems default encoding. * Since properties can change without rewriting content, the actual encoding can differ. * * @param cms {@link CmsObject} used to read properties of the given file. * @param file the file for which the encoding is requested * @return the file's encoding according to the content-encoding property, or the system's default encoding as default. */ public static String getEncoding(CmsObject cms, CmsResource file) { CmsProperty encodingProperty = CmsProperty.getNullProperty(); try { encodingProperty = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true); } catch (CmsException e) { LOG.debug(e.getLocalizedMessage(), e); } return CmsEncoder.lookupEncoding(encodingProperty.getValue(""), OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * 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(); } }
/** * Creates a "broken link" bean based on a resource.<p> * * @param resource the resource * * @return the "broken link" bean with the data from the resource * * @throws CmsException if something goes wrong */ protected CmsBrokenLinkBean createSitemapBrokenLinkBean(CmsResource resource) throws CmsException { CmsObject cms = getCmsObject(); CmsProperty titleProp = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, true); String defaultTitle = ""; String title = titleProp.getValue(defaultTitle); String path = cms.getSitePath(resource); String subtitle = path; return new CmsBrokenLinkBean(resource.getStructureId(), title, subtitle); }
/** * 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 file the file which is to be checked * @return the encoding for the file */ protected String getFileEncoding(CmsObject cms, CmsResource file) { String result; try { result = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue( OpenCms.getSystemInfo().getDefaultEncoding()); } catch (CmsException e) { result = OpenCms.getSystemInfo().getDefaultEncoding(); } return CmsEncoder.lookupEncoding(result, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Creates a "broken link" bean based on a resource.<p> * * @param resource the resource * @return the "broken link" bean with the data from the resource * * @throws CmsException if something goes wrong */ protected CmsBrokenLinkBean createSitemapBrokenLinkBean(CmsResource resource) throws CmsException { CmsProperty titleProp = m_cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, true); String typeName = OpenCms.getResourceManager().getResourceType(resource).getTypeName(); String defaultTitle = CmsResource.getName(resource.getRootPath()); String title = titleProp.getValue(defaultTitle); String path = m_cms.getSitePath(resource); String subtitle = path; return new CmsBrokenLinkBean(resource.getStructureId(), title, subtitle, typeName); }