/** * Checks whether a resource has a navigation property.<p> * * @param cms the current CMS context * @param resource the resource to use * * @return true if the resource has a navigation property * * @throws CmsException if something goes wrong */ private boolean hasNavigationProperty(CmsObject cms, CmsResource resource) throws CmsException { List<CmsProperty> props = cms.readPropertyObjects(resource, false); Map<String, String> propMap = CmsProperty.toMap(props); return propMap.containsKey(CmsPropertyDefinition.PROPERTY_NAVPOS) || propMap.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT); }
/** * Gets the properties of a resource as a map of client properties.<p> * * @param cms the CMS context to use * @param res the resource whose properties to read * @param search true if the inherited properties should be read * * @return the client properties as a map * * @throws CmsException if something goes wrong */ Map<String, CmsClientProperty> getClientProperties(CmsObject cms, CmsResource res, boolean search) throws CmsException { List<CmsProperty> props = cms.readPropertyObjects(res, search); Map<String, CmsClientProperty> result = createClientProperties(props, false); return result; }
/** * Returns a map with CmsProperty object values keyed by property keys.<p> * * @return a map with CmsProperty object values */ protected Map<String, CmsProperty> getActiveProperties() { // get all used properties for the resource if (m_activeProperties == null) { try { m_activeProperties = CmsPropertyAdvanced.getPropertyMap( getCms().readPropertyObjects(getParamResource(), false)); } catch (CmsException e) { // create an empty list if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage()); } m_activeProperties = new HashMap<String, CmsProperty>(); } } return m_activeProperties; }
/** * Returns a CmsJspNavElement for the named resource.<p> * * @param cms context provider for the current request * @param resource the resource name to get the nav information for, * must be a full path name, e.g. "/docs/index.html". * @return a CmsJspNavElement for the given resource */ public static CmsJspNavElement getNavigationForResource(CmsObject cms, String resource) { List properties; try { properties = cms.readPropertyObjects(resource, false); } catch (Exception e) { return null; } int level = CmsResource.getPathLevel(resource); if (resource.endsWith("/")) { level--; } return new CmsJspNavElement(resource, CmsProperty.toMap(properties), level); }
/** * Returns a map with CmsProperty object values keyed by property keys.<p> * * @return a map with CmsProperty object values */ protected Map getActiveProperties() { // get all used properties for the resource if (m_activeProperties == null) { try { m_activeProperties = CmsPropertyAdvanced.getPropertyMap(getCms().readPropertyObjects( getParamResource(), false)); } catch (CmsException e) { // create an empty list if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage()); } m_activeProperties = new HashMap(); } } return m_activeProperties; }
/** * Initializes the comparator key based on the member variables.<p> * * @param resource the resource to use * @param cms the current OpenCms user contxt */ private void init(CmsResource resource, CmsObject cms) { List properties; try { properties = cms.readPropertyObjects(resource, false); } catch (CmsException e) { m_priority = 0; m_date = 0; return; } try { m_priority = Integer.parseInt(CmsProperty.get(CmsPriorityResourceCollector.PROPERTY_PRIORITY, properties).getValue()); } catch (NumberFormatException e) { m_priority = CmsPriorityResourceCollector.PRIORITY_STANDARD; } try { m_date = Long.parseLong(CmsProperty.get(PROPERTY_DATE, properties).getValue()); } catch (NumberFormatException e) { m_date = 0; } }
/** * Initializes the comparator key based on the member variables.<p> * * @param resource the resource to use * @param cms the current OpenCms user contxt */ private void init(CmsResource resource, CmsObject cms) { List<CmsProperty> properties; try { properties = cms.readPropertyObjects(resource, false); } catch (CmsException e) { m_priority = 0; m_date = 0; return; } try { m_priority = Integer.parseInt( CmsProperty.get(CmsPriorityResourceCollector.PROPERTY_PRIORITY, properties).getValue()); } catch (NumberFormatException e) { m_priority = CmsPriorityResourceCollector.PRIORITY_STANDARD; } try { m_date = Long.parseLong(CmsProperty.get(PROPERTY_DATE, properties).getValue()); } catch (NumberFormatException e) { m_date = 0; } }
properties = cms.readPropertyObjects(resource, false); } catch (CmsException e) { m_priority = 0;
/** * Initializes the comparator key based on the member variables.<p> * * @param resource the resource to use * @param cms the current OpenCms user contxt */ private void init(CmsResource resource, CmsObject cms) { List properties; try { properties = cms.readPropertyObjects(resource, false); } catch (CmsException e) { m_priority = 0; m_title = ""; return; } try { m_priority = Integer.parseInt(CmsProperty.get(CmsPriorityResourceCollector.PROPERTY_PRIORITY, properties).getValue()); } catch (NumberFormatException e) { m_priority = CmsPriorityResourceCollector.PRIORITY_STANDARD; } m_title = CmsProperty.get(CmsPropertyDefinition.PROPERTY_TITLE, properties).getValue(); if (CmsStringUtil.isEmpty(m_title)) { m_title = ""; } } }
List<CmsProperty> propList = m_context.getCms().readPropertyObjects(m_resource, false); List<CmsProperty> inheritedPropList = m_context.getCms().readPropertyObjects(m_resource, true); Map<String, CmsProperty> propMap = CmsProperty.toObjectMap(propList); Map<String, CmsProperty> inheritedPropMap = CmsProperty.toObjectMap(inheritedPropList);
/** * Adds the alias links for a given structure id to the results.<p> * * @param aliasStructureId the alias target structure id */ private void addAliasLinks(CmsUUID aliasStructureId) { try { CmsResource aliasTarget = m_guestCms.readResource(aliasStructureId); List<CmsProperty> properties = m_guestCms.readPropertyObjects(aliasTarget, true); double priority = getPriority(properties); String changeFrequency = getChangeFrequency(properties); Collection<CmsAlias> aliases = m_pageAliasesBelowBaseFolderByStructureId.get(aliasStructureId); for (CmsAlias alias : aliases) { String aliasLink = (m_siteRootLink + "/" + alias.getAliasPath()).replaceAll("(?<!:)//+", "/"); CmsXmlSitemapUrlBean aliasUrlBean = new CmsXmlSitemapUrlBean( replaceServerUri(aliasLink), -1, changeFrequency, priority); aliasUrlBean.setOriginalResource(aliasTarget); addResult(aliasUrlBean, 1); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } }
CmsResource source = relation.getSource(m_cms, CmsResourceFilter.IGNORE_EXPIRATION); if (CmsResourceTypeXmlContainerPage.isContainerPage(source)) { List<CmsProperty> pagePropertiesList = m_cms.readPropertyObjects(source, true); Map<String, CmsProperty> pageProperties = CmsProperty.toObjectMap(pagePropertiesList); Locale pageLocale = OpenCms.getLocaleManager().getDefaultLocale(m_cms, source);
/** * Internal action method.<p> * * @param action the search action * @param req the current request * * @return String the value of the property or <code>null</code> if not found (and no defaultValue provided) * * @throws CmsException if something goes wrong */ public static Map<String, String> propertiesTagAction(String action, ServletRequest req) throws CmsException { CmsFlexController controller = CmsFlexController.getController(req); // now read the property from the VFS Map<String, String> value = new HashMap<String, String>(); CmsPropertyAction propertyAction = new CmsPropertyAction(req, action); if (null != propertyAction.getVfsUri()) { value = CmsProperty.toMap( controller.getCmsObject().readPropertyObjects(propertyAction.getVfsUri(), propertyAction.isSearch())); } return value; }
/** * Generates a list of property values inherited to the site-map root entry.<p> * * @param rootPath the root entry name * * @return the list of property values inherited to the site-map root entry * * @throws CmsException if something goes wrong reading the properties */ private Map<String, CmsClientProperty> generateParentProperties(String rootPath) throws CmsException { CmsObject cms = getCmsObject(); if (rootPath == null) { rootPath = cms.getRequestContext().addSiteRoot("/"); } CmsObject rootCms = OpenCms.initCmsObject(cms); rootCms.getRequestContext().setSiteRoot(""); String parentRootPath = CmsResource.getParentFolder(rootPath); Map<String, CmsClientProperty> result = new HashMap<String, CmsClientProperty>(); if (parentRootPath != null) { List<CmsProperty> props = rootCms.readPropertyObjects(parentRootPath, true); for (CmsProperty prop : props) { CmsClientProperty clientProp = createClientProperty(prop, true); result.put(clientProp.getName(), clientProp); } } return result; }
Map<String, CmsProperty> props = CmsProperty.toObjectMap(cms.readPropertyObjects(resource, false)); CmsProperty navtextProp = props.get(CmsPropertyDefinition.PROPERTY_NAVTEXT); CmsProperty titleProp = props.get(CmsPropertyDefinition.PROPERTY_TITLE);
result.setId(id); result.setFolder(resource.isFolder()); List<CmsProperty> props = cms.readPropertyObjects(resource, false); List<CmsProperty> defaultFileProps = cms.readPropertyObjects(defaultFile, false); Map<String, CmsClientProperty> clientProps = createClientProperties(props, true); Map<String, CmsClientProperty> clientDefaultFileProps = createClientProperties(defaultFileProps, true); result.setInheritedProperties(createClientProperties(cms.readPropertyObjects(parent, true), true)); result.setPath(resource.getRootPath()); String name = CmsFileUtil.removeTrailingSeparator(CmsResource.getName(resource.getRootPath()));
/** * 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; } }
JSONObject jsonAttachment = new JSONObject(); CmsResource res = clone.readResource(m_rootPath, CmsResourceFilter.IGNORE_EXPIRATION); Map<String, String> props = CmsProperty.toMap(clone.readPropertyObjects(res, false));
/** * Adds the detail page links for a given page to the results.<p> * * @param containerPage the container page resource * @param locale the locale of the container page * * @throws CmsException if something goes wrong */ protected void addDetailLinks(CmsResource containerPage, Locale locale) throws CmsException { List<I_CmsResourceType> types = getDetailTypesForPage(containerPage); for (I_CmsResourceType type : types) { List<CmsResource> resourcesForType = getDetailResources(type); for (CmsResource detailRes : resourcesForType) { if (!isValidDetailPageCombination(containerPage, locale, detailRes)) { continue; } List<CmsProperty> detailProps = m_guestCms.readPropertyObjects(detailRes, true); String detailLink = getDetailLink(containerPage, detailRes, locale); detailLink = CmsFileUtil.removeTrailingSeparator(detailLink); CmsXmlSitemapUrlBean detailUrlBean = new CmsXmlSitemapUrlBean( replaceServerUri(detailLink), detailRes.getDateLastModified(), getChangeFrequency(detailProps), getPriority(detailProps)); detailUrlBean.setOriginalResource(detailRes); detailUrlBean.setDetailPageResource(containerPage); addResult(detailUrlBean, 2); } } }
/** * @see org.opencms.site.xmlsitemap.CmsXmlSitemapGenerator#addDetailLinks(org.opencms.file.CmsResource, java.util.Locale) */ @Override protected void addDetailLinks(CmsResource containerPage, Locale locale) throws CmsException { Collection<DetailInfo> detailInfos = getDetailInfosForPage(containerPage); for (DetailInfo info : detailInfos) { List<CmsResource> contents = getContents(info.getFolderPath(), info.getType()); for (CmsResource detailRes : contents) { List<CmsProperty> detailProps = m_guestCms.readPropertyObjects(detailRes, true); String detailLink = getDetailLink(containerPage, detailRes, locale); detailLink = CmsFileUtil.removeTrailingSeparator(detailLink); CmsXmlSitemapUrlBean detailUrlBean = new CmsXmlSitemapUrlBean( replaceServerUri(detailLink), detailRes.getDateLastModified(), getChangeFrequency(detailProps), getPriority(detailProps)); detailUrlBean.setLocale(locale); detailUrlBean.setOriginalResource(detailRes); detailUrlBean.setDetailPageResource(containerPage); detailUrlBean.setSubsite(info.getBasePath()); addResult(detailUrlBean, 2); } } }