Package org.apache.jetspeed.om.page

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


            SecurityConstraints copiedSecurity = copySecurityConstraints(PAGE_NODE_TYPE, srcSecurity);
            dest.setSecurityConstraints(copiedSecurity);
        }   

        // copy fragments
        BaseFragmentElement root = copyFragment(source.getRootFragment(), null, copyIds);
        dest.setRootFragment(root);
    }
View Full Code Here


     */
    public BaseFragmentElement copyFragment(BaseFragmentElement source, String name, boolean copyIds)
        throws NodeException
    {
        // create the new fragment and copy attributes
        BaseFragmentElement copy;
        if (source instanceof Fragment)
        {
            copy = newFragment();
        }
        else if (source instanceof FragmentReference)
        {
            copy = newFragmentReference();
        }
        else if (source instanceof PageFragment)
        {
            copy = newPageFragment();
        }
        else
        {
            throw new IllegalArgumentException("Unsupported fragment type: "+((source != null) ? source.getClass().getName() : "null"));
        }

        if (copyIds)
        {
            copy.setId(source.getId());
        }
        copy.setDecorator(source.getDecorator());
        copy.setLayoutColumn(source.getLayoutColumn());
        copy.setLayoutHeight(source.getLayoutHeight());
        copy.setLayoutRow(source.getLayoutRow());
        copy.setLayoutSizes(source.getLayoutSizes());
        copy.setLayoutX(source.getLayoutX());
        copy.setLayoutY(source.getLayoutY());
        copy.setLayoutZ(source.getLayoutZ());
        copy.setLayoutWidth(source.getLayoutWidth());
        copy.setMode(source.getMode());
        copy.setShortTitle(source.getShortTitle());
        copy.setSkin(source.getSkin());
        copy.setState(source.getState());
        copy.setTitle(source.getTitle());
       
        // copy security constraints
        SecurityConstraints srcSecurity = source.getSecurityConstraints();       
        if ((srcSecurity != null) && !srcSecurity.isEmpty())
        {
            SecurityConstraints copiedSecurity = copySecurityConstraints(FRAGMENT_NODE_TYPE, srcSecurity);
            copy.setSecurityConstraints(copiedSecurity);
        }
       
        // copy properties, (only properties for global and
        // current user/group/role specific values copied)
        Iterator props = source.getProperties().iterator();
        while (props.hasNext())
        {
            FragmentProperty prop = (FragmentProperty)props.next();
            String propName = prop.getName();
            String propScope = prop.getScope();
            String propScopeValue = prop.getScopeValue();
            if (FragmentProperty.GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED ||
                (propScope == null) ||
                (!propScope.equals(FragmentProperty.GROUP_PROPERTY_SCOPE) && !propScope.equals(FragmentProperty.ROLE_PROPERTY_SCOPE)))
            {
                if (copy.getProperty(propName, propScope, propScopeValue) == null)
                {
                    copy.setProperty(propName, propScope, propScopeValue, prop.getValue());
                }
            }
        }
                 
        // copy preferences
        Iterator prefs = source.getPreferences().iterator();
        while (prefs.hasNext())
        {
            FragmentPreference pref = (FragmentPreference)prefs.next();
            FragmentPreference newPref = this.newFragmentPreference();
            newPref.setName(pref.getName());
            newPref.setReadOnly(pref.isReadOnly());
            newPref.setValueList(DatabasePageManagerUtils.createList());
            Iterator values = pref.getValueList().iterator();           
            while (values.hasNext())
            {
                String value = (String)values.next();
                newPref.getValueList().add(value);
            }
            copy.getPreferences().add(newPref);
        }

        if (source instanceof Fragment)
        {
            Fragment copyFragment = (Fragment)copy;
            Fragment sourceFragment = (Fragment)source;
            if (name == null)
            {
                name = sourceFragment.getName();
            }
            copyFragment.setName(name);
            copyFragment.setType(sourceFragment.getType());

            // recursively copy fragments
            Iterator fragments = sourceFragment.getFragments().iterator();
            while (fragments.hasNext())
            {
                BaseFragmentElement fragment = (BaseFragmentElement)fragments.next();
                BaseFragmentElement copiedFragment = copyFragment(fragment, null, copyIds);
                copyFragment.getFragments().add(copiedFragment);
            }
        }
        else if (source instanceof FragmentReference)
        {
View Full Code Here

        if (getRootFragment() != null)
        {
            stack.push(getRootFragment());
        }

        BaseFragmentElement f = (BaseFragmentElement) stack.pop();

        while ((f != null) && (!(f.getId().equals(id))))
        {
            if (f instanceof Fragment)
            {
                Iterator i = ((Fragment)f).getFragments().iterator();
View Full Code Here

        Stack stack = new Stack();
        if (getRootFragment() != null)
        {
            stack.push(getRootFragment());
        }
        BaseFragmentElement f = (BaseFragmentElement) stack.pop();
        while ((f != null) && (!(f.getId().equals(id))))
        {
            if (f instanceof Fragment)
            {
                Iterator i = ((Fragment)f).getFragments().iterator();

                while (i.hasNext())
                {
                    BaseFragmentElement child = (BaseFragmentElement)i.next();
                    stack.push(child);
                    parents.put(child, f);
                }
            }

            if (stack.size() > 0)
            {
                f = (BaseFragmentElement) stack.pop();
            }
            else
            {
                f = null;
            }
        }

        // remove fragment from parent/page root
        if (f != null)
        {
            BaseFragmentElement parent = (BaseFragmentElement)parents.get(f);
            if (parent != null)
            {
                if (parent instanceof Fragment)
                {
                    if (((Fragment)parent).getFragments().remove(f))
View Full Code Here

        if (getRootFragment() != null)
        {
            stack.push(getRootFragment());
        }

        BaseFragmentElement f = (BaseFragmentElement) stack.pop();

        while (f != null)
        {
            if (f instanceof Fragment)
            {
View Full Code Here

        if (getRootFragment() != null)
        {
            stack.push(getRootFragment());
        }

        BaseFragmentElement f = (BaseFragmentElement) stack.pop();

        while (f != null)
        {
            if ((interfaceFilter == null) || interfaceFilter.isInstance(f))
            {
View Full Code Here

                throw new IllegalArgumentException("Page root content fragment not found or is locked");               
            }

            // retrieve current page or template and root fragment from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            BaseFragmentElement rootFragment = pageOrTemplate.getRootFragment();
            if (!(rootFragment instanceof Fragment))
            {
                throw new IllegalArgumentException("New fragment cannot be added to page root fragment");               
            }
            Fragment fragment = (Fragment)rootFragment;
View Full Code Here

                throw new IllegalArgumentException("Only page fragments can be modified");
            }

            // retrieve current page or template and fragment from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentFragmentImpl.getPageOrTemplate().getPath());
            BaseFragmentElement parentFragment = pageOrTemplate.getFragmentById(contentFragmentImpl.getFragment().getId());
            if (!(parentFragment instanceof Fragment))
            {
                throw new IllegalArgumentException("New fragment cannot be added to parent fragment");
            }
            Fragment fragment = (Fragment)parentFragment;
View Full Code Here

                throw new IllegalArgumentException("Page root content fragment not found or is locked");               
            }

            // retrieve current page or template and root fragment from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPage.getPageOrTemplate().getPath());
            BaseFragmentElement rootFragment = pageOrTemplate.getRootFragment();
            if (!(rootFragment instanceof Fragment))
            {
                throw new IllegalArgumentException("New Fragment cannot be added to page root fragment");               
            }
            Fragment fragment = (Fragment)rootFragment;
View Full Code Here

                throw new IllegalArgumentException("Only page fragments can be modified");
            }

            // retrieve current page or template and fragment from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentFragmentImpl.getPageOrTemplate().getPath());
            BaseFragmentElement parentFragment = pageOrTemplate.getFragmentById(contentFragmentImpl.getFragment().getId());
            if (!(parentFragment instanceof Fragment))
            {
                throw new IllegalArgumentException("New fragment cannot be added to parent fragment");               
            }
            Fragment fragment = (Fragment)parentFragment;
View Full Code Here

TOP

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

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.