Eric,

On 11/18/2010 9:14 AM, Eric Dalquist wrote:
> I remember the talking but this is not supported yet. My first
> impression is that it seems like a neat idea but how do we deal with
> duplicate header/footer channels?

We can make the DLM fragment header/footer content feature optional.  If 
you don't want to use it, you won't have to worry about duplicates.

But if you want the feature, I think we could deal with duplicates, for 
the most part, by not having them.  You have to migrate your data to 
move to a new version anyway;  perhaps we can each take a moment to make 
adjustments to the header/footer areas in layouts.

It might be sensible not to have header & footer channels in template 
users or individual user layouts... to move them to fragments entirely. 
  We've been moving away from template users for years;  this is just 
one more extension of that general theme.

Aren't the header & footer channels just noise in the UP-LAYOUT_STRUCT 
table for the most part anyway?

I ran a search on the current universality theme XSL;  the only header & 
footer channels that are currently in use are:

   - fragment-admin (displays for Portal Administrators only)
   - fragment-admin-exit (displays for fragment owners only)
   - login (guest user only)

> One thought that I've had about DLM
> would be adding a new dlm:fragmentRoot attribute. This would define what
> the root element in the fragment owner's layout actually defines the
> layout fragment for merging. If we had support for a feature like that
> we could even look at things like subscribing to a column.

I like this idea too, but I wonder... wouldn't you have to make the 
dlm:fragmentRoot element the root of the layout if you wanted to get all 
the tabs defined for the fragment?  If that's the case, you wouldn't be 
able to get all of a fragment's tabs without also getting its header & 
footer content.

I wrote up a JIRA for this enhancement: 
https://issues.jasig.org/browse/UP-2894

I've also developed a patch, which is attached here and to the JIRA.

drew wills

-- 
You are currently subscribed to uportal-dev@lists.ja-sig.org as: 
arch...@mail-archive.com
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/uportal-dev
Index: 
uportal-impl/src/main/java/org/jasig/portal/layout/dlm/FragmentActivator.java
===================================================================
--- 
uportal-impl/src/main/java/org/jasig/portal/layout/dlm/FragmentActivator.java   
    (revision 22224)
+++ 
uportal-impl/src/main/java/org/jasig/portal/layout/dlm/FragmentActivator.java   
    (working copy)
@@ -24,6 +24,7 @@
 import java.util.Map;
 import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -57,6 +58,10 @@
     private static final int CHANNELS = 0;
     private static final int FOLDERS = 1;
     
