Package org.apache.jetspeed.om.page

Examples of org.apache.jetspeed.om.page.Link


        assertTrue(folder.getDefaultDecorator(Fragment.PORTLET).equals("test-portlet"));
    }

    public void testCreateLink() throws Exception
    {
        Link link = pageManager.newLink(this.testLink002);
        System.out.println("Retrieved test_id in create " + this.testLink002);
        link.setTitle("Created Link");
        link.setSkin("test-skin");
        link.setUrl("http://www.created.link.com/");

        try
        {
            pageManager.updateLink(link);
        }
        catch (Exception e)
        {
            String errmsg = "Exception in link update: " + e.toString();
            e.printStackTrace();
            System.err.println(errmsg);
            assertNotNull(errmsg, null);
        }

        link = pageManager.getLink(this.testLink002);
        assertNotNull(link);
        assertTrue(link.getId().equals(this.testLink002));
        assertTrue(link.getTitle().equals("Created Link"));
        assertTrue(link.getSkin().equals("test-skin"));
    }
View Full Code Here


        assertTrue(page.getTitle().equals("Updated Deep Title"));
    }

    public void testUpdateLink() throws Exception
    {
        Link link = pageManager.getLink(this.testLink002);
        link.setTitle("Updated Title");

        try
        {
            pageManager.updateLink(link);
        }
        catch (Exception e)
        {
            String errmsg = "Exception in link update: " + e.toString();
            e.printStackTrace();
            System.err.println(errmsg);
            assertNotNull(errmsg, null);
        }

        link = pageManager.getLink(this.testLink002);
        assertTrue(link.getTitle().equals("Updated Title"));
    }
