Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 29 Next »

Step 1. First take a look at the dlm.xml file

  • Open the dlm.xml file which located at ../uportal-impl/src/main/resources/properties/dlm.xml and let's take a look at the existing fragments that are defined. Below is a snippet of the fragments that come with uPortal already in place.
    <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'>
          <paren mode="NOT">
            <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>
    
      <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'/>
          </paren>
        </dlm:audience>
      </dlm:fragment>
    
      <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'/>
          </paren>
        </dlm:audience>
      </dlm:fragment>
    
      <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'/>
          </paren>
        </dlm:audience>
      </dlm:fragment>
    
      <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'/>
          </paren>
        </dlm:audience>
      </dlm:fragment>
    
      <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'/>
          </paren>
        </dlm:audience>
      </dlm:fragment>
    
    
  • Let's now dissect the "Student" fragment below to get an idea of how this works.  The name of the fragment is Student and the fragment is owned by the user account student-lo. What we want to do is push this fragment to our Students group and to do this we define our audience using the GroupMembershipEvaluatorFactory . GroupMembershipEvaluatorFactory evaluates group memberships and with the <paren> and <attribute> directives we specify the group we wish to target. So we will interpret the syntax below as find everyone who is a memberOf the Students group and push this fragment to them.
    <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'/>
          </paren>
        </dlm:audience>
      </dlm:fragment>
    
  • What if we want to push the fragment to more than one group? What if we wanted to push the fragment to Students OR Faculty? We can do this by using the <paren> directive's mode attributes OR, NOT, or AND.
    • Here are some examples of using <paren> and <attribute> together to target specific groups:
      <!-- Push this fragment to anyone who is a member of the Students OR Faculty group -->
      <dlm:audience evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
          <paren mode="OR">
            <attribute mode='memberOf' name='Students'/>
            <attribute mode='memberOf' name='Faculty'/>
          </paren>
        </dlm:audience>
      
      <!-- Push this fragment to members of the Students group who are NOT also members of the Faculty group -->
      <dlm:audience evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
          <paren mode="AND">
            <attribute mode='memberOf' name='Students'/>
            <paren mode="NOT">
              <attribute mode='memberOf' name='Faculty'/>
            </paren>
          </paren>
        </dlm:audience>
      
    • So as you can see from the above examples there is some flexibility to targeting specific groups of interest.
  •  For complete documentation of how to target your audience take a look at the "define audiences" manual page for details.

Step 2: Define a new fragment

  • Let's imagine that we want to setup a fragment named "Library". This library fragment will contain all information about library services that we wish to send out to Faculty groups but NOT Staff groups. Here's what we would do:
  • Define our new fragment as follows in the dlm.xml file
<dlm:fragment name='Library' ownerID='library-lo' precedence='40'>
    <dlm:audience evaluatorFactory='org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluatorFactory'>
      <paren mode="OR">
         <attribute mode='memberOf' name='Faculty'/>                  
        <paren mode="NOT">
          <attribute mode='memberOf' name='Staff'/>
        </paren>
      </paren>
    </dlm:audience>
  </dlm:fragment>
  • Setting the precedence attribute
    • Each fragment must also declare an integer precedence value. This value is used during merging of fragments to position elements contributed from different fragments. It is also used to determine which precedence elements can override a lower precedence.

                 

Step 3: Deploy your new fragment

  • Go back to the source uPortal directory and issue the following command to deploy your new fragment
    ant clean deploy-ear

Step 4: Restart uPortal

Now that we have created our new fragment we need to restart tomcat to activate the new fragment.

$TOMCAT_HOME/bin/shutdown.sh
$TOMCAT_HOME/bin/startup.sh

Step 5: Setup our new fragment user account

After we restarted uPortal we now need to create our new user account who owns the fragment we just defined above (library-lo).

  • From your uPortal source directory create the new account by issuing the following command from the command-line:
    ant md5passwd -Dusername=library-lo
    
  • You will be prompted to enter a password for the new account
    Buildfile: build.xml
    
    prodPrompt:
    
    md5passwd:
    
    install-parent-pom:
    [artifact:install] [INFO] Installing /portal/uPortal-3.2.2/pom.xml to /root/.m2/repository/org/jasig/portal/...
        [touch] Creating /tmp/jasig/uportal-parent.pom-1617936594-marker
         [echo] Artifact '/portal/uPortal-3.2.2/uportal-impl/target/uportal-impl-3.2.2.jar' is up-to-date
    [artifact:install] [INFO] Installing /portal/uPortal-3.2.2/uportal-impl/target/uportal-impl-3.2.2.jar to /root/.m2/...
         [java] Working directory ignored when same JVM is used.
         [java] log4j:WARN No appenders could be found for logger (org.jasig.portal.spring.locator.PortalDbLocator).
         [java] log4j:WARN Please initialize the log4j system properly.
         [java] Enter Password for library-lo:
    
  • Once you enter a password you should receive the success message
    ...
    [java] Password Updated...
    
    BUILD SUCCESSFUL
    Total time: 34 seconds
    
  • Now login to uPortal as an administrator and you will automatically receive the library-lo account in the Password Management portlet (see image below)

  • If you highlight the library-lo account and click on "Fetch" you can enter further details for the account such as first and last name, etc...

Step 6: Setup the layout for our fragment

Now, that we have setup our fragment we can now start customizing the layout of our new fragment. For the second half of this tutorial see detailed instructions at this manual page setup a fragment layout.

Additional References

Having problems with these instructions?

Please send us feedback at uportal-user@lists.ja-sig.org

  • No labels