Package org.apache.jetspeed.om.folder

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


        PageManager pageManager = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPageManager();
        if (!StringUtils.isEmpty(getSubSiteRoot()))
        {
            try
            {
                Folder subsiteFolder = pageManager.getFolder(getSubSiteRoot());
                NodeSet set = pageManager.getFolders(subsiteFolder);
                if (set != null && !set.isEmpty())
                {
                    Iterator setIterator = set.iterator();
                    while (setIterator.hasNext())
                    {
                        Folder f = (Folder) setIterator.next();
                        subsites.add(f.getTitle());
                    }
                }
            }
            catch (FolderNotFoundException fnfe)
            {
View Full Code Here


                       
                        if (!StringUtils.isEmpty(templateFolder))
                        {
                            try
                            {
                                Folder source = pageManager.getFolder(templateFolder);
                                pageManager.deepCopyFolder(source, subSite, user.getName());
                            }
                            catch (FolderNotFoundException e)
                            {
                                error(e.getMessage());
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.jetspeed.page.PageSerializer#importPages(java.lang.String, Boolean, Boolean, Boolean, org.apache.commons.logging.Log)
     */
    private Result execute(PageManager src, PageManager dest, Context context, boolean importing) throws JetspeedException
    {
        Folder folder = null;
        try
        {
            folder = src.getFolder(context.folder);
        }
        catch (FolderNotFoundException fnfe)
View Full Code Here

        return context;
    }
   
    private Folder processFolder(Folder srcFolder, PageManager dest, Context context) throws JetspeedException
    {
        Folder dstFolder = lookupFolder(dest, srcFolder.getPath());
        if (null != dstFolder)
        {
            if (context.overwriteFolders)
            {
                context.logger.info("overwriting folder " + srcFolder.getPath());
                dest.removeFolder(dstFolder);
                dstFolder = dest.copyFolder(srcFolder, srcFolder.getPath());
                dest.updateFolder(dstFolder);
                context.folderCount++;

            }
            else
            {
                context.logger.info("skipping folder " + srcFolder.getPath());
            }
        }
        else
        {
            context.logger.info("processing new folder " + srcFolder.getPath());
            dstFolder = dest.copyFolder(srcFolder, srcFolder.getPath());
            dest.updateFolder(dstFolder);
            context.folderCount++;
        }
        Iterator pages = srcFolder.getPages().iterator();
        while (pages.hasNext())
        {
            Page srcPage = (Page) pages.next();
            Page dstPage = lookupPage(dest, srcPage.getPath());
            if (null != dstPage)
            {
                if (context.overwritePages)
                {
                    context.logger.info("overwriting page " + srcPage.getPath());
                    dest.removePage(dstPage);
                    dstPage = dest.copyPage(srcPage, srcPage.getPath(), true);
                    dest.updatePage(dstPage);
                    context.pageCount++;
                }
                else
                {
                    context.logger.info("skipping page " + srcPage.getPath());
                }
            }
            else
            {
                context.logger.info("processing new page " + srcPage.getPath());
                dstPage = dest.copyPage(srcPage, srcPage.getPath(), true);
                dest.updatePage(dstPage);
                context.pageCount++;
            }
        }
        Iterator pageTemplates = srcFolder.getPageTemplates().iterator();
        while (pageTemplates.hasNext())
        {
            PageTemplate srcPageTemplate = (PageTemplate) pageTemplates.next();
            PageTemplate dstPageTemplate = lookupPageTemplate(dest, srcPageTemplate.getPath());
            if (null != dstPageTemplate)
            {
                if (context.overwritePages)
                {
                    context.logger.info("overwriting page template " + srcPageTemplate.getPath());
                    dest.removePageTemplate(dstPageTemplate);
                    dstPageTemplate = dest.copyPageTemplate(srcPageTemplate, srcPageTemplate.getPath(), true);
                    dest.updatePageTemplate(dstPageTemplate);
                    context.pageCount++;
                }
                else
                {
                    context.logger.info("skipping page template " + srcPageTemplate.getPath());
                }
            }
            else
            {
                context.logger.info("processing new page template " + srcPageTemplate.getPath());
                dstPageTemplate = dest.copyPageTemplate(srcPageTemplate, srcPageTemplate.getPath(), true);
                dest.updatePageTemplate(dstPageTemplate);
                context.pageCount++;
            }
        }
        Iterator dynamicPages = srcFolder.getDynamicPages().iterator();
        while (dynamicPages.hasNext())
        {
            DynamicPage srcDynamicPage = (DynamicPage) dynamicPages.next();
            DynamicPage dstDynamicPage = lookupDynamicPage(dest, srcDynamicPage.getPath());
            if (null != dstDynamicPage)
            {
                if (context.overwritePages)
                {
                    context.logger.info("overwriting dynamic page " + srcDynamicPage.getPath());
                    dest.removeDynamicPage(dstDynamicPage);
                    dstDynamicPage = dest.copyDynamicPage(srcDynamicPage, srcDynamicPage.getPath(), true);
                    dest.updateDynamicPage(dstDynamicPage);
                    context.pageCount++;
                }
                else
                {
                    context.logger.info("skipping dynamic page " + srcDynamicPage.getPath());
                }
            }
            else
            {
                context.logger.info("processing new dynamic page " + srcDynamicPage.getPath());
                dstDynamicPage = dest.copyDynamicPage(srcDynamicPage, srcDynamicPage.getPath(), true);
                dest.updateDynamicPage(dstDynamicPage);
                context.pageCount++;
            }
        }
        Iterator fragmentDefinitions = srcFolder.getFragmentDefinitions().iterator();
        while (fragmentDefinitions.hasNext())
        {
            FragmentDefinition srcFragmentDefinition = (FragmentDefinition) fragmentDefinitions.next();
            FragmentDefinition dstFragmentDefinition = lookupFragmentDefinition(dest, srcFragmentDefinition.getPath());
            if (null != dstFragmentDefinition)
            {
                if (context.overwritePages)
                {
                    context.logger.info("overwriting fragment definition " + srcFragmentDefinition.getPath());
                    dest.removeFragmentDefinition(dstFragmentDefinition);
                    dstFragmentDefinition = dest.copyFragmentDefinition(srcFragmentDefinition, srcFragmentDefinition.getPath(), true);
                    dest.updateFragmentDefinition(dstFragmentDefinition);
                    context.pageCount++;
                }
                else
                {
                    context.logger.info("skipping fragment definition " + srcFragmentDefinition.getPath());
                }
            }
            else
            {
                context.logger.info("processing fragment definition " + srcFragmentDefinition.getPath());
                dstFragmentDefinition = dest.copyFragmentDefinition(srcFragmentDefinition, srcFragmentDefinition.getPath(), true);
                dest.updateFragmentDefinition(dstFragmentDefinition);
                context.pageCount++;
            }
        }
        Iterator links = srcFolder.getLinks().iterator();
        while (links.hasNext())
        {
            Link srcLink = (Link) links.next();
            Link dstLink = lookupLink(dest, srcLink.getPath());
            if (null != dstLink)
            {
                if (context.overwritePages)
                {
                    context.logger.info("overwriting link " + srcLink.getPath());
                    dest.removeLink(dstLink);
                    dstLink = dest.copyLink(srcLink, srcLink.getPath());
                    dest.updateLink(dstLink);
                    context.linkCount++;
                }
                else
                {
                    context.logger.info("skipping link " + srcLink.getPath());
                }
            }
            else
            {
                context.logger.info("processing new link " + srcLink.getPath());
                dstLink = dest.copyLink(srcLink, srcLink.getPath());
                dest.updateLink(dstLink);
                context.linkCount++;
            }
        }

        Iterator folders = srcFolder.getFolders().iterator();
        while (folders.hasNext())
        {
            Folder folder = (Folder) folders.next();
            processFolder(folder, dest, context);
        }

        return dstFolder;
    }
View Full Code Here

        try
        {
            Criteria filter = new Criteria();
            filter.addEqualTo("path", folderPath);
            QueryByCriteria query = QueryFactory.newQuery(FolderImpl.class, filter);
            Folder folder = (Folder)getPersistenceBrokerTemplate().getObjectByQuery(query);
           
            // return folder or throw exception
            if (folder == null)
            {
                throw new FolderNotFoundException("Folder " + folderPath + " not found.");
            }

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

            return folder;
        }
        catch (FolderNotFoundException fnfe)
        {
View Full Code Here

        try
        {
            // retrieve current page or template and parent folders from page manager
            ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
            BaseFragmentsElement pageOrTemplates = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            Folder pageFolder = (Folder)pageOrTemplates.getParent();
            Folder documentOrderingFolder = (Folder)pageFolder.getParent();
            if (documentOrderingFolder != null)
            {
                // check for edit permission
                documentOrderingFolder.checkAccess(JetspeedActions.EDIT);

                // shift document order and update document ordering in page manager
                boolean update = shiftDocumentOrder(documentOrderingFolder, pageFolder.getName(), null, true);
                if (update)
                {
View Full Code Here

        try
        {
            // retrieve current page or template and parent folder from page manager
            ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            Folder documentOrderingFolder = (Folder)pageOrTemplate.getParent();

            // check for edit permission
            documentOrderingFolder.checkAccess(JetspeedActions.EDIT);

            // shift document order and update document ordering in page manager
            boolean update = shiftDocumentOrder(documentOrderingFolder, pageOrTemplate.getName(), pageOrTemplate.getType(), true);
            if (update)
            {
View Full Code Here

        try
        {
            // retrieve current page or template and parent folders from page manager
            ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            Folder pageFolder = (Folder)pageOrTemplate.getParent();
            Folder documentOrderingFolder = (Folder)pageFolder.getParent();
            if (documentOrderingFolder != null)
            {
                // check for edit permission
                documentOrderingFolder.checkAccess(JetspeedActions.EDIT);

                // shift document order and update document ordering in page manager
                boolean update = shiftDocumentOrder(documentOrderingFolder, pageFolder.getName(), null, false);
                if (update)
                {
View Full Code Here

        try
        {
            // retrieve current page or template and parent folder from page manager
            ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            Folder documentOrderingFolder = (Folder)pageOrTemplate.getParent();

            // check for edit permission
            documentOrderingFolder.checkAccess(JetspeedActions.EDIT);

            // shift document order and update document ordering in page manager
            boolean update = shiftDocumentOrder(documentOrderingFolder, pageOrTemplate.getName(), pageOrTemplate.getType(), false);
            if (update)
            {
View Full Code Here

        {
            // retrieve current page or template and parent folder from page manager
            ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            BasePageElement page = ((pageOrTemplate instanceof BasePageElement) ? (BasePageElement)pageOrTemplate : null);
            Folder folder = (Folder)pageOrTemplate.getParent();
           
            // check for edit permission
            folder.checkAccess(JetspeedActions.EDIT);

            // construct new sibling folder
            String newFolderPath = folder.getPath()+(folder.getPath().endsWith(Folder.PATH_SEPARATOR) ? "" : Folder.PATH_SEPARATOR)+folderName;
            if (pageManager.folderExists(newFolderPath))
            {
                throw new IllegalArgumentException("Folder "+newFolderPath+" exists");
            }
            Folder newFolder = pageManager.newFolder(newFolderPath);
            if (!Utils.isNull(folderTitle))
            {
                newFolder.setTitle(folderTitle);
            }
            if (!Utils.isNull(folderShortTitle))
            {
                newFolder.setShortTitle(folderShortTitle);
            }
            String defaultLayoutDecorator = null;
            String defaultPortletDecorator = null;
            if (page != null)
            {
                defaultLayoutDecorator = page.getDefaultDecorator(Fragment.LAYOUT);
                if (defaultLayoutDecorator != null)
                {
                    newFolder.setDefaultDecorator(defaultLayoutDecorator, Fragment.LAYOUT);
                }
                defaultPortletDecorator = page.getDefaultDecorator(Fragment.PORTLET);
                if (defaultPortletDecorator != null)
                {
                    newFolder.setDefaultDecorator(defaultPortletDecorator, Fragment.PORTLET);
                }
            }
           
            // update new folder in page manager
            pageManager.updateFolder(newFolder);
           
            // add new folder to parent document order list
            List documentOrder = folder.getDocumentOrder();
            if (documentOrder == null)
            {
                documentOrder = new ArrayList(4);
                folder.setDocumentOrder(documentOrder);
            }
            if (documentOrder.indexOf(newFolder.getName()) == -1)
            {
                documentOrder.add(newFolder.getName());
            }

            // update folder in page manager
            pageManager.updateFolder(folder);
           
            // create default page in new folder
            String newPagePath = newFolder.getPath()+(newFolder.getPath().endsWith(Folder.PATH_SEPARATOR) ? "" : Folder.PATH_SEPARATOR)+"default-page"+Page.DOCUMENT_TYPE;
            Page newPage = pageManager.newPage(newPagePath);
            if (!Utils.isNull(defaultPageLayoutName) && (newPage.getRootFragment() instanceof Fragment))
            {
                ((Fragment)newPage.getRootFragment()).setName(defaultPageLayoutName);
            }
            if (!Utils.isNull(folderTitle))
            {
                newPage.setTitle(folderTitle);
            }
            if (!Utils.isNull(folderShortTitle))
            {
                newPage.setShortTitle(folderShortTitle);
            }
            if (defaultLayoutDecorator != null)
            {
                newPage.setDefaultDecorator(defaultLayoutDecorator, Fragment.LAYOUT);
            }
            if (defaultPortletDecorator != null)
            {
                newPage.setDefaultDecorator(defaultPortletDecorator, Fragment.PORTLET);
            }

            // update default page in page manager
            pageManager.updatePage(newPage);

            // add new page to parent document order list
            documentOrder = newFolder.getDocumentOrder();
            if (documentOrder == null)
            {
                documentOrder = new ArrayList(4);
                newFolder.setDocumentOrder(documentOrder);
            }
            if (documentOrder.indexOf(newPage.getName()) == -1)
            {
                documentOrder.add(newPage.getName());
            }
View Full Code Here

TOP

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

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.