Package org.apache.jetspeed.om.page

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


            {
                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


        root.setName("TestLayout");
        Fragment f = pageManager.newFragment();
        f.setType(Fragment.PORTLET);
        f.setName("TestPortlet");
        List properties = f.getProperties();
        FragmentProperty fp = pageManager.newFragmentProperty();
        fp.setName(Fragment.ROW_PROPERTY_NAME);
        fp.setValue("0");
        properties.add(fp);
        fp = pageManager.newFragmentProperty();
        fp.setName(Fragment.COLUMN_PROPERTY_NAME);
        fp.setValue("0");
        properties.add(fp);
        f.setLayoutX(100.0F);
        f.setLayoutY(100.0F);
        f.setProperty("custom-0", null, null, "custom-value-0");
        f.setProperty("custom-1", null, null, "custom-value-1");
        f.setProperty("custom-2", null, null, "custom-value-2");
        root.getFragments().add(f);
        FragmentReference fr = pageManager.newFragmentReference();
        fr.setRefId("test002");
        root.getFragments().add(fr);

        SecurityConstraints constraints = page.newSecurityConstraints();
        constraints.setOwner("new-user");
        List constraintsList = new ArrayList(1);
        SecurityConstraint constraint = page.newSecurityConstraint();
        constraint.setUsers(Shared.makeListFromCSV("user10,user11"));
        constraint.setRoles(Shared.makeListFromCSV("*"));
        constraint.setPermissions(Shared.makeListFromCSV(JetspeedActions.EDIT + "," + JetspeedActions.VIEW));
        constraintsList.add(constraint);
        constraints.setSecurityConstraints(constraintsList);
        List constraintsRefsList = new ArrayList(1);
        constraintsRefsList.add("public-view");
        constraints.setSecurityConstraintsRefs(constraintsRefsList);
        page.setSecurityConstraints(constraints);

        try
        {
            pageManager.updatePage(page);
        }
        catch (Exception e)
        {
            String errmsg = "Exception in page update: " + e.toString();
            e.printStackTrace();
            System.err.println(errmsg);
            assertNotNull(errmsg, null);
        }
       
        final Fragment userFragment = (Fragment)((Fragment)page.getRootFragment()).getFragments().get(0);
        Exception userException = (Exception)JSSubject.doAsPrivileged(constructUserSubject(), new PrivilegedAction()
        {
            public Object run()
            {
                try
                {
                    userFragment.setProperty("custom-1", Fragment.USER_PROPERTY_SCOPE, "user", "custom-value-user-1");
                    userFragment.setProperty("custom-2", Fragment.USER_PROPERTY_SCOPE, null, "custom-value-user-2");

                    try
                    {
                        pageManager.updateFragmentProperties(userFragment, PageManager.USER_PROPERTY_SCOPE);
                    }
                    catch (Exception e)
                    {
                        String errmsg = "Exception in page fragment properties update: " + e.toString();
                        e.printStackTrace();
                        System.err.println(errmsg);
                        assertNotNull(errmsg, null);
                    }
                    return null;
                }
                catch (Exception e)
                {
                    return e;
                }
                finally
                {
                    JSSubject.clearSubject();
                }
            }
        }, null);
        if (userException != null)
        {
            throw userException;
        }

        page = pageManager.getPage("/test002.psml");
        assertNotNull(page);
        assertTrue(page.getId().equals("/test002.psml"));
        assertEquals("Created Page", page.getTitle());
        assertEquals("Created Page de PSML", page.getTitle(Locale.FRENCH));
        assertEquals("Created \u3078\u3088\u3046\u3053\u305d", page.getTitle(Locale.JAPANESE));
        assertNotNull(page.getRootFragment());
        rootFragmentElement = page.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        assertTrue(root.getName().equals("TestLayout"));
        assertTrue(root.getFragments().size() == 2);
        BaseFragmentElement bf = (BaseFragmentElement)root.getFragments().get(0);
        assertTrue(bf instanceof Fragment);
        f = (Fragment)bf;
        assertNotNull(f.getProperties());
        assertEquals(0, f.getIntProperty(Fragment.ROW_PROPERTY_NAME));
        assertTrue((99.9F < f.getLayoutX()) && (100.1F > f.getLayoutX()));
        assertEquals("custom-value-0", f.getProperty("custom-0"));
        assertEquals("custom-value-1", f.getProperty("custom-1"));
        final Fragment userFragment2 = f;
        Exception userException2 = (Exception)JSSubject.doAsPrivileged(constructUserSubject(), new PrivilegedAction()
        {
            public Object run()
            {
                try
                {
                    assertEquals("custom-value-0", userFragment2.getProperty("custom-0"));
                    assertEquals("custom-value-user-1", userFragment2.getProperty("custom-1"));
                    assertEquals("custom-value-user-2", userFragment2.getProperty("custom-2"));
                    return null;
                }
                catch (Exception e)
                {
                    return e;
                }
                finally
                {
                    JSSubject.clearSubject();
                }
            }
        }, null);
        if (userException2 != null)
        {
            throw userException2;
        }

        PageTemplate pagetemplate = pageManager.newPageTemplate("/test002.tpsml");
        pagetemplate.setTitle("Created Page Template");
        metadata = pagetemplate.getMetadata();
        metadata.addField(null, "description", "Page Template Description");
        rootFragmentElement = pagetemplate.getRootFragment();
        assertTrue(rootFragmentElement instanceof Fragment);
        root = (Fragment)rootFragmentElement;
        root.setName("TestLayout");
        f = pageManager.newFragment();
        f.setType(Fragment.PORTLET);
        f.setName("TestPortlet");
        properties = f.getProperties();
        fp = pageManager.newFragmentProperty();
        fp.setName(Fragment.ROW_PROPERTY_NAME);
        fp.setValue("1");
        properties.add(fp);
        fp = pageManager.newFragmentProperty();
        fp.setName(Fragment.COLUMN_PROPERTY_NAME);
        fp.setValue("1");
        properties.add(fp);
        root.getFragments().add(f);
        fr = pageManager.newFragmentReference();
        fr.setRefId("test002");
        root.getFragments().add(fr);
View Full Code Here

        if ((add.getName() == null) || (add.getValue() == null))
        {
            throw new IllegalArgumentException("Property name and value must be set.");
        }
        // find existing matching property
        FragmentProperty addMatch = getMatchingProperty(add);
        if (addMatch != null)
        {
            // modify existing property
            addMatch.setValue(add.getValue());
        }
        else
        {
            // try to recycle removed properties
            add = recycleProperty(add);
View Full Code Here

        if ((set.getName() == null) || (set.getValue() == null))
        {
            throw new IllegalArgumentException("Property name and value must be set.");
        }
        // find existing matching property
        FragmentProperty setMatch = getMatchingProperty(set);
        if (setMatch != null)
        {
            // modify existing property
            setMatch.setValue(set.getValue());
            // remove property if not matching
            if (properties.get(index) != setMatch)
            {
                return remove(index);
            }
View Full Code Here

        {
            propScopeValue = PropertyImpl.getCurrentUserScopeValue();
        }

        // find specified scoped property value
        FragmentProperty fragmentProperty = PropertyImpl.findFragmentProperty(propName, propScope, propScopeValue, propertyImpls);
        if (fragmentProperty != null)
        {
            return fragmentProperty.getValue();
        }
        return null;
    }
View Full Code Here

        {
            propScopeValue = PropertyImpl.getCurrentUserScopeValue();
        }

        // find specified scoped property value
        FragmentProperty fragmentProperty = PropertyImpl.findFragmentProperty(propName, propScope, propScopeValue, propertyImpls);

        // add, set, or remove property
        if (propValue != null)
        {
            if (fragmentProperty == null)
            {
                fragmentProperty = new PropertyImpl();
                fragmentProperty.setName(propName);
                fragmentProperty.setScope(propScope);
                fragmentProperty.setScopeValue(propScopeValue);
                fragmentProperty.setValue(propValue);
                propertyImpls.add(fragmentProperty);
            }
            else
            {
                fragmentProperty.setValue(propValue);
            }
        }
        else if (fragmentProperty != null)
        {
            propertyImpls.remove(fragmentProperty);
View Full Code Here

        {
            propScopeValue = FragmentPropertyImpl.getCurrentUserScopeValue();
        }

        // find specified scoped property value
        FragmentProperty fragmentProperty = FragmentPropertyImpl.findFragmentProperty(propName, propScope, propScopeValue, getProperties());
        if (fragmentProperty != null)
        {
            return fragmentProperty.getValue();
        }
        return null;
    }
View Full Code Here

        {
            propScopeValue = FragmentPropertyImpl.getCurrentUserScopeValue();
        }

        // find specified scoped property value
        FragmentProperty fragmentProperty = FragmentPropertyImpl.findFragmentProperty(propName, propScope, propScopeValue, getProperties());
        if (fragmentProperty != null)
        {
            return Integer.parseInt(fragmentProperty.getValue());
        }
        return -1;
    }
View Full Code Here

        {
            propScopeValue = FragmentPropertyImpl.getCurrentUserScopeValue();
        }

        // find specified scoped property value
        FragmentProperty fragmentProperty = FragmentPropertyImpl.findFragmentProperty(propName, propScope, propScopeValue, getProperties());
        if (fragmentProperty != null)
        {
            return Float.parseFloat(fragmentProperty.getValue());
        }
        return -1.0F;
    }
View Full Code Here

        {
            propScopeValue = FragmentPropertyImpl.getCurrentUserScopeValue();
        }

        // find specified scoped property value
        FragmentProperty fragmentProperty = FragmentPropertyImpl.findFragmentProperty(propName, propScope, propScopeValue, getProperties());

        // add, set, or remove property
        if (propValue != null)
        {
            if (fragmentProperty == null)
            {
                fragmentProperty = new FragmentPropertyImpl();
                fragmentProperty.setName(propName);
                fragmentProperty.setScope(propScope);
                fragmentProperty.setScopeValue(propScopeValue);
                fragmentProperty.setValue(propValue);
                getProperties().add(fragmentProperty);
            }
            else
            {
                fragmentProperty.setValue(propValue);
            }
        }
        else if (fragmentProperty != null)
        {
            getProperties().remove(fragmentProperty);
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.