Package org.apache.jetspeed.om.page

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


    /* (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

            // caching the links collection for this folder
            return getPageManager().getLink(this, name);
        }

        // select link by name from cached links collection
        Link link = (Link)getLinksNodeSet().get(name);
        if (link == null)
        {
            throw new DocumentNotFoundException("Link not found: " + name);
        }

        // check for view access on link
        link.checkAccess(JetspeedActions.VIEW);

        return link;
    }
View Full Code Here

     * @throws NodeException
     */
    public Link getLink(String name, boolean checkAccess) throws DocumentNotFoundException, NodeException
    {
        // get link
        Link link = (Link) getAllNodes().subset(Link.DOCUMENT_TYPE).get(name);
        if (link == null)
        {
            throw new DocumentNotFoundException("Jetspeed PSML link not found: " + name);
        }

        // check access
        if (checkAccess)
        {
            link.checkAccess(JetspeedActions.VIEW);
        }
        return link;
    }
View Full Code Here

                            Page source = folder.getPage(fileName);
                            Page page = pageManager.copyPage(source, destPath + "/" + fileName);
                            pageManager.updatePage(page);
                            success = true;
                        }else if(fileType.equalsIgnoreCase("link")){
                            Link source = folder.getLink(fileName);
                            Link page = pageManager.copyLink(source, destPath + "/" + fileName);
                            pageManager.updateLink(page);
                            success = true;
                        }else if(fileType.equalsIgnoreCase("zip")){
                            unzipfile(fileName,usrFolder + path,path);
                            folder = castorPageManager.getFolder(request.getUserPrincipal().toString());
View Full Code Here

            pageManager.updatePage(dstPage);
        }

        Iterator links = srcFolder.getLinks().iterator();
        while (links.hasNext()) {
            Link srcLink = (Link) links.next();
            Link dstLink = lookupLink(srcLink.getPath());
            newPath = destination+getRealPath(srcLink.getPath());
            dstLink = pageManager.copyLink(srcLink, newPath);
            pageManager.updateLink(dstLink);
        }
        Iterator folders = srcFolder.getFolders().iterator();
View Full Code Here

        try
        {
            Criteria filter = new Criteria();
            filter.addEqualTo("path", path);
            QueryByCriteria query = QueryFactory.newQuery(LinkImpl.class, filter);
            Link link = (Link)getPersistenceBrokerTemplate().getObjectByQuery(query);
           
            // return link or throw exception
            if (link == null)
            {
                throw new DocumentNotFoundException("Link " + path + " not found.");
            }

            // check for view access on link
            link.checkAccess(JetspeedActions.VIEW);

            return link;
        }
        catch (DocumentNotFoundException dnfe)
        {
View Full Code Here

            // caching the links collection for this folder
            return pageManager.getLink(this, name);
        }

        // select link by name from cached links collection
        Link link = (Link)getLinksNodeSet().get(name);
        if (link == null)
        {
            throw new DocumentNotFoundException("Link not found: " + name);
        }

        // check for view access on link
        link.checkAccess(JetspeedActions.VIEW);

        return link;
    }
View Full Code Here

        Folder rootFolder = pageManager.getFolder("/");
        assertNotNull(rootFolder);
        Page rootPage0 = pageManager.getPage("/page0.psml");
        assertNotNull(rootPage0);
        assertEquals(rootFolder.getPage("page0.psml"), rootPage0);       
        Link rootLink0 = pageManager.getLink("/link0.link");       
        assertNotNull(rootLink0);
        assertEquals(rootFolder.getLink("link0.link"), rootLink0);       
    }