View Full Code Here

        assertEquals("My First PSML Page", defaultTitle);
    }

    public void testLinks() throws Exception
    {
        Link link = pageManager.getLink("/apache_portals.link");
        assertNotNull(link);
        assertEquals("http://portals.apache.org", link.getUrl());
        assertEquals("Apache Portals Website", link.getTitle());
        assertEquals("Apache Software Foundation [french]", link.getTitle(Locale.FRENCH));
        assertEquals("test-skin", link.getSkin());

        Folder folder = pageManager.getFolder("/");
        assertNotNull(folder);
        assertNotNull(folder.getLinks());
        assertEquals(2,folder.getLinks().size());
View Full Code Here

        assertTrue(exceptionFound);
    }

    public void testRemoveLink() throws Exception
    {
        Link link = pageManager.getLink(this.testLink002);

        try
        {
            pageManager.removeLink(link);
        }
View Full Code Here

        SecurityConstraint pageConstraint = page.newSecurityConstraint();
        pageConstraint.setUsers(Shared.makeListFromCSV("UPDATED"));
        page.getSecurityConstraints().getSecurityConstraints().add(0, pageConstraint);
        pageManager.updatePage(page);

        Link link = pageManager.getLink("/default.link");
        assertEquals("/default.link", link.getPath());
        link.setTitle("UPDATED");
        link.getSecurityConstraints().setOwner("UPDATED");
        pageManager.updateLink(link);

        Folder folder = pageManager.getFolder("/");
        assertEquals("/", folder.getPath());
        folder.setTitle("UPDATED");
        folder.getDocumentOrder().remove("some-other-page.psml");
        folder.getDocumentOrder().add("UPDATED");
        folder.getDocumentOrder().add("some-other-page.psml");
        MenuDefinition updateMenu = (MenuDefinition)folder.getMenuDefinitions().get(1);
        updateMenu.setName("UPDATED");
        updateMenu.setTitle("UPDATED");
        updateMenu.getMetadata().addField(Locale.JAPANESE, "short-title", "[ja] UPDATED");
        ((MenuOptionsDefinition)updateMenu.getMenuElements().get(2)).setProfile("UPDATED");
        pageManager.updateFolder(folder);
        assertNotNull(folder.getAll());
        assertEquals(6, folder.getAll().size());
        Iterator all = folder.getAll().iterator();
        assertEquals("default-page.psml", ((Node)all.next()).getName());
        assertEquals("some-other-page.psml", ((Node)all.next()).getName());

        folder.setTitle("FOLDER-UPDATED-DEEP");
        page.setTitle("FOLDER-UPDATED-DEEP");
        link.setTitle("FOLDER-UPDATED-DEEP");
        Folder deepFolder = pageManager.getFolder(deepFolderPath);
        deepFolder.setTitle("FOLDER-UPDATED-DEEP");
        Page deepPage = pageManager.getPage(deepPagePath);
        deepPage.setTitle("FOLDER-UPDATED-DEEP");
        pageManager.updateFolder(folder, true);
View Full Code Here

        catch (DocumentNotFoundException e)
        {
        }
        try
        {
            Link check = pageManager.getLink("/default.link");
            assertTrue("Link /default.link FOUND", false);
        }
        catch (DocumentNotFoundException e)
        {
        }
View Full Code Here

        // search for link by name or absolute path from
        // aggregated links
        NodeSet allLinks = getLinks(proxy);
        if (allLinks != null)
        {
            Link link = (Link)allLinks.get(name);
            if (link != null)
            {
                return link;
            }
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.jetspeed.page.PageManager#newLink(java.lang.String)
     */
    public Link newLink(String path)
    {
        Link link = null;
        try
        {
            // factory create the page and set id/path
            link = (Link)createObject(this.linkClass);           
            if (!path.startsWith(Folder.PATH_SEPARATOR))
            {
                path = Folder.PATH_SEPARATOR + path;
            }
            if (!path.endsWith(Link.DOCUMENT_TYPE))
            {
                path += Link.DOCUMENT_TYPE;
            }
            link.setPath(path);
        }
        catch (ClassCastException e)
        {
            String message = "Failed to create link object for " + this.linkClass;
            log.error(message, e);
View Full Code Here

   
    public Link copyLink(Link source, String path)
    throws NodeException
    {
        // create the new link and copy attributes
        Link link = newLink(path);
        link.setTitle(source.getTitle());
        link.setShortTitle(source.getShortTitle());
        link.setSkin(source.getSkin());
        link.setVersion(source.getVersion());
        link.setTarget(source.getTarget());
        link.setUrl(source.getUrl());
        link.setHidden(source.isHidden());
       
        // copy locale specific metadata
        link.getMetadata().copyFields(source.getMetadata().getFields());
       
        // copy security constraints
        SecurityConstraints srcSecurity = source.getSecurityConstraints();       
        if ((srcSecurity != null) && !srcSecurity.isEmpty())
        {
            SecurityConstraints copiedSecurity = copySecurityConstraints(LINK_NODE_TYPE, srcSecurity);
            link.setSecurityConstraints(copiedSecurity);
        }   

        return link;
    }
View Full Code Here

        assertNotNull(page.getParent());
        assertEquals(page.getParent().getId(), folder.getId());
        assertEquals(3, folder.getPages().size());
        assertEquals(3, pageManager.getPages(folder).size());

        Link link = pageManager.newLink("/default.link");
        assertEquals("Default", link.getTitle());
        link.setTitle("Default Link");
        link.setVersion("1.23");
        link.setShortTitle("Default");
        link.setTarget("top");
        link.setUrl("http://www.default.org/");
        metadata = link.getMetadata();
        metadata.addField(Locale.FRENCH, "title", "[fr] Default Link");
        metadata.addField(Locale.GERMAN, "title", "[de] Default Link");
        SecurityConstraints linkConstraints = link.newSecurityConstraints();
        linkConstraints.setOwner("user");
        List inlineLinkConstraints = new ArrayList(1);
        SecurityConstraint linkConstraint = link.newSecurityConstraint();
        linkConstraint.setUsers(Shared.makeListFromCSV("jetspeed"));
        linkConstraint.setPermissions(Shared.makeListFromCSV("edit"));
        inlineLinkConstraints.add(linkConstraint);
        linkConstraints.setSecurityConstraints(inlineLinkConstraints);
        List linkConstraintsRefs = new ArrayList(1);
        linkConstraintsRefs.add("manager-edit");
        linkConstraints.setSecurityConstraintsRefs(linkConstraintsRefs);
        link.setSecurityConstraints(linkConstraints);

        pageManager.updateLink(link);

        assertNotNull(link.getParent());
        assertEquals(link.getParent().getId(), folder.getId());
        assertNotNull(folder.getLinks());
        assertEquals(1, folder.getLinks().size());
        assertNotNull(pageManager.getLinks(folder));
        assertEquals(1, pageManager.getLinks(folder).size());

        PageSecurity pageSecurity = pageManager.newPageSecurity();
        List constraintsDefs = new ArrayList(2);
        SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
        constraintsDef.setName("public-view");
        List defConstraints = new ArrayList(1);
        SecurityConstraint defConstraint = pageSecurity.newSecurityConstraint();
        defConstraint.setUsers(Shared.makeListFromCSV("*"));
        defConstraint.setPermissions(Shared.makeListFromCSV("view"));
        defConstraints.add(defConstraint);
        constraintsDef.setSecurityConstraints(defConstraints);
        constraintsDefs.add(constraintsDef);
        constraintsDef = pageSecurity.newSecurityConstraintsDef();
        constraintsDef.setName("admin-all");
        defConstraints = new ArrayList(2);
        defConstraint = pageSecurity.newSecurityConstraint();
        defConstraint.setRoles(Shared.makeListFromCSV("admin"));
        defConstraint.setPermissions(Shared.makeListFromCSV("view,edit"));
        defConstraints.add(defConstraint);
        defConstraint = pageSecurity.newSecurityConstraint();
        defConstraint.setRoles(Shared.makeListFromCSV("nobody"));
        defConstraints.add(defConstraint);
        constraintsDef.setSecurityConstraints(defConstraints);
        constraintsDefs.add(constraintsDef);
        pageSecurity.setSecurityConstraintsDefs(constraintsDefs);
        List globalConstraintsRefs = new ArrayList(2);
        globalConstraintsRefs.add("admin-all");
        globalConstraintsRefs.add("public-view");
        pageSecurity.setGlobalSecurityConstraintsRefs(globalConstraintsRefs);

        pageManager.updatePageSecurity(pageSecurity);

        assertNotNull(pageSecurity.getParent());
        assertEquals(pageSecurity.getParent().getId(), folder.getId());
        assertNotNull(folder.getPageSecurity());

        // test duplicate creates
        try
        {
            Folder dupFolder = pageManager.newFolder("/");
            pageManager.updateFolder(dupFolder);
            assertTrue("Duplicate Folder / CREATED", false);
        }
        catch (FolderNotUpdatedException e)
        {
        }
        try
        {
            Page dupPage = pageManager.newPage("/default-page.psml");
            pageManager.updatePage(dupPage);
            assertTrue("Duplicate Page / CREATED", false);
        }
        catch (PageNotUpdatedException e)
        {
        }
        try
        {
            Link dupLink = pageManager.newLink("/default.link");
            pageManager.updateLink(dupLink);
            assertTrue("Duplicate Link / CREATED", false);
        }
        catch (FailedToUpdateDocumentException e)
        {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.page.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.