KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > webui > actions > config > ShowAddApplicationAction


1 /**
2  * Copyright 2004-2005 jManage.org
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 package org.jmanage.webui.actions.config;
17
18 import org.jmanage.webui.actions.BaseAction;
19 import org.jmanage.webui.util.WebContext;
20 import org.jmanage.webui.util.Forwards;
21 import org.jmanage.webui.util.RequestAttributes;
22 import org.jmanage.webui.forms.ApplicationForm;
23 import org.jmanage.core.services.AccessController;
24 import org.jmanage.core.config.*;
25 import org.apache.struts.action.ActionForward;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.action.ActionForm;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32 /**
33  * This action class creates MetaApplicationConfig instance based on the type of
34  * application being added and sets in the request to make the ApplicationForm
35  * dynamic.
36  *
37  * Date: Nov 3, 2004 12:46:00 AM
38  * @author Shashank Bellary
39  */

40 public class ShowAddApplicationAction extends BaseAction {
41     /**
42      *
43      * @param context
44      * @param mapping
45      * @param actionForm
46      * @param request
47      * @param response
48      * @return
49      * @throws Exception
50      */

51     public ActionForward execute(WebContext context,
52                                  ActionMapping mapping,
53                                  ActionForm actionForm,
54                                  HttpServletRequest JavaDoc request,
55                                  HttpServletResponse JavaDoc response)
56             throws Exception JavaDoc {
57         AccessController.checkAccess(context.getServiceContext(),
58                 ACL_ADD_APPLICATIONS);
59         ApplicationForm appForm = (ApplicationForm)actionForm;
60         ApplicationType appType =
61                 ApplicationTypes.getApplicationType(appForm.getType());
62         assert appType != null: "Invalid app type: " + appForm.getType();
63         ModuleConfig moduleConfig = appType.getModule();
64         MetaApplicationConfig metaAppConfig = moduleConfig.getMetaApplicationConfig();
65         request.setAttribute(RequestAttributes.META_APP_CONFIG, metaAppConfig);
66
67         appForm.setHost(appType.getDefaultHost());
68         appForm.setPort(appType.getDefaultPort());
69         appForm.setURL(appType.getDefaultURL());
70
71         /*set current page for navigation*/
72         request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Add Application");
73         return mapping.findForward(Forwards.SUCCESS);
74     }
75 }
76
Popular Tags