portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager PortletApplicationManager.java
Date Sat, 26 Mar 2005 22:05:14 GMT
ate         2005/03/26 14:05:14

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager
                        PortletApplicationManager.java
  Log:
  Optionally create roles defined in the web descriptor on registration of a portlet application.
  This is configurable in the springframework definition. Just set properties roleManager
and autoCreateRoles.
  See http://issues.apache.org/jira/browse/JS2-211
  
  Revision  Changes    Path
  1.20      +39 -3     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
  
  Index: PortletApplicationManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PortletApplicationManager.java	23 Mar 2005 22:54:30 -0000	1.19
  +++ PortletApplicationManager.java	26 Mar 2005 22:05:13 -0000	1.20
  @@ -27,9 +27,11 @@
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
   import org.apache.jetspeed.search.SearchEngine;
  +import org.apache.jetspeed.security.RoleManager;
   import org.apache.jetspeed.util.FileSystemHelper;
   import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
   
  +import org.apache.pluto.om.common.SecurityRole;
   import org.apache.pluto.om.entity.PortletEntity;
   import org.apache.pluto.om.portlet.PortletDefinition;
   
  @@ -52,7 +54,9 @@
       protected PortletFactory        portletFactory;
       protected PortletRegistry       registry;
       protected PortletWindowAccessor windowAccess;
  -    protected SearchEngine searchEngine;
  +    protected SearchEngine          searchEngine;
  +    protected RoleManager           roleManager;
  +    protected boolean               autoCreateRoles;
   
       /**
   	 * Creates a new PortletApplicationManager object.
  @@ -65,6 +69,16 @@
   		this.entityAccess	    = entityAccess;
   		this.windowAccess	    = windowAccess;
   	}
  +    
  +    public void setRoleManager(RoleManager roleManager)
  +    {
  +        this.roleManager = roleManager;
  +    }
  +    
  +    public void setAutoCreateRoles(boolean autoCreateRoles)
  +    {
  +        this.autoCreateRoles = autoCreateRoles;
  +    }
   
   	public void setSearchEngine(SearchEngine searchEngine)
   	{
  @@ -236,6 +250,28 @@
   				searchEngine.add(pa.getPortletDefinitions());
   				log.info("Registered the portlet application in the search engine... " + paName);
   			}
  +            
  +            if ( autoCreateRoles && roleManager != null && pa.getWebApplicationDefinition().getSecurityRoles()
!= null )
  +            {
  +                try
  +                {
  +                    Iterator rolesIter = pa.getWebApplicationDefinition().getSecurityRoles().iterator();
  +                    SecurityRole sr;
  +                    while ( rolesIter.hasNext() )
  +                    {
  +                        sr = (SecurityRole)rolesIter.next();
  +                        if ( !roleManager.roleExists(sr.getRoleName()) )
  +                        {
  +                            roleManager.addRole(sr.getRoleName());
  +                            log.info("AutoCreated role: "+sr.getRoleName()+" from portlet
application "+paName+" its web definition");
  +                        }
  +                    }
  +                }
  +                catch (SecurityException sex)
  +                {
  +                    log.warn("Failed to autoCreate roles for portlet application " + paName+":
"+sex.getMessage(), sex);
  +                }
  +            }
   
   			return pa;
   		}
  @@ -248,7 +284,7 @@
   			{
   				try
   				{
  -					registry.removeApplication(pa);
  +					unregisterPortletApplication(pa, local);
   				}
   				catch (Exception re)
   				{
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message