View Full Code Here

        assertEquals("/page0.psml", extractFileSystemPathFromId(rootPage0Proxy.getId()));
        Page rootHiddenProxy = rootFolderProxy.getPage("hidden.psml");
        assertNotNull(rootHiddenProxy);
        assertEquals("hidden.psml", rootHiddenProxy.getName());
        assertTrue(rootHiddenProxy.isHidden());
        Link rootLink0Proxy = rootFolderProxy.getLink("link0.link");
        assertNotNull(rootLink0Proxy);
        assertEquals(rootFolderProxy, rootLink0Proxy.getParent());
        assertEquals("link0.link", rootLink0Proxy.getName());
        assertEquals("/link0.link", extractFileSystemPathFromId(rootLink0Proxy.getId()));
        Folder rootFolder0Proxy = rootFolderProxy.getFolder("folder0");
        assertNotNull(rootFolder0Proxy);
        assertEquals(rootFolderProxy, rootFolder0Proxy.getParent());
        assertEquals(1, rootFolder0Proxy.getPages().size());
        assertEquals(null, rootFolder0Proxy.getLinks());
        assertEquals("folder0", rootFolder0Proxy.getName());
        assertEquals("/folder0", extractFileSystemPathFromId(rootFolder0Proxy.getId()));
        Page folder0Page0Proxy = rootFolder0Proxy.getPage("page0.psml");
        assertNotNull(folder0Page0Proxy);
        assertEquals(rootFolder0Proxy, folder0Page0Proxy.getParent());
        assertEquals("page0.psml", folder0Page0Proxy.getName());
        assertEquals("/folder0/page0.psml", extractFileSystemPathFromId(folder0Page0Proxy.getId()));

        // test SiteView access by path
        Folder rootFolderProxyByPath = (Folder)baseView.getNodeProxy("/", null, false, false);
        assertNotNull(rootFolderProxyByPath);
        assertEquals(rootFolderProxy, rootFolderProxyByPath);
        Folder rootFolder0ProxyByPath = (Folder)baseView.getNodeProxy("/folder0/", null, false, false);
        assertNotNull(rootFolder0ProxyByPath);
        assertEquals(rootFolder0Proxy, rootFolder0ProxyByPath);
        Page folder0Page0ProxyByPath = (Page)baseView.getNodeProxy("/folder0/page0.psml", null, false, false);
        assertNotNull(folder0Page0ProxyByPath);
        assertEquals(folder0Page0Proxy, folder0Page0ProxyByPath);
        folder0Page0ProxyByPath = (Page)baseView.getNodeProxy("page0.psml", rootFolder0Proxy, false, false);
        assertNotNull(folder0Page0ProxyByPath);
        assertEquals(folder0Page0Proxy, folder0Page0ProxyByPath);
        List rootPageProxiesByPath = baseView.getNodeProxies("/page?.psml", null, false, false);
        assertNotNull(rootPageProxiesByPath);
        assertEquals(3,rootPageProxiesByPath.size());
        assertTrue(rootPageProxiesByPath.contains(rootPage0Proxy));
        List rootFolderProxiesByPath = baseView.getNodeProxies("/*/", null, false, false);
        assertNotNull(rootFolderProxiesByPath);
        assertEquals(4,rootFolderProxiesByPath.size());
        assertTrue(rootFolderProxiesByPath.contains(rootFolder0Proxy));
        List folderPageProxiesByPath = baseView.getNodeProxies("*/p*[0-9].psml", rootFolderProxy, false, false);
        assertNotNull(folderPageProxiesByPath);
        assertEquals(2,folderPageProxiesByPath.size());
        assertTrue(folderPageProxiesByPath.contains(folder0Page0Proxy));

        // test aggregating SiteView
        SiteView aggregateView = new SiteView(pageManager, "/_user/user,/_role/role0,/_group/group,/");
        assertEquals("/_user/user,/_role/role0,/_group/group,/", aggregateView.getSearchPathsString());
        rootFolderProxy = aggregateView.getRootFolderProxy();
        assertNotNull(rootFolderProxy);
        assertEquals("/", rootFolderProxy.getName());
        assertEquals("user root", rootFolderProxy.getTitle());
        assertEquals("/_user/user", extractFileSystemPathFromId(rootFolderProxy.getId()));
        assertEquals(4, rootFolderProxy.getFolders().size());
        assertEquals(4, rootFolderProxy.getPages().size());
        assertEquals(2, rootFolderProxy.getLinks().size());
        rootPage0Proxy = rootFolderProxy.getPage("page0.psml");
        assertNotNull(rootPage0Proxy);
        assertEquals(rootFolderProxy, rootPage0Proxy.getParent());
        assertEquals("page0.psml", rootPage0Proxy.getName());
        assertEquals("/page0.psml", extractFileSystemPathFromId(rootPage0Proxy.getId()));
        List rootPage0ProxyMenus = rootPage0Proxy.getMenuDefinitions();
        assertNotNull(rootPage0ProxyMenus);
        assertEquals(2 + aggregateView.getStandardMenuNames().size(), rootPage0ProxyMenus.size());
        Iterator menusIter = rootPage0ProxyMenus.iterator();
        MenuDefinition rootPage0ProxyTopMenu = (MenuDefinition)menusIter.next();
        assertEquals("top", rootPage0ProxyTopMenu.getName());
        assertEquals("/", rootPage0ProxyTopMenu.getOptions());
        assertEquals(2, rootPage0ProxyTopMenu.getDepth());
        assertEquals("dhtml-pull-down", rootPage0ProxyTopMenu.getSkin());
        MenuDefinition rootPage0ProxyBreadCrumbMenu = (MenuDefinition)menusIter.next();
        assertEquals("bread-crumbs", rootPage0ProxyBreadCrumbMenu.getName());
        assertEquals("./", rootPage0ProxyBreadCrumbMenu.getOptions());
        assertEquals(true, rootPage0ProxyBreadCrumbMenu.isPaths());
        for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
        {
            assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
        }
        Page rootPage2Proxy = rootFolderProxy.getPage("page2.psml");
        assertNotNull(rootPage2Proxy);
        assertEquals(rootFolderProxy, rootPage2Proxy.getParent());
        assertEquals("page2.psml", rootPage2Proxy.getName());
        assertEquals("/_user/user/page2.psml", extractFileSystemPathFromId(rootPage2Proxy.getId()));
        List rootPage2ProxyMenus = rootPage2Proxy.getMenuDefinitions();
        assertNotNull(rootPage2ProxyMenus);
        assertEquals(2 + aggregateView.getStandardMenuNames().size(), rootPage2ProxyMenus.size());
        menusIter = rootPage2ProxyMenus.iterator();
        MenuDefinition rootPage2ProxyTopMenu = (MenuDefinition)menusIter.next();
        assertEquals("top", rootPage2ProxyTopMenu.getName());
        assertEquals("/", rootPage2ProxyTopMenu.getOptions());
        assertEquals(1, rootPage2ProxyTopMenu.getDepth());
        MenuDefinition rootPage2ProxyBreadCrumbMenu = (MenuDefinition)menusIter.next();
        assertEquals("bread-crumbs", rootPage2ProxyBreadCrumbMenu.getName());
        for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
        {
            assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
        }
        rootLink0Proxy = rootFolderProxy.getLink("link0.link");
        assertNotNull(rootLink0Proxy);
        assertEquals(rootFolderProxy, rootLink0Proxy.getParent());
        assertEquals("link0.link", rootLink0Proxy.getName());
        assertEquals("/_group/group/link0.link", extractFileSystemPathFromId(rootLink0Proxy.getId()));
        rootFolder0Proxy = rootFolderProxy.getFolder("folder0");
        assertNotNull(rootFolder0Proxy);
        assertEquals(rootFolderProxy, rootFolder0Proxy.getParent());
        assertEquals(1, rootFolder0Proxy.getPages().size());
        assertEquals(null, rootFolder0Proxy.getLinks());
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.