KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > context > AddContextAction


1 /*
2  * Copyright 2001-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.webapp.admin.context;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Locale JavaDoc;
21 import javax.servlet.ServletException JavaDoc;
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24 import javax.servlet.http.HttpSession JavaDoc;
25 import org.apache.struts.action.Action;
26 import org.apache.struts.action.ActionForm;
27 import org.apache.struts.action.ActionForward;
28 import org.apache.struts.action.ActionMapping;
29 import org.apache.struts.util.MessageResources;
30 import org.apache.webapp.admin.Lists;
31 import org.apache.webapp.admin.TomcatTreeBuilder;
32 /**
33  * The <code>Action</code> that sets up <em>Add Context</em> transactions.
34  *
35  * @author Manveen Kaur
36  * @version $Revision: 1.9 $ $Date: 2005/01/14 23:55:41 $
37  */

38
39 public class AddContextAction extends Action {
40     
41     // --------------------------------------------------------- Public Methods
42

43     /**
44      * Process the specified HTTP request, and create the corresponding HTTP
45      * response (or forward to another web component that will create it).
46      * Return an <code>ActionForward</code> instance describing where and how
47      * control should be forwarded, or <code>null</code> if the response has
48      * already been completed.
49      *
50      * @param mapping The ActionMapping used to select this instance
51      * @param actionForm The optional ActionForm bean for this request (if any)
52      * @param request The HTTP request we are processing
53      * @param response The HTTP response we are creating
54      *
55      * @exception IOException if an input/output error occurs
56      * @exception ServletException if a servlet exception occurs
57      */

58     public ActionForward execute(ActionMapping mapping,
59     ActionForm form,
60     HttpServletRequest JavaDoc request,
61     HttpServletResponse JavaDoc response)
62     throws IOException JavaDoc, ServletException JavaDoc {
63         
64         // Acquire the resources that we need
65
HttpSession JavaDoc session = request.getSession();
66         Locale JavaDoc locale = getLocale(request);
67         MessageResources resources = getResources(request);
68         
69         // Fill in the form values for display and editing
70
ContextForm contextFm = new ContextForm();
71         session.setAttribute("contextForm", contextFm);
72         contextFm.setAdminAction("Create");
73         contextFm.setObjectName("");
74         String JavaDoc parent = request.getParameter("parent");
75         contextFm.setParentObjectName(parent);
76         int i = parent.indexOf(":");
77         String JavaDoc domain = parent.substring(0, i);
78         int position = parent.indexOf(",");
79         String JavaDoc loader = domain + TomcatTreeBuilder.LOADER_TYPE +
80                 parent.substring(position, parent.length());
81         String JavaDoc manager = domain + TomcatTreeBuilder.MANAGER_TYPE +
82                 parent.substring(position, parent.length());
83         contextFm.setLoaderObjectName(loader);
84         contextFm.setManagerObjectName(manager);
85         contextFm.setNodeLabel("");
86         contextFm.setCookies("");
87         contextFm.setCrossContext("false");
88         contextFm.setDocBase("");
89         contextFm.setOverride("false");
90         contextFm.setPrivileged("false");
91         contextFm.setPath("");
92         contextFm.setReloadable("false");
93         contextFm.setSwallowOutput("false");
94         contextFm.setUseNaming("false");
95         contextFm.setWorkDir("");
96         contextFm.setPath("");
97         //loader initialization
98
//contextFm.setLdrCheckInterval("15");
99
contextFm.setLdrReloadable("false");
100         //manager initialization
101
//contextFm.setMgrCheckInterval("60");
102
contextFm.setMgrMaxSessions("-1");
103         contextFm.setMgrSessionIDInit("");
104         
105         contextFm.setBooleanVals(Lists.getBooleanValues());
106         
107         // Forward to the context display page
108
return (mapping.findForward("Context"));
109         
110     }
111 }
112
Popular Tags