KickJava   Java API By Example, From Geeks To Geeks.

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


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.webui.forms.ApplicationForm;
24 import org.jmanage.core.config.*;
25 import org.jmanage.core.services.AccessController;
26 import org.apache.struts.action.ActionForward;
27 import org.apache.struts.action.ActionMapping;
28 import org.apache.struts.action.ActionForm;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32 import java.util.Map JavaDoc;
33
34 /**
35  *
36  * date: Jun 25, 2004
37  * @author Rakesh Kalra, Shashank Bellary
38  */

39 public class ShowEditApplicationAction extends BaseAction {
40
41     /**
42      * Gets the application for given application id and sets it on request.
43      *
44      * @param mapping
45      * @param actionForm
46      * @param request
47      * @param response
48      * @return
49      */

50     public ActionForward execute(WebContext context,
51                                  ActionMapping mapping,
52                                  ActionForm actionForm,
53                                  HttpServletRequest JavaDoc request,
54                                  HttpServletResponse JavaDoc response)
55             throws Exception JavaDoc{
56         AccessController.checkAccess(context.getServiceContext(),
57                 ACL_EDIT_APPLICATIONS);
58         ApplicationConfig config = context.getApplicationConfig();
59         ApplicationForm appForm = (ApplicationForm)actionForm;
60         ApplicationType appType = config.getApplicationType();
61         MetaApplicationConfig metaAppConfig =
62                 appType.getModule().getMetaApplicationConfig();
63
64         /* populate the form */
65         appForm.setApplicationId(config.getApplicationId());
66         appForm.setName(config.getName());
67         appForm.setType(config.getType());
68         if(metaAppConfig.isDisplayHost())
69             appForm.setHost(config.getHost());
70         if(metaAppConfig.isDisplayPort())
71             appForm.setPort(String.valueOf(config.getPort()));
72         if(metaAppConfig.isDisplayURL())
73             appForm.setURL(config.getURL());
74         if(metaAppConfig.isDisplayUsername())
75             appForm.setUsername(config.getUsername());
76         if(metaAppConfig.isDisplayPassword() && config.getPassword() != null
77                 && config.getPassword().length()>0)
78             appForm.setPassword(ApplicationForm.FORM_PASSWORD);
79
80         // for jsr160
81
Map JavaDoc paramValues = config.getParamValues();
82         appForm.setJndiFactory((String JavaDoc)paramValues.get(ApplicationConfig.JNDI_FACTORY));
83         appForm.setJndiURL((String JavaDoc)paramValues.get(ApplicationConfig.JNDI_URL));
84
85         request.setAttribute(RequestAttributes.META_APP_CONFIG, metaAppConfig);
86
87         /*set current page for navigation*/
88         request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Edit Application");
89
90         return mapping.findForward(Forwards.SUCCESS);
91     }
92 }
93
Popular Tags