Package org.apache.jetspeed.om.page

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


        Principal userPrincipal = null;
        boolean skipPropertyScopes = false;
        Iterator propertiesIter = properties.iterator();
        while ((userValue[0] == null) && propertiesIter.hasNext())
        {
            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
            if (fragmentProperty.getName().equals(propName))
            {
                String fragmentPropertyScope = fragmentProperty.getScope();
                if (fragmentPropertyScope != null)
                {
                    if (!skipPropertyScopes)
                    {
                        // get principals
                        if (principals == null)
                        {
                            // get current request context subject for principals
                            Subject subject = JSSubject.getSubject(AccessController.getContext());
                            if (subject != null)
                            {
                                if (GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
                                {
                                    principals = subject.getPrincipals();
                                }
                                else
                                {
                                    userPrincipal = SubjectHelper.getBestPrincipal(subject, User.class);
                                }
                            }
                            else
                            {
                                skipPropertyScopes = true;
                            }
                        }
                        String fragmentPropertyScopeValue = fragmentProperty.getScopeValue();
                        if (userPrincipal != null)
                        {
                            // match user property scope and scope value with user principal
                            if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE) && userPrincipal.getName().equals(fragmentPropertyScopeValue))
                            {
                                userValue[0] = fragmentProperty.getValue();
                                valueFound = true;
                            }
                        }
                        else if (principals != null)
                        {
                            // match property scope and scope value with most specific
                            // principal without a value
                            Iterator principalsIter = principals.iterator();
                            while ((userValue[0] == null) && principalsIter.hasNext())
                            {
                                Principal principal = (Principal)principalsIter.next();
                                if (principal.getName().equals(fragmentPropertyScopeValue))
                                {
                                    if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE) && (principal instanceof User))
                                    {
                                        userValue[0] = fragmentProperty.getValue();
                                        valueFound = true;
                                    }
                                    else if (groupValue[0] == null)
                                    {
                                        if (fragmentPropertyScope.equals(GROUP_PROPERTY_SCOPE) && (principal instanceof Group))
                                        {
                                            groupValue[0] = fragmentProperty.getValue();
                                            valueFound = true;
                                        }
                                        else if (roleValue[0] == null)
                                        {
                                            if (fragmentPropertyScope.equals(ROLE_PROPERTY_SCOPE) && (principal instanceof Role))
                                            {
                                                roleValue[0] = fragmentProperty.getValue();
                                                valueFound = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if ((groupValue[0] == null) && (roleValue[0] == null) && (globalValue[0] == null))
                {
                    globalValue[0] = fragmentProperty.getValue();
                    valueFound = true;
                }
            }
        }
       
View Full Code Here


        Principal userPrincipal = null;
        boolean skipPropertyScopes = false;
        Iterator propertiesIter = properties.iterator();
        while (propertiesIter.hasNext())
        {
            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
            String fragmentPropertyScope = fragmentProperty.getScope();
            if (fragmentPropertyScope != null)
            {
                if (!skipPropertyScopes)
                {
                    // get principals
                    if (principals == null)
                    {
                        // get current request context subject for principals
                        Subject subject = JSSubject.getSubject(AccessController.getContext());
                        if (subject != null)
                        {
                            if (GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
                            {
                                principals = subject.getPrincipals();
                            }
                            else
                            {
                                userPrincipal = SubjectHelper.getBestPrincipal(subject, User.class);
                            }
                        }
                        else
                        {
                            skipPropertyScopes = true;
                        }
                    }
                    String fragmentPropertyScopeValue = fragmentProperty.getScopeValue();
                    if (userPrincipal != null)
                    {
                        // match user property scope and scope value with user principal
                        if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE) && userPrincipal.getName().equals(fragmentPropertyScopeValue))
                        {
View Full Code Here

     * @return fragment property
     */
    public static FragmentProperty findFragmentProperty(String propName, String propScope, String propScopeValue, List properties)
    {
        // iterate through properties to find specified scoped property
        FragmentProperty fragmentProperty = null;
        Iterator propertiesIter = properties.iterator();
        while (propertiesIter.hasNext())
        {
            FragmentProperty findFragmentProperty = (FragmentProperty)propertiesIter.next();
            if (findFragmentProperty.getName().equals(propName))
            {
                String findFragmentPropertyScope = findFragmentProperty.getScope();
                if ((propScope == null) && (findFragmentPropertyScope == null))
                {
                    return findFragmentProperty;
                }
                else if ((findFragmentPropertyScope != null) && findFragmentPropertyScope.equals(propScope))
                {
                    String findFragmentPropertyScopeValue = findFragmentProperty.getScopeValue();
                    if ((findFragmentPropertyScopeValue != null) && findFragmentPropertyScopeValue.equals(propScopeValue))
                    {
                        return findFragmentProperty;
                    }
                }
View Full Code Here

        root.setName("jetspeed-layouts::VelocityTwoColumns");
        root.setShortTitle("Root");
        root.setTitle("Root Fragment");
        root.setState("Normal");
        root.setLayoutSizes("50%,50%");
        FragmentProperty property1 = pageManager.newFragmentProperty();
        property1.setName("custom-prop1");
        property1.setValue("custom-prop-value1");
        root.getProperties().add(property1);
        FragmentProperty property2 = pageManager.newFragmentProperty();
        property2.setName("custom-prop2");
        property2.setValue("custom-prop-value2");
        root.getProperties().add(property2);
        root.setProperty("custom-0", null, null, "custom-value-0");
        root.setProperty("custom-1", null, null, "custom-value-1");
        root.setProperty("custom-2", null, null, "custom-value-2");
        root.setProperty("custom-3", null, null, "custom-value-3");
View Full Code Here

        pageSecurity.getGlobalSecurityConstraintsRefs().add("UPDATED");
        pageManager.updatePageSecurity(pageSecurity);
        Page page = pageManager.getPage("/default-page.psml");
        assertEquals("/default-page.psml", page.getPath());
        page.setTitle("UPDATED");
        FragmentProperty removeProperty = null;
        Iterator propertyIter = page.getRootFragment().getProperties().iterator();
        while (propertyIter.hasNext())
        {
            FragmentProperty property = (FragmentProperty)propertyIter.next();
            if (property.getName().equals("custom-prop1"))
            {
                removeProperty = property;
            }
        }
        page.getRootFragment().getProperties().remove(removeProperty);
        FragmentProperty property = pageManager.newFragmentProperty();
        property.setName("UPDATED");
        property.setValue("UPDATED");
        page.getRootFragment().getProperties().add(property);
        BaseFragmentElement rootFragmentElement = page.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        Fragment root = (Fragment)rootFragmentElement;
        assertNotNull(root.getFragments());
View Full Code Here

        // 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
View Full Code Here

                    // and here we are assuming that only the current user has
                    // access to the new objects
                    Iterator sourceIter = transientList.iterator();
                    while (sourceIter.hasNext())
                    {
                        FragmentProperty sourceProperty = (FragmentProperty)sourceIter.next();
                        FragmentProperty targetProperty = list.getMatchingProperty(sourceProperty);
                        if (targetProperty != null)
                        {
                            targetProperty.setValue(sourceProperty.getValue());
                        }
                        else
                        {
                            list.add(sourceProperty);
                        }
View Full Code Here

            {
                Iterator propertiesIter = fragment.getProperties().iterator();
                while (propertiesIter.hasNext())
                {
                    boolean foundProperty = false;
                    FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
                    String name = fragmentProperty.getName();
                    String scope = fragmentProperty.getScope();
                    String scopeValue = fragmentProperty.getScopeValue();
                    Iterator scanPropertiesIter = contentFragmentImpl.getProperties().iterator();
                    while (!foundProperty && scanPropertiesIter.hasNext())
                    {
                        FragmentProperty scanFragmentProperty = (FragmentProperty)scanPropertiesIter.next();
                        String scanName = scanFragmentProperty.getName();
                        if (name.equals(scanName))
                        {
                            String scanScope = scanFragmentProperty.getScope();
                            if ((scope == null) && (scanScope == null))
                            {
                                foundProperty = true;
                            }
                            else if ((scope != null) && scope.equals(scanScope))
                            {
                                String scanScopeValue = scanFragmentProperty.getScopeValue();
                                foundProperty = ((scopeValue != null) && scopeValue.equals(scanScopeValue));
                            }
                        }
                    }
                    if (!foundProperty)
View Full Code Here

        // get property names
        Set propertyNames = new HashSet();
        Iterator propertiesIter = getProperties().iterator();
        while (propertiesIter.hasNext())
        {
            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
            propertyNames.add(fragmentProperty.getName());
        }
       
        // construct and return properties map
        Map propertiesMap = new HashMap();
        Iterator propertyNamesIter = propertyNames.iterator();
View Full Code Here

        // property value; assumes properties are already filtered
        // for current user user, group, and role scopes
        Iterator propertiesIter = getProperties().iterator();
        while ((userValue == null) && propertiesIter.hasNext())
        {
            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
            if (fragmentProperty.getName().equals(propName))
            {
                String fragmentPropertyScope = fragmentProperty.getScope();
                if (fragmentPropertyScope != null)
                {
                    if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE))
                    {
                        userValue = fragmentProperty.getValue();
                    }
                    else if (GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
                    {
                        if (groupValue == null)
                        {
                            if (fragmentPropertyScope.equals(GROUP_PROPERTY_SCOPE))
                            {
                                groupValue = fragmentProperty.getValue();
                            }
                            else if (roleValue == null)
                            {
                                if (fragmentPropertyScope.equals(ROLE_PROPERTY_SCOPE))
                                {
                                    roleValue = fragmentProperty.getValue();
                                }
                            }
                        }
                    }
                }
                else if ((groupValue == null) && (roleValue == null) && (globalValue == null))
                {
                    globalValue = fragmentProperty.getValue();
                }
            }
        }

        // return most specifically scoped property value
View Full Code Here

TOP

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

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.