taylor      2004/07/23 00:43:27

  Modified:    fusion/src/java/org/apache/jetspeed/fusion/tools/pamanager
                        FusionPAM.java
  Log:
  hook into special deployment event for generic deployment (deployment at servlet 
init)
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.7       +73 -34    
jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/tools/pamanager/FusionPAM.java
  
  Index: FusionPAM.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/tools/pamanager/FusionPAM.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FusionPAM.java    23 Jul 2004 07:06:54 -0000      1.6
  +++ FusionPAM.java    23 Jul 2004 07:43:27 -0000      1.7
  @@ -26,6 +26,7 @@
   import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
   import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
   import org.apache.jetspeed.container.window.PortletWindowAccessor;
  +import org.apache.jetspeed.exception.RegistryException;
   import org.apache.jetspeed.fusion.services.resources.FusionResources;
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.profile.Entry;
  @@ -44,6 +45,7 @@
   import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
   import org.apache.jetspeed.tools.pamanager.Registration;
   import org.apache.jetspeed.tools.pamanager.DeploymentRegistration;
  +import org.apache.jetspeed.util.FileSystemHelper;
   import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
   import org.apache.pluto.om.common.Description;
   import org.apache.pluto.om.common.DisplayName;
  @@ -161,8 +163,13 @@
       {
         //  System.out.println("***** Deploying now...." + paWar.);
           super.deploy(paWar);
  -        
  -                
  +
  +        fusionDeploy(paWar.getPortletApplicationName());
  +    }
  +    
  +    private void fusionDeploy(String paName)
  +    throws PortletApplicationException    
  +    {        
           //create xreg
           PersistenceStore store = registry.getPersistenceStore();
           try
  @@ -172,7 +179,6 @@
               store.getTransaction().begin();
               log.info("Saving the portlet.xml in the J1 registry...");
               
  -            String paName = paWar.getPortletApplicationName();
               MutablePortletApplication app = registry.getPortletApplication(paName);
               
               Collection pds = app.getPortletDefinitions();
  @@ -195,6 +201,7 @@
               log.error("Error processing rollback.  Attempting to rollback registry 
transaction.", e1);
           }
           //TurbineServices.getInstance().shutdownServices();
  +        
       }
       
       public static PortletEntry createPortletEntry(String paName, PortletDefinition 
portletDefinition)
  @@ -334,36 +341,7 @@
           String paName = paWar.getPortletApplicationName();
           System.out.println("***** UN Deploying now...." + paName);
           
  -        PortletRegistryComponent registry = (PortletRegistryComponent) 
Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
  -        
  -        try
  -        {
  -            // remove entries from the registry
  -            
  -            MutablePortletApplication app = registry.getPortletApplication(paName);
  -            
  -            Collection pds = app.getPortletDefinitions();
  -            Iterator pdsIter = pds.iterator();
  -            while (pdsIter.hasNext()) 
  -            {
  -                PortletDefinition pdef = (PortletDefinition) pdsIter.next();
  -                String name = pdef.getName();                
  -                Registry.removeEntry(Registry.PORTLET, name);                
  -                System.out.println("registry entry removed: " + name);
  -
  -                // remove PSML refs                
  -                removePSML(name);                
  -            }
  -            
  -        }        
  -        catch (Exception e1)
  -        {
  -            e1.printStackTrace();
  -            // store.getTransaction().rollback();
  -            log.error("Error processing rollback.  Attempting to rollback registry 
transaction.", e1);
  -        }
  -        //TurbineServices.getInstance().shutdownServices();
  -        
  +        fusionUndeploy(paName, true);
           super.undeploy(paWar);
           
       }
  @@ -403,5 +381,66 @@
               e.printStackTrace();
               log.error("Remove PSML: Failed to remove profiles for portlet: " + 
name, e );
           }        
  +    }
  +    
  +    public boolean registerPortletApplication(FileSystemHelper fileSystem,
  +            String portletApplicationName) 
  +    throws RegistryException
  +    {
  +        boolean existed = (registry.getPortletApplication(portletApplicationName) 
!= null);
  +        boolean registered = super.registerPortletApplication(fileSystem, 
portletApplicationName);
  +        if (registered)
  +        {
  +            if (existed)
  +            {
  +                fusionUndeploy(portletApplicationName, false);
  +            }
  +            try
  +            {
  +                fusionDeploy(portletApplicationName);
  +            }
  +            catch (Exception e)
  +            {
  +                throw new RegistryException(e);
  +            }               
  +        }
  +        return registered;
  +    }
  +    
  +    private void fusionUndeploy(String paName, boolean zapPSML)
  +    {
  +        PortletRegistryComponent registry = (PortletRegistryComponent) 
Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
  +        
  +        try
  +        {
  +            // remove entries from the registry
  +            
  +            MutablePortletApplication app = registry.getPortletApplication(paName);
  +            
  +            Collection pds = app.getPortletDefinitions();
  +            Iterator pdsIter = pds.iterator();
  +            while (pdsIter.hasNext()) 
  +            {
  +                PortletDefinition pdef = (PortletDefinition) pdsIter.next();
  +                String name = pdef.getName();                
  +                Registry.removeEntry(Registry.PORTLET, name);                
  +                System.out.println("registry entry removed: " + name);
  +
  +                // remove PSML refs                
  +                if (zapPSML)
  +                {
  +                    removePSML(name);
  +                }
  +            }
  +            
  +        }        
  +        catch (Exception e1)
  +        {
  +            e1.printStackTrace();
  +            // store.getTransaction().rollback();
  +            log.error("Error processing rollback.  Attempting to rollback registry 
transaction.", e1);
  +        }
  +        //TurbineServices.getInstance().shutdownServices();
  +        
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to