Package org.apache.jetspeed.om.page

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


     */
    public ContentPage newContentPage(BaseFragmentsElement pageOrTemplate, PageTemplate pageTemplate, Map fragmentDefinitions)
    {
        // generate content page
        BaseConcretePageElement concretePage = ((pageOrTemplate instanceof BaseConcretePageElement) ? (BaseConcretePageElement)pageOrTemplate : null);
        DynamicPage dynamicPage = ((pageOrTemplate instanceof DynamicPage) ? (DynamicPage)pageOrTemplate : null);
        FragmentDefinition fragmentDefinition = (((concretePage == null) && (pageOrTemplate instanceof FragmentDefinition)) ? (FragmentDefinition)pageOrTemplate : null);
        String contentPageId = pageOrTemplate.getId();
        ContentPageImpl contentPageImpl = new ContentPageImpl(this, contentPageId, pageOrTemplate, pageTemplate, fragmentDefinitions);
        // set/merge page attributes
        mergeContentPageAttributes(contentPageImpl, pageOrTemplate);
        contentPageImpl.setName(pageOrTemplate.getName());
        contentPageImpl.setPath(pageOrTemplate.getPath());
        contentPageImpl.setUrl(pageOrTemplate.getUrl());
        contentPageImpl.setHidden(pageOrTemplate.isHidden());       
        // merge template attributes
        mergeContentPageAttributes(contentPageImpl, pageTemplate);           
        // set effective default detectors from merged default
        // decorators or inherit page effective default decorators
        Map effectiveDefaultDecorators = null;
        String effectiveLayoutDefaultDecorator = contentPageImpl.getDefaultDecorator(Fragment.LAYOUT);
        if (effectiveLayoutDefaultDecorator == null)
        {
            if (concretePage != null)
            {
                effectiveLayoutDefaultDecorator = concretePage.getEffectiveDefaultDecorator(Fragment.LAYOUT);
            }
            else if (pageOrTemplate.getParent() != null)
            {
                effectiveLayoutDefaultDecorator = ((Folder)pageOrTemplate.getParent()).getEffectiveDefaultDecorator(Fragment.LAYOUT);
            }
        }
        if (effectiveLayoutDefaultDecorator != null)
        {
            if (effectiveDefaultDecorators == null)
            {
                effectiveDefaultDecorators = new HashMap();
            }
            effectiveDefaultDecorators.put(Fragment.LAYOUT, effectiveLayoutDefaultDecorator);
        }
        String effectivePortletDefaultDecorator = contentPageImpl.getDefaultDecorator(Fragment.PORTLET);
        if (effectivePortletDefaultDecorator == null)
        {
            if (concretePage != null)
            {
                effectivePortletDefaultDecorator = concretePage.getEffectiveDefaultDecorator(Fragment.PORTLET);
            }
            else if (pageOrTemplate.getParent() != null)
            {
                effectiveLayoutDefaultDecorator = ((Folder)pageOrTemplate.getParent()).getEffectiveDefaultDecorator(Fragment.PORTLET);
            }
        }
        if (effectivePortletDefaultDecorator != null)
        {
            if (effectiveDefaultDecorators == null)
            {
                effectiveDefaultDecorators = new HashMap();
            }
            effectiveDefaultDecorators.put(Fragment.PORTLET, effectivePortletDefaultDecorator);
        }
        contentPageImpl.setEffectiveDefaultDecorators(effectiveDefaultDecorators);
        if (dynamicPage != null)
        {
            contentPageImpl.setContentType(dynamicPage.getContentType());
            contentPageImpl.setInheritable(dynamicPage.isInheritable());
        }
        if (fragmentDefinition != null)
        {
            contentPageImpl.setDefId(fragmentDefinition.getDefId());
        }
View Full Code Here


            String newDynamicPagePath = folder.getPath()+(folder.getPath().endsWith(Folder.PATH_SEPARATOR) ? "" : Folder.PATH_SEPARATOR)+pageName+DynamicPage.DOCUMENT_TYPE;
            if (pageManager.dynamicPageExists(newDynamicPagePath))
            {
                throw new IllegalArgumentException("Dynamic page "+newDynamicPagePath+" exists");
            }
            DynamicPage newDynamicPage = pageManager.newDynamicPage(newDynamicPagePath);
            newDynamicPage.setContentType(!Utils.isNull(contentType) ? contentType : "*");
            if (!Utils.isNull(layoutName) && (newDynamicPage.getRootFragment() instanceof Fragment))
            {
                ((Fragment)newDynamicPage.getRootFragment()).setName(layoutName);
            }
            if (!Utils.isNull(pageTitle))
            {
                newDynamicPage.setTitle(pageTitle);
            }
            if (!Utils.isNull(pageShortTitle))
            {
                newDynamicPage.setShortTitle(pageShortTitle);
            }
            String defaultLayoutDecorator = null;
            String defaultPortletDecorator = null;
            if (page != null)
            {
                defaultLayoutDecorator = page.getDefaultDecorator(Fragment.LAYOUT);
                if (defaultLayoutDecorator != null)
                {
                    newDynamicPage.setDefaultDecorator(defaultLayoutDecorator, Fragment.LAYOUT);
                }
                defaultPortletDecorator = page.getDefaultDecorator(Fragment.PORTLET);
                if (defaultPortletDecorator != null)
                {
                    newDynamicPage.setDefaultDecorator(defaultPortletDecorator, Fragment.PORTLET);
                }
            }

            // update new dynamic page in page manager
            pageManager.updateDynamicPage(newDynamicPage);
View Full Code Here

            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            if (!(pageOrTemplate instanceof DynamicPage))
            {
                throw new IllegalArgumentException("Content only supported on dynamic pages.");
            }
            DynamicPage dynamicPage = (DynamicPage)pageOrTemplate;
           
            // check for edit permission
            dynamicPage.checkAccess(JetspeedActions.EDIT);           

            // update default decorator and page in page manager
            boolean update = false;
            if (!Utils.isNull(contentType) && !contentType.equals(dynamicPage.getContentType()))
            {
                dynamicPage.setContentType(contentType);
                update = true;
            }
            if ((inheritable != null) && (inheritable.booleanValue() != dynamicPage.isInheritable()))
            {
                dynamicPage.setInheritable(inheritable.booleanValue());
                update = true;
            }
            if (update)
            {
                updatePage(dynamicPage);
View Full Code Here

            castorPageManager.updatePageTemplate(dstPageTemplate);
        }       
        Iterator dynamicPages = srcFolder.getDynamicPages().iterator();
        while (dynamicPages.hasNext())
        {
            DynamicPage srcDynamicPage = (DynamicPage) dynamicPages.next();
            DynamicPage dstDynamicPage = lookupDynamicPage(castorPageManager,srcDynamicPage.getPath());
            newPath = getUserFolder(userName, true) + destination + getRealPath(srcDynamicPage.getPath());
            dstDynamicPage = castorPageManager.copyDynamicPage(srcDynamicPage, newPath, copyIds);
            castorPageManager.updateDynamicPage(dstDynamicPage);
        }
        Iterator fragmentDefinitions = srcFolder.getFragmentDefinitions().iterator();
View Full Code Here

                                                copyIds);
                                        pageManager.updatePageTemplate(pageTemplate);
                                        success = true;
                                    } else if (fileType.equalsIgnoreCase("dpsml"))
                                    {
                                        DynamicPage source = folder.getDynamicPage(fileName);
                                        DynamicPage dynamicPage = null;
                                        if (pageManager.dynamicPageExists(destPath
                                                + pathSeparator + fileName))
                                        {
                                            pageManager.removeDynamicPage(pageManager
                                                    .getDynamicPage(destPath
View Full Code Here

        assertNotNull(testpagetemplate.getRootFragment());
        assertNotNull(testpagetemplate.getRootFragment().getId());
        assertTrue(testpagetemplate.getRootFragment() instanceof Fragment);
        assertEquals(((Fragment)testpagetemplate.getRootFragment()).getType(), Fragment.LAYOUT);

        DynamicPage testdynamicpage = pageManager.newDynamicPage("/test003.dpsml");
        assertNotNull(testdynamicpage);
        assertNotNull(testdynamicpage.getId());
        assertNotNull(testdynamicpage.getPath());
        assertEquals(testdynamicpage.getId(), testdynamicpage.getPath());
        assertNotNull(testdynamicpage.getRootFragment());
        assertNotNull(testdynamicpage.getRootFragment().getId());
        assertTrue(testdynamicpage.getRootFragment() instanceof Fragment);
        assertEquals(((Fragment)testdynamicpage.getRootFragment()).getType(), Fragment.LAYOUT);

        FragmentDefinition testfragmentdefinition = pageManager.newFragmentDefinition("/test003.fpsml");
        assertNotNull(testfragmentdefinition);
        assertNotNull(testfragmentdefinition.getId());
        assertNotNull(testfragmentdefinition.getPath());
View Full Code Here

        assertTrue(bf instanceof FragmentReference);
        fr = (FragmentReference)bf;
        assertTrue(fr.getId().equals("pt-f004"));
        assertTrue(fr.getRefId().equals("test001"));

        DynamicPage testdynamicpage = pageManager.getDynamicPage("/test001.dpsml");
        assertTrue(testdynamicpage.getId().equals("/test001.dpsml"));
        assertTrue(testdynamicpage.getContentType().equals("default"));       
        assertTrue(testdynamicpage.isInheritable());       
        assertTrue(testdynamicpage.getTitle().equals("Test Dynamic Page"));
        assertTrue(testdynamicpage.getVersion().equals("2.77"));
        rootFragmentElement = testdynamicpage.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        assertNotNull(root);
        assertTrue(root.getId().equals("dp-f001"));
        assertTrue(root.getName().equals("TwoColumns"));
        assertTrue(root.getType().equals(Fragment.LAYOUT));
        assertNotNull(root.getFragments());
        assertTrue(root.getFragments().size() == 2);
        f = (Fragment)root.getFragments().get(0);
        assertTrue(f.getId().equals("dp-f002"));
        assertTrue(f.getName().equals("HelloPortlet"));
        assertTrue(f.getType().equals(Fragment.PORTLET));
        bf = testdynamicpage.getFragmentById("dp-f003");
        assertTrue(bf instanceof FragmentReference);
        fr = (FragmentReference)bf;
        assertTrue(fr.getId().equals("dp-f003"));
        assertTrue(fr.getRefId().equals("test001"));
   
View Full Code Here

        fr = (FragmentReference)bf;
        assertTrue(fr.getRefId().equals("test002"));
        bf = (BaseFragmentElement)root.getFragments().get(2);
        assertTrue(bf instanceof PageFragment);

        DynamicPage dynamicpage = pageManager.newDynamicPage("/test002.dpsml");
        dynamicpage.setContentType("default");       
        dynamicpage.setInheritable(false);       
        dynamicpage.setTitle("Created Dynamic Page");
        rootFragmentElement = dynamicpage.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        root.setName("TestLayout");
        f = pageManager.newFragment();
        f.setType(Fragment.PORTLET);
        f.setName("TestPortlet");
        root.getFragments().add(f);       
        fr = pageManager.newFragmentReference();
        fr.setRefId("test002");
        root.getFragments().add(fr);       
        try
        {
            pageManager.updateDynamicPage(dynamicpage);
        }
        catch (Exception e)
        {
            String errmsg = "Exception in dynamic page update: " + e.toString();
            e.printStackTrace();
            System.err.println(errmsg);
            assertNotNull(errmsg, null);
        }
        dynamicpage = pageManager.getDynamicPage("/test002.dpsml");
        assertNotNull(dynamicpage);
        assertTrue(dynamicpage.getId().equals("/test002.dpsml"));
        assertEquals("default", dynamicpage.getContentType());
        assertFalse(dynamicpage.isInheritable());
        assertEquals("Created Dynamic Page", dynamicpage.getTitle());
        assertNotNull(dynamicpage.getRootFragment());
        rootFragmentElement = dynamicpage.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        assertTrue(root.getName().equals("TestLayout"));
        assertTrue(root.getType().equals(Fragment.LAYOUT));
        assertTrue(root.getFragments().size() == 2);
View Full Code Here

        }
        pagetemplate = pageManager.getPageTemplate("/test002.tpsml");
        assertNotNull(pagetemplate);
        assertEquals("Updated Title", pagetemplate.getTitle());

        DynamicPage dynamicpage = pageManager.getDynamicPage("/test002.dpsml");
        dynamicpage.setTitle("Updated Title");
        try
        {
            pageManager.updateDynamicPage(dynamicpage);
        }
        catch (Exception e)
        {
            String errmsg = "Exception in dynamic page update: " + e.toString();
            e.printStackTrace();
            System.err.println(errmsg);
            assertNotNull(errmsg, null);
        }
        dynamicpage = pageManager.getDynamicPage("/test002.dpsml");
        assertNotNull(dynamicpage);
        assertEquals("Updated Title", dynamicpage.getTitle());

        FragmentDefinition fragmentdefinition = pageManager.getFragmentDefinition("/test002.fpsml");
        fragmentdefinition.setTitle("Updated Title");
        try
        {
View Full Code Here

        {
            exceptionFound = true;
        }
        assertTrue(exceptionFound);

        DynamicPage dynamicpage = pageManager.getDynamicPage("/test002.dpsml");
        try
        {
            pageManager.removeDynamicPage(dynamicpage);
        }
        catch (Exception e)
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.