Package org.apache.lenya.cms.site

Examples of org.apache.lenya.cms.site.Link


        }
        return languages;
    }

    public Link getLink(String language) throws SiteException {
        Link link = getLinkInternal(language);
        if (link == null) {
            throw new SiteException("The node [" + this + "] doesn't contain the language ["
                    + language + "].");
        }
        return link;
View Full Code Here


        this.contentHandler.endElement(NAMESPACE, ELEM_NODE, PREFIX + ':' + ELEM_NODE);
    }

    public void generateLink(SiteNode node, String language) throws SAXException {
        if (node.isVisible() && node.hasLink(language)) {
            Link link = getLink(node, language);
            AttributesImpl attrs = new AttributesImpl();
            attrs.addAttribute(XML_NAMESPACE, ATTR_LANG, XML_PREFIX + ":" + ATTR_LANG, "CDATA",
                    link.getLanguage());
            addAttribute(attrs, ATTR_LABEL, link.getLabel());
            addAttribute(attrs, ATTR_HREF, getHref(link).getUri());
           
            if (node.getPath().equals(getPath()) && language.equals(getLanguage())) {
                addAttribute(attrs, ATTR_CURRENT, Boolean.toString(true));
            }
View Full Code Here

     */
    final public void testAddLabel() throws SiteException {
        this.siteTree.addLabel("/foo/bar", "en", "Tutorial");
        String[] labels = ((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLanguages();
        assertEquals(labels.length, 1);
        Link label = ((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLink("en");
        assertNotNull(label);
        assertEquals(label.getLabel(), "Tutorial");
    }
View Full Code Here

                DocumentLocator[] requiredNodes = siteManager
                        .getRequiredResources(map, liveLoc);
                for (int i = 0; i < requiredNodes.length; i++) {
                    String path = requiredNodes[i].getPath();
                    if (!liveSite.contains(path)) {
                        Link link = getExistingLink(path, document);
                        if (link != null) {
                            missingDocuments.add(link.getDocument());
                        }
                    }

                }
            }
View Full Code Here

     * @return A link or <code>null</code>.
     * @throws SiteException if an error occurs.
     */
    protected Link getExistingLink(String path, Document document) throws SiteException {
        SiteNode node = document.area().getSite().getNode(path);
        Link link = null;
        String uuid = node.getUuid();
        if (uuid != null) {
            if (node.hasLink(document.getLanguage())) {
                link = node.getLink(document.getLanguage());
            } else if (node.getLanguages().length > 0) {
View Full Code Here

        SiteStructure destSite = sourceDoc.getPublication().getArea(destArea).getSite();

        if (sourceDoc.hasLink()) {
            if (destDoc.hasLink()) {
                Link srcLink = sourceDoc.getLink();
                Link destLink = destDoc.getLink();
                destLink.setLabel(srcLink.getLabel());
                destLink.getNode().setVisible(srcLink.getNode().isVisible());
            } else {
                String label = sourceDoc.getLink().getLabel();
                boolean visible = sourceDoc.getLink().getNode().isVisible();
                if (destSite.contains(sourceDoc.getLink().getNode().getPath())) {
                    addToSiteManager(destPath, destDoc, label, visible);
View Full Code Here

            String targetPath) throws PublicationException {

        SiteNode sourceNode = sourceArea.getSite().getNode(sourcePath);
        String[] languages = sourceNode.getLanguages();
        for (int i = 0; i < languages.length; i++) {
            Link sourceLink = sourceNode.getLink(languages[i]);
            String label = sourceLink.getLabel();
            Document sourceDoc = sourceLink.getDocument();
            sourceLink.delete();

            Document targetDoc;
            if (sourceArea.getName().equals(targetArea.getName())) {
                targetDoc = sourceDoc;
            } else {
                targetDoc = addVersion(sourceDoc, targetArea.getName(), sourceDoc.getLanguage());
                copyRevisions(sourceDoc, targetDoc);
                sourceDoc.delete();
            }

            Link link = targetArea.getSite().add(targetPath, targetDoc);
            link.setLabel(label);
            Assert.isTrue("label set", targetDoc.getLink().getLabel().equals(label));
        }
        SiteNode targetNode = targetArea.getSite().getNode(targetPath);
        targetNode.setVisible(sourceNode.isVisible());
    }
View Full Code Here

            Publication pub = factory.getPublication(pubId);
            this.site = pub.getArea(area).getSite();

            if (this.path == null) {
                if (site.containsByUuid(uuid, language)) {
                    Link link = site.getByUuid(uuid, language);
                    this.path = link.getNode().getPath();
                } else {
                    throw new ProcessingException(
                            "Path parameter not provided, no node for UUID and language found.");
                }
            }
View Full Code Here

     */
    protected void addLabels(SiteNode node) throws SAXException {
        String[] languages = node.getLanguages();

        for (int i = 0; i < languages.length; i++) {
            Link link;
            try {
                link = node.getLink(languages[i]);
            } catch (SiteException e) {
                throw new RuntimeException(e);
            }
            addLabel(link.getLabel(), languages[i]);
        }
    }
View Full Code Here

     * Test getLabel
     * @throws SiteException
     *
     */
    final public void testGetLabel() throws SiteException {
        Link label = this.node.getLink("en");
        assertNotNull(label);
        assertEquals(label.getLabel(), "Bar");
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.site.Link

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.