Author: rwatler Date: Tue Dec 22 00:30:40 2009 New Revision: 893047 URL: http://svn.apache.org/viewvc?rev=893047&view=rev Log: add missing scopeValue parameter to ContentFragment get*Property() APIs
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentUtils.java portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/PageLayoutComponent.java portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseFragmentElement.java portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/ContentFragment.java portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/FragmentProperty.java Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentUtils.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentUtils.java?rev=893047&r1=893046&r2=893047&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentUtils.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentUtils.java Tue Dec 22 00:30:40 2009 @@ -16,6 +16,15 @@ */ package org.apache.jetspeed.layout.impl; +import java.security.AccessController; +import java.security.Principal; + +import javax.security.auth.Subject; + +import org.apache.jetspeed.security.JSSubject; +import org.apache.jetspeed.security.SubjectHelper; +import org.apache.jetspeed.security.User; + /** * Page layout component utilities. * @@ -58,5 +67,25 @@ { return (value < 0); } + + /** + * Lookup current default user scope value. + * + * @return current user principal name + */ + public static String getCurrentUserScopeValue() + { + // lookup current user principal using subject + Subject subject = JSSubject.getSubject(AccessController.getContext()); + if (subject != null) + { + Principal userPrincipal = SubjectHelper.getBestPrincipal(subject, User.class); + if (userPrincipal != null) + { + return userPrincipal.getName(); + } + } + return null; + } } } Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java?rev=893047&r1=893046&r2=893047&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java Tue Dec 22 00:30:40 2009 @@ -189,11 +189,11 @@ } /* (non-Javadoc) - * @see org.apache.jetspeed.om.page.ContentFragment#getFloatProperty(java.lang.String, java.lang.String) + * @see org.apache.jetspeed.om.page.ContentFragment#getFloatProperty(java.lang.String, java.lang.String, java.lang.String) */ - public float getFloatProperty(String propName, String scope) + public float getFloatProperty(String propName, String scope, String scopeValue) { - String propValue = getProperty(propName, scope); + String propValue = getProperty(propName, scope, scopeValue); if (propValue != null) { return Float.parseFloat(propValue); @@ -235,11 +235,11 @@ } /* (non-Javadoc) - * @see org.apache.jetspeed.om.page.ContentFragment#getIntProperty(java.lang.String, java.lang.String) + * @see org.apache.jetspeed.om.page.ContentFragment#getIntProperty(java.lang.String, java.lang.String, java.lang.String) */ - public int getIntProperty(String propName, String scope) + public int getIntProperty(String propName, String scope, String scopeValue) { - String propValue = getProperty(propName, scope); + String propValue = getProperty(propName, scope, scopeValue); if (propValue != null) { return Integer.parseInt(propValue); @@ -427,21 +427,24 @@ String fragmentPropertyScope = fragmentProperty.getScope(); if (fragmentPropertyScope != null) { - if (fragmentPropertyScope.equals(FragmentProperty.USER_PROPERTY_SCOPE)) + if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE)) { userValue = fragmentProperty.getValue(); } - else if (groupValue == null) + else if (GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED) { - if (fragmentPropertyScope.equals(FragmentProperty.GROUP_PROPERTY_SCOPE)) + if (groupValue == null) { - groupValue = fragmentProperty.getValue(); - } - else if (roleValue == null) - { - if (fragmentPropertyScope.equals(FragmentProperty.ROLE_PROPERTY_SCOPE)) + if (fragmentPropertyScope.equals(GROUP_PROPERTY_SCOPE)) + { + groupValue = fragmentProperty.getValue(); + } + else if (roleValue == null) { - roleValue = fragmentProperty.getValue(); + if (fragmentPropertyScope.equals(ROLE_PROPERTY_SCOPE)) + { + roleValue = fragmentProperty.getValue(); + } } } } @@ -458,9 +461,9 @@ } /* (non-Javadoc) - * @see org.apache.jetspeed.om.page.ContentFragment#getProperty(java.lang.String, java.lang.String) + * @see org.apache.jetspeed.om.page.ContentFragment#getProperty(java.lang.String, java.lang.String, java.lang.String) */ - public String getProperty(String propName, String scope) + public String getProperty(String propName, String scope, String scopeValue) { // iterate through properties list to get property value Iterator propertiesIter = getProperties().iterator(); @@ -469,11 +472,26 @@ FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next(); if (fragmentProperty.getName().equals(propName)) { + // compare scopes String fragmentPropertyScope = fragmentProperty.getScope(); - if (((fragmentPropertyScope == null) && (scope == null)) || - ((fragmentPropertyScope != null) && fragmentPropertyScope.equals(scope))) + if ((fragmentPropertyScope == null) && (scope == null)) { - return fragmentProperty.getValue(); + return fragmentProperty.getValue(); + } + else if ((fragmentPropertyScope != null) && fragmentPropertyScope.equals(scope)) + { + // default user scope value + if ((scopeValue == null) && scope.equals(USER_PROPERTY_SCOPE)) + { + scopeValue = Utils.getCurrentUserScopeValue(); + } + // compare scope values + String fragmentPropertyScopeValue = fragmentProperty.getScopeValue(); + if (((fragmentPropertyScopeValue == null) && (scopeValue == null)) || + ((fragmentPropertyScopeValue != null) && fragmentPropertyScopeValue.equals(scopeValue))) + { + return fragmentProperty.getValue(); + } } } } @@ -1532,4 +1550,3 @@ this.id = id; } } - Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/PageLayoutComponent.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/PageLayoutComponent.java?rev=893047&r1=893046&r2=893047&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/PageLayoutComponent.java (original) +++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/PageLayoutComponent.java Tue Dec 22 00:30:40 2009 @@ -32,14 +32,14 @@ public interface PageLayoutComponent { /** - * global standard property scope + * user standard property scope */ - String GLOBAL_PROPERTY_SCOPE = ContentFragment.GLOBAL_PROPERTY_SCOPE; + String USER_PROPERTY_SCOPE = ContentFragment.USER_PROPERTY_SCOPE; /** - * user standard property scope + * group standard property scope */ - String USER_PROPERTY_SCOPE = ContentFragment.USER_PROPERTY_SCOPE; + String GROUP_PROPERTY_SCOPE = ContentFragment.GROUP_PROPERTY_SCOPE; /** * role standard property scope @@ -47,9 +47,9 @@ String ROLE_PROPERTY_SCOPE = ContentFragment.ROLE_PROPERTY_SCOPE; /** - * group standard property scope + * global standard property scope */ - String GROUP_PROPERTY_SCOPE = ContentFragment.GROUP_PROPERTY_SCOPE; + String GLOBAL_PROPERTY_SCOPE = ContentFragment.GLOBAL_PROPERTY_SCOPE; /** * group and role standard property scopes enabled flag Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseFragmentElement.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseFragmentElement.java?rev=893047&r1=893046&r2=893047&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseFragmentElement.java (original) +++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseFragmentElement.java Tue Dec 22 00:30:40 2009 @@ -90,11 +90,6 @@ String HEIGHT_PROPERTY_NAME = "height"; /** - * global standard property scope - */ - String GLOBAL_PROPERTY_SCOPE = FragmentProperty.GLOBAL_PROPERTY_SCOPE; - - /** * user standard property scope */ String USER_PROPERTY_SCOPE = FragmentProperty.USER_PROPERTY_SCOPE; @@ -110,6 +105,11 @@ String ROLE_PROPERTY_SCOPE = FragmentProperty.ROLE_PROPERTY_SCOPE; /** + * global standard property scope + */ + String GLOBAL_PROPERTY_SCOPE = FragmentProperty.GLOBAL_PROPERTY_SCOPE; + + /** * group and role standard property scopes enabled flag */ boolean GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED = FragmentProperty.GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED; Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/ContentFragment.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/ContentFragment.java?rev=893047&r1=893046&r2=893047&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/ContentFragment.java (original) +++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/ContentFragment.java Tue Dec 22 00:30:40 2009 @@ -132,14 +132,14 @@ String HEIGHT_PROPERTY_NAME = BaseFragmentElement.HEIGHT_PROPERTY_NAME; /** - * global standard property scope + * user standard property scope */ - String GLOBAL_PROPERTY_SCOPE = BaseFragmentElement.GLOBAL_PROPERTY_SCOPE; + String USER_PROPERTY_SCOPE = BaseFragmentElement.USER_PROPERTY_SCOPE; /** - * user standard property scope + * group standard property scope */ - String USER_PROPERTY_SCOPE = BaseFragmentElement.USER_PROPERTY_SCOPE; + String GROUP_PROPERTY_SCOPE = BaseFragmentElement.GROUP_PROPERTY_SCOPE; /** * role standard property scope @@ -147,9 +147,9 @@ String ROLE_PROPERTY_SCOPE = BaseFragmentElement.ROLE_PROPERTY_SCOPE; /** - * group standard property scope + * global standard property scope */ - String GROUP_PROPERTY_SCOPE = BaseFragmentElement.GROUP_PROPERTY_SCOPE; + String GLOBAL_PROPERTY_SCOPE = BaseFragmentElement.GLOBAL_PROPERTY_SCOPE; /** * group and role standard property scopes enabled flag @@ -159,14 +159,14 @@ /** * Returns the name of the skin associated to this fragment * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). */ String getSkin(); /** * Returns the name of the decorator bound to this fragment * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). */ String getDecorator(); @@ -174,7 +174,7 @@ * Returns the display state of this fragment. The state may have the * following values: "Normal","Minimized","Maximized","Hidden" * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). */ String getState(); @@ -182,14 +182,14 @@ * Returns the display mode of this fragment. The mode may have the * following values: "View","Edit","Help","Config","Print","Custom" * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). */ String getMode(); /** * Get named property value. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @param propName property name * @return value @@ -201,14 +201,16 @@ * * @param propName property name * @param scope the name of the property scope to retrieve + * @param scopeValue the scope discriminator value, (unless scope is GLOBAL + * or USER where the default user name is used if null) * @return value */ - String getProperty(String propName, String scope); + String getProperty(String propName, String scope, String scopeValue); /** * Get named property value as integer. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @param propName property name * @return int value @@ -220,14 +222,16 @@ * * @param propName property name * @param scope the name of the property scope to retrieve + * @param scopeValue the scope discriminator value, (unless scope is GLOBAL + * or USER where the default user name is used if null) * @return int value */ - int getIntProperty(String propName, String scope); + int getIntProperty(String propName, String scope, String scopeValue); /** * Get named property value as float. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @param propName property name * @return float value @@ -239,9 +243,11 @@ * * @param propName property name * @param scope the name of the property scope to retrieve + * @param scopeValue the scope discriminator value, (unless scope is GLOBAL + * or USER where the default user name is used if null) * @return float value */ - float getFloatProperty(String propName, String scope); + float getFloatProperty(String propName, String scope, String scopeValue); /** * Get read-only list of fragment property objects that @@ -253,7 +259,7 @@ /** * Get named property value map. Property values are returned - * for the most specific scope found, (i.e. user, role, group, + * for the most specific scope found, (i.e. user, group, role, * or global scopes). * * @return map of fragment property values @@ -263,7 +269,7 @@ /** * Get layout row property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return row layout property **/ @@ -272,7 +278,7 @@ /** * Get layout column property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return column layout property **/ @@ -281,7 +287,7 @@ /** * Get layout sizes property, (i.e. "25%,75%"). * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return sizes layout property **/ @@ -290,7 +296,7 @@ /** * Get layout x coordinate property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return the x coordinate value **/ @@ -299,7 +305,7 @@ /** * Get layout y coordinate property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return the y coordinate value **/ @@ -308,7 +314,7 @@ /** * Get layout z coordinate property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return the z coordinate value **/ @@ -317,7 +323,7 @@ /** * Get layout width property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return the width value **/ @@ -326,7 +332,7 @@ /** * Get layout height property. * Property value is returned for the most specific scope - * found, (i.e. user, role, group, or global scopes). + * found, (i.e. user, group, role, or global scopes). * * @return the height value **/ Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/FragmentProperty.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/FragmentProperty.java?rev=893047&r1=893046&r2=893047&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/FragmentProperty.java (original) +++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/FragmentProperty.java Tue Dec 22 00:30:40 2009 @@ -25,11 +25,6 @@ public interface FragmentProperty { /** - * global standard property scope - */ - String GLOBAL_PROPERTY_SCOPE = null; - - /** * user standard property scope */ String USER_PROPERTY_SCOPE = "user"; @@ -45,6 +40,11 @@ String ROLE_PROPERTY_SCOPE = "role"; /** + * global standard property scope + */ + String GLOBAL_PROPERTY_SCOPE = null; + + /** * group and role standard property scopes enabled flag */ boolean GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED = false; --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscr...@portals.apache.org For additional commands, e-mail: jetspeed-dev-h...@portals.apache.org