Package org.apache.jetspeed.om.page

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


        assertTrue(bf instanceof FragmentReference);
        FragmentReference fr = (FragmentReference)bf;
        assertFalse(fr.getId().equals("cpt-f004"));
        assertTrue(fr.getRefId().equals("ctest001"));

        DynamicPage testdynamicpage = pageManager.getDynamicPage("/clonetest.dpsml");
        assertNotNull(testdynamicpage);
        DynamicPage clonedynamicpage = pageManager.copyDynamicPage(testdynamicpage, "/cloned.dpsml");
        assertNotNull(clonedynamicpage);
        assertTrue(clonedynamicpage.getId().equals("/cloned.dpsml"));
        assertTrue(clonedynamicpage.getContentType().equals("default"));       
        assertTrue(clonedynamicpage.isInheritable());       
        assertTrue(clonedynamicpage.getTitle().equals("Clone Test Dynamic Page"));
        rootFragmentElement = clonedynamicpage.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        assertNotNull(root);
        assertFalse(root.getId().equals("cdp-f001"));
        assertTrue(root.getName().equals("TwoColumns"));
View Full Code Here


        // by name, (most specific page definitions are merged first
        // since they override any folder definitions); note parent
        // folder menu definitions include standard menu definition
        // locator defaults
        FolderProxy parentFolderProxy = FolderProxy.getFolderProxy(getParent());
        DynamicPage dynamicPage = dynamicPageReference.getDynamicPage();
        mergeMenuDefinitionLocators(dynamicPage.getMenuDefinitions(), dynamicPage, parentFolderProxy.getPath(), true);
        mergeMenuDefinitionLocators(parentFolderProxy.getMenuDefinitionLocators());
    }
View Full Code Here

     *
     * @return dynamic page
     */
    public DynamicPage getDynamicPage()
    {
        DynamicPage dynamicPage = referentDynamicPage.get();
        if ((dynamicPage != null) && !dynamicPage.isStale())
        {
            return dynamicPage;
        }
        else
        {
View Full Code Here

        BaseFragmentElement removeElement0 = (BaseFragmentElement)root.getFragments().get(0);
        assertTrue(removeElement0 instanceof Fragment);
        pageTemplate.removeFragmentById(removeElement0.getId());
        pageManager.updatePageTemplate(pageTemplate);

        DynamicPage dynamicPage = pageManager.getDynamicPage("/dynamic-page.dpsml");
        assertEquals("/dynamic-page.dpsml", dynamicPage.getPath());
        dynamicPage.setTitle("UPDATED");
        dynamicPage.setContentType("UPDATED");
        dynamicPage.setInheritable(true);
        pageManager.updateDynamicPage(dynamicPage);

        FragmentDefinition fragmentDefinition = pageManager.getFragmentDefinition("/fragment-definition.fpsml");
        assertEquals("/fragment-definition.fpsml", fragmentDefinition.getPath());
        fragmentDefinition.setTitle("UPDATED");
View Full Code Here

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

     */
    public DynamicPage copyDynamicPage(DynamicPage source, String path, boolean copyIds)
        throws NodeException
    {
        // create the new dynamic page and copy attributes
        DynamicPage dynamicPage = newDynamicPage(path);
        copyPageAttributes(source, copyIds, dynamicPage);
        dynamicPage.setHidden(source.isHidden());
        dynamicPage.setContentType(source.getContentType());
        dynamicPage.setInheritable(source.isInheritable());
        return dynamicPage;
    }
View Full Code Here

                // merge page and parent folder menu definition locators
                // by name, (most specific page definitions are merged first
                // since they override any folder definitions); note parent
                // folder menu definitions include standard menu definition
                // locator defaults
                DynamicPage dynamicPage = (DynamicPage)node;
                Folder folder = (Folder)node.getParent();
                locators = SiteViewUtils.mergeMenuDefinitionLocators(dynamicPage.getMenuDefinitions(), dynamicPage, folder.getPath(), true, locators);
                locators = SiteViewUtils.mergeMenuDefinitionLocators(getMenuDefinitionLocators(folder), locators);
            }
            else if (node instanceof PageTemplate)
            {
                // merge only page template menu definition locators by name
View Full Code Here

                  Page newPage = pageManager.copyPage((Page)page,destination);
                  pageManager.updatePage(newPage);
              }
              else if (page instanceof DynamicPage)
              {
                    DynamicPage newPage = pageManager.copyDynamicPage((DynamicPage)page,destination);
                    pageManager.updateDynamicPage(newPage);                 
              }
            }
            else if (method.equals("move"))
            {             
              String destination = getActionParameter(requestContext, "destination");
              String name = getActionParameter(requestContext, RESOURCE_NAME);             
              destination = destination + Folder.PATH_SEPARATOR + name;
                if (page instanceof Page)
                {
                    Page newPage = pageManager.copyPage((Page)page, destination, true);
                    pageManager.updatePage(newPage);
                    pageManager.removePage((Page)page);
                }
                else if (page instanceof DynamicPage)
                {
                    DynamicPage newPage = pageManager.copyDynamicPage((DynamicPage)page, destination, true);
                    pageManager.updateDynamicPage(newPage);
                    pageManager.removeDynamicPage((DynamicPage)page);
                }
            }
            else if (method.equals("remove"))