+    private static final String PROPERTY_ALLOW_EXPANDED_CONTENT = 
"allowExpandedContent";
+    private static final Pattern STANDARD_PATTERN = 
Pattern.compile("\\A[Rr][Ee][Gg][Uu][Ll][Aa][Rr]\\z");
+    private static final Pattern EXPANDED_PATTERN = Pattern.compile(".*");
+    
     public FragmentActivator( RDBMDistributedLayoutStore dls,
                               List<FragmentDefinition> fragments )
     {
@@ -475,6 +480,13 @@
         if ( view.getUserId() == -1 ||
              view.layout == null )
             return;
+        
+        // Choose what types of content to apply from the fragment
+        Pattern contentPattern = STANDARD_PATTERN;  // default
+        boolean allowExpandedContent = 
Boolean.parseBoolean(dls.getProperty(PROPERTY_ALLOW_EXPANDED_CONTENT));
+        if (allowExpandedContent) {
+            contentPattern = EXPANDED_PATTERN;
+        }
 
         // remove all non-regular or hidden top level folders
         // skip root folder that is only child of top level layout element
@@ -484,24 +496,18 @@
 
         // process the children backwards since as we delete some the indices
         // shift around
-        for( int i=children.getLength()-1; i>=0; i-- )
-        {
+        for( int i=children.getLength()-1; i>=0; i-- ) {
             Node node = children.item(i);
-            if ( node.getNodeType() == Node.ELEMENT_NODE &&
-                 node.getNodeName().equals("folder") )
-            {
+            if (node.getNodeType() == Node.ELEMENT_NODE && 
node.getNodeName().equals("folder")) {
                 Element folder = (Element) node;
 
                 // strip out folder types 'header', 'footer' and regular, 
                 // hidden folder "User Preferences" since users have their own
-                if ( ! folder.getAttribute( "type" ).equals( "regular" ) ||
-                     folder.getAttribute( "hidden" ).equals( "true" ) )
-                    try
-                    {
-                        root.removeChild( folder );
-                    }
-                    catch( Exception e )
-                    {
+                boolean isApplicable = 
contentPattern.matcher(folder.getAttribute("type")).matches();
+                if (!isApplicable || 
folder.getAttribute("hidden").equals("true")) {
+                    try {
+                        root.removeChild(folder);
+                    } catch(Exception e) {
                         throw new RuntimeException(
                               "Anomaly occurred while stripping out " +
                               " portions of layout for fragment '" +
@@ -509,6 +515,7 @@
                               "'. The fragment will not be available for " +
                               "inclusion into user layouts.", e );
                     }
+                }
             }
         }
         // now re-lable all remaining nodes below root to have a safe system
Index: uportal-impl/src/main/resources/properties/dlm.xml
===================================================================
--- uportal-impl/src/main/resources/properties/dlm.xml  (revision 22224)
+++ uportal-impl/src/main/resources/properties/dlm.xml  (working copy)
@@ -25,82 +25,90 @@
 
 <managedLayoutFragments xmlns:dlm="http://org.jasig.portal.layout.dlm.config";>
 
-  <dlm:property name='defaultLayoutOwner' value='fragmentTemplate'/>
-  <!--  <dlm:property name='layoutDecorator' value='someClass'/> -->
+  <dlm:property name="defaultLayoutOwner" value="fragmentTemplate"/>
+  <!--  <dlm:property name="layoutDecorator" value="someClass"/> -->
   
   <!-- Controls clearing of dlm fragment cache.  This allows changes  made to 
layout
   owners to be reflected once the cache has been updated.  Specified in 
minutes. -->
   
-  <dlm:property 
name='org.jasig.portal.layout.dlm.RDBMDistributedLayoutStore.fragment_cache_refresh'
 value="5"/>
+  <dlm:property 
name="org.jasig.portal.layout.dlm.RDBMDistributedLayoutStore.fragment_cache_refresh"
 value="5"/>
 
   <!--
-   | Uncomment this property to turn on the 'RDBMConfigurationLoader' 
implementation, 
-   | which stores FragmentDefinition instances in the database via JPA and 
Hibernate.  
-   | The advantage of this approach is that fragment definitions can be 
-   | added/removed/modified without a portal restart.  Without this property, 
DLM 
-   | will behave exactly as it always has.
+   | Uncomment this property to allow DLM fragments to add non-regular (header 
and footer)
+   | content to the layouts of users who receive those fragments.  This is a 
+   | very useful feature because, without this behavior, it's terribly 
difficult 
+   | to add new header and footer content after launch.  Without this feature, 
+   | users only receive header and footer portlets from their template user, 
at 
+   | creation time.  To add new header and footer portlets, you would likely 
+   | have to export all user layouts, make adjustments to the exported XML 
+   | files, then re-import the layouts.
    |
-   | If you decide to enable this functionality, you should also:
-   |   - Uncomment the "fragmentDefinitionDao" bean in persistenceContext.xml
-   |   - Uncomment the "org.jasig.portal.layout.dlm.Evaluator" cache in 
ehcache.xml
+   | WARNING:  Before this feature was added, fragment layouts (from uPortal 
+   | distributions) commonly contained extra garbage in the header and footer 
+   | areas.  If you want to enable this feature for a portal based on earlier 
+   | data, you will likely need to remove unnecessary portlets from the header 
+   | and footer of all fragment layouts AND from the 'fragmentTemplate' 
layout.  
+   | You can accomplish that by exporting them, adjusting them, and 
re-importing 
+   | them.  If you enable this feature without making these changes you will 
+   | probably see unwanted behavior.
    +-->
   <!--
-  <dlm:property name="ConfigurationLoader.impl" 
value="org.jasig.portal.layout.dlm.RDBMConfigurationLoader"/>
+  <dlm:property name="allowExpandedContent" value="true"/>
   -->
-  
-  <dlm:fragment name='Guests' ownerID='guest-lo' precedence='80'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.GuestUserEvaluatorFactory'/>
+
+  <dlm:fragment name="Guests" ownerID="guest-lo" precedence="80">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.GuestUserEvaluatorFactory"/>
   </dlm:fragment>
   
-  <dlm:fragment name='Welcome' ownerID='welcome-lo' precedence='80'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.PersonEvaluatorFactory'>
+  <dlm:fragment name="Welcome" ownerID="welcome-lo" precedence="80">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.PersonEvaluatorFactory">
       <paren mode="NOT">
-        <attribute name="username" mode='equals' value='guest'/>
+        <attribute name="username" mode="equals" value="guest"/>
       </paren>
     </dlm:audience>
   </dlm:fragment>
 
-  <dlm:fragment name='News' ownerID='news-lo' precedence='60'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.AllUsersEvaluatorFactory'/>
+  <dlm:fragment name="News" ownerID="news-lo" precedence="60">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.AllUsersEvaluatorFactory"/>
   </dlm:fragment>
   
-  <dlm:fragment name='Faculty' ownerID='faculty-lo' precedence='50'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
+  <dlm:fragment name="Faculty" ownerID="faculty-lo" precedence="50">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory">
       <paren mode="OR">     
-        <attribute mode='memberOf' name='Faculty'/>
+        <attribute mode="memberOf" name="Faculty"/>
       </paren>
     </dlm:audience>
   </dlm:fragment>
   
-  <dlm:fragment name='Staff' ownerID='staff-lo' precedence='50'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
+  <dlm:fragment name="Staff" ownerID="staff-lo" precedence="50">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory">
       <paren mode="OR">     
-        <attribute mode='memberOf' name='Staff'/>
+        <attribute mode="memberOf" name="Staff"/>
       </paren>
     </dlm:audience>
   </dlm:fragment>
   
-  <dlm:fragment name='Student' ownerID='student-lo' precedence='50'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
+  <dlm:fragment name="Student" ownerID="student-lo" precedence="50">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory">
       <paren mode="OR">     
-        <attribute mode='memberOf' name='Students'/>
+        <attribute mode="memberOf" name="Students"/>
       </paren>
     </dlm:audience>
   </dlm:fragment>
   
-  <dlm:fragment name='Developer' ownerID='developer-lo' precedence='40'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
+  <dlm:fragment name="Developer" ownerID="developer-lo" precedence="40">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory">
       <paren mode="OR">     
-        <attribute mode='memberOf' name='Portal Developers'/>
+        <attribute mode="memberOf" name="Portal Developers"/>
       </paren>
     </dlm:audience>
   </dlm:fragment>
   
-  <dlm:fragment name='Admin' ownerID='admin-lo' precedence='40'>
-    <dlm:audience 
evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
+  <dlm:fragment name="Admin" ownerID="admin-lo" precedence="40">
+    <dlm:audience 
evaluatorFactory="org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory">
       <paren mode="OR">     
-        <attribute mode='memberOf' name='Portal Administrators'/>
-        <attribute mode='memberOf' name='Portal Developers'/>
+        <attribute mode="memberOf" name="Portal Administrators"/>
+        <attribute mode="memberOf" name="Portal Developers"/>
       </paren>
     </dlm:audience>
   </dlm:fragment>

Reply via email to