/** * Gets the change frequency for a sitemap entry from a list of properties.<p> * * If the change frequency is not defined in the properties, this method will return null.<p> * * @param properties the properties from which the change frequency should be obtained * * @return the change frequency string */ protected static String getChangeFrequency(List<CmsProperty> properties) { CmsProperty prop = CmsProperty.get(CmsPropertyDefinition.PROPERTY_XMLSITEMAP_CHANGEFREQ, properties); if (prop.isNullProperty()) { return null; } String result = prop.getValue().trim(); return result; }
/** * Gets the page priority from a list of properties.<p> * * If the page priority can't be found among the properties, -1 will be returned.<p> * * @param properties the properties of a resource * * @return the page priority read from the properties, or -1 */ protected static double getPriority(List<CmsProperty> properties) { CmsProperty prop = CmsProperty.get(CmsPropertyDefinition.PROPERTY_XMLSITEMAP_PRIORITY, properties); if (prop.isNullProperty()) { return -1.0; } try { double result = Double.parseDouble(prop.getValue().trim()); return result; } catch (NumberFormatException e) { return -1.0; } }
/** * @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(); } } }
/** * Checks whether the given resource is a model reuse group.<p> * * @param cms the cms context * @param resource the resource * * @return <code>true</code> in case the resource is a model reuse group */ public static boolean isModelReuseGroup(CmsObject cms, CmsResource resource) { boolean result = false; if (isModelGroup(resource)) { try { CmsProperty tempElementsProp = cms.readPropertyObject( resource, CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS, false); if (tempElementsProp.isNullProperty() || !CmsContainerElement.USE_AS_COPY_MODEL.equals(tempElementsProp.getValue())) { result = true; } } catch (CmsException e) { LOG.warn(e.getMessage(), e); } } return result; }
/** * Reads the (compound) value of a property mapped to a specified resource.<p> * * @param resourcePath the resource to look up the property for * @param property the name of the property to look up * * @return the value of the property found, <code>null</code> if nothing was found * * @throws CmsException in case there where problems reading the property * * @see CmsProperty#getValue() * * @deprecated use <code>{@link #readPropertyObject(String, String, boolean)}</code> instead. */ public String readProperty(String resourcePath, String property) throws CmsException { CmsResource resource = readResource(resourcePath, CmsResourceFilter.ALL); CmsProperty value = m_securityManager.readPropertyObject(m_context, resource, property, false); return value.isNullProperty() ? null : value.getValue(); }
/** * Reads the (compound) value of a property mapped to a specified resource * with optional direcory upward cascading.<p> * * @param resourcePath the resource to look up the property for * @param property the name of the property to look up * @param search if <code>true</code>, the property will be looked up on all parent folders if it is not attached to the the resource, if false not (ie. normal property lookup) * * @return the value of the property found, <code>null</code> if nothing was found * * @throws CmsException in case there where problems reading the property * * @see CmsProperty#getValue() * * @deprecated use <code>{@link #readPropertyObject(String, String, boolean)}</code> instead. */ public String readProperty(String resourcePath, String property, boolean search) throws CmsException { CmsResource resource = readResource(resourcePath, CmsResourceFilter.ALL); CmsProperty value = m_securityManager.readPropertyObject(m_context, resource, property, search); return value.isNullProperty() ? null : value.getValue(); }
/** * Gets the fields which should be displayed for a single resource.<p> * * @param resource the resource for which we should fetch the fields * * @return a string array containing the information for the given resource */ public String[] getResourceInfo(CmsResource resource) { String rootPath = resource.getRootPath(); String title = "-"; try { CmsProperty titleProp = m_adminCms.readPropertyObject( resource, CmsPropertyDefinition.PROPERTY_TITLE, false); if (!titleProp.isNullProperty()) { title = titleProp.getValue(); } } catch (CmsException e) { // ignore } return new String[] {rootPath, title}; }
/** * Reads the (compound) value of a property mapped to a specified resource * with optional directory upward cascading, a default value will be returned if the property * is not found on the resource (or it's parent folders in case search is set to <code>true</code>).<p> * * @param resourcePath the resource to look up the property for * @param property the name of the property to look up * @param search if <code>true</code>, the property will be looked up on all parent folders if it is not attached to the the resource, if <code>false</code> not (ie. normal property lookup) * @param propertyDefault a default value that will be returned if the property was not found on the selected resource * * @return the value of the property found, if nothing was found the value of the <code>propertyDefault</code> parameter is returned * * @throws CmsException in case there where problems reading the property * * @see CmsProperty#getValue() * * @deprecated use <code>{@link #readPropertyObject(String, String, boolean)}</code> instead. */ public String readProperty(String resourcePath, String property, boolean search, String propertyDefault) throws CmsException { CmsResource resource = readResource(resourcePath, CmsResourceFilter.ALL); CmsProperty value = m_securityManager.readPropertyObject(m_context, resource, property, search); return value.isNullProperty() ? propertyDefault : value.getValue(); }
/** * Creates a new image scaler by reading the property <code>{@link CmsPropertyDefinition#PROPERTY_IMAGE_SIZE}</code> * from the given resource.<p> * * In case of any errors reading or parsing the property, * <code>{@link #isValid()}</code> will return <code>false</code>.<p> * * @param cms the OpenCms user context to use when reading the property * @param res the resource to read the property from */ public CmsImageScaler(CmsObject cms, CmsResource res) { init(); String sizeValue = null; if ((cms != null) && (res != null)) { try { CmsProperty sizeProp = cms.readPropertyObject(res, CmsPropertyDefinition.PROPERTY_IMAGE_SIZE, false); if (!sizeProp.isNullProperty()) { // parse property value using standard procedures sizeValue = sizeProp.getValue(); } } catch (Exception e) { LOG.debug(e.getMessage(), e); } } if (CmsStringUtil.isNotEmpty(sizeValue)) { parseParameters(sizeValue); } }
/** * Returns whether the given resource is a folder and is marked to be a navigation level folder.<p> * * @param cms the cms context * @param resource the resource * * @return <code>true</code> if the resource is marked to be a navigation level folder */ public static boolean isNavLevelFolder(CmsObject cms, CmsResource resource) { if (resource.isFolder()) { I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource); if (CmsResourceTypeFolder.RESOURCE_TYPE_NAME.equals(type.getTypeName())) { try { CmsProperty prop = cms.readPropertyObject( resource, CmsPropertyDefinition.PROPERTY_DEFAULT_FILE, false); return !prop.isNullProperty() && NAVIGATION_LEVEL_FOLDER.equals(prop.getValue()); } catch (CmsException e) { LOG.debug(e.getMessage(), e); } } } return false; }
/** * Checks the shared property {@link CmsTagReplaceSettings#PROPERTY_CONTENTOOLS_TAGREPLACE} if * it has the value of this configuration ({@link CmsTagReplaceSettings#getPropertyValueTagReplaceID()}).<p> * * @param resource the resource to test. * * @return true if the property with the value was found. * * @throws CmsException if reading a property fails. */ private boolean isProcessedBefore(CmsResource resource) throws CmsException { CmsProperty testProp = getCms().readPropertyObject( resource, CmsTagReplaceSettings.PROPERTY_CONTENTOOLS_TAGREPLACE, false); if (testProp.isNullProperty()) { return false; } else { String testValue = testProp.getResourceValue(); if (CmsStringUtil.isEmptyOrWhitespaceOnly(testValue)) { return false; } else { return testValue.equals(m_settings.getPropertyValueTagReplaceID()); } } }
/** * Creates a new image scaler by reading the property <code>{@link CmsPropertyDefinition#PROPERTY_IMAGE_SIZE}</code> * from the given resource.<p> * * In case of any errors reading or parsing the property, * <code>{@link #isValid()}</code> will return <code>false</code>.<p> * * @param cms the OpenCms user context to use when reading the property * @param res the resource to read the property from */ public CmsImageScaler(CmsObject cms, CmsResource res) { init(); String sizeValue = null; if ((cms != null) && (res != null)) { try { CmsProperty sizeProp = cms.readPropertyObject(res, CmsPropertyDefinition.PROPERTY_IMAGE_SIZE, false); if (!sizeProp.isNullProperty()) { // parse property value using standard procedures sizeValue = sizeProp.getValue(); } } catch (Exception e) { // ignore } } if (CmsStringUtil.isNotEmpty(sizeValue)) { parseParameters(sizeValue); } }
/** * Gets the template name for a template resource, using a cache for efficiency.<p> * * @param cms the current CMS context * @param resource the template resource * @return the template name * * @throws CmsException if something goes wrong */ private String getTemplateName(CmsObject cms, CmsResource resource) throws CmsException { String templateName = (String)(m_templateNameCache.getCachedObject(cms, resource.getRootPath())); if (templateName == null) { CmsProperty nameProperty = cms.readPropertyObject( resource, CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS, false); String nameFromProperty = ""; if (!nameProperty.isNullProperty()) { nameFromProperty = nameProperty.getValue(); } m_templateNameCache.putCachedObject(cms, resource.getRootPath(), nameFromProperty); return nameFromProperty; } else { return templateName; } }
CmsProperty titleProp = cms.readPropertyObject(titleResource, CmsPropertyDefinition.PROPERTY_TITLE, true); String rawName; if (titleProp.isNullProperty()) { rawName = cms.getSitePath(titleResource); } else {
/** * Creates a node entry for the root node of the current site.<p> * * @return a node entry for the root node of the current site */ private String getRootNode() { CmsResource resource = null; String title = null; String folder = getRootFolder(); try { resource = getCms().readFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION); // get the title information of the folder CmsProperty titleProperty = getCms().readPropertyObject(folder, CmsPropertyDefinition.PROPERTY_TITLE, false); if ((titleProperty == null) || titleProperty.isNullProperty()) { getCms().getSitePath(resource); title = resource.getRootPath(); } else { title = titleProperty.getValue(); } return getNode(resource.getRootPath(), title, resource.getTypeId(), true, resource.getState(), false); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e); } } return ""; }
false); if ((titleProperty == null) || titleProperty.isNullProperty()) { getCms().getSitePath(resource); title = resource.getRootPath();
CmsProperty prop = cms.readPropertyObject(reference, "repositoryfolder_" + type, true); if (!prop.isNullProperty() && cms.existsResource(prop.getValue(), CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) { CmsResource uploadFolder = cms.readResource(
/** * Gets the template context provider for a given path.<p> * * @param cms the current CMS context * @param path the path for which the template context provider should be determined * * @return the template context provider for the given path * * @throws CmsException if something goes wrong */ public I_CmsTemplateContextProvider getTemplateContextProvider(CmsObject cms, String path) throws CmsException { CmsResource resource = cms.readResource(path); I_CmsResourceLoader loader = OpenCms.getResourceManager().getLoader(resource); if (loader instanceof A_CmsXmlDocumentLoader) { String propertyName = ((A_CmsXmlDocumentLoader)loader).getTemplatePropertyDefinition(); List<CmsProperty> properties = cms.readPropertyObjects(resource, true); CmsProperty property = CmsProperty.get(propertyName, properties); if ((property != null) && !property.isNullProperty()) { String propertyValue = property.getValue(); if (CmsTemplateContextManager.hasPropertyPrefix(propertyValue)) { return getTemplateContextProvider(removePropertyPrefix(propertyValue)); } } return null; } else { return null; } }
String sitePath = cms.getSitePath(resource); String templateValue = sitePath; if (!selectValueProp.isNullProperty() && !CmsStringUtil.isEmptyOrWhitespaceOnly(selectValueProp.getValue())) { String selectValue = selectValueProp.getValue(); CmsMacroResolver resolver = new CmsMacroResolver();