You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by am...@apache.org on 2003/03/11 04:26:19 UTC

cvs commit: jakarta-tomcat-4.0/webapps/admin/context contexts.jsp

amyroh      2003/03/10 19:26:19

  Modified:    webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        Lists.java TomcatTreeBuilder.java
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context
                        ContextForm.java ContextsForm.java
                        DeleteContextAction.java DeleteContextsAction.java
                        EditContextAction.java SaveContextAction.java
               webapps/admin/context contexts.jsp
  Log:
  Update to use JSR77 names.
  
  Revision  Changes    Path
  1.15      +16 -10    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java
  
  Index: Lists.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Lists.java	3 Feb 2003 22:55:00 -0000	1.14
  +++ Lists.java	11 Mar 2003 03:26:19 -0000	1.15
  @@ -229,16 +229,22 @@
           throws Exception {
   
           StringBuffer sb = new StringBuffer(host.getDomain());
  -        sb.append(":type=Context,host=");
  -        sb.append(host.getKeyProperty("host"));
  -        sb.append(",service=");
  -        sb.append(host.getKeyProperty("service"));
  -        sb.append(",*");
  +        sb.append(":j2eeType=WebModule,*");
  +        //sb.append(":type=Context,host=");
  +        //sb.append(host.getKeyProperty("host"));
  +        //sb.append(",service=");
  +        //sb.append(host.getKeyProperty("service"));
  +        //sb.append(",*");
           ObjectName search = new ObjectName(sb.toString());
           ArrayList contexts = new ArrayList();
           Iterator names = mbserver.queryNames(search, null).iterator();
  +        String hostName = host.getKeyProperty("host");
  +        String queryString = "Catalina:j2eeType=WebModule,name=//"+hostName;
           while (names.hasNext()) {
  -            contexts.add(names.next().toString());
  +            String name = names.next().toString();
  +            if (name.startsWith(queryString)) {
  +                contexts.add(name);
  +            }
           }
           Collections.sort(contexts);
           return (contexts);
  
  
  
  1.37      +38 -18    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java
  
  Index: TomcatTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- TomcatTreeBuilder.java	13 Sep 2002 01:35:34 -0000	1.36
  +++ TomcatTreeBuilder.java	11 Mar 2003 03:26:19 -0000	1.37
  @@ -103,6 +103,7 @@
       // This SERVER_LABEL needs to be localized
       private final static String SERVER_LABEL = "Tomcat Server";
       
  +    public final static String DOMAIN = "Catalina";
       public final static String SERVER_TYPE = "Catalina:type=Server";
       public final static String FACTORY_TYPE = "Catalina:type=MBeanFactory";
       public final static String SERVICE_TYPE = "Catalina:type=Service";
  @@ -110,6 +111,7 @@
       public final static String CONNECTOR_TYPE = "Catalina:type=Connector";
       public final static String HOST_TYPE = "Catalina:type=Host";
       public final static String CONTEXT_TYPE = "Catalina:type=Context";
  +    public final static String CONTEXT_JSR77_TYPE = "Catalina:j2eeType=WebModule";
       public final static String DEFAULTCONTEXT_TYPE = "Catalina:type=DefaultContext";
       public final static String LOADER_TYPE = "Catalina:type=Loader";
       public final static String MANAGER_TYPE = "Catalina:type=Manager";
  @@ -317,8 +319,10 @@
           while (contextNames.hasNext()) {
               String contextName = (String) contextNames.next();
               ObjectName objectName = new ObjectName(contextName);
  +            String name = objectName.getKeyProperty("name");
  +            String path = name.substring(name.lastIndexOf('/'));
               String nodeLabel =
  -                "Context (" + objectName.getKeyProperty("path") + ")";
  +                "Context (" + path + ")";
               TreeControlNode contextNode =
                   new TreeControlNode(contextName,
                                       "Context.gif",
  @@ -326,7 +330,9 @@
                                       "EditContext.do?select=" +
                                       URLEncoder.encode(contextName) +
                                       "&nodeLabel=" +
  -                                    URLEncoder.encode(nodeLabel),
  +                                    URLEncoder.encode(nodeLabel) +
  +                                    "&hostName=" +
  +                                    URLEncoder.encode(hostName),
                                       "content",
                                       false);
               hostNode.addChild(contextNode);
  @@ -452,19 +458,33 @@
                                 MessageResources resources) throws Exception {
   
           ObjectName oname = new ObjectName(containerName);
  -        String type = oname.getKeyProperty("type");
  -        if (type == null) {
  -            type = "";
  +        String type = null;
  +        String path = null;
  +        String host = null;
  +        String service = null;
  +        if (oname.getKeyProperty("j2eeType").equals("WebModule")) {
  +            type = "Context";
  +            String name = oname.getKeyProperty("name");
  +            path = name.substring(name.lastIndexOf('/'));
  +            TreeControlNode hostNode = containerNode.getParent();
  +            ObjectName honame = new ObjectName(hostNode.getName());
  +            host = honame.getKeyProperty("host");
  +            service = honame.getKeyProperty("service");
  +        } else {
  +            type = oname.getKeyProperty("type");
  +            if (type == null) {
  +                type = "";
  +            }
  +            path = oname.getKeyProperty("path");
  +            if (path == null) {
  +                path = "";
  +            }        
  +            host = oname.getKeyProperty("host");
  +            if (host == null) {
  +                host = "";
  +            }        
  +            service = oname.getKeyProperty("service");
           }
  -        String path = oname.getKeyProperty("path");
  -        if (path == null) {
  -            path = "";
  -        }        
  -        String host = oname.getKeyProperty("host");
  -        if (host == null) {
  -            host = "";
  -        }        
  -        String service = oname.getKeyProperty("service");
           TreeControlNode subtree = new TreeControlNode
               ("Context Resource Administration " + containerName,
                "folder_16_pad.gif",
  
  
  
  1.10      +9 -7      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextForm.java
  
  Index: ContextForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextForm.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ContextForm.java	5 Sep 2002 01:56:39 -0000	1.9
  +++ ContextForm.java	11 Mar 2003 03:26:19 -0000	1.10
  @@ -798,9 +798,11 @@
               
               // if path is empty, it's root context
               // validate context starting with "/" only at the time of context creation.
  -            //if ("Create".equalsIgnoreCase(adminAction) && !path.startsWith("/")) {
  -            //    errors.add("path", new ActionError("error.path.prefix"));                
  -            //}
  +            if ((path !=null) && (path.length() > 0)) {
  +                if ("Create".equalsIgnoreCase(adminAction) && !path.startsWith("/")) {
  +                    errors.add("path", new ActionError("error.path.prefix"));                
  +                }
  +            }
                           
               //if ((workDir == null) || (workDir.length() < 1)) {
               //    errors.add("workDir", new ActionError("error.workDir.required"));
  
  
  
  1.2       +14 -3     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextsForm.java
  
  Index: ContextsForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextsForm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextsForm.java	23 Mar 2002 23:16:57 -0000	1.1
  +++ ContextsForm.java	11 Mar 2003 03:26:19 -0000	1.2
  @@ -92,6 +92,16 @@
       public void setContexts(String contexts[]) {
           this.contexts = contexts;
       }
  +    
  +    private String hostName = null;
  +    
  +    public String getHostName() {
  +        return hostName;
  +    }
  +    
  +    public void setHostName(String hostName) {
  +        this.hostName = hostName;
  +    }
   
   
       // --------------------------------------------------------- Public Methods
  @@ -106,6 +116,7 @@
       public void reset(ActionMapping mapping, HttpServletRequest request) {
   
           this.contexts = new String[0];
  +        this.hostName = null;
   
       }
           
  
  
  
  1.2       +29 -17    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/DeleteContextAction.java
  
  Index: DeleteContextAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/DeleteContextAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeleteContextAction.java	23 Mar 2002 23:16:57 -0000	1.1
  +++ DeleteContextAction.java	11 Mar 2003 03:26:19 -0000	1.2
  @@ -90,6 +90,7 @@
   import org.apache.struts.util.MessageResources;
   
   import org.apache.webapp.admin.ApplicationServlet;
  +import org.apache.webapp.admin.Lists;
   import org.apache.webapp.admin.TomcatTreeBuilder;
   
   /**
  @@ -167,28 +168,36 @@
               contextsForm.setContexts(contexts);
               patternObject = select;
           }        
  -        request.setAttribute("contextsForm", contextsForm);
                   
           // get the parent host object name
           String parent = request.getParameter("parent");
           if (parent != null) {                
               patternObject = parent;
           } 
  +        contextsForm.setHostName(patternObject);
  +        request.setAttribute("contextsForm", contextsForm);
           
  +        ObjectName poname = null;
           // Accumulate a list of all available contexts
  -        ArrayList list = new ArrayList();
  +        // ArrayList list = new ArrayList();
  +        List list = null;
           try {
  -            ObjectName poname = new ObjectName(patternObject);
  -            String pattern = TomcatTreeBuilder.CONTEXT_TYPE +
  -                             TomcatTreeBuilder.WILDCARD +
  -                             ",host=" + poname.getKeyProperty("host") +
  -                             ",service=" + poname.getKeyProperty("service"); 
  +            poname = new ObjectName(patternObject);
  +            //String pattern = TomcatTreeBuilder.DOMAIN +
  +            //                 TomcatTreeBuilder.CONTEXT_JSR77_TYPE +
  +            //                 TomcatTreeBuilder.WILDCARD;      
  +            //getServlet().log(pattern);
  +            //String pattern = TomcatTreeBuilder.CONTEXT_TYPE +
  +            //                 TomcatTreeBuilder.WILDCARD +
  +            //                 ",host=" + poname.getKeyProperty("host") +
  +            //                 ",service=" + poname.getKeyProperty("service"); 
               // get all available contexts only for this host
  -            Iterator items =
  -                mBServer.queryNames(new ObjectName(pattern), null).iterator();
  -            while (items.hasNext()) {
  -                list.add(items.next().toString());
  -            }
  +            //Iterator items =
  +            //    mBServer.queryNames(new ObjectName(pattern), null).iterator();
  +            //while (items.hasNext()) {
  +            //    list.add(items.next().toString());
  +            //}
  +            list = Lists.getContexts(mBServer, poname);
           } catch (Exception e) {
               getServlet().log
                   (resources.getMessage(locale, "users.error.select"));
  @@ -199,7 +208,10 @@
           }
           Collections.sort(list);
           request.setAttribute("contextsList", list);
  -        
  +        request.setAttribute("hostName", parent);
  +        String host = poname.getKeyProperty("host");
  +        request.setAttribute("host",host);
  +             
           // Forward to the list display page
           return (mapping.findForward("Contexts"));
   
  
  
  
  1.2       +8 -5      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/DeleteContextsAction.java
  
  Index: DeleteContextsAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/DeleteContextsAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeleteContextsAction.java	23 Mar 2002 23:16:57 -0000	1.1
  +++ DeleteContextsAction.java	11 Mar 2003 03:26:19 -0000	1.2
  @@ -104,6 +104,7 @@
        */
       private String removeContextTypes[] =
       { "java.lang.String",      // Object name
  +      "java.lang.String"       // Parent object name 
       };
   
   
  @@ -161,7 +162,8 @@
           
           // Delete the specified Contexts
           String contexts[]  = ((ContextsForm) form).getContexts();
  -        String values[] = new String[1];
  +        String pname = ((ContextsForm) form).getHostName();
  +        String values[] = new String[2];
           String operation = "removeContext";
   
           try {
  @@ -173,6 +175,7 @@
               TreeControl control = (TreeControl)
                   session.getAttribute("treeControlTest");
   
  +            values[1] = pname;
               // Remove the specified contexts
               for (int i = 0; i < contexts.length; i++) {
                   values[0] = contexts[i];
  
  
  
  1.3       +27 -11    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/EditContextAction.java
  
  Index: EditContextAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/EditContextAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EditContextAction.java	5 Sep 2002 01:56:39 -0000	1.2
  +++ EditContextAction.java	11 Mar 2003 03:26:19 -0000	1.3
  @@ -147,9 +147,12 @@
               ("Cannot acquire MBeanServer reference", t);
           }
           
  +                
           // Set up the object names of the MBeans we are manipulating
           // Context mBean
           ObjectName cname = null;
  +        // Parent Host mBean
  +        ObjectName hname = null;        
           // Loader mBean
           ObjectName lname = null;
           // Manager mBean 
  @@ -166,17 +169,30 @@
               response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
               return (null);
           }
  +        try {
  +            hname = new ObjectName(request.getParameter("hostName"));
  +        } catch (Exception e) {
  +            String message =
  +                resources.getMessage("error.hostName.bad",
  +                                     request.getParameter("hostName"));
  +            getServlet().log(message);
  +            response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
  +            return (null);
  +        }
  +        
  +        String name = cname.getKeyProperty("name");
  +        String path = name.substring(name.lastIndexOf('/'));
           
           // Get the corresponding loader
           try {
               sb = new StringBuffer(cname.getDomain());
               sb.append(":type=Loader");
               sb.append(",path=");
  -            sb.append(cname.getKeyProperty("path"));
  +            sb.append(path);
               sb.append(",host=");
  -            sb.append(cname.getKeyProperty("host"));
  +            sb.append(hname.getKeyProperty("host"));
               sb.append(",service=");
  -            sb.append(cname.getKeyProperty("service"));
  +            sb.append(hname.getKeyProperty("service"));
               lname = new ObjectName(sb.toString());
            } catch (Exception e) {
               String message =
  @@ -193,11 +209,11 @@
               sb = new StringBuffer(cname.getDomain());
               sb.append(":type=Manager");
               sb.append(",path=");
  -            sb.append(cname.getKeyProperty("path"));
  +            sb.append(path);
               sb.append(",host=");
  -            sb.append(cname.getKeyProperty("host"));
  +            sb.append(hname.getKeyProperty("host"));
               sb.append(",service=");
  -            sb.append(cname.getKeyProperty("service"));
  +            sb.append(hname.getKeyProperty("service"));
               mname = new ObjectName(sb.toString());
           } catch (Exception e) {
               String message =
  @@ -216,7 +232,7 @@
           contextFm.setLoaderObjectName(lname.toString());
           contextFm.setManagerObjectName(mname.toString());
           sb = new StringBuffer("Context (");
  -        sb.append(cname.getKeyProperty("path"));
  +        sb.append(path);
           sb.append(")");
           contextFm.setNodeLabel(sb.toString());
           contextFm.setDebugLvlVals(Lists.getDebugLevels());
  
  
  
  1.9       +27 -20    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SaveContextAction.java
  
  Index: SaveContextAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SaveContextAction.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SaveContextAction.java	18 Sep 2002 19:15:51 -0000	1.8
  +++ SaveContextAction.java	11 Mar 2003 03:26:19 -0000	1.9
  @@ -201,11 +201,19 @@
                   ObjectName honame = new ObjectName(parentName);
                   
                   // Ensure that the requested context name is unique
  -                ObjectName oname =
  -                    new ObjectName(TomcatTreeBuilder.CONTEXT_TYPE +
  -                                   ",path=" + cform.getPath() +
  -                                   ",host=" + honame.getKeyProperty("host") +
  -                                   ",service=" + honame.getKeyProperty("service"));
  +                String path = cform.getPath();
  +                String hostName = honame.getKeyProperty("host");
  +                String localName= "//" +
  +                    ((hostName==null)? "DEFAULT" : hostName) + path;
  +                ObjectName oname = new ObjectName(TomcatTreeBuilder.DOMAIN + 
  +                                                ":j2eeType=WebModule,name=" +
  +                                                localName + 
  +                                                ",J2EEApplication=none,J2EEServer=none");
  +                //ObjectName oname =
  +                //    new ObjectName(TomcatTreeBuilder.CONTEXT_TYPE +
  +                //                   ",path=" + cform.getPath() +
  +                //                   ",host=" + honame.getKeyProperty("host") +
  +                //                   ",service=" + honame.getKeyProperty("service"));
                   
                   if (mBServer.isRegistered(oname)) {
                       ActionErrors errors = new ActionErrors();
  @@ -250,7 +258,7 @@
                                       values, createStandardManagerTypes);
                   
                   // Add the new Context to our tree control node
  -                addToTreeControlNode(oname, cObjectName, parentName, 
  +                addToTreeControlNode(oname, cObjectName, parentName, path, 
                                       resources, session);
   
               } catch (Exception e) {
  @@ -456,15 +464,16 @@
        *  messages
        */
       public void addToTreeControlNode(ObjectName oname, String containerName, 
  -                                    String parentName, MessageResources resources, 
  -                                    HttpSession session) 
  +                                    String parentName, String path,
  +                                    MessageResources resources, HttpSession session) 
           throws Exception {
                                 
           TreeControl control = (TreeControl) session.getAttribute("treeControlTest");
           if (control != null) {
               TreeControlNode parentNode = control.findNode(parentName);
  +            ObjectName pname = new ObjectName(parentName);
               if (parentNode != null) {
  -                String path = oname.getKeyProperty("path");
  +                //String path = oname.getKeyProperty("path");
                   String nodeLabel = "Context (" + path + ")";
                   String encodedName = URLEncoder.encode(oname.toString());
                   TreeControlNode childNode = 
  @@ -472,23 +481,21 @@
                                           "Context.gif",
                                           nodeLabel,
                                           "EditContext.do?select=" +
  -                                        encodedName,
  +                                        encodedName + "&hostName=" +
  +                                        URLEncoder.encode(parentName),
                                           "content",
                                           true);
                   parentNode.addChild(childNode);
                   // FIXME - force a redisplay
  -                String type = oname.getKeyProperty("type");
  -                if (type == null) {
  -                    type = "";
  -                }
  +                String type = "Context";
                   if (path == null) {
                       path = "";
                   }        
  -                String host = oname.getKeyProperty("host");
  +                String host = pname.getKeyProperty("host");
                   if (host == null) {
                       host = "";
                   }        
  -                String service = oname.getKeyProperty("service");
  +                String service = pname.getKeyProperty("service");
                   TreeControlNode subtree = new TreeControlNode
                       ("Context Resource Administration " + containerName,
                       "folder_16_pad.gif",
  
  
  
  1.9       +8 -3      jakarta-tomcat-4.0/webapps/admin/context/contexts.jsp
  
  Index: contexts.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/context/contexts.jsp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- contexts.jsp	15 Jan 2003 22:25:19 -0000	1.8
  +++ contexts.jsp	11 Mar 2003 03:26:19 -0000	1.9
  @@ -18,6 +18,8 @@
   
   <html:form method="post" action="/DeleteContexts">
   
  +  <html:hidden property="hostName"/>
  +  
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
       <tr bgcolor="7171A5">
         <td width="81%">
  @@ -65,10 +67,12 @@
             <tr class="line-row">
               <td><div align="left" class="table-normal-text">&nbsp;
                 <%-- admin context cannot be deleted from the tool --%>
  -              <logic:match name="context" value='<%= "path="+request.getContextPath()+"," %>'>
  +              <logic:match name="context" value='<%= "name=//"+request.getAttribute("host")+
  +                                                    request.getContextPath()+"," %>'>
                   <font color='red'>*</font>
                 </logic:match>
  -              <logic:notMatch name="context" value='<%= "path="+request.getContextPath()+"," %>'>
  +              <logic:notMatch name="context" value='<%= "name=//"+request.getAttribute("host")+
  +                                                    request.getContextPath()+"," %>'>
                 <label for="contexts"></label>
                 <html:multibox property="contexts"
                                   value="<%= context.toString() %>" styleId="contexts"/>
  @@ -76,7 +80,8 @@
               </div></td>
               <td><div align="left" class="table-normal-text">&nbsp;
                 <html:link page='<%= "/EditContext.do?select=" +
  -                         java.net.URLEncoder.encode(context.toString()) %>'>
  +                         java.net.URLEncoder.encode(context.toString()) +
  +                         "&hostName=" + request.getAttribute("hostName") %>'>
                   <controls:attribute name="context" attribute="path"/>
                 </html:link>
               </div></td>
  
  
  

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