portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager CatalinaPAM.java
Date Mon, 19 Jan 2004 21:37:09 GMT
weaver      2004/01/19 13:37:09

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager
                        CatalinaPAM.java
  Log:
  Now extends FileSystemPAM
  
  Revision  Changes    Path
  1.7       +19 -196   jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/CatalinaPAM.java
  
  Index: CatalinaPAM.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/CatalinaPAM.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CatalinaPAM.java	16 Jan 2004 19:52:28 -0000	1.6
  +++ CatalinaPAM.java	19 Jan 2004 21:37:09 -0000	1.7
  @@ -53,20 +53,15 @@
    */
   package org.apache.jetspeed.tools.pamanager;
   
  -import java.io.File;
  +
  +
  +import java.io.IOException;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.jetspeed.Jetspeed;
  -import org.apache.jetspeed.container.JetspeedPortletContext;
  -import org.apache.jetspeed.exception.RegistryException;
  -import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
  -import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
  -import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
  -import org.apache.jetspeed.persistence.TransactionStateException;
   import org.apache.jetspeed.registry.JetspeedPortletRegistry;
   import org.apache.jetspeed.tools.pamanager.servletcontainer.TomcatManager;
  -import org.apache.jetspeed.util.DirectoryUtils;
  +
   
   /**
    * This is the catalina specific implemenation for deplyment of Portlet Applications.
  @@ -75,8 +70,8 @@
     * @version $Id$
    */
   
  -//public class CatalinaPAM extends FileSystemPAM implements Deployment, Lifecycle
  -public class CatalinaPAM implements Deployment, Lifecycle
  +
  +public class CatalinaPAM extends FileSystemPAM implements Deployment, Lifecycle
   {
       // Implementaion of deplyment interface
   
  @@ -85,6 +80,8 @@
   
       public CatalinaPAM(String server, int port, String user, String password) throws PortletApplicationException
       {
  +    	useDefaultPluginFordeploy = true;
  +		
           try
           {
               tomcatManager = new TomcatManager(server, port, user, password);
  @@ -99,10 +96,10 @@
       // Interface not supported by this implementation 
       public void deploy(String webAppsDir, String warFile, String paName) throws PortletApplicationException
       {
  -        //super.deploy(webAppsDir, warFile, paName);
  +        
           try
  -        {
  -            sysDeploy(webAppsDir, warFile, paName, 0);
  +        {            
  +			super.deploy(webAppsDir, warFile, paName);
               //checkResponse(tomcatManager.install(warFile, paName));
               checkResponse(tomcatManager.install(webAppsDir + "/" + paName, paName));
           }
  @@ -128,7 +125,7 @@
   
       public void deploy(String warFile, String paName) throws PortletApplicationException
       {
  -        //super.deploy(warFile, paName);
  +		super.deploy(null, warFile, paName, 0);	
           try
           {
               checkResponse(tomcatManager.install(warFile, paName));
  @@ -155,7 +152,7 @@
           try
           {
               checkResponse(tomcatManager.remove(paName));
  -            //super.undeploy(paName);
  +            super.undeploy(paName);
           }
           catch (UnsupportedOperationException usoe)
           {
  @@ -179,7 +176,7 @@
           try
           {
               checkResponse(tomcatManager.remove(paName));
  -            //super.undeploy(webAppsDir, paName);
  +            super.undeploy(webAppsDir, paName);
           }
           catch (PortletApplicationException pe)
           {
  @@ -291,7 +288,7 @@
           throws PortletApplicationException
       {
   
  -        //super.deploy((String) webAppsDir, (String) warFile, (String) paName, (String)
deploymentDbAlias, (int)startState);		
  +		super.deploy(webAppsDir, warFile, paName, startState);		
           try
           {
               checkResponse(tomcatManager.install(warFile, paName));
  @@ -306,186 +303,12 @@
           }
       }
   
  -    protected void sysDeploy(String webAppsDir, String warFile, String paName, int startState)
throws PortletApplicationException
  -    {
  -
  -        // Call into DeplyUtilities class
  -        DeployUtilities util = new DeployUtilities();
  -
  -        // State of deployment -- use integer to signal the state
  -        // 0 Initial state
  -        // 1 Archive deployed
  -        // 2 WEB XML updated
  -        // 3 Registry updated
  -        //
  -        int nState = 0; //Initialize
  -        MutablePortletApplication app = null;
  -
  -        try
  -        {
  -            if (startState <= nState)
  -            {
  -                // prepend a slash if need be
  -                if (paName.indexOf('/') != 0)
  -                {
  -                    paName = "/" + paName;
  -                }
  -                util.deployArchive(webAppsDir, warFile, paName);
  -            }
  -
  -            nState = 1;
  -
  -            if (startState <= nState)
  -            {
  -                util.processWebXML(util.getWebXMLPath(webAppsDir, warFile, paName), paName);
  -            }
  -
  -            nState = 2;
  -
  -            if (startState <= nState)
  -            {
  -                registerApplication(webAppsDir, paName);
  -            }
  -
  -            nState = 3;
  -
  -            // DONE
  -            log.info("FileSystem deployment done.");
  -
  -        }
  -        catch (PortletApplicationException pae)
  -        {
  -            log.error(
  -                "PortletApplicationException encountered deploying portlet application:
"
  -                    + pae.toString()
  -                    + " attempting rollback...",
  -                pae);
  -            rollback(nState, webAppsDir, paName, app);
  -            throw pae;
  -        }
  -        catch (Throwable t)
  -        {
  -            log.error("Unexpected exception deploying portlet application: " + t.toString()
+ " attempting rollback...", t);
  -            rollback(nState, webAppsDir, paName, app);
  -            throw new PortletApplicationException(t);
  -        }
  -
  -    }
  -    protected void registerApplication(String webAppsDir, String paName)
  -        throws PortletApplicationException, RegistryException
  -    {
  -        MutablePortletApplication app;
  -        // Application is deployed -- populate the registry with the portlet.xml
  -        String portletXMLPath = webAppsDir + paName + "/WEB-INF/portlet.xml";
  -        
  -        // load the portlet.xml
  -        log.info("Loading " + portletXMLPath + " into memory....");
  -        app = (MutablePortletApplication) PortletDescriptorUtilities.loadPortletDescriptor(portletXMLPath,
paName);
  -        
  -        if (app == null)
  -        {
  -            String msg = "Error loading: " + portletXMLPath;
  -            log.error(msg);
  -            throw new PortletApplicationException(msg);
  -        }
  -        
  -        if (webAppsDir.indexOf(JetspeedPortletContext.LOCAL_PA_ROOT) > -1)
  -        {
  -            app.setApplicationType(MutablePortletApplication.LOCAL);
  -        }
  -        else
  -        {
  -            app.setApplicationType(MutablePortletApplication.WEBAPP);
  -        }
  -        //					// create the web application
  -        MutableWebApplication webapp = new WebApplicationDefinitionImpl();
  -        if (paName.startsWith("/"))
  -        {
  -            webapp.setContextRoot(paName);
  -        }
  -        else
  -        {
  -            webapp.setContextRoot("/" + paName);
  -        }
  -        webapp.addDisplayName(Jetspeed.getDefaultLocale(), paName);
  -        app.setWebApplicationDefinition(webapp);
  -        
  -        // save it to the registry
  -        log.info("Saving the portlet.xml in the registry...");
  -        
  -        JetspeedPortletRegistry.registerPortletApplication(app);
  -       // return app;
  -    }
  -
  -    protected void rollback(int nState, String webAppsDir, String paName, MutablePortletApplication
app)
  -    {
  -        log.info("Exception in deploy. Rollback of application deployment...");
  -        if (nState >= 2 && app != null)
  -        {
  -            rollbackRegistry(app);
  -        }
  -
  -        if (nState >= 1)
  -        {
  -            rollbackFileSystem(webAppsDir, paName);
  -        }
  -    }
  -    
  -    protected void rollbackFileSystem(String webAppsDir, String paName)
  -    {
  -        try
  -        {
  -        
  -            // Remove the webapps directory
  -            log.info("Rollback: Remove " + webAppsDir + paName + " and all sub-directories.");
  -        
  -            // Call into DeplyUtilities class
  -            DeployUtilities util = new DeployUtilities();
  -            if (DirectoryUtils.rmdir(new File(webAppsDir + paName)) == false)
  -            {
  -                log.error(
  -                    "Rollback: Failed to delete web app directory "
  -                        + webAppsDir
  -                        + " .Make sure the application is no longer running.");
  -            }
  -        }
  -        catch (Exception e)
  -        {
  -            log.error("Error removing file system deployment artifacts: " + e.toString(),
e);
  -        }
  -    }
  -    
       /**
  -     * Roles back any registry changes that have been made
  -     * @param app
  +     * @see org.apache.jetspeed.tools.pamanager.FileSystemPAM#identifyDeploymentSystem()
        */
  -    protected void rollbackRegistry(MutablePortletApplication app)
  +    protected void identifyDeploymentSystem() throws IOException
       {
  -        try
  -        {
  -
  -            // remove entries from the registry
  -            // JetspeedPortletRegistry.processPortletApplicationTree(app, "remove");
  -            log.info("Saving the portlet.xml in the registry...");
  -
  -            JetspeedPortletRegistry.beginTransaction();
  -            JetspeedPortletRegistry.removeApplication(app);
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -
  -        catch (Exception e1)
  -        {
  -            try
  -            {
  -                log.error("Error processing rollback.  Attempting to rollback registry
transaction.", e1);
  -                JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e2)
  -            {
  -                log.error("Error processing tranasction: " + e2.toString(), e2);      
        
  -            }
  -
  -        }
  +		JetspeedPortletRegistry.setDeploymentSystem(null, null);
       }
   
   }
  
  
  

---------------------------------------------------------------------
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