Package org.apache.jetspeed.om.folder

Examples of org.apache.jetspeed.om.folder.MenuDefinition


    {
        List copiedMenus = new ArrayList(4);
        Iterator menus = srcMenus.iterator();
        while (menus.hasNext())
        {
            MenuDefinition srcMenu = (MenuDefinition)menus.next();
            MenuDefinition copiedMenu = (MenuDefinition)copyMenuElement(type, srcMenu);
            if (copiedMenu != null)
            {
                copiedMenus.add(copiedMenu);
            }
        }
View Full Code Here


    protected Object copyMenuElement(String type, Object srcElement)
    {
        if (srcElement instanceof MenuDefinition)
        {
            // create the new menu element and copy attributes
            MenuDefinition source = (MenuDefinition)srcElement;
            MenuDefinition menu = null;
            if (type.equals(PAGE_NODE_TYPE))
            {
                menu = newPageMenuDefinition();
            }
            else if (type.equals(FOLDER_NODE_TYPE))
            {
                menu = newFolderMenuDefinition();
            }
            menu.setDepth(source.getDepth());
            menu.setName(source.getName());
            menu.setOptions(source.getOptions());
            menu.setOrder(source.getOrder());
            menu.setPaths(source.isPaths());
            menu.setProfile(source.getProfile());
            menu.setRegexp(source.isRegexp());
            menu.setShortTitle(source.getShortTitle());
            menu.setSkin(source.getSkin());
            menu.setTitle(source.getTitle());

            // copy locale specific metadata
            menu.getMetadata().copyFields(source.getMetadata().getFields());
       
            // recursively copy menu elements
            List elements = source.getMenuElements();
            if (elements != null)
            {
                List copiedElements = new ArrayList(4);
                Iterator elementsIter = elements.iterator();
                while (elementsIter.hasNext())
                {
                    Object element = elementsIter.next();
                    Object copiedElement = copyMenuElement(type, element);
                    if (copiedElement != null)
                    {
                        copiedElements.add(copiedElement);
                    }
                }
                menu.setMenuElements(copiedElements);
            }

            return menu;
        }
        else if (srcElement instanceof MenuExcludeDefinition)
View Full Code Here

            assertNotNull(check.getSecurityConstraints().getSecurityConstraints());
            assertEquals(1, check.getSecurityConstraints().getSecurityConstraints().size());
            assertEquals("jetspeed", Shared.makeCSVFromList(((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getUsers()));
            assertNotNull(check.getMenuDefinitions());
            assertEquals(2, check.getMenuDefinitions().size());
            MenuDefinition checkMenu = (MenuDefinition)check.getMenuDefinitions().get(0);
            assertEquals("page-menu-1", checkMenu.getName());
            assertEquals("The Test Page Menu", checkMenu.getTitle());
            assertEquals("[fr] The Test Page Menu", checkMenu.getTitle(Locale.FRENCH));
            assertNotNull(checkMenu.getMenuElements());
            assertEquals(5,checkMenu.getMenuElements().size());
            assertTrue(checkMenu.getMenuElements().get(0) instanceof MenuSeparatorDefinition);
            assertEquals("-- Page Menu --", ((MenuSeparatorDefinition)checkMenu.getMenuElements().get(0)).getText());
            assertTrue(checkMenu.getMenuElements().get(1) instanceof MenuOptionsDefinition);
            assertEquals("/*.psml", ((MenuOptionsDefinition)checkMenu.getMenuElements().get(1)).getOptions());
            assertTrue(checkMenu.getMenuElements().get(2) instanceof MenuDefinition);
            assertEquals("/*/", ((MenuDefinition)checkMenu.getMenuElements().get(2)).getOptions());
            assertNotNull(((MenuDefinition)checkMenu.getMenuElements().get(2)).getMenuElements());
            assertTrue(((MenuDefinition)checkMenu.getMenuElements().get(2)).getMenuElements().isEmpty());
            assertTrue(checkMenu.getMenuElements().get(3) instanceof MenuExcludeDefinition);
            assertEquals("exclude-menu", ((MenuExcludeDefinition)checkMenu.getMenuElements().get(3)).getName());
            assertTrue(checkMenu.getMenuElements().get(4) instanceof MenuIncludeDefinition);
            assertEquals("include-menu", ((MenuIncludeDefinition)checkMenu.getMenuElements().get(4)).getName());
            checkMenu = (MenuDefinition)check.getMenuDefinitions().get(1);
            assertEquals("page-menu-2", checkMenu.getName());
            assertNotNull(checkMenu.getMenuElements());
            assertTrue(checkMenu.getMenuElements().isEmpty());
            assertNotNull(check.getRootFragment());
            assertEquals("blue-gradient", check.getRootFragment().getDecorator());
            assertEquals("jetspeed-layouts::VelocityTwoColumns", check.getRootFragment().getName());
            assertEquals("Root", check.getRootFragment().getShortTitle());
            assertEquals("Root Fragment", check.getRootFragment().getTitle());
            assertEquals("Normal", check.getRootFragment().getState());
            assertEquals("50%,50%", check.getRootFragment().getLayoutSizes());
            assertNotNull(check.getRootFragment().getProperties());
            assertEquals("custom-prop-value1", check.getRootFragment().getProperty("custom-prop1"));
            assertNotNull(check.getRootFragment().getFragments());
            assertEquals(2, check.getRootFragment().getFragments().size());
            Fragment check0 = (Fragment)check.getRootFragment().getFragments().get(0);
            assertEquals("security::LoginPortlet", check0.getName());
            assertEquals("Portlet", check0.getShortTitle());
            assertEquals("Portlet Fragment", check0.getTitle());
            assertEquals("Normal", check0.getState());
            assertEquals(88, check0.getLayoutRow());
            assertEquals(88, check0.getIntProperty(Fragment.ROW_PROPERTY_NAME));
            assertEquals(99, check0.getLayoutColumn());
            assertNotNull(check0.getPreferences());
            assertEquals(2, check0.getPreferences().size());
            assertEquals("pref0", ((FragmentPreference)check0.getPreferences().get(0)).getName());
            assertTrue(((FragmentPreference)check0.getPreferences().get(0)).isReadOnly());
            assertNotNull(((FragmentPreference)check0.getPreferences().get(0)).getValueList());
            assertEquals(2, ((FragmentPreference)check0.getPreferences().get(0)).getValueList().size());
            assertEquals("pref0-value0", (String)((FragmentPreference)check0.getPreferences().get(0)).getValueList().get(0));
            assertEquals("pref0-value1", (String)((FragmentPreference)check0.getPreferences().get(0)).getValueList().get(1));
            assertEquals("pref1", ((FragmentPreference)check0.getPreferences().get(1)).getName());
            assertFalse(((FragmentPreference)check0.getPreferences().get(1)).isReadOnly());
            assertNotNull(((FragmentPreference)check0.getPreferences().get(1)).getValueList());
            assertEquals(1, ((FragmentPreference)check0.getPreferences().get(1)).getValueList().size());
            assertEquals("pref1-value", (String)((FragmentPreference)check0.getPreferences().get(1)).getValueList().get(0));
            Fragment check1 = (Fragment)check.getRootFragment().getFragments().get(1);
            assertEquals("some-app::SomePortlet", check1.getName());
            assertEquals("Some Portlet", check1.getShortTitle());
            assertEquals("Some Portlet Fragment", check1.getTitle());
            assertEquals("Normal", check1.getState());
            assertEquals(22, check1.getLayoutRow());
            assertEquals(11, check1.getLayoutColumn());
            assertNotNull(check1.getSecurityConstraints());
            assertEquals("user", check1.getSecurityConstraints().getOwner());
            assertNotNull(check.getFragmentById(check0.getId()));
            assertNotNull(check.getFragmentsByName("some-app::SomePortlet"));
            assertEquals(1, check.getFragmentsByName("some-app::SomePortlet").size());
            assertNotNull(check.getParent());
        }
        catch (PageNotFoundException e)
        {
            assertTrue("Page /default-page.psml NOT FOUND", false);
        }
        try
        {
            Folder check = pageManager.getFolder("/");
            assertEquals("/", check.getPath());
            assertEquals("/", check.getName());
            assertEquals("/", check.getUrl());
            assertEquals("Root Folder", check.getTitle());
            assertEquals("default-page.psml", check.getDefaultPage());
            assertEquals("Root", check.getShortTitle());
            assertNotNull(check.getMetadata());
            assertEquals("[fr] Root Folder", check.getTitle(Locale.FRENCH));
            assertNotNull(check.getSecurityConstraints());
            assertEquals("admin", check.getSecurityConstraints().getOwner());
            assertNotNull(check.getSecurityConstraints().getSecurityConstraintsRefs());
            assertEquals(2, check.getSecurityConstraints().getSecurityConstraintsRefs().size());
            assertEquals("public-edit", (String)check.getSecurityConstraints().getSecurityConstraintsRefs().get(1));
            assertNotNull(check.getSecurityConstraints().getSecurityConstraints());
            assertEquals(2, check.getSecurityConstraints().getSecurityConstraints().size());
            assertEquals("user,admin", Shared.makeCSVFromList(((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getUsers()));
            assertEquals("manager", Shared.makeCSVFromList(((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getRoles()));
            assertNull(((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getGroups());
            assertEquals("edit", Shared.makeCSVFromList(((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(1)).getPermissions()));
            assertNotNull(check.getDocumentOrder());
            assertEquals(2, check.getDocumentOrder().size());
            assertEquals("some-other-page.psml", (String)check.getDocumentOrder().get(0));
            assertEquals("default-page.psml", (String)check.getDocumentOrder().get(1));
            assertNull(check.getParent());
            assertNotNull(check.getPageSecurity());
            assertNotNull(check.getPages());
            assertEquals(3, check.getPages().size());
            assertNotNull(check.getLinks());
            assertEquals(1, check.getLinks().size());
            assertNotNull(check.getFolders());
            assertEquals(1, check.getFolders().size());
            assertNotNull(check.getAll());
            assertEquals(6, check.getAll().size());
            Iterator all = check.getAll().iterator();
            assertEquals("some-other-page.psml", ((Node)all.next()).getName());
            assertEquals("default-page.psml", ((Node)all.next()).getName());
            assertEquals("__subsite-rootx", ((Node)all.next()).getName());
            assertEquals("another-page.psml", ((Node)all.next()).getName());
            assertEquals("default.link", ((Node)all.next()).getName());
            assertEquals("page.security", ((Node)all.next()).getName());
            assertNotNull(check.getMenuDefinitions());
            assertEquals(2, check.getMenuDefinitions().size());
            MenuDefinition checkMenu = (MenuDefinition)check.getMenuDefinitions().get(0);
            assertEquals("folder-breadcrumb-menu", checkMenu.getName());
            assertEquals("bread-crumbs", checkMenu.getSkin());
            assertEquals("./", checkMenu.getOptions());
            assertTrue(checkMenu.isPaths());
            assertNotNull(checkMenu.getMenuElements());
            assertTrue(checkMenu.getMenuElements().isEmpty());
            checkMenu = (MenuDefinition)check.getMenuDefinitions().get(1);
            assertEquals("folder-menu", checkMenu.getName());
            assertEquals("The Test Folder Menu", checkMenu.getTitle());
            assertEquals("Folder Menu", checkMenu.getShortTitle());
            assertEquals("group-fallback", checkMenu.getProfile());
            assertEquals("[fr] Folder Menu", checkMenu.getShortTitle(Locale.FRENCH));
            assertEquals("[fr] The Test Folder Menu", checkMenu.getTitle(Locale.FRENCH));
            assertNotNull(checkMenu.getMenuElements());
            assertEquals(6,checkMenu.getMenuElements().size());
            assertTrue(checkMenu.getMenuElements().get(0) instanceof MenuSeparatorDefinition);
            assertEquals("-- Folder Menu --", ((MenuSeparatorDefinition)checkMenu.getMenuElements().get(0)).getText());
            assertEquals("Rollover: Folder Menu", ((MenuSeparatorDefinition)checkMenu.getMenuElements().get(0)).getTitle());
            assertEquals("header", ((MenuSeparatorDefinition)checkMenu.getMenuElements().get(0)).getSkin());
            assertEquals("-- [fr] Folder Menu --", ((MenuSeparatorDefinition)checkMenu.getMenuElements().get(0)).getText(Locale.FRENCH));
            assertEquals("[fr] Rollover: Folder Menu", ((MenuSeparatorDefinition)checkMenu.getMenuElements().get(0)).getTitle(Locale.FRENCH));
            assertTrue(checkMenu.getMenuElements().get(1) instanceof MenuOptionsDefinition);
            assertEquals("/*.psml", ((MenuOptionsDefinition)checkMenu.getMenuElements().get(1)).getOptions());
            assertTrue(((MenuOptionsDefinition)checkMenu.getMenuElements().get(1)).isRegexp());
            assertEquals("flash", ((MenuOptionsDefinition)checkMenu.getMenuElements().get(1)).getSkin());
            assertTrue(checkMenu.getMenuElements().get(2) instanceof MenuOptionsDefinition);
            assertEquals("/folder0", ((MenuOptionsDefinition)checkMenu.getMenuElements().get(2)).getOptions());
            assertEquals("role-fallback", ((MenuOptionsDefinition)checkMenu.getMenuElements().get(2)).getProfile());
            assertEquals("/folder*", ((MenuOptionsDefinition)checkMenu.getMenuElements().get(2)).getOrder());
            assertEquals(1, ((MenuOptionsDefinition)checkMenu.getMenuElements().get(2)).getDepth());
            assertTrue(((MenuOptionsDefinition)checkMenu.getMenuElements().get(2)).isPaths());
            assertTrue(checkMenu.getMenuElements().get(3) instanceof MenuDefinition);
            assertEquals("/*/", ((MenuDefinition)checkMenu.getMenuElements().get(3)).getOptions());
            assertTrue(((MenuDefinition)checkMenu.getMenuElements().get(3)).isRegexp());
            assertEquals(2, ((MenuDefinition)checkMenu.getMenuElements().get(3)).getDepth());
            assertEquals("/x*/,/y*/,/z*/", ((MenuDefinition)checkMenu.getMenuElements().get(3)).getOrder());
            assertEquals("bold", ((MenuDefinition)checkMenu.getMenuElements().get(3)).getSkin());
            assertNotNull(((MenuDefinition)checkMenu.getMenuElements().get(3)).getMenuElements());
            assertTrue(((MenuDefinition)checkMenu.getMenuElements().get(3)).getMenuElements().isEmpty());
            assertTrue(checkMenu.getMenuElements().get(4) instanceof MenuExcludeDefinition);
            assertEquals("exclude-menu", ((MenuExcludeDefinition)checkMenu.getMenuElements().get(4)).getName());
            assertTrue(checkMenu.getMenuElements().get(5) instanceof MenuIncludeDefinition);
            assertEquals("include-menu", ((MenuIncludeDefinition)checkMenu.getMenuElements().get(5)).getName());
            assertTrue(((MenuIncludeDefinition)checkMenu.getMenuElements().get(5)).isNest());
        }
        catch (FolderNotFoundException e)
        {
            assertTrue("Folder / NOT FOUND", false);
        }
View Full Code Here

        assertNotNull(folder);
        List menus = folder.getMenuDefinitions();
        assertNotNull(menus);
        assertEquals(5, menus.size());

        MenuDefinition simpleMenu = (MenuDefinition)menus.get(0);
        assertNotNull(simpleMenu);
        assertEquals("simple", simpleMenu.getName());
        assertNotNull(simpleMenu.getMenuElements());
        assertEquals(1, simpleMenu.getMenuElements().size());
        assertTrue(simpleMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
        assertEquals("/test001.psml,/folder1/folder2", ((MenuOptionsDefinition)simpleMenu.getMenuElements().get(0)).getOptions());

        MenuDefinition top2LevelsMenu = (MenuDefinition)menus.get(1);
        assertNotNull(top2LevelsMenu);
        assertEquals("top-2-levels", top2LevelsMenu.getName());
        assertNull(top2LevelsMenu.getMenuElements());
        assertEquals("/", top2LevelsMenu.getOptions());
        assertEquals(2, top2LevelsMenu.getDepth());
        assertEquals("dhtml-pull-down", top2LevelsMenu.getSkin());

        MenuDefinition topRolePagesMenu = (MenuDefinition)menus.get(2);
        assertNotNull(topRolePagesMenu);
        assertEquals("top-role-pages", topRolePagesMenu.getName());
        assertTrue(topRolePagesMenu.isRegexp());
        assertEquals("roles", topRolePagesMenu.getProfile());
        assertEquals("*.psml,*.link", topRolePagesMenu.getOrder());

        MenuDefinition breadCrumbsMenu = (MenuDefinition)menus.get(3);
        assertNotNull(breadCrumbsMenu);
        assertEquals("bread-crumbs", breadCrumbsMenu.getName());
        assertTrue(breadCrumbsMenu.isPaths());

        MenuDefinition topCustomMenu = (MenuDefinition)menus.get(4);
        assertNotNull(topCustomMenu);
        assertEquals("top-custom", topCustomMenu.getName());
        assertEquals("Top Menu", topCustomMenu.getTitle());
        assertEquals("Top", topCustomMenu.getShortTitle());
        assertEquals("Haut", topCustomMenu.getTitle(Locale.FRENCH));
        assertEquals("H", topCustomMenu.getShortTitle(Locale.FRENCH));
        assertNotNull(topCustomMenu.getMenuElements());
        assertEquals(5, topCustomMenu.getMenuElements().size());
        assertTrue(topCustomMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
        assertTrue(((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).isRegexp());
        assertEquals("groups", ((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).getProfile());
        assertTrue(topCustomMenu.getMenuElements().get(1) instanceof MenuDefinition);
        assertTrue(topCustomMenu.getMenuElements().get(2) instanceof MenuExcludeDefinition);
        assertEquals("top-role-pages", ((MenuExcludeDefinition)topCustomMenu.getMenuElements().get(2)).getName());
        assertTrue(topCustomMenu.getMenuElements().get(3) instanceof MenuSeparatorDefinition);
        assertEquals("More Top Pages", ((MenuSeparatorDefinition)topCustomMenu.getMenuElements().get(3)).getText());
        assertTrue(topCustomMenu.getMenuElements().get(4) instanceof MenuIncludeDefinition);
        assertEquals("simple", ((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).getName());
        assertTrue(((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).isNest());

        MenuDefinition topCustomNestedMenu = (MenuDefinition)topCustomMenu.getMenuElements().get(1);
        assertEquals("/", topCustomNestedMenu.getOptions());
        assertEquals("page", topCustomNestedMenu.getProfile());
        assertEquals(5, topCustomNestedMenu.getMenuElements().size());
        assertTrue(topCustomNestedMenu.getMenuElements().get(0) instanceof MenuSeparatorDefinition);
        assertEquals("Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText());
        assertEquals("Ye Olde Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText(Locale.ENGLISH));
        assertEquals("Select from Top Pages menu...", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle());
        assertEquals("Haut", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle(Locale.FRENCH));
        assertTrue(topCustomNestedMenu.getMenuElements().get(1) instanceof MenuOptionsDefinition);
        assertTrue(topCustomNestedMenu.getMenuElements().get(2) instanceof MenuSeparatorDefinition);
        assertEquals("bold", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getSkin());
        assertEquals("Custom Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getTitle());
        assertTrue(topCustomNestedMenu.getMenuElements().get(3) instanceof MenuOptionsDefinition);
        assertEquals(1, ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getDepth());
        assertEquals("*.psml", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getOrder());
        assertTrue(topCustomNestedMenu.getMenuElements().get(4) instanceof MenuOptionsDefinition);
        assertTrue(((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).isPaths());
        assertEquals("*", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getProfile());
        assertEquals("links", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getSkin());
        assertEquals("@", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getOptions());

        // test page resident menu definitions
        Page page = pageManager.getPage("/test001.psml");
        assertNotNull(page);
        menus = page.getMenuDefinitions();
        assertNotNull(menus);
        assertEquals(1, menus.size());

        simpleMenu = (MenuDefinition)menus.get(0);
        assertNotNull(simpleMenu);
        assertEquals("simple", simpleMenu.getName());
        assertNotNull(simpleMenu.getMenuElements());
        assertEquals(2, simpleMenu.getMenuElements().size());

        // test writing page menu definitions
        page = pageManager.getPage(this.testPage002);
        page.setMenuDefinitions(new ArrayList());
        MenuDefinition newMenu = page.newMenuDefinition();
        newMenu.setName("updated-menu");
        newMenu.setSkin("tabs");
        newMenu.setMenuElements(new ArrayList());
        MenuSeparatorDefinition newSeparator = page.newMenuSeparatorDefinition();
        newSeparator.setText("-- Updated Menu --");
        newMenu.getMenuElements().add(newSeparator);
        MenuOptionsDefinition newOptions0 = page.newMenuOptionsDefinition();
        newOptions0.setOptions("/*.psml");
        newOptions0.setRegexp(true);
        newMenu.getMenuElements().add(newOptions0);
        MenuOptionsDefinition newOptions1 = page.newMenuOptionsDefinition();
        newOptions1.setOptions("/folder0");
        newMenu.getMenuElements().add(newOptions1);
        MenuDefinition newNestedMenu = page.newMenuDefinition();
        newNestedMenu.setOptions("/*/");
        newNestedMenu.setRegexp(true);
        newMenu.getMenuElements().add(newNestedMenu);
        MenuExcludeDefinition newExcludeMenu = page.newMenuExcludeDefinition();
        newExcludeMenu.setName("exclude-menu");
        newMenu.getMenuElements().add(newExcludeMenu);
        MenuIncludeDefinition newIncludeMenu = page.newMenuIncludeDefinition();
View Full Code Here

        {
            Iterator definitionsIter = definitions.iterator();
            while (definitionsIter.hasNext())
            {
                // aggregate menu definition by valid name
                MenuDefinition definition = (MenuDefinition)definitionsIter.next();
                String definitionName = definition.getName();
                if (definitionName != null)
                {
                    // add unique menu definition to end of
                    // ordered menu definition locators list
                    if (!menuDefinitionLocatorsContains(definitionName))
View Full Code Here

        assertNotNull(folder);
        List menus = folder.getMenuDefinitions();
        assertNotNull(menus);
        assertEquals(5, menus.size());

        MenuDefinition simpleMenu = (MenuDefinition)menus.get(0);
        assertNotNull(simpleMenu);
        assertEquals("simple", simpleMenu.getName());
        assertNotNull(simpleMenu.getMenuElements());
        assertEquals(1, simpleMenu.getMenuElements().size());
        assertTrue(simpleMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
        assertEquals("/test001.psml,/folder1/folder2", ((MenuOptionsDefinition)simpleMenu.getMenuElements().get(0)).getOptions());

        MenuDefinition top2LevelsMenu = (MenuDefinition)menus.get(1);
        assertNotNull(top2LevelsMenu);
        assertEquals("top-2-levels", top2LevelsMenu.getName());
        assertNull(top2LevelsMenu.getMenuElements());
        assertEquals("/", top2LevelsMenu.getOptions());
        assertEquals(2, top2LevelsMenu.getDepth());
        assertEquals("dhtml-pull-down", top2LevelsMenu.getSkin());

        MenuDefinition topRolePagesMenu = (MenuDefinition)menus.get(2);
        assertNotNull(topRolePagesMenu);
        assertEquals("top-role-pages", topRolePagesMenu.getName());
        assertTrue(topRolePagesMenu.isRegexp());
        assertEquals("roles", topRolePagesMenu.getProfile());
        assertEquals("*.psml,*.link", topRolePagesMenu.getOrder());

        MenuDefinition breadCrumbsMenu = (MenuDefinition)menus.get(3);
        assertNotNull(breadCrumbsMenu);
        assertEquals("bread-crumbs", breadCrumbsMenu.getName());
        assertTrue(breadCrumbsMenu.isPaths());

        MenuDefinition topCustomMenu = (MenuDefinition)menus.get(4);
        assertNotNull(topCustomMenu);
        assertEquals("top-custom", topCustomMenu.getName());
        assertEquals("Top Menu", topCustomMenu.getTitle());
        assertEquals("Top", topCustomMenu.getShortTitle());
        assertEquals("Haut", topCustomMenu.getTitle(Locale.FRENCH));
        assertEquals("H", topCustomMenu.getShortTitle(Locale.FRENCH));
        assertNotNull(topCustomMenu.getMenuElements());
        assertEquals(5, topCustomMenu.getMenuElements().size());
        assertTrue(topCustomMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
        assertTrue(((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).isRegexp());
        assertEquals("groups", ((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).getProfile());
        assertTrue(topCustomMenu.getMenuElements().get(1) instanceof MenuDefinition);
        assertTrue(topCustomMenu.getMenuElements().get(2) instanceof MenuExcludeDefinition);
        assertEquals("top-role-pages", ((MenuExcludeDefinition)topCustomMenu.getMenuElements().get(2)).getName());
        assertTrue(topCustomMenu.getMenuElements().get(3) instanceof MenuSeparatorDefinition);
        assertEquals("More Top Pages", ((MenuSeparatorDefinition)topCustomMenu.getMenuElements().get(3)).getText());
        assertTrue(topCustomMenu.getMenuElements().get(4) instanceof MenuIncludeDefinition);
        assertEquals("simple", ((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).getName());
        assertTrue(((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).isNest());

        MenuDefinition topCustomNestedMenu = (MenuDefinition)topCustomMenu.getMenuElements().get(1);
        assertEquals("/", topCustomNestedMenu.getOptions());
        assertEquals("page", topCustomNestedMenu.getProfile());
        assertEquals(5, topCustomNestedMenu.getMenuElements().size());
        assertTrue(topCustomNestedMenu.getMenuElements().get(0) instanceof MenuSeparatorDefinition);
        assertEquals("Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText());
        assertEquals("Ye Olde Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText(Locale.ENGLISH));
        assertEquals("Select from Top Pages menu...", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle());
        assertEquals("Haut", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle(Locale.FRENCH));
        assertTrue(topCustomNestedMenu.getMenuElements().get(1) instanceof MenuOptionsDefinition);
        assertTrue(topCustomNestedMenu.getMenuElements().get(2) instanceof MenuSeparatorDefinition);
        assertEquals("bold", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getSkin());
        assertEquals("Custom Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getTitle());
        assertTrue(topCustomNestedMenu.getMenuElements().get(3) instanceof MenuOptionsDefinition);
        assertEquals(1, ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getDepth());
        assertEquals("*.psml", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getOrder());
        assertTrue(topCustomNestedMenu.getMenuElements().get(4) instanceof MenuOptionsDefinition);
        assertTrue(((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).isPaths());
        assertEquals("*", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getProfile());
        assertEquals("links", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getSkin());
        assertEquals("@", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getOptions());

        // test page resident menu definitions
        Page page = pageManager.getPage("/test001.psml");
        assertNotNull(page);
        menus = page.getMenuDefinitions();
        assertNotNull(menus);
        assertEquals(1, menus.size());

        simpleMenu = (MenuDefinition)menus.get(0);
        assertNotNull(simpleMenu);
        assertEquals("simple", simpleMenu.getName());
        assertNotNull(simpleMenu.getMenuElements());
        assertEquals(2, simpleMenu.getMenuElements().size());

        // test writing page menu definitions
        page = pageManager.getPage(this.testPage002);
        page.setMenuDefinitions(new ArrayList());
        MenuDefinition newMenu = page.newMenuDefinition();
        newMenu.setName("updated-menu");
        newMenu.setSkin("tabs");
        newMenu.setMenuElements(new ArrayList());
        MenuSeparatorDefinition newSeparator = page.newMenuSeparatorDefinition();
        newSeparator.setText("-- Updated Menu --");
        newMenu.getMenuElements().add(newSeparator);
        MenuOptionsDefinition newOptions0 = page.newMenuOptionsDefinition();
        newOptions0.setOptions("/*.psml");
        newOptions0.setRegexp(true);
        newMenu.getMenuElements().add(newOptions0);
        MenuOptionsDefinition newOptions1 = page.newMenuOptionsDefinition();
        newOptions1.setOptions("/folder0");
        newMenu.getMenuElements().add(newOptions1);
        MenuDefinition newNestedMenu = page.newMenuDefinition();
        newNestedMenu.setOptions("/*/");
        newNestedMenu.setRegexp(true);
        newMenu.getMenuElements().add(newNestedMenu);
        MenuExcludeDefinition newExcludeMenu = page.newMenuExcludeDefinition();
        newExcludeMenu.setName("exclude-menu");
        newMenu.getMenuElements().add(newExcludeMenu);
        MenuIncludeDefinition newIncludeMenu = page.newMenuIncludeDefinition();
View Full Code Here

    {
        List copiedMenus = DatabasePageManagerUtils.createList();
        Iterator menus = srcMenus.iterator();
        while (menus.hasNext())
        {
            MenuDefinition srcMenu = (MenuDefinition)menus.next();
            MenuDefinition copiedMenu = (MenuDefinition)copyMenuElement(type, srcMenu);
            if (copiedMenu != null)
            {
                copiedMenus.add(copiedMenu);
            }
        }
View Full Code Here

    protected Object copyMenuElement(String type, Object srcElement)
    {
        if (srcElement instanceof MenuDefinition)
        {
            // create the new menu element and copy attributes
            MenuDefinition source = (MenuDefinition)srcElement;
            MenuDefinition menu = null;
            if (type.equals(PAGE_NODE_TYPE))
            {
                menu = newPageMenuDefinition();
            }
            else if (type.equals(FOLDER_NODE_TYPE))
            {
                menu = newFolderMenuDefinition();
            }
            menu.setDepth(source.getDepth());
            menu.setName(source.getName());
            menu.setOptions(source.getOptions());
            menu.setOrder(source.getOrder());
            menu.setPaths(source.isPaths());
            menu.setProfile(source.getProfile());
            menu.setRegexp(source.isRegexp());
            menu.setShortTitle(source.getShortTitle());
            menu.setSkin(source.getSkin());
            menu.setTitle(source.getTitle());

            // copy locale specific metadata
            menu.getMetadata().copyFields(source.getMetadata().getFields());
       
            // recursively copy menu elements
            List elements = source.getMenuElements();
            if (elements != null)
            {
                List copiedElements = DatabasePageManagerUtils.createList();
                Iterator elementsIter = elements.iterator();
                while (elementsIter.hasNext())
                {
                    Object element = elementsIter.next();
                    Object copiedElement = copyMenuElement(type, element);
                    if (copiedElement != null)
                    {
                        copiedElements.add(copiedElement);
                    }
                }
                menu.setMenuElements(copiedElements);
            }

            return menu;
        }
        else if (srcElement instanceof MenuExcludeDefinition)
View Full Code Here

        folder.setSecurityConstraints(folderConstraints);
        List documentOrder = new ArrayList(2);
        documentOrder.add("some-other-page.psml");
        documentOrder.add("default-page.psml");
        folder.setDocumentOrder(documentOrder);
        MenuDefinition newMenu = folder.newMenuDefinition();
        newMenu.setName("folder-menu");
        newMenu.setTitle("The Test Folder Menu");
        newMenu.setShortTitle("Folder Menu");
        newMenu.setProfile("group-fallback");
        metadata = newMenu.getMetadata();
        metadata.addField(Locale.FRENCH, "short-title", "[fr] Folder Menu");
        metadata.addField(Locale.FRENCH, "title", "[fr] The Test Folder Menu");
        MenuSeparatorDefinition newSeparator = folder.newMenuSeparatorDefinition();
        newSeparator.setText("-- Folder Menu --");
        newSeparator.setTitle("Rollover: Folder Menu");
        newSeparator.setSkin("header");
        metadata = newSeparator.getMetadata();
        metadata.addField(Locale.FRENCH, "text", "-- [fr] Folder Menu --");
        metadata.addField(Locale.FRENCH, "title", "[fr] Rollover: Folder Menu");
        newMenu.getMenuElements().add(newSeparator);
        MenuOptionsDefinition newOptions0 = folder.newMenuOptionsDefinition();
        newOptions0.setOptions("/*.psml");
        newOptions0.setRegexp(true);
        newOptions0.setSkin("flash");
        newMenu.getMenuElements().add(newOptions0);
        MenuOptionsDefinition newOptions1 = folder.newMenuOptionsDefinition();
        newOptions1.setOptions("/folder0");
        newOptions1.setProfile("role-fallback");
        newOptions1.setOrder("/folder*");
        newOptions1.setDepth(1);
        newOptions1.setPaths(true);
        newMenu.getMenuElements().add(newOptions1);
        MenuDefinition newNestedMenu = folder.newMenuDefinition();
        newNestedMenu.setOptions("/*/");
        newNestedMenu.setRegexp(true);
        newNestedMenu.setDepth(2);
        newNestedMenu.setOrder("/x*/,/y*/,/z*/");
        newNestedMenu.setSkin("bold");
        newMenu.getMenuElements().add(newNestedMenu);
        MenuExcludeDefinition newExcludeMenu = folder.newMenuExcludeDefinition();
        newExcludeMenu.setName("exclude-menu");
        newMenu.getMenuElements().add(newExcludeMenu);
        MenuIncludeDefinition newIncludeMenu = folder.newMenuIncludeDefinition();
        newIncludeMenu.setName("include-menu");
        newIncludeMenu.setNest(true);
        newMenu.getMenuElements().add(newIncludeMenu);
        folder.getMenuDefinitions().add(newMenu);
        newMenu = folder.newMenuDefinition();
        newMenu.setName("folder-breadcrumb-menu");
        newMenu.setSkin("bread-crumbs");
        newMenu.setOptions("./");
        newMenu.setPaths(true);
        folder.getMenuDefinitions().add(newMenu);
        pageManager.updateFolder(folder);
       
        assertNull(folder.getParent());

        Page page = pageManager.newPage("/default-page.psml");
        assertEquals("Default Page", page.getTitle());
        page.setTitle("Default Page");
        page.setVersion("6.89");
        page.setDefaultDecorator("tigris", Fragment.LAYOUT);
        page.setDefaultDecorator("blue-gradient", Fragment.PORTLET);
        page.setSkin("skin-1");
        page.setShortTitle("Default");
        metadata = page.getMetadata();
        metadata.addField(Locale.FRENCH, "title", "[fr] Default Page");
        metadata.addField(Locale.JAPANESE, "title", "[ja] Default Page");
        SecurityConstraints pageConstraints = page.newSecurityConstraints();
        pageConstraints.setOwner("user");
        List inlinePageConstraints = new ArrayList(1);
        SecurityConstraint pageConstraint = page.newSecurityConstraint();
        pageConstraint.setUsers(Shared.makeListFromCSV("jetspeed"));
        pageConstraint.setPermissions(Shared.makeListFromCSV("edit"));
        inlinePageConstraints.add(pageConstraint);
        pageConstraints.setSecurityConstraints(inlinePageConstraints);
        List pageConstraintsRefs = new ArrayList(1);
        pageConstraintsRefs.add("manager-edit");
        pageConstraints.setSecurityConstraintsRefs(pageConstraintsRefs);
        page.setSecurityConstraints(pageConstraints);
        List pageMenus = new ArrayList();
        newMenu = page.newMenuDefinition();
        newMenu.setName("page-menu-1");
        newMenu.setTitle("The Test Page Menu");
        metadata = newMenu.getMetadata();
        metadata.addField(Locale.FRENCH, "title", "[fr] The Test Page Menu");
        newSeparator = page.newMenuSeparatorDefinition();
        newSeparator.setText("-- Page Menu --");
        List menuElements = new ArrayList();
        menuElements.add(newSeparator);
        newOptions0 = page.newMenuOptionsDefinition();
        newOptions0.setOptions("/*.psml");
        menuElements.add(newOptions0);
        newNestedMenu = page.newMenuDefinition();
        newNestedMenu.setOptions("/*/");
        menuElements.add(newNestedMenu);
        newExcludeMenu = page.newMenuExcludeDefinition();
        newExcludeMenu.setName("exclude-menu");
        menuElements.add(newExcludeMenu);
        newIncludeMenu = page.newMenuIncludeDefinition();
View Full Code Here

            return false;
        }
        else
        {
           
            MenuDefinition definition = (MenuDefinition) obj;
            if (!StringUtils.equals(definition.getName(),name) || !StringUtils.equals(definition.getOptions(),options) || definition.getDepth() != depth ||
                definition.isPaths() != paths || definition.isRegexp() != regexp || !StringUtils.equals(definition.getProfile(),profile) ||
                !StringUtils.equals(definition.getOrder(),order) || !StringUtils.equals(definition.getSkin(),skin) || !StringUtils.equals(definition.getTitle(),title))
            {
                return false;
            }
            if (definition.getMenuElements() != null && menuElements != null)
            {
                if (definition.getMenuElements().size() != menuElements.size())
                {
                    return false;
                }
            }
            return true;
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.folder.MenuDefinition

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.