Index: lams_admin/conf/language/ApplicationResources.properties
===================================================================
diff -u -rc88ccc1422ccad2cc0f9d95bc5edae4eb92e5560 -r36e114e125b1ce88588f7b9c03121ea56c491015
--- lams_admin/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision c88ccc1422ccad2cc0f9d95bc5edae4eb92e5560)
+++ lams_admin/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 36e114e125b1ce88588f7b9c03121ea56c491015)
@@ -167,3 +167,8 @@
cache.explanation2=Warning: Removing nodes will reduce the performance of the LAMS server. After a while, the cache will build up again and LAMS will run as usual.
cache.explanation3=Warning: If you remove a node, you will remove the node and all its child nodes.
cache.button.remove=Remove
+
+#==================== Configuration Screen ========================#
+admin.config.key=Key
+admin.config.value=Value
+admin.config.edit=Edit Configuration
Index: lams_admin/conf/xdoclet/struts-forms.xml
===================================================================
diff -u -rbc3bb1a439e4ae77a6ae5c2f072e3d0a03426596 -r36e114e125b1ce88588f7b9c03121ea56c491015
--- lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision bc3bb1a439e4ae77a6ae5c2f072e3d0a03426596)
+++ lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 36e114e125b1ce88588f7b9c03121ea56c491015)
@@ -75,4 +75,10 @@
+
+
+
+
+
+
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java (revision 36e114e125b1ce88588f7b9c03121ea56c491015)
@@ -0,0 +1,102 @@
+/****************************************************************
+ * Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * ConfigAction
+ *
+ * @author Mitchell Seaton
+ */
+/**
+ * struts doclets
+ *
+ * @struts.action path="/config" parameter="method" name="ConfigForm" input=".config" scope="request" validate="false"
+ * @struts.action-forward name="config" path=".config"
+ * @struts.action-forward name="sysadmin" path=".sysadmin"
+ */
+public class ConfigAction extends LamsDispatchAction {
+
+ private static Configuration configurationService;
+
+ private Configuration getConfiguration() {
+ if (configurationService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ configurationService = (Configuration) ctx.getBean("configurationService");
+
+ }
+ return configurationService;
+ }
+
+ public ActionForward unspecified(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws Exception{
+
+ request.setAttribute("config", Configuration.getAll());
+
+ return mapping.findForward("config");
+ }
+
+ public ActionForward save(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws Exception{
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
+ }
+
+ DynaActionForm configForm = (DynaActionForm) form;
+ String[] keys = (String[])configForm.get("cKey");
+ String[] values = (String[])configForm.get("cValue");
+
+ for(int i=0; i
+
@@ -33,6 +37,12 @@
+
+
+
+
+
+
@@ -47,14 +57,14 @@
+
-
@@ -63,14 +73,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -103,14 +146,17 @@
/>
@@ -127,6 +173,157 @@
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lams_admin/web/config/editconfig.jsp
===================================================================
diff -u
--- lams_admin/web/config/editconfig.jsp (revision 0)
+++ lams_admin/web/config/editconfig.jsp (revision 36e114e125b1ce88588f7b9c03121ea56c491015)
@@ -0,0 +1,38 @@
+<%@ page contentType="text/html; charset=utf-8" language="java" %>
+<%@ taglib uri="tags-html" prefix="html" %>
+<%@ taglib uri="tags-logic" prefix="logic" %>
+<%@ taglib uri="tags-core" prefix="c" %>
+<%@ taglib uri="tags-fmt" prefix="fmt" %>
+<%@ taglib uri="tags-lams" prefix="lams" %>
+
+
+
+
+ :
+
+
+
+
+
+ |
+ |
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lams_admin/web/sysadmin.jsp
===================================================================
diff -u -r4bffd066ba691f65f52272bb5c8e484195d2d9fe -r36e114e125b1ce88588f7b9c03121ea56c491015
--- lams_admin/web/sysadmin.jsp (.../sysadmin.jsp) (revision 4bffd066ba691f65f52272bb5c8e484195d2d9fe)
+++ lams_admin/web/sysadmin.jsp (.../sysadmin.jsp) (revision 36e114e125b1ce88588f7b9c03121ea56c491015)
@@ -11,7 +11,7 @@
-
+
Index: lams_build/lib/lams/lams.jar
===================================================================
diff -u -r7050d6d6c85aa9a65dd36777521038291cd871c2 -r36e114e125b1ce88588f7b9c03121ea56c491015
Binary files differ
Index: lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java
===================================================================
diff -u -r080d04eb033f76179ece18d8bd3ac466899f29e5 -r36e114e125b1ce88588f7b9c03121ea56c491015
--- lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java (.../Configuration.java) (revision 080d04eb033f76179ece18d8bd3ac466899f29e5)
+++ lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java (.../Configuration.java) (revision 36e114e125b1ce88588f7b9c03121ea56c491015)
@@ -24,6 +24,7 @@
package org.lamsfoundation.lams.util;
import java.util.Collections;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -61,12 +62,6 @@
this.configurationDAO = configurationDAO;
}
- /**
- * This class initialize method called by Spring framework.
- */
- public void init(){
-
- }
public void afterPropertiesSet() {
if(items != null) {
@@ -76,13 +71,13 @@
Map itemsmap = Collections.synchronizedMap(new HashMap());
try {
- List mapitems = configurationDAO.getAllItems();
-
+ List mapitems = getAllItems();
+
if(mapitems.size() > 0) {
Iterator it = mapitems.iterator();
while(it.hasNext()) {
ConfigurationItem item = (ConfigurationItem) it.next();
- itemsmap.put(item.getKey(), item.getValue());
+ itemsmap.put(item.getKey(), item);
}
}
@@ -93,30 +88,60 @@
}
}
+ public List getAllItems() {
+ return configurationDAO.getAllItems();
+ }
+
+ public static Map getAll() {
+ return items;
+ }
+
+ public static String getItemValue(Object obj) {
+ ConfigurationItem item = (ConfigurationItem) obj;
+ if(item.getValue() != null)
+ return item.getValue();
+ return null;
+ }
+
+ public static void setItemValue(Object obj, String value) {
+ ConfigurationItem item = (ConfigurationItem) obj;
+ item.setValue(value);
+ }
+
public static String get(String key)
{
if ((items != null)&&(items.get(key)!=null))
- return (String) items.get(key);
+ if(getItemValue(items.get(key)) != null)
+ return getItemValue(items.get(key));
return null;
}
public static int getAsInt(String key)
{
if ((items != null)&&(items.get(key)!=null))
//could throw NumberFormatException which is a RuntimeException
- return new Integer((String)items.get(key)).intValue();
+ if(getItemValue(items.get(key)) != null)
+ return new Integer(getItemValue(items.get(key))).intValue();
return -1;
}
public static boolean getAsBoolean(String key)
{
if((items != null)&&(items.get(key)!=null))
- {
- return new Boolean((String)items.get(key)).booleanValue();
- }
+ if(getItemValue(items.get(key)) != null)
+ return new Boolean(getItemValue(items.get(key))).booleanValue();
return false;
}
+ public static void updateItem(String key, String value) {
+ if(items.containsKey(key))
+ setItemValue(items.get(key), value);
+ }
+
+ public void persistUpdate() {
+ configurationDAO.insertOrUpdateAll(items.values());
+ }
+
public String toString()
{
return "Configuration items:"