Package org.apache.jetspeed.om.page.impl

Examples of org.apache.jetspeed.om.page.impl.ContentFragmentImpl


            rootFragment = definition.getRootFragment();
        }
        if (rootFragment != null)
        {
            // generate content page/fragment hierarchy for page           
            ContentFragmentImpl rootContentFragmentImpl = newContentFragment(null, pageOrTemplate, fragmentDefinitions, definition, rootFragment, rootTemplate);
            // ensure that page/fragment hierarchy root is a layout
            // portlet by generating a transient locked parent
            // layout fragment if necessary
            if (!rootContentFragmentImpl.getType().equals(ContentFragment.LAYOUT))
            {
                ContentFragmentImpl layoutContentFragmentImpl = newContentFragment("", pageOrTemplate, null, null, null, null, rootTemplate, true);
                layoutContentFragmentImpl.setType(ContentFragment.LAYOUT);
                layoutContentFragmentImpl.setName(defaultLayoutPortletName);
                layoutContentFragmentImpl.getFragments().add(rootContentFragmentImpl);
                rootContentFragmentImpl = layoutContentFragmentImpl;               
            }
            // save content page/fragment hierarchy
            contentPageImpl.setRootFragment(rootContentFragmentImpl);
        }
View Full Code Here


        try
        {
            // lookup page manager fragment and fragment id
            ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
            ContentFragmentImpl [] parentContentFragmentImpl = new ContentFragmentImpl[]{null};
            ContentFragmentImpl contentFragmentImpl = contentPageImpl.getFragmentById(fragmentId, parentContentFragmentImpl);
            if (contentFragmentImpl.getDefinition() == null)
            {
                throw new IllegalArgumentException("Transient content fragments are not mutable");
            }           
            if ((contentFragmentImpl == null) || !contentFragmentImpl.getDefinition().getPath().equals(contentPageImpl.getPath()))
            {
                throw new IllegalArgumentException("FragmentId and page not consistent");               
            }
            if ((parentContentFragmentImpl[0] != null) && (!parentContentFragmentImpl[0].getDefinition().getPath().equals(contentPageImpl.getPageOrTemplate().getPath()) ||
                                                           parentContentFragmentImpl[0].isLocked()))
            {
                throw new IllegalArgumentException("Parent content fragment and page not consistent or locked");               
            }
            boolean contentFragmentIsReference = (contentFragmentImpl.getReference() != null);
           
            // retrieve current page or template and fragment from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
            String pageFragmentId = (contentFragmentIsReference ? contentFragmentImpl.getReference().getId() : contentFragmentImpl.getFragment().getId());
            BaseFragmentElement fragment = pageOrTemplate.getFragmentById(pageFragmentId);
            if (fragment == null)
            {
                throw new IllegalArgumentException("Remove fragmentId and page not consistent");               
            }
View Full Code Here

        try
        {
            // validate content fragment and lookup current fragment
            // of page or page template from page manager and check
            // edit or view access requirements
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            BaseFragmentElement fragment = lookupPageOrTemplateFragment(contentFragmentImpl, scope);
           
            // update fragment decorator and page or page template in
            // page manager
            boolean update = false;
            decoratorName = (!Utils.isNull(decoratorName) ? decoratorName : null);
            if (((decoratorName != null) && !decoratorName.equals(fragment.getDecorator()) ||
                ((decoratorName == null) && (fragment.getDecorator() != null))))
            {
                fragment.setDecorator(scope, scopeValue, decoratorName);
                update = true;
            }
            if (update)
            {
                updatePageOrPageTemplateFragmentProperties(fragment, scope);
            }
           
            // update content context
            contentFragmentImpl.setDecorator(scope, scopeValue, decoratorName);
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
        }
View Full Code Here

            {
                throw new IllegalArgumentException("Fragment name not specified.");
            }
           
            // validate content fragment
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            if (contentFragmentImpl.isLocked())
            {
                throw new IllegalArgumentException("Locked content fragment is not mutable");               
            }
            if (contentFragmentImpl.getDefinition() == null)
            {
                throw new IllegalArgumentException("Transient content fragments are not mutable");
            }           
            if (!contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPageOrTemplate().getPath()))
            {
                throw new IllegalArgumentException("Only page fragments can be modified");
            }
           
            // retrieve current fragment and page or template from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentFragmentImpl.getPageOrTemplate().getPath());
            BaseFragmentElement foundFragment = pageOrTemplate.getFragmentById(contentFragmentImpl.getFragment().getId());
            if (!(foundFragment instanceof Fragment))
            {
                throw new IllegalArgumentException("Fragment and page not consistent");               
            }
            Fragment fragment = (Fragment)foundFragment;

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

            // update fragment name and page in page manager
            boolean update = false;
            if (!name.equals(fragment.getName()))
            {
                fragment.setName(name);
                update = true;
            }
            if (update)
            {
                updatePage(pageOrTemplate);
            }

            // update content context
            contentFragmentImpl.setName(name);
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
        }
