KickJava   Java API By Example, From Geeks To Geeks.

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


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.Utils;
22 import org.jmanage.webui.forms.ApplicationForm;
23 import org.jmanage.core.util.CoreUtils;
24 import org.jmanage.core.data.ApplicationConfigData;
25 import org.jmanage.core.services.ConfigurationService;
26 import org.jmanage.core.services.ServiceFactory;
27 import org.jmanage.core.config.ApplicationConfig;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionMapping;
30 import org.apache.struts.action.ActionForward;
31
32 import javax.servlet.http.HttpServletResponse JavaDoc;
33 import javax.servlet.http.HttpServletRequest JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.util.HashMap JavaDoc;
36
37 /**
38  *
39  * date: Jun 25, 2004
40  * @author Rakesh Kalra
41  */

42 public class AddApplicationAction extends BaseAction {
43
44     /**
45      * Add a new application
46      *
47      * @param mapping
48      * @param actionForm
49      * @param request
50      * @param response
51      * @return
52      */

53     public ActionForward execute(WebContext context,
54                                  ActionMapping mapping,
55                                  ActionForm actionForm,
56                                  HttpServletRequest JavaDoc request,
57                                  HttpServletResponse JavaDoc response)
58             throws Exception JavaDoc{
59         ApplicationForm appForm = (ApplicationForm)actionForm;
60
61         /* create ApplicationConfigData from this form */
62         ApplicationConfigData appConfigData = new ApplicationConfigData();
63         CoreUtils.copyProperties(appConfigData, appForm);
64         Map JavaDoc paramValues = new HashMap JavaDoc();
65         if(appForm.getJndiFactory() != null)
66             paramValues.put(ApplicationConfig.JNDI_FACTORY, appForm.getJndiFactory());
67         if(appForm.getJndiURL() != null)
68             paramValues.put(ApplicationConfig.JNDI_URL, appForm.getJndiURL());
69         appConfigData.setParamValues(paramValues);
70
71         ConfigurationService service = ServiceFactory.getConfigurationService();
72
73         service.addApplication(Utils.getServiceContext(context), appConfigData);
74
75         return mapping.findForward(Forwards.SUCCESS);
76     }
77 }
78
Popular Tags