View Full Code Here

        constraints.setOwner("admin");
        pageTemplate.setSecurityConstraints(constraints);

        pageManager.updatePageTemplate(pageTemplate);

        DynamicPage dynamicPage = pageManager.newDynamicPage("/dynamic-page.dpsml");
        dynamicPage.setContentType("default");
        assertTrue(dynamicPage.isInheritable());
        dynamicPage.setInheritable(false);       
        dynamicPage.setTitle("Created Dynamic Page");
        rootFragmentElement = dynamicPage.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        root.setName("jetspeed-layouts::VelocityTwoColumns");
        portlet = pageManager.newFragment();
        portlet.setType(Fragment.PORTLET);
        portlet.setName("content-app::ContentPortlet");
        root.getFragments().add(portlet);       
        fragmentReference = pageManager.newFragmentReference();
        fragmentReference.setRefId("fragment-definition");
        root.getFragments().add(fragmentReference);       

        pageManager.updateDynamicPage(dynamicPage);

        FragmentDefinition fragmentDefinition = pageManager.newFragmentDefinition("/fragment-definition.fpsml");
        fragmentDefinition.setTitle("Created Fragment Definition");
        rootFragmentElement = fragmentDefinition.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        root.setName("security::LoginPortlet");
        root.setId("fragment-definition");

        pageManager.updateFragmentDefinition(fragmentDefinition);

        // 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
        {
            PageTemplate dupPageTemplate = pageManager.newPageTemplate("/page-template.tpsml");
            pageManager.updatePageTemplate(dupPageTemplate);
            assertTrue("Duplicate PageTemplate / CREATED", false);
        }
        catch (PageNotUpdatedException e)
        {
        }
        try
        {
            DynamicPage dupDynamicPage = pageManager.newDynamicPage("/dynamic-page.dpsml");
            pageManager.updateDynamicPage(dupDynamicPage);
            assertTrue("Duplicate DynamicPage / CREATED", false);
        }
        catch (PageNotUpdatedException e)
        {
View Full Code Here

        {
            assertTrue("FragmentDefinition /fragment-definition NOT FOUND", false);
        }
        try
        {
            DynamicPage check = pageManager.getDynamicPage("/dynamic-page.dpsml");
            assertNotNull(check);
            assertEquals("default", check.getContentType());
            assertFalse(check.isInheritable());
            assertEquals("Created Dynamic Page", check.getTitle());
            assertNotNull(check.getRootFragment());
            BaseFragmentElement rootFragmentElement = check.getRootFragment();
            assertTrue(rootFragmentElement instanceof Fragment);
            Fragment root = (Fragment)rootFragmentElement;
            assertEquals("jetspeed-layouts::VelocityTwoColumns", root.getName());
            assertEquals(Fragment.LAYOUT, root.getType());
            assertEquals(2, root.getFragments().size());
            BaseFragmentElement checkElement0 = (BaseFragmentElement)root.getFragments().get(0);
            assertTrue(checkElement0 instanceof Fragment);
            Fragment check0 = (Fragment)checkElement0;
            assertEquals("content-app::ContentPortlet", check0.getName());
            assertEquals(Fragment.PORTLET, check0.getType());
            BaseFragmentElement checkElement1 = (BaseFragmentElement)root.getFragments().get(1);
            assertTrue(checkElement1 instanceof FragmentReference);
            FragmentReference check1 = (FragmentReference)checkElement1;
            assertEquals("fragment-definition", check1.getRefId());
        }
        catch (PageNotFoundException e)
        {
            assertTrue("DynamicPage /dynamic-page.dpsml NOT FOUND", false);
        }
        try
        {
            PageTemplate check = pageManager.getPageTemplate("/page-template.tpsml");
            assertNotNull(check);
            assertEquals("Created Page Template", check.getTitle());
            assertNotNull(check.getRootFragment());
            BaseFragmentElement rootFragmentElement = check.getRootFragment();
            assertTrue(rootFragmentElement instanceof Fragment);
            Fragment root = (Fragment)rootFragmentElement;
            assertEquals("jetspeed-layouts::VelocityTwoColumns", root.getName());
            assertEquals(Fragment.LAYOUT, root.getType());
            assertEquals(3, root.getFragments().size());
            BaseFragmentElement checkElement0 = (BaseFragmentElement)root.getFragments().get(0);
            assertTrue(checkElement0 instanceof Fragment);
            Fragment check0 = (Fragment)checkElement0;
            assertEquals("templates::MenusTemplatePortlet", check0.getName());
            assertEquals(Fragment.PORTLET, check0.getType());
            assertEquals(1, check0.getLayoutRow());
            BaseFragmentElement checkElement1 = (BaseFragmentElement)root.getFragments().get(1);
            assertTrue(checkElement1 instanceof FragmentReference);
            FragmentReference check1 = (FragmentReference)checkElement1;
            assertEquals("fragment-definition", check1.getRefId());
            BaseFragmentElement checkElement2 = (BaseFragmentElement)root.getFragments().get(2);
            assertTrue(checkElement2 instanceof PageFragment);
        }
        catch (PageNotFoundException e)
        {
            assertTrue("PageTemplate /page-template.tpsml NOT FOUND", false);
        }
        try
        {
            Page check = pageManager.getPage("/default-page.psml");
            assertEquals("/default-page.psml", check.getPath());
            assertEquals("default-page.psml", check.getName());
            assertEquals("/default-page.psml", check.getUrl());
            assertEquals("Default Page", check.getTitle());
            assertEquals("6.89", check.getVersion());           
            assertEquals("tigris", check.getEffectiveDefaultDecorator(Fragment.LAYOUT));
            assertEquals("tigris", check.getDefaultDecorator(Fragment.LAYOUT));
            assertEquals("blue-gradient", check.getDefaultDecorator(Fragment.PORTLET));
            assertEquals("skin-1", check.getSkin());
            assertEquals("Default", check.getShortTitle());
            assertNotNull(check.getMetadata());
            assertEquals("[fr] Default Page", check.getTitle(Locale.FRENCH));
            assertEquals("[ja] Default Page", check.getTitle(Locale.JAPANESE));
            assertNotNull(check.getSecurityConstraints());
            assertEquals("user", check.getSecurityConstraints().getOwner());
            assertNotNull(check.getSecurityConstraints().getSecurityConstraintsRefs());
            assertEquals(1, check.getSecurityConstraints().getSecurityConstraintsRefs().size());
            assertEquals("manager-edit", (String)check.getSecurityConstraints().getSecurityConstraintsRefs().get(0));
            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());
            BaseFragmentElement checkRootFragmentElement = check.getRootFragment();
            assertTrue(checkRootFragmentElement instanceof Fragment);
            Fragment checkRootFragment = (Fragment)checkRootFragmentElement;
            assertEquals("jetspeed-layouts::VelocityTwoColumns", checkRootFragment.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"));
            assertEquals("custom-value-0", checkRootFragment.getProperty("custom-0"));
            assertEquals("custom-value-1", checkRootFragment.getProperty("custom-1"));
            assertEquals("custom-value-2", checkRootFragment.getProperty("custom-2"));
            assertEquals("custom-value-3", checkRootFragment.getProperty("custom-3"));
            final Fragment checkUserFragment = checkRootFragment;
            Exception userException = (Exception)JSSubject.doAsPrivileged(constructUserSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    try
                    {
                        List properties = checkUserFragment.getProperties();
                        assertNotNull(properties);
                        assertEquals((FragmentProperty.GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED ? 12 : 7), properties.size());
                        assertEquals("50%,50%", checkUserFragment.getProperty(Fragment.SIZES_PROPERTY_NAME));
                        assertEquals("custom-value-0", checkUserFragment.getProperty("custom-0"));
                        assertNull(checkUserFragment.getProperty("custom-0", Fragment.USER_PROPERTY_SCOPE, null));
                        assertNull(checkUserFragment.getProperty("custom-0", Fragment.USER_PROPERTY_SCOPE, "user"));
                        if (FragmentProperty.GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
                        {
                            assertEquals("custom-value-role-1", checkUserFragment.getProperty("custom-1"));
                            assertNotNull(checkUserFragment.getProperty("custom-1", Fragment.ROLE_PROPERTY_SCOPE, "role"));
                        }
                        else
                        {
                            assertEquals("custom-value-1", checkUserFragment.getProperty("custom-1"));                       
                        }
                        assertNull(checkUserFragment.getProperty("custom-1", Fragment.USER_PROPERTY_SCOPE, "user"));
                        if (FragmentProperty.GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
                        {
                            assertEquals("custom-value-group-2", checkUserFragment.getProperty("custom-2"));
                            assertNotNull(checkUserFragment.getProperty("custom-2", Fragment.GROUP_PROPERTY_SCOPE, "group"));
                        }
                        else
                        {
                            assertEquals("custom-value-2", checkUserFragment.getProperty("custom-2"));                       
                        }
                        assertNull(checkUserFragment.getProperty("custom-2", Fragment.USER_PROPERTY_SCOPE, "user"));
                        assertEquals("custom-value-user-3", checkUserFragment.getProperty("custom-3"));
                        assertNotNull(checkUserFragment.getProperty("custom-3", Fragment.USER_PROPERTY_SCOPE, null));
                        assertNotNull(checkUserFragment.getProperty("custom-3", Fragment.USER_PROPERTY_SCOPE, "user"));
                        return null;
                    }
                    catch (Exception e)
                    {
                        return e;
                    }
                    finally
                    {
                        JSSubject.clearSubject();
                    }
                }
            }, null);
            if (userException != null)
            {
                throw userException;
            }
            assertNotNull(checkRootFragment.getFragments());
            assertEquals(3, checkRootFragment.getFragments().size());
            BaseFragmentElement checkElement0 = (BaseFragmentElement)checkRootFragment.getFragments().get(0);
            assertTrue(checkElement0 instanceof Fragment);
            Fragment check0 = (Fragment)checkElement0;
            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.getProperty(Fragment.X_PROPERTY_NAME));
            assertTrue(check0.getProperty(Fragment.X_PROPERTY_NAME).startsWith("12.3"));
            assertTrue((check0.getLayoutX() > 12.0F) && (check0.getLayoutX() < 13.0F));
            assertTrue((check0.getFloatProperty(Fragment.X_PROPERTY_NAME) > 12.0F) &&
                       (check0.getFloatProperty(Fragment.X_PROPERTY_NAME) < 13.0F));
            assertTrue((check0.getLayoutY() > 23.0F) && (check0.getLayoutY() < 24.0F));
            assertTrue((check0.getLayoutZ() > 34.0F) && (check0.getLayoutZ() < 35.0F));
            assertTrue((check0.getLayoutWidth() > 45.0F) && (check0.getLayoutWidth() < 46.0F));
            assertTrue((check0.getLayoutHeight() > 56.0F) && (check0.getLayoutWidth() < 57.0F));
            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));
            BaseFragmentElement checkElement1 = (BaseFragmentElement)checkRootFragment.getFragments().get(1);
            assertTrue(checkElement1 instanceof Fragment);
            Fragment check1 = (Fragment)checkElement1;
            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());
            assertTrue((check1.getLayoutX() > 11.0F) && (check1.getLayoutX() < 12.0F));
            assertTrue((check1.getLayoutY() > 22.0F) && (check1.getLayoutY() < 23.0F));
            assertTrue((check1.getLayoutZ() > 33.0F) && (check1.getLayoutZ() < 34.0F));
            assertTrue((check1.getLayoutWidth() > 44.0F) && (check1.getLayoutWidth() < 45.0F));
            assertTrue((check1.getLayoutHeight() > 55.0F) && (check1.getLayoutWidth() < 56.0F));
            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());
            BaseFragmentElement checkElement2 = (BaseFragmentElement)checkRootFragment.getFragments().get(2);
            assertTrue(checkElement2 instanceof FragmentReference);
            FragmentReference checkFragmentReference = (FragmentReference)checkElement2;
            assertTrue(checkFragmentReference.getRefId().equals("fragment-definition"));
            assertNotNull(check.getFragmentsByInterface(null));
            assertEquals(4, check.getFragmentsByInterface(null).size());
            assertNotNull(check.getFragmentsByInterface(FragmentReference.class));
            assertEquals(1, check.getFragmentsByInterface(FragmentReference.class).size());
        }
        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("jetspeed", check.getEffectiveDefaultDecorator(Fragment.LAYOUT));
            assertEquals("jetspeed", check.getDefaultDecorator(Fragment.LAYOUT));
            assertEquals("gray-gradient", check.getDefaultDecorator(Fragment.PORTLET));
            assertEquals("skin-1", check.getSkin());
            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()));
            assertEquals("*", Shared.makeCSVFromList(((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(9, 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("dynamic-page.dpsml", ((Node)all.next()).getName());
            assertEquals("fragment-definition.fpsml", ((Node)all.next()).getName());
            assertEquals("page-template.tpsml", ((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);
        }
        try
        {
            Page check = pageManager.getPage("/another-page.psml");
            assertEquals("/another-page.psml", check.getPath());
            assertEquals("another-page.psml", check.getName());
            assertEquals("Another Page", check.getTitle());
            assertEquals("jetspeed", check.getEffectiveDefaultDecorator(Fragment.LAYOUT));
            assertEquals("gray-gradient", check.getEffectiveDefaultDecorator(Fragment.PORTLET));
            assertNull(check.getDefaultDecorator(Fragment.LAYOUT));
            assertNull(check.getDefaultDecorator(Fragment.PORTLET));
        }
        catch (PageNotFoundException e)
        {
            assertTrue("Page /default-page.psml NOT FOUND", false);
        }

        try
        {
            Page check = pageManager.getPage(deepPagePath);
            assertEquals(deepPagePath, check.getPath());
            assertNotNull(check.getParent());
        }
        catch (PageNotFoundException e)
        {
            assertTrue("Page " + deepPagePath + " NOT FOUND", false);
        }
        try
        {
            Folder check = pageManager.getFolder(deepFolderPath);
            assertEquals(deepFolderPath, check.getPath());
            assertNotNull(check.getParent());
        }
        catch (FolderNotFoundException e)
        {
            assertTrue("Folder " + deepFolderPath + " NOT FOUND", false);
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.page.DynamicPage

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.