/** * Adds the XML for a property value of a property of type 'vfslist' to the DOM.<p> * * @param cms the current CMS context * @param valueElement the element to which the vfslist property value should be added * @param propValue the property value which should be saved */ protected static void addFileListPropertyValue(CmsObject cms, Element valueElement, String propValue) { // resource list value Element filelistElem = valueElement.addElement(CmsXmlContentProperty.XmlNode.FileList.name()); for (String strId : CmsStringUtil.splitAsList(propValue, CmsXmlContentProperty.PROP_SEPARATOR)) { try { Element fileValueElem = filelistElem.addElement(CmsXmlContentProperty.XmlNode.Uri.name()); CmsVfsFileValueBean fileValue = getFileValueForIdOrUri(cms, strId); // HACK: here we assume weak relations, but it would be more robust to check it, with smth like: // type = xmlContent.getContentDefinition().getContentHandler().getRelationType(fileValueElem.getPath()); CmsRelationType type = CmsRelationType.XML_WEAK; CmsXmlVfsFileValue.fillEntry(fileValueElem, fileValue.getId(), fileValue.getPath(), type); } catch (CmsException e) { // should never happen LOG.error(e.getLocalizedMessage(), e); } } }
/** * Given a string which might be a id or a (sitemap or VFS) URI, this method will return * a bean containing the right (sitemap or vfs) root path and (sitemap entry or structure) id.<p> * * @param cms the current CMS context * @param idOrUri a string containing an id or an URI * * @return a bean containing a root path and an id * * @throws CmsException if something goes wrong */ protected static CmsVfsFileValueBean getFileValueForIdOrUri(CmsObject cms, String idOrUri) throws CmsException { CmsVfsFileValueBean result; if (CmsUUID.isValidUUID(idOrUri)) { CmsUUID id = new CmsUUID(idOrUri); String uri = getUriForId(cms, id); result = new CmsVfsFileValueBean(cms.getRequestContext().addSiteRoot(uri), id); } else { String uri = idOrUri; CmsUUID id = getIdForUri(cms, idOrUri); result = new CmsVfsFileValueBean(cms.getRequestContext().addSiteRoot(uri), id); } return result; }