tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r446457 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/startup/ webapps/docs/ webapps/manager/WEB-INF/classes/org/apache/catalina/manager/
Date Fri, 15 Sep 2006 02:01:04 GMT
Author: markt
Date: Thu Sep 14 19:01:03 2006
New Revision: 446457

URL: http://svn.apache.org/viewvc?view=rev&rev=446457
Log:
Fix bug 34399 - disable the undeploy option if the webapp has not been 'deployed'
This occurs, for example, if the webapp is defined in server.xml

Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml
    tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/HTMLManagerServlet.java
    tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/LocalStrings.properties
    tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java?view=diff&rev=446457&r1=446456&r2=446457
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java
(original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java
Thu Sep 14 19:01:03 2006
@@ -354,6 +354,23 @@
     }
     
     
+    /**
+     * Has the specified application been deployed? Note applications defined
+     * in server.xml will not have been deployed.
+     * @return <code>true</code> if the application has been deployed and
+     * <code>false</code> if the applciation has not been deployed or does not
+     * exist
+     */
+    public boolean isDeployed(String name) {
+        DeployedApplication app = (DeployedApplication) deployed.get(name);
+        if (app == null) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+    
+    
     // ------------------------------------------------------ Protected Methods
 
     
@@ -670,8 +687,6 @@
         
         if (files == null)
             return;
-        
-        boolean checkAdditionalDeployments = false;
         
         for (int i = 0; i < files.length; i++) {
             

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml?view=diff&rev=446457&r1=446456&r2=446457
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml
(original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml
Thu Sep 14 19:01:03 2006
@@ -79,6 +79,15 @@
                  type="java.lang.String"/>
     </operation>
 
+    <operation name="isDeployed"
+               description="Was this web application deployed by this component"
+               impact="ACTION"
+               returnType="boolean">
+      <parameter name="name"
+                 description="Application name"
+                 type="java.lang.String"/>
+    </operation>
+
     <operation name="manageApp"
                description="Add a web application managed externally"
                impact="ACTION"

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=446457&r1=446456&r2=446457
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Sep 14 19:01:03 2006
@@ -41,6 +41,14 @@
       </fix>
     </changelog>
   </subsection>   
+  <subsection name="Webapps">
+    <changelog>
+      <fix>
+        <bug>34399</bug>: Disable undeploy for applciations that have not
+        been deployed such as those defined in server.xml (markt)
+      </fix>
+    </changelog>
+  </subsection> 
 </section>
 
 

Modified: tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/HTMLManagerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/HTMLManagerServlet.java?view=diff&rev=446457&r1=446456&r2=446457
==============================================================================
--- tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/HTMLManagerServlet.java
(original)
+++ tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/HTMLManagerServlet.java
Thu Sep 14 19:01:03 2006
@@ -333,6 +333,7 @@
 
         Iterator iterator = sortedContextPathsMap.entrySet().iterator();
         boolean isHighlighted = true;
+        boolean isDeployed = true;
         String highlightColor = null;
 
         while (iterator.hasNext()) {
@@ -353,6 +354,13 @@
             }
 
             if (context != null ) {
+                try {
+                    isDeployed = isDeployed(contextPath);
+                } catch (Exception e) {
+                    // Assume false on failure for safety
+                    isDeployed = false;
+                }
+                
                 args = new Object[6];
                 args[0] = displayPath;
                 args[1] = context.getDisplayName();
@@ -398,12 +406,18 @@
                 if (context.getPath().equals(this.context.getPath())) {
                     writer.print(MessageFormat.format(
                         MANAGER_APP_ROW_BUTTON_SECTION, args));
-                } else if (context.getAvailable()) {
+                } else if (context.getAvailable() && isDeployed) {
+                    writer.print(MessageFormat.format(
+                        STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
+                } else if (context.getAvailable() && !isDeployed) {
                     writer.print(MessageFormat.format(
-                        STARTED_APPS_ROW_BUTTON_SECTION, args));
+                        STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
+                } else if (!context.getAvailable() && isDeployed) {
+                    writer.print(MessageFormat.format(
+                        STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
                 } else {
                     writer.print(MessageFormat.format(
-                        STOPPED_APPS_ROW_BUTTON_SECTION, args));
+                        STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
                 }
 
             }
@@ -584,7 +598,7 @@
         " </td>\n" +
         "</tr>\n";
 
-    private static final String STARTED_APPS_ROW_BUTTON_SECTION =
+    private static final String STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION =
         " <td class=\"row-left\" bgcolor=\"{8}\">\n" +
         "  <small>\n" +
         "  &nbsp;{1}&nbsp;\n" +
@@ -595,13 +609,35 @@
         " </td>\n" +
         "</tr>\n";
 
-    private static final String STOPPED_APPS_ROW_BUTTON_SECTION =
+    private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION =
         " <td class=\"row-left\" bgcolor=\"{8}\">\n" +
         "  <small>\n" +
         "  &nbsp;<a href=\"{0}\" onclick=\"return(confirm('''Are you sure?'''))\">{1}</a>&nbsp;\n"
+
         "  &nbsp;{3}&nbsp;\n" +
         "  &nbsp;{5}&nbsp;\n" +
         "  &nbsp;<a href=\"{6}\" onclick=\"return(confirm('''Are you sure?  This will
delete the application.'''))\">{7}</a>&nbsp;\n" +
+        "  </small>\n" +
+        " </td>\n" +
+        "</tr>\n";
+
+    private static final String STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION =
+        " <td class=\"row-left\" bgcolor=\"{8}\">\n" +
+        "  <small>\n" +
+        "  &nbsp;{1}&nbsp;\n" +
+        "  &nbsp;<a href=\"{2}\" onclick=\"return(confirm('''Are you sure?'''))\">{3}</a>&nbsp;\n"
+
+        "  &nbsp;<a href=\"{4}\" onclick=\"return(confirm('''Are you sure?'''))\">{5}</a>&nbsp;\n"
+
+        "  &nbsp;{7}&nbsp;\n" +
+        "  </small>\n" +
+        " </td>\n" +
+        "</tr>\n";
+
+    private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION =
+        " <td class=\"row-left\" bgcolor=\"{8}\">\n" +
+        "  <small>\n" +
+        "  &nbsp;<a href=\"{0}\" onclick=\"return(confirm('''Are you sure?'''))\">{1}</a>&nbsp;\n"
+
+        "  &nbsp;{3}&nbsp;\n" +
+        "  &nbsp;{5}&nbsp;\n" +
+        "  &nbsp;{7}&nbsp;\n" +
         "  </small>\n" +
         " </td>\n" +
         "</tr>\n";

Modified: tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/LocalStrings.properties?view=diff&rev=446457&r1=446456&r2=446457
==============================================================================
--- tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/LocalStrings.properties
(original)
+++ tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/LocalStrings.properties
Thu Sep 14 19:01:03 2006
@@ -58,6 +58,7 @@
 managerServlet.noRole=FAIL - User does not possess role {0}
 managerServlet.noSelf=FAIL - The manager can not reload, undeploy, stop, or undeploy itself
 managerServlet.noWrapper=Container has not called setWrapper() for this servlet
+managerServlet.notDeployed=FAIL - Context {0} is defined in server.xml and may not be undeployed
 managerServlet.reloaded=OK - Reloaded application at context path {0}
 managerServlet.undeployd=OK - Undeployed application at context path {0}
 managerServlet.resourcesAll=OK - Listed global resources of all types

Modified: tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java?view=diff&rev=446457&r1=446456&r2=446457
==============================================================================
--- tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java
(original)
+++ tomcat/container/tc5.5.x/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java
Thu Sep 14 19:01:03 2006
@@ -1276,6 +1276,12 @@
                 }
             }
 
+            if (!isDeployed(path)) {
+                writer.println(sm.getString("managerServlet.notDeployed",
+                        RequestUtil.filter(displayPath)));
+                return;
+            }
+
             if (!isServiced(path)) {
                 addServiced(path);
                 try {
@@ -1368,6 +1374,19 @@
 
 
     /**
+     * Invoke the isDeployed method on the deployer.
+     */
+    protected boolean isDeployed(String name) 
+        throws Exception {
+        String[] params = { name };
+        String[] signature = { "java.lang.String" };
+        Boolean result = 
+            (Boolean) mBeanServer.invoke(oname, "isDeployed", params, signature);
+        return result.booleanValue();
+    }
+    
+
+    /**
      * Invoke the check method on the deployer.
      */
     protected void check(String name) 
@@ -1379,7 +1398,7 @@
     
 
     /**
-     * Invoke the check method on the deployer.
+     * Invoke the isServiced method on the deployer.
      */
     protected boolean isServiced(String name) 
         throws Exception {
@@ -1392,7 +1411,7 @@
     
 
     /**
-     * Invoke the check method on the deployer.
+     * Invoke the addServiced method on the deployer.
      */
     protected void addServiced(String name) 
         throws Exception {
@@ -1403,7 +1422,7 @@
     
 
     /**
-     * Invoke the check method on the deployer.
+     * Invoke the removeServiced method on the deployer.
      */
     protected void removeServiced(String name) 
         throws Exception {



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


Mime
View raw message