/** * Updates the given xml element with this link information.<p> * * @param link the link to get the information from * @param element the <link> element to update */ public static void updateXmlForVfsFile(CmsLink link, Element element) { // if element is not null if (element != null) { // update the type attribute updateAttribute(element, CmsLink.ATTRIBUTE_TYPE, link.getType().getNameForXml()); // update the sub-elements updateXml(link, element, false); } }
/** * Updates the link node in the underlying XML page document.<p> * * @param link the link to update * @param element the <link> element to update * @param updateOnly if set and the element has no {@link CmsLink#NODE_TARGET} subelement, so no action if executed at all */ public static void updateXml(CmsLink link, Element element, boolean updateOnly) { // if element is not null if (element != null) { if (!updateOnly || (element.element(CmsLink.NODE_TARGET) != null)) { String strId = (link.getStructureId() == null ? null : link.getStructureId().toString()); // there may still be entities in the target, so we decode it updateNode(element, CmsLink.NODE_TARGET, link.getTarget(), true); updateNode(element, CmsLink.NODE_UUID, strId, false); updateNode(element, CmsLink.NODE_ANCHOR, link.getAnchor(), true); updateNode(element, CmsLink.NODE_QUERY, link.getQuery(), true); } } }
/** * Updates the given xml element with this link information.<p> * * @param link the link to get the information from * @param name the (optional) name of the link * @param element the <link> element to update */ public static void updateXmlForHtmlValue(CmsLink link, String name, Element element) { // if element is not null if (element != null) { // update the additional attributes if (name != null) { updateAttribute(element, CmsLink.ATTRIBUTE_NAME, link.getName()); } updateAttribute(element, CmsLink.ATTRIBUTE_INTERNAL, Boolean.toString(link.isInternal())); // update the common sub-elements and attributes updateXmlForVfsFile(link, element); } }
/** * Fills the given element with a {@link CmsXmlCategoryValue} for the given data.<p> * * @param element the element to fill * @param id the id to use * @param rootPath the path to use * @param type the relation type to use */ public static void fillEntry(Element element, CmsUUID id, String rootPath, CmsRelationType type) { CmsLink link = new CmsLink(CmsXmlCategoryValue.TYPE_VFS_LINK, type, id, rootPath, true); // get xml node Element linkElement = element.element(CmsXmlPage.NODE_LINK); if (linkElement == null) { // create xml node if needed linkElement = element.addElement(CmsXmlPage.NODE_LINK); } // update xml node CmsLinkUpdateUtil.updateXmlForVfsFile(link, linkElement); }
/** * Updates the uri of this link with a new value.<p> * * Also updates the structure of the underlying XML page document this link belongs to.<p> * * Note that you can <b>not</b> update the "internal" or "type" values of the link, * so the new link must be of same type (A, IMG) and also remain either an internal or external link.<p> * * @param uri the uri to update this link with <code>scheme://authority/path#anchor?query</code> */ public void updateLink(String uri) { // set the uri m_uri = uri; // update the components setComponents(); // update the xml CmsLinkUpdateUtil.updateXml(this, m_element, true); }
/** * Returns the link objects represented by this XML content value.<p> * * @param cms the cms context, can be <code>null</code> but in this case no link check is performed * * @return a list of link objects represented by this XML content value */ public List<CmsLink> getLinks(CmsObject cms) { List<CmsLink> result = new ArrayList<CmsLink>(); @SuppressWarnings("unchecked") List<Element> linkElements = m_element.elements(CmsXmlPage.NODE_LINK); for (Element linkElement : linkElements) { if (linkElement == null) { String uri = m_element.getText(); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(uri)) { setStringValue(cms, uri); } } CmsLinkUpdateUtil.updateType(linkElement, getRelationType(getPath())); CmsLink link = new CmsLink(linkElement); link.checkConsistency(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) { continue; } result.add(link); } return result; }
for (Iterator<CmsLink> i = linkTable.iterator(); i.hasNext();) { CmsLink link = i.next(); CmsLinkUpdateUtil.updateXmlForHtmlValue( link, link.getName(),
/** * Updates the type for a link xml element node.<p> * * @param element the link element node to update * @param type the relation type to set */ public static void updateType(Element element, CmsRelationType type) { updateAttribute(element, CmsLink.ATTRIBUTE_TYPE, type.getNameForXml()); }
/** * Fills the given element with a {@link CmsXmlVfsFileValue} for the given data.<p> * * @param element the element to fill * @param id the id to use * @param rootPath the path to use * @param type the relation type to use */ public static void fillEntry(Element element, CmsUUID id, String rootPath, CmsRelationType type) { CmsLink link = new CmsLink(CmsXmlVfsFileValue.TYPE_VFS_LINK, type, id, rootPath, true); // get xml node Element linkElement = element.element(CmsXmlPage.NODE_LINK); if (linkElement == null) { // create xml node if needed linkElement = element.addElement(CmsXmlPage.NODE_LINK); } // update xml node CmsLinkUpdateUtil.updateXmlForVfsFile(link, linkElement); }
/** * Updates the uri of this link with a new value.<p> * * Also updates the structure of the underlying XML page document this link belongs to.<p> * * Note that you can <b>not</b> update the "internal" or "type" values of the link, * so the new link must be of same type (A, IMG) and also remain either an internal or external link.<p> * * @param uri the uri to update this link with <code>scheme://authority/path#anchor?query</code> */ public void updateLink(String uri) { // set the uri m_uri = uri; // update the components setComponents(); // update the xml CmsLinkUpdateUtil.updateXml(this, m_element, true); }
/** * Returns the link object represented by this XML content value.<p> * * @param cms the cms context, can be <code>null</code> but in this case no link check is performed * * @return the link object represented by this XML content value (will return null for an empty link) */ public CmsLink getLink(CmsObject cms) { Element linkElement = m_element.element(CmsXmlPage.NODE_LINK); if (linkElement == null) { String uri = m_element.getText(); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(uri)) { setStringValue(cms, uri); } linkElement = m_element.element(CmsXmlPage.NODE_LINK); if (linkElement == null) { return null; } } CmsLinkUpdateUtil.updateType(linkElement, getRelationType(getPath())); CmsLink link = new CmsLink(linkElement); link.checkConsistency(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) { return null; } return link; }
for (Iterator<CmsLink> i = linkTable.iterator(); i.hasNext();) { CmsLink link = i.next(); CmsLinkUpdateUtil.updateXmlForHtmlValue( link, link.getName(),
/** * Updates the type for a link xml element node.<p> * * @param element the link element node to update * @param type the relation type to set */ public static void updateType(Element element, CmsRelationType type) { updateAttribute(element, CmsLink.ATTRIBUTE_TYPE, type.getNameForXml()); }
/** * Updates the given xml element with this link information.<p> * * @param link the link to get the information from * @param element the <link> element to update */ public static void updateXmlForVfsFile(CmsLink link, Element element) { // if element is not null if (element != null) { // update the type attribute updateAttribute(element, CmsLink.ATTRIBUTE_TYPE, link.getType().getNameForXml()); // update the sub-elements updateXml(link, element, false); } }
/** * Updates the given xml element with this link information.<p> * * @param link the link to get the information from * @param name the (optional) name of the link * @param element the <link> element to update */ public static void updateXmlForHtmlValue(CmsLink link, String name, Element element) { // if element is not null if (element != null) { // update the additional attributes if (name != null) { updateAttribute(element, CmsLink.ATTRIBUTE_NAME, link.getName()); } updateAttribute(element, CmsLink.ATTRIBUTE_INTERNAL, Boolean.toString(link.isInternal())); // update the common sub-elements and attributes updateXmlForVfsFile(link, element); } }
/** * Sets the value as a structure id.<p> * * @param cms the current CMS context * @param id the structure id which should be stored in the category value */ public void setIdValue(CmsObject cms, CmsUUID id) { CmsRelationType type = CmsRelationType.CATEGORY; CmsLink link = new CmsLink(TYPE_VFS_LINK, type, id, "@", true); // link management check link.checkConsistency(cms); // update xml node CmsLinkUpdateUtil.updateXmlForVfsFile(link, m_element.addElement(CmsXmlPage.NODE_LINK)); }
/** * Updates the uri of this link with a new target, anchor and query.<p> * * If anchor and/or query are <code>null</code>, this features are not used.<p> * * Note that you can <b>not</b> update the "internal" or "type" values of the link, * so the new link must be of same type (A, IMG) and also remain either an internal or external link.<p> * * Also updates the structure of the underlying XML page document this link belongs to.<p> * * @param target the target (destination) of this link * @param anchor the anchor or null if undefined * @param query the query or null if undefined */ public void updateLink(String target, String anchor, String query) { // set the components m_target = target; m_anchor = anchor; setQuery(query); // create the uri from the components setUri(); // update the xml CmsLinkUpdateUtil.updateXml(this, m_element, true); }
/** * Returns the link object represented by this XML content value.<p> * * @param cms the cms context, can be <code>null</code> but in this case no link check is performed * * @return the link object represented by this XML content value */ public CmsLink getLink(CmsObject cms) { Element linkElement = m_element.element(CmsXmlPage.NODE_LINK); if (linkElement == null) { String uri = m_element.getText(); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(uri)) { setStringValue(cms, uri); } linkElement = m_element.element(CmsXmlPage.NODE_LINK); if (linkElement == null) { return null; } } CmsLinkUpdateUtil.updateType(linkElement, getContentDefinition().getContentHandler().getRelationType(this)); CmsLink link = new CmsLink(linkElement); // link management check link.checkConsistency(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) { return null; } return link; }
CmsLinkUpdateUtil.updateXmlForHtmlValue(link, null, m_element.addElement(CmsXmlPage.NODE_LINK));
/** * Updates the link node in the underlying XML page document.<p> * * @param link the link to update * @param element the <link> element to update * @param updateOnly if set and the element has no {@link CmsLink#NODE_TARGET} subelement, so no action if executed at all */ public static void updateXml(CmsLink link, Element element, boolean updateOnly) { // if element is not null if (element != null) { if (!updateOnly || (element.element(CmsLink.NODE_TARGET) != null)) { String strId = (link.getStructureId() == null ? null : link.getStructureId().toString()); updateNode(element, CmsLink.NODE_TARGET, link.getTarget(), true); updateNode(element, CmsLink.NODE_UUID, strId, false); updateNode(element, CmsLink.NODE_ANCHOR, link.getAnchor(), true); updateNode(element, CmsLink.NODE_QUERY, link.getQuery(), true); } } }