1 25 26 package org.objectweb.jonas.webapp.jonasadmin.resource; 27 28 import java.io.IOException ; 29 import java.util.Properties ; 30 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionForward; 37 import org.apache.struts.action.ActionMapping; 38 import org.objectweb.jonas.jmx.JonasManagementRepr; 39 import org.objectweb.jonas.jmx.JonasObjectName; 40 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 41 42 45 46 public class EditDatasourcePropertiesAction extends JonasBaseAction { 47 48 50 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 51 , HttpServletRequest p_Request, HttpServletResponse p_Response) 52 throws IOException , ServletException { 53 54 String sAction = p_Request.getParameter("action"); 56 if (sAction == null) { 57 sAction ="edit"; 58 } 59 String sName = p_Request.getParameter("name"); 61 62 DatasourcePropertiesForm oForm = null; 63 oForm = new DatasourcePropertiesForm(); 64 m_Session.setAttribute("datasourcePropertiesForm", oForm); 65 oForm.reset(p_Mapping, p_Request); 66 oForm.setAction(sAction); 67 68 if (sName != null) { 70 try { 71 populate(sName, oForm); 72 } 73 catch (Throwable t) { 74 addGlobalError(t); 75 saveErrors(p_Request, m_Errors); 76 return (p_Mapping.findForward("Global Error")); 77 } 78 } 79 return (p_Mapping.findForward("Datasource Properties")); 81 } 82 83 85 protected void populate(String p_Name, DatasourcePropertiesForm p_Form) 86 throws Exception { 87 88 String [] asParam = new String [1]; 89 String [] asSignature = new String [1]; 90 asParam[0] = p_Name; 91 asSignature[0] = "java.lang.String"; 92 93 Properties oProps = (Properties ) JonasManagementRepr.invoke(JonasObjectName.databaseService() 94 , "getDataSourcePropertiesFile", asParam, asSignature); 95 p_Form.setName(p_Name); 97 p_Form.setDatasourceName(getStringAttribute(oProps, "datasource.name" 98 , p_Form.getDatasourceName())); 99 p_Form.setDatasourceDescription(getStringAttribute(oProps, "datasource.description" 100 , p_Form.getDatasourceDescription())); 101 p_Form.setDatasourceUrl(getStringAttribute(oProps, "datasource.url" 102 , p_Form.getDatasourceUrl())); 103 p_Form.setDatasourceClassname(getStringAttribute(oProps, "datasource.classname" 104 , p_Form.getDatasourceClassname())); 105 p_Form.setDatasourceUsername(getStringAttribute(oProps, "datasource.username" 106 , p_Form.getDatasourceUsername())); 107 p_Form.setDatasourcePassword(getStringAttribute(oProps, "datasource.password" 108 , p_Form.getDatasourcePassword())); 109 p_Form.setDatasourceMapper(getStringAttribute(oProps, "datasource.mapper" 110 , p_Form.getDatasourceMapper())); 111 p_Form.setJdbcConnmaxage(getStringAttribute(oProps, "jdbc.connmaxage" 112 , p_Form.getJdbcConnmaxage())); 113 p_Form.setJdbcMaxopentime(getStringAttribute(oProps, "jdbc.maxopentime" 114 , p_Form.getJdbcMaxopentime())); 115 p_Form.setJdbcConnchecklevel(getStringAttribute(oProps, "jdbc.connchecklevel" 116 , p_Form.getJdbcConnchecklevel())); 117 p_Form.setJdbcConnteststmt(getStringAttribute(oProps, "jdbc.connteststmt" 118 , p_Form.getJdbcConnteststmt())); 119 p_Form.setJdbcMinconpool(getStringAttribute(oProps, "jdbc.minconpool" 120 , p_Form.getJdbcMinconpool())); 121 p_Form.setJdbcMaxconpool(getStringAttribute(oProps, "jdbc.maxconpool" 122 , p_Form.getJdbcMaxconpool())); 123 p_Form.setJdbcMaxwaittime(getStringAttribute(oProps, "jdbc.maxwaittime" 124 , p_Form.getJdbcMaxwaittime())); 125 p_Form.setJdbcMaxwaiters(getStringAttribute(oProps, "jdbc.maxwaiters" 126 , p_Form.getJdbcMaxwaiters())); 127 p_Form.setJdbcSamplingperiod(getStringAttribute(oProps, "jdbc.samplingperiod" 128 , p_Form.getJdbcSamplingperiod())); 129 } 130 } 131 | Popular Tags |