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/servletcontainer TomcatManager.java
Date Fri, 16 Jan 2004 19:53:34 GMT
weaver      2004/01/16 11:53:34

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer
                        TomcatManager.java
  Log:
  fixed issue with install() not returning a response object
  
  added additional methods for building the install query string
  
  Revision  Changes    Path
  1.3       +52 -39    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
  
  Index: TomcatManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TomcatManager.java	15 Jan 2004 23:42:47 -0000	1.2
  +++ TomcatManager.java	16 Jan 2004 19:53:34 -0000	1.3
  @@ -9,6 +9,7 @@
   import java.io.File;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.net.MalformedURLException;
   
   import org.apache.commons.httpclient.HostConfiguration;
   import org.apache.commons.httpclient.HttpClient;
  @@ -28,7 +29,7 @@
    * @version $Id$
    *
    */
  -public class TomcatManager 
  +public class TomcatManager
   {
       private static final String DEFUALT_MANAGER_APP_PATH = "/manager";
   
  @@ -43,7 +44,7 @@
       private String removePath = managerAppPath + "/remove";
       private String deployPath = managerAppPath + "/deploy";
       private String installPath = managerAppPath + "/install";
  -	private String reloadPath = managerAppPath + "/reload";
  +    private String reloadPath = managerAppPath + "/reload";
       private String serverInfoPath = managerAppPath + "/serverinfo";
   
       private HttpClient client;
  @@ -51,8 +52,8 @@
       private HttpMethod start;
   
       private HttpMethod stop;
  -    
  -	private HttpMethod reload;
  +
  +    private HttpMethod reload;
   
       private HttpMethod remove;
   
  @@ -94,19 +95,19 @@
   
           // perform a test, we can use this to close a
           GetMethod test = new GetMethod(serverInfoPath);
  -//        try
  -//        {
  -//            client.executeMethod(test);
  -//        }
  -//        finally
  -//        {
  -//            test.releaseConnection();
  -//        }
  +        //        try
  +        //        {
  +        //            client.executeMethod(test);
  +        //        }
  +        //        finally
  +        //        {
  +        //            test.releaseConnection();
  +        //        }
           start = new GetMethod(startPath);
           stop = new GetMethod(stopPath);
           remove = new GetMethod(removePath);
           install = new GetMethod(installPath);
  -		reload = new GetMethod(reloadPath);
  +        reload = new GetMethod(reloadPath);
           deploy = new PutMethod(deployPath);
       }
   
  @@ -139,21 +140,21 @@
               stop.setPath(stopPath);
           }
       }
  -    
  -	public String reload(String appPath) throws HttpException, IOException
  -	{
  -		try
  -		{
  -			reload.setQueryString(buildPathQueryArgs(appPath));
  -			client.executeMethod(reload);
  -			return reload.getResponseBodyAsString();
  -		}
  -		finally
  -		{
  -			reload.recycle();
  -			reload.setPath(reloadPath);
  -		}
  -	}
  +
  +    public String reload(String appPath) throws HttpException, IOException
  +    {
  +        try
  +        {
  +            reload.setQueryString(buildPathQueryArgs(appPath));
  +            client.executeMethod(reload);
  +            return reload.getResponseBodyAsString();
  +        }
  +        finally
  +        {
  +            reload.recycle();
  +            reload.setPath(reloadPath);
  +        }
  +    }
   
       public String remove(String appPath) throws HttpException, IOException
       {
  @@ -175,14 +176,10 @@
       {
           try
           {
  -            install.setQueryString(buildWarQueryArgs(warPath));
  -            if (contexPath != null)
  -            {
  -                install.setQueryString(buildPathQueryArgs(contexPath));
  -            }
  +            install.setQueryString(buildWarQueryArgs(warPath, contexPath));
   
               client.executeMethod(install);
  -            return deploy.getResponseBodyAsString();
  +            return install.getResponseBodyAsString();
           }
           finally
           {
  @@ -192,8 +189,6 @@
   
       }
   
  -
  -
       public String deploy(String appPath, InputStream is, int size) throws HttpException,
IOException
       {
           try
  @@ -220,12 +215,30 @@
   
       protected NameValuePair[] buildPathQueryArgs(String appPath)
       {
  +        if (!appPath.startsWith("/"))
  +        {
  +            appPath = "/" + appPath;
  +        }
           return new NameValuePair[] { new NameValuePair("path", appPath)};
       }
   
  -    protected NameValuePair[] buildWarQueryArgs(String appPath)
  +    protected NameValuePair[] buildWarQueryArgs(String warPath, String appPath) throws
MalformedURLException
       {
  -        return new NameValuePair[] { new NameValuePair("war", appPath)};
  +        if (appPath != null)
  +        {
  +            if (!appPath.startsWith("/"))
  +            {
  +                appPath = "/" + appPath;
  +            }
  +            return new NameValuePair[] {
  +                new NameValuePair("war", new File(warPath).toURL().toString()),
  +                new NameValuePair("path", appPath)};
  +        }
  +        else
  +        {
  +            return new NameValuePair[] { new NameValuePair("war", warPath)};
  +        }
  +
       }
   
       /**
  
  
  

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