/** * 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 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); } } }
/** * 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); } }
/** * Adds a new link to the link table.<p> * * @param type type of the link * @param targetUri link destination * @param internal flag to indicate if the link is a local link * * @return the new link entry */ public CmsLink addLink(CmsRelationType type, String targetUri, boolean internal) { CmsLink link = new CmsLink(LINK_PREFIX + m_linkTable.size(), type, targetUri, internal); m_linkTable.put(link.getName(), link); return link; }
while (i.hasNext()) { CmsLink link = (CmsLink)i.next(); String target = link.getTarget(); if (link.isInternal()) { target = m_cmsObject.getRequestContext().getFileTranslator().translateResource(target); link.updateLink(target, link.getAnchor(), link.getQuery()); link.checkConsistency(m_cmsObject);
} else { CmsLinkUpdateUtil.updateType(linkElement, getRelationType(getPath())); CmsLink link = new CmsLink(linkElement); if (link.isInternal()) { link.checkConsistency(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) {
CmsLink link = new CmsLink("link0", type, uuid, path, true); link.checkConsistency(m_cms); // update id/path m_links.add(link); return m_cms.getRequestContext().removeSiteRoot(link.getTarget()); } else { newMacro.append(I_CmsMacroResolver.MACRO_START); newMacro.append(macro); newMacro.append(link.getSitePath()); if ((link.getStructureId() != null) && !link.getStructureId().isNullUUID()) { newMacro.append(KEY_SEPARATOR).append(link.getStructureId());
CmsLink link = new CmsLink("link0", type, uuid, path, true); link.checkConsistency(m_cms); // update id/path m_links.add(link); return m_cms.getRequestContext().removeSiteRoot(link.getTarget()); } else { newMacro.append(I_CmsMacroResolver.MACRO_START); newMacro.append(macro); newMacro.append(link.getVfsUri()); if ((link.getStructureId() != null) && !link.getStructureId().isNullUUID()) { newMacro.append(KEY_SEPARATOR).append(link.getStructureId());
/** * 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; }
while (itLinks.hasNext()) { CmsLink link = itLinks.next(); if (link.isInternal()) { // only update internal links if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) { CmsUUID targetId = link.getStructureId(); String destPath = link.getTarget(); resource.getStructureId(), resource.getRootPath(), link.getStructureId(), destPath, link.getType()); originalRelation.getTargetId(), originalRelation.getTargetPath(), link.getType()); vfsDriver.createRelation(dbc, dbc.currentProject().getUuid(), relation);
while (k.hasNext()) { CmsLink link = (CmsLink)k.next(); if (link.isInternal()) { link.checkConsistency(cms); links.add(link);
while (itLinks.hasNext()) { CmsLink link = (CmsLink)itLinks.next(); if (link.isInternal()) { // only update internal links if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) { try { CmsResource target = readResource(dbc, link.getTarget(), CmsResourceFilter.ALL); originalRelation = new CmsRelation(resource, target, link.getType()); } catch (Exception e) { resource.getRootPath(), CmsUUID.getNullUUID(), link.getTarget(), link.getType()); originalRelation.getTargetId(), originalRelation.getTargetPath(), link.getType()); m_vfsDriver.createRelation(dbc, dbc.currentProject().getUuid(), relation);
if (link != null) { String l = link.getLink(m_cms); if (TAG_PARAM.equals(tag.getTagName())) { link.checkConsistency(m_cms); tag.setAttribute(attr, CmsMacroResolver.formatMacro(link.getName()));
checkConsistency(cms); String uri = computeUri(target, m_query, m_anchor); String siteRoot = getSiteRoot(); if (siteRoot == null) { return OpenCms.getLinkManager().substituteLink(cms, uri); return OpenCms.getLinkManager().substituteLink(cms, getSitePath(uri), siteRoot); } else {
link = ((CmsXmlVarLinkValue)value).getLink(cms); if ((link == null) || !link.isInternal()) { return false; String sitePath = cms.getRequestContext().removeSiteRoot(link.getTarget());
checkConsistency(cms); String siteRoot = getSiteRoot(); if (siteRoot == null) { return OpenCms.getLinkManager().substituteLink(cms, m_uri); return OpenCms.getLinkManager().substituteLink(cms, getVfsUri(), siteRoot); } else {
/** * Creates the String value for this VarLink value element.<p> * * @param cms the current users OpenCms context * * @return the String value for this VarLink value element */ private String createStringValue(CmsObject cms) { Attribute enabled = m_element.attribute(CmsXmlPage.ATTRIBUTE_ENABLED); String content = ""; if ((enabled == null) || Boolean.valueOf(enabled.getText()).booleanValue()) { CmsLink link = getLink(cms); if (link != null) { content = link.getUri(); if (link.isInternal() && (cms != null)) { // remove site root for internal links content = cms.getRequestContext().removeSiteRoot(link.getUri()); } } } return content; } }
elementId = new CmsLink(uriLink).getStructureId(); formatterId = new CmsLink(formatterLink).getStructureId();
link = ((CmsXmlVarLinkValue)value).getLink(cms); if ((link == null) || !link.isInternal()) { return false; CmsResource res = cms.readResource(link.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
locale); CmsLink link = ((CmsXmlVfsFileValue)linkValue).getLink(m_cms); if ((link != null) && link.getStructureId().equals(modelId)) { defaultModelTarget = link.getTarget(); } else { isDefaultValue.setStringValue(m_cms, Boolean.FALSE.toString());