View Full Code Here

        try
        {
            // validate content fragment and lookup current fragment
            // of page or page template from page manager and check
            // edit or view access requirements
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            BaseFragmentElement fragment = lookupPageOrTemplateFragment(contentFragmentImpl, scope);
           
            // update fragment position and page or page template
            // in page manager
            boolean update = false;
            if (!Utils.isNull(x))
            {
                if (x != fragment.getLayoutX())
                {
                    fragment.setLayoutX(scope, scopeValue, x);
                    update = true;
                }
            }
            if (!Utils.isNull(y))
            {
                if (y != fragment.getLayoutY())
                {
                    fragment.setLayoutY(scope, scopeValue, y);
                    update = true;
                }
            }
            if (!Utils.isNull(z))
            {
                if (z != fragment.getLayoutZ())
                {
                    fragment.setLayoutZ(scope, scopeValue, z);
                    update = true;
                }
            }
            if (!Utils.isNull(width))
            {
                if (width != fragment.getLayoutWidth())
                {
                    fragment.setLayoutWidth(scope, scopeValue, width);
                    update = true;
                }
            }
            if (!Utils.isNull(height))
            {
                if (height != fragment.getLayoutHeight())
                {
                    fragment.setLayoutHeight(scope, scopeValue, height);
                    update = true;
                }
            }
            if (update)
            {
                updatePageOrPageTemplateFragmentProperties(fragment, scope);
            }

            // update content context
            if (!Utils.isNull(x))
            {
                contentFragmentImpl.setLayoutX(scope, scopeValue, x);
            }
            if (!Utils.isNull(y))
            {
                contentFragmentImpl.setLayoutY(scope, scopeValue, y);
            }
            if (!Utils.isNull(z))
            {
                contentFragmentImpl.setLayoutZ(scope, scopeValue, z);
            }
            if (!Utils.isNull(width))
            {
                contentFragmentImpl.setLayoutWidth(scope, scopeValue, width);
            }
            if (!Utils.isNull(height))
            {
                contentFragmentImpl.setLayoutWidth(scope, scopeValue, height);
            }
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
View Full Code Here

    {
        log.debug("PageLayoutComponentImpl.updatePreferences() invoked");
        try
        {
            // validate content fragment
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            if (contentFragmentImpl.getDefinition() == null)
            {
                throw new IllegalArgumentException("Transient content fragments are not mutable");
            }           
            if (!contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPageOrTemplate().getPath()))
            {
                throw new IllegalArgumentException("Only page fragments can be modified");
            }
            boolean contentFragmentIsReference = (contentFragmentImpl.getReference() != null);
           
            // retrieve current fragment and page or template from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentFragmentImpl.getPageOrTemplate().getPath());
            String pageFragmentId = (contentFragmentIsReference ? contentFragmentImpl.getReference().getId() : contentFragmentImpl.getFragment().getId());
            BaseFragmentElement fragment = pageOrTemplate.getFragmentById(pageFragmentId);
            if (fragment == null)
            {
                throw new IllegalArgumentException("Fragment and page not consistent");               
            }

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

            // update fragment preferences and page in page manager
            fragment.getPreferences().clear();
            if (preferences != null)
            {
                Iterator preferencesIter = preferences.entrySet().iterator();
                while (preferencesIter.hasNext())
                {
                    Map.Entry preferencesEntry = (Map.Entry)preferencesIter.next();
                    FragmentPreference preference = pageManager.newFragmentPreference();
                    preference.setName((String)preferencesEntry.getKey());
                    Object values = preferencesEntry.getValue();
                    if (values instanceof String)
                    {
                        preference.getValueList().add((String)values);
                    }
                    else if (values instanceof String [])
                    {
                        preference.getValueList().addAll(Arrays.asList(((String [])values)));
                    }
                    else if (values instanceof FragmentPreference)
                    {
                        FragmentPreference fragmentPreference = (FragmentPreference)values;
                        preference.setReadOnly(fragmentPreference.isReadOnly());
                        preference.getValueList().addAll(fragmentPreference.getValueList());
                    }
                    else if (values instanceof PortletPreference)
                    {
                        PortletPreference portletPreference = (PortletPreference)values;
                        preference.setReadOnly(portletPreference.isReadOnly());
                        String [] prefValues = portletPreference.getValues();
                        if (prefValues != null)
                        {
                            preference.getValueList().addAll(Arrays.asList(prefValues));
                        }
                    }
                    else
                    {
                        throw new IllegalArgumentException("Unexpected preference value type");
                    }
                    fragment.getPreferences().add(preference);
                }
            }
            updatePage(pageOrTemplate);

            // update content context
            contentFragmentImpl.setPreferences(preferences);
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
        }
View Full Code Here

        try
        {
            // validate content fragment and lookup current fragment
            // of page or page template from page manager and check
            // edit or view access requirements
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            BaseFragmentElement fragment = lookupPageOrTemplateFragment(contentFragmentImpl, scope);
           
            // update fragment property and page or page template
            // in page manager
            propValue = (!Utils.isNull(propValue) ? propValue : null);
            String currentPropValue = fragment.getProperty(propName, scope, scopeValue);
            if (((propValue == null) && (currentPropValue != null)) || ((propValue != null) && !propValue.equals(currentPropValue)))
            {
                fragment.setProperty(propName, scope, scopeValue, propValue);
                updatePageOrPageTemplateFragmentProperties(fragment, scope);
            }

            // update content context
            contentFragmentImpl.setProperty(propName, scope, scopeValue, propValue);
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
        }
View Full Code Here

    {
        log.debug("PageLayoutComponentImpl.updateRefId() invoked");
        try
        {
            // validate content fragment
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            if (contentFragmentImpl.getDefinition() == null)
            {
                throw new IllegalArgumentException("Transient content fragments are not mutable");
            }           
            boolean contentFragmentIsReference = (contentFragmentImpl.getReference() != null);
            if ((contentFragmentIsReference && !contentFragmentImpl.getReferenceDefinition().getPath().equals(contentFragmentImpl.getPageOrTemplate().getPath())) ||
                (!contentFragmentIsReference && !contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPageOrTemplate().getPath())))
            {
                throw new IllegalArgumentException("Only page fragment references can be modified");
            }
           
            // retrieve current fragment reference and page or template from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentFragmentImpl.getPageOrTemplate().getPath());
            String pageFragmentId = (contentFragmentIsReference ? contentFragmentImpl.getReference().getId() : contentFragmentImpl.getFragment().getId());
            BaseFragmentElement fragment = pageOrTemplate.getFragmentById(pageFragmentId);
            if (fragment == null)
            {
                throw new IllegalArgumentException("Fragment and page not consistent");               
            }
            if (!(fragment instanceof FragmentReference))
            {
                throw new IllegalArgumentException("Fragment reference required");               
            }
            FragmentReference fragmentReference = (FragmentReference)fragment;

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

            // update fragment reference in page manager
            boolean update = false;
            if (!refId.equals(fragmentReference.getRefId()))
            {
                fragmentReference.setRefId(refId);
                update = true;
            }
            if (update)
            {
                updatePage(pageOrTemplate);
            }

            // update content context
            contentFragmentImpl.setRefId(refId);
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
        }
View Full Code Here

        try
        {
            // validate content fragment and lookup current fragment
            // of page or page template from page manager and check
            // edit or view access requirements
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            BaseFragmentElement fragment = lookupPageOrTemplateFragment(contentFragmentImpl, scope);
           
            // update fragment row and column and page or page
            // template in page manager
            boolean update = false;
            if (!Utils.isNull(row))
            {
                if (row != fragment.getLayoutRow())
                {
                    fragment.setLayoutRow(scope, scopeValue, row);
                    update = true;
                }
            }
            if (!Utils.isNull(column))
            {
                if (column != fragment.getLayoutColumn())
                {
                    fragment.setLayoutColumn(scope, scopeValue, column);
                    update = true;
                }
            }
            if (update)
            {
                updatePageOrPageTemplateFragmentProperties(fragment, scope);
            }

            // update content context
            if (!Utils.isNull(row))
            {
                contentFragmentImpl.setLayoutRow(scope, scopeValue, row);
            }
            if (!Utils.isNull(column))
            {
                contentFragmentImpl.setLayoutColumn(scope, scopeValue, column);
            }
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
View Full Code Here

    {
        log.debug("PageLayoutComponentImpl.updateSecurityConstraints() invoked");
        try
        {
            // validate content fragment
            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
            if (contentFragmentImpl.getDefinition() == null)
            {
                throw new IllegalArgumentException("Transient content fragments are not mutable");
            }           
            if (!contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPageOrTemplate().getPath()))
            {
                throw new IllegalArgumentException("Only page fragments can be modified");
            }
            boolean contentFragmentIsReference = (contentFragmentImpl.getReference() != null);
           
            // retrieve current fragment and page or template from page manager
            BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentFragmentImpl.getPageOrTemplate().getPath());
            String pageFragmentId = (contentFragmentIsReference ? contentFragmentImpl.getReference().getId() : contentFragmentImpl.getFragment().getId());
            BaseFragmentElement fragment = pageOrTemplate.getFragmentById(pageFragmentId);
            if (fragment == null)
            {
                throw new IllegalArgumentException("Fragment and page not consistent");               
            }

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

            // update fragment preferences and page in page manager.
           
            // Initializing security constraints by setting empty one first to reset it after aggregating into fragmentConstraintsConstraints..
            //
            //TODO: JS2-1259: BaseElementImpl doesn't consider null input; DBPM based security constraints update needs to be more tested.
            //      For now, set an empty one instead of null to avoid this problem as well as possible side effects.
            //
            //fragment.setSecurityConstraints(null);
            fragment.setSecurityConstraints(fragment.newSecurityConstraints());
           
            if ((constraints != null) && !constraints.isEmpty())
            {
                SecurityConstraints fragmentConstraints = fragment.newSecurityConstraints();
                String constraintsOwner = constraints.getOwner();
                if (constraintsOwner != null)
                {
                    fragmentConstraints.setOwner(constraintsOwner);
                }
                List constraintsConstraints = constraints.getSecurityConstraints();
                if ((constraintsConstraints != null) && !constraintsConstraints.isEmpty())
                {
                    List fragmentConstraintsConstraints = new ArrayList(constraintsConstraints.size());
                    Iterator constraintsIter = constraintsConstraints.iterator();
                    while (constraintsIter.hasNext())
                    {
                        SecurityConstraint constraint = (SecurityConstraint)constraintsIter.next();
                        SecurityConstraint fragmentConstraintsConstraint = fragment.newSecurityConstraint();
                        fragmentConstraintsConstraint.setGroups(constraint.getGroups());
                        fragmentConstraintsConstraint.setPermissions(constraint.getPermissions());
                        fragmentConstraintsConstraint.setRoles(constraint.getRoles());
                        fragmentConstraintsConstraint.setUsers(constraint.getUsers());
                        fragmentConstraintsConstraints.add(fragmentConstraintsConstraint);
                    }
                    fragmentConstraints.setSecurityConstraints(fragmentConstraintsConstraints);
                }
                List constraintsConstraintsRefs = constraints.getSecurityConstraintsRefs();
                if ((constraintsConstraintsRefs != null) && !constraintsConstraintsRefs.isEmpty())
                {
                    List fragmentConstraintsConstraintsRefs = new ArrayList(constraintsConstraintsRefs.size());
                    Iterator constraintsRefsIter = constraintsConstraintsRefs.iterator();
                    while (constraintsRefsIter.hasNext())
                    {
                        fragmentConstraintsConstraintsRefs.add((String)constraintsRefsIter.next());
                    }
                    fragmentConstraints.setSecurityConstraintsRefs(fragmentConstraintsConstraintsRefs);
                }
                fragment.setSecurityConstraints(fragmentConstraints);
            }
            updatePage(pageOrTemplate);

            // update content context
            contentFragmentImpl.setSecurityConstraints(constraints);
        }
        catch (Exception e)
        {
            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.page.impl.ContentFragmentImpl

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.