amyroh      2002/09/12 18:35:35

  Modified:    webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        Lists.java TomcatTreeBuilder.java
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context
                        SaveContextAction.java
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin/defaultcontext
                        SaveDefaultContextAction.java
  Log:
  Add NamingResource handling for DefaultContext.
  
  Revision  Changes    Path
  1.12      +24 -18    
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Lists.java        11 Sep 2002 14:20:00 -0000      1.11
  +++ Lists.java        13 Sep 2002 01:35:34 -0000      1.12
  @@ -259,10 +259,9 @@
        * @exception Exception if thrown while retrieving the list
        */
       public static List getDefaultContexts(MBeanServer mbserver, String 
  -        container, String containerType) throws Exception {
  +        container) throws Exception {
   
  -        return (getDefaultContexts(mbserver, new ObjectName(container), 
  -            containerType));
  +        return (getDefaultContexts(mbserver, new ObjectName(container)));
   
       }
       
  @@ -280,19 +279,26 @@
        * @exception Exception if thrown while retrieving the list
        */
       public static List getDefaultContexts(MBeanServer mbserver, ObjectName 
  -        container, String containerType) throws Exception {
  -
  +        container) throws Exception {
  +        
           StringBuffer sb = new StringBuffer(container.getDomain());
  -        if (containerType.equals("service")) {
  -            sb.append(":type=DefaultContext,service=");
  -            sb.append(container.getKeyProperty("name"));
  -            sb.append(",*");
  -        } else if (containerType.equals("host")) {
  -            sb.append(":type=DefaultContext,host=");
  -            sb.append(container.getKeyProperty("host"));
  +        sb.append(":type=DefaultContext");
  +        String type = container.getKeyProperty("type");
  +        String host = container.getKeyProperty("host");
  +        if ("Host".equals(type)) {
  +            host = container.getKeyProperty("host");
  +        }
  +        if (host != null) {
  +            sb.append(",host=");
  +            sb.append(host);
  +        }
  +        String service = container.getKeyProperty("service");
  +        if ("Service".equals(type)) {
  +            service = container.getKeyProperty("name");
  +        }
  +        if (service != null) {
               sb.append(",service=");
  -            sb.append(container.getKeyProperty("service"));
  -            sb.append(",*");
  +            sb.append(service);
           }
           ObjectName search = new ObjectName(sb.toString());
           ArrayList defaultContexts = new ArrayList();
  
  
  
  1.36      +8 -10     
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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- TomcatTreeBuilder.java    11 Sep 2002 14:20:00 -0000      1.35
  +++ TomcatTreeBuilder.java    13 Sep 2002 01:35:34 -0000      1.36
  @@ -215,7 +215,7 @@
                                       false);
               serverNode.addChild(serviceNode);
               getConnectors(serviceNode, serviceName);
  -            getDefaultContexts(serviceNode, serviceName, "service", resources);
  +            getDefaultContexts(serviceNode, serviceName, resources);
               getHosts(serviceNode, serviceName, resources);
               getLoggers(serviceNode, serviceName);
               getRealms(serviceNode, serviceName);
  @@ -290,7 +290,7 @@
                                       false);
               serviceNode.addChild(hostNode);
               getContexts(hostNode, hostName, resources);            
  -            getDefaultContexts(hostNode, hostName, "host", resources);
  +            getDefaultContexts(hostNode, hostName, resources);
               getLoggers(hostNode, hostName);
               getRealms(hostNode, hostName);
               getValves(hostNode, hostName);
  @@ -350,12 +350,10 @@
        * @exception Exception if an exception occurs building the tree
        */
       public void getDefaultContexts(TreeControlNode hostNode, String containerName, 
  -                        String containerType, MessageResources resources) 
  -                        throws Exception {
  +                                    MessageResources resources) throws Exception {
           
           Iterator defaultContextNames =
  -            Lists.getDefaultContexts(mBServer, containerName, 
  -                containerType).iterator();
  +            Lists.getDefaultContexts(mBServer, containerName).iterator();
           while (defaultContextNames.hasNext()) {
               String defaultContextName = (String) defaultContextNames.next();
               ObjectName objectName = new ObjectName(defaultContextName);
  
  
  
  1.6       +7 -6      
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SaveContextAction.java    5 Sep 2002 01:56:39 -0000       1.5
  +++ SaveContextAction.java    13 Sep 2002 01:35:34 -0000      1.6
  @@ -224,12 +224,13 @@
                   values[0] = parentName;
                   values[1] = cform.getPath();
                   values[2] = cform.getDocBase();
  +
  +                operation = "createStandardContext";    
                   
  -                operation = "createStandardContext";
                   cObjectName = (String)
                       mBServer.invoke(fname, operation,
                                       values, createStandardContextTypes);
  -
  +                
                   // Create a new Loader object
                   values = new String[1];
                   // parent of loader is the newly created context
  
  
  
  1.2       +118 -31   
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/defaultcontext/SaveDefaultContextAction.java
  
  Index: SaveDefaultContextAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/defaultcontext/SaveDefaultContextAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SaveDefaultContextAction.java     11 Sep 2002 14:20:00 -0000      1.1
  +++ SaveDefaultContextAction.java     13 Sep 2002 01:35:35 -0000      1.2
  @@ -247,33 +247,8 @@
                   //                    values, createStandardManagerTypes);
                   
                   // Add the new Default Context to our tree control node
  -                TreeControl control = (TreeControl)
  -                    session.getAttribute("treeControlTest");
  -                if (control != null) {
  -                    TreeControlNode parentNode = control.findNode(parentName);
  -                    if (parentNode != null) {
  -                        String nodeLabel =
  -                            "DefaultContext";
  -                        String encodedName =
  -                            URLEncoder.encode(cObjectName);
  -                        TreeControlNode childNode =
  -                            new TreeControlNode(cObjectName,
  -                                                "DefaultContext.gif",
  -                                                nodeLabel,
  -                                                "EditDefaultContext.do?select=" +
  -                                                encodedName,
  -                                                "content",
  -                                                true);
  -                        parentNode.addChild(childNode);
  -                        // FIXME - force a redisplay
  -                    } else {
  -                        getServlet().log
  -                            ("Cannot find parent node '" + parentName + "'");
  -                    }
  -                } else {
  -                    getServlet().log
  -                        ("Cannot find TreeControlNode!");
  -                }
  +                addToTreeControlNode(oname, "DefaultContext", 
  +                                    parentName, resources, session);
   
               } catch (Exception e) {
                   getServlet().log
  @@ -429,6 +404,118 @@
           session.removeAttribute(mapping.getAttribute());
           return (mapping.findForward("Save Successful"));
           
  +    }
  +    
  +    
  +    /**
  +     * Append nodes for any define resources for the specified Context.
  +     *
  +     * @param containerNode Container node for the tree control
  +     * @param containerName Object name of the parent container
  +     * @param resources The MessageResources for our localized messages
  +     *  messages
  +     */
  +    public void addToTreeControlNode(ObjectName oname, String containerName, 
  +                                    String parentName, MessageResources resources,
  +                                    HttpSession session) 
  +        throws Exception {
  +                              
  +        TreeControl control = (TreeControl) session.getAttribute("treeControlTest");
  +        if (control != null) {
  +            TreeControlNode parentNode = control.findNode(parentName);
  +            if (parentNode != null) {
  +                String nodeLabel = "DefaultContext";
  +                String encodedName = URLEncoder.encode(oname.toString());
  +                TreeControlNode childNode = 
  +                    new TreeControlNode(oname.toString(),
  +                                        "DefaultContext.gif",
  +                                        nodeLabel,
  +                                        "EditDefaultContext.do?select=" +
  +                                        encodedName,
  +                                        "content",
  +                                        true);
  +                parentNode.addChild(childNode);
  +                // FIXME - force a redisplay
  +                String type = oname.getKeyProperty("type");
  +                if (type == null) {
  +                    type = "";
  +                }
  +                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",
  +                    resources.getMessage("resources.treeBuilder.subtreeNode"),
  +                    null,
  +                    "content",
  +                    true);        
  +                childNode.addChild(subtree);
  +                TreeControlNode datasources = new TreeControlNode
  +                    ("Context Data Sources " + containerName,
  +                    "Datasource.gif",
  +                    resources.getMessage("resources.treeBuilder.datasources"),
  +                    "resources/listDataSources.do?resourcetype=" + 
  +                    URLEncoder.encode(type) + "&path=" +
  +                    URLEncoder.encode(path) + "&host=" + 
  +                    URLEncoder.encode(host) + "&service=" +
  +                    URLEncoder.encode(service) + "&forward=" +
  +                    URLEncoder.encode("DataSources List Setup"),
  +                    "content",
  +                    false);
  +                TreeControlNode mailsessions = new TreeControlNode
  +                    ("Context Mail Sessions " + containerName,
  +                    "Mailsession.gif",
  +                    resources.getMessage("resources.treeBuilder.mailsessions"),
  +                    "resources/listMailSessions.do?resourcetype=" + 
  +                    URLEncoder.encode(type) + "&path=" +
  +                    URLEncoder.encode(path) + "&host=" + 
  +                    URLEncoder.encode(host) + "&service=" +
  +                    URLEncoder.encode(service) + "&forward=" +
  +                    URLEncoder.encode("MailSessions List Setup"),
  +                    "content",
  +                    false);
  +                TreeControlNode resourcelinks = new TreeControlNode
  +                    ("Resource Links " + containerName,
  +                    "ResourceLink.gif",
  +                    resources.getMessage("resources.treeBuilder.resourcelinks"),
  +                    "resources/listResourceLinks.do?resourcetype=" + 
  +                    URLEncoder.encode(type) + "&path=" +
  +                    URLEncoder.encode(path) + "&host=" + 
  +                    URLEncoder.encode(host) + "&service=" +
  +                    URLEncoder.encode(service) + "&forward=" +
  +                    URLEncoder.encode("ResourceLinks List Setup"),
  +                    "content",
  +                    false);
  +                TreeControlNode envs = new TreeControlNode
  +                    ("Context Environment Entries "+ containerName,
  +                    "EnvironmentEntries.gif",
  +                    resources.getMessage("resources.env.entries"),
  +                    "resources/listEnvEntries.do?resourcetype=" + 
  +                    URLEncoder.encode(type) + "&path=" +
  +                    URLEncoder.encode(path) + "&host=" + 
  +                    URLEncoder.encode(host) + "&service=" +
  +                    URLEncoder.encode(service) + "&forward=" +
  +                    URLEncoder.encode("EnvEntries List Setup"),
  +                    "content",
  +                    false);
  +                subtree.addChild(datasources);
  +                subtree.addChild(mailsessions);
  +                subtree.addChild(resourcelinks);
  +                subtree.addChild(envs);                    
  +            } else {
  +                    getServlet().log
  +                        ("Cannot find parent node '" + parentName + "'");
  +            } 
  +        }else {
  +            getServlet().log("Cannot find TreeControlNode!");
  +        }                              
       }
       
   }
  
  
  

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

Reply via email to