From: <pka...@us...> - 2009-06-30 19:13:54
|
Revision: 282 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=282&view=rev Author: pkasprzak Date: 2009-06-30 19:13:00 +0000 (Tue, 30 Jun 2009) Log Message: ----------- * Fix: allow editing of settings with the same names (use better ids) * Cleanups Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-ejb/src/java/configuration.xml trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/src/java/de/campussource/cse/webconfig/EditConfigurationServlet.java trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/web/WEB-INF/web.xml Modified: trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-ejb/src/java/configuration.xml =================================================================== --- trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-ejb/src/java/configuration.xml 2009-06-30 11:40:17 UTC (rev 281) +++ trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-ejb/src/java/configuration.xml 2009-06-30 19:13:00 UTC (rev 282) @@ -14,6 +14,14 @@ <setting name="ilias_login_password" description="Passwort f\xFCr Login" default="cs3-1p"/> <setting name="ilias_ws_url" description="URL der WS-Schnittstelle" default="http://localhost/ilias3/webservice/soap/server.php?debug=1"/> </category> + + <category name="Ilias2" description="Ilias-Adapter Einstellungen"> + <setting name="ilias_login_client" description="Ident des Clients" default="test"/> + <setting name="ilias_login_username" description="Username f\xFCr Login" default="root"/> + <setting name="ilias_login_password" description="Passwort f\xFCr Login" default="cs3-1p"/> + <setting name="ilias_ws_url" description="URL der WS-Schnittstelle" default="http://localhost/ilias3/webservice/soap/server.php?debug=1"/> + </category> + <!-- <category public="false" name="csecore" description="Grundlegende CSE Systemeinstellungen"> <setting name="CSE_Health_Komponente_Aktiv" description="Nutzung der Health Komponente (automatische Behebung von Inkonsistenzen)" default="true" type="1"/> Modified: trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/src/java/de/campussource/cse/webconfig/EditConfigurationServlet.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/src/java/de/campussource/cse/webconfig/EditConfigurationServlet.java 2009-06-30 11:40:17 UTC (rev 281) +++ trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/src/java/de/campussource/cse/webconfig/EditConfigurationServlet.java 2009-06-30 19:13:00 UTC (rev 282) @@ -2,16 +2,12 @@ import java.io.IOException; import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Collection; import java.util.LinkedList; import javax.naming.NamingException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; /** * EditConfigurationServlet allows editing of a existing Configuration as well as creating a new one @@ -24,27 +20,12 @@ private static final long serialVersionUID = 8190420191955939951L; /** - * set this parameter to any value and the user will get a formular to create a new config - */ -// public static final String PARAM_CREATENEW_CONFIG = "createconfig"; - - /** - * set this parameter to the ID of an existing config and the user will be - * able to manipulate its values. - */ -// public static final String PARAM_EDIT_CONFIG = "editconfig"; - - /** * set this parameter to the ID of an existing config and the input settings * will be saved for the setting with this ID if this parameter is missing, * a new config will be created. */ - public static final String FIELD_SAFE_EDIT_CONFIG = "safeeditconfig"; - /** this parameter must hold tha value of a freshly created config. */ - // public static final String FIELD_NEWCONFIG_NAME = "nameofnewconfig"; - /** uri to the edit_config_servlet. */ public static final String URI_EDIT_SERVLET = "editConfigurationServlet"; @@ -68,25 +49,10 @@ PrintWriter out = resp.getWriter(); printHeader("Edit configuration", out, req); - //try to unmarshal configuration from XML -/* - Configuration configFromXml = null; - try { - Unmarshaller um = JAXBContext.newInstance("de.campussource.cse.webconfig").createUnmarshaller(); - configFromXml = (Configuration) um.unmarshal(getClass().getResourceAsStream(ConfigurationManager.CONFIG_XML_LOCATION)); - } catch (Exception e) { - e.printStackTrace(); - printError("Fehler beim Parsen der " + ConfigurationManager.CONFIG_XML_LOCATION + ": " + e, out); - printFooter(out); - return; - } -*/ - /* HANDLING USER INPUT */ - - /* checking input */ - + /* Validate user-input */ - String errors = ""; //this will hold the error message (if any) + /* This will hold the error message (if any) */ + String errors = ""; //all names of settings with wrong input will go in here //DO NOT USE settingswithError.size()==0 to find out if there where errors! @@ -111,8 +77,8 @@ break; case Setting.TYPE_INT_LIST: try { - setting.setValue(input); //this will create the list, regardless if this a valid int list - setting.getAsListOfIntegers(); //this will get us a exception if the user made a error + setting.setValue(input); //this will create the list, regardless if this a valid int list + setting.getAsListOfIntegers(); //this will get us a exception if the user made a error } catch (IllegalArgumentException e) { errors += "<br>" + setting.getName(); settingswithError.add(setting.getName()); @@ -150,22 +116,7 @@ configManager.updateSetting(setting); } } - /* - int editid=new Integer(req.getParameter(FIELD_SAFE_EDIT_CONFIG)).intValue(); - Configuration configToUpdate=configManager.getConfigById(editid); - - //update all configs from this setting - for(Setting setting:configToUpdate.getSettings()){ - //generate a unique name for this setting to be used for the inpout fields - String inputkey=generateInputFieldName(setting); - //the field is null when the user didnt had the rights to manipulate this setting - if(req.getParameter(inputkey)!=null){ - setting.setValue(req.getParameter(inputkey)); - } - } - configManager.updateConfiguration(configToUpdate); - */ - printConfirm("Die Konfiguration wurde geändert", out); + printConfirm("Die Konfiguration wurde ge\xE4ndert", out); } /* END OF HANDLING USER INPUT */ @@ -175,9 +126,7 @@ boolean isNewConfig = false; printHiddenField(out, FIELD_SAFE_EDIT_CONFIG, 666); - //set edit param again so the user can continue editing this entry after he saved his changes -// printHiddenField(out, PARAM_EDIT_CONFIG, configFromXml.getConfigurationId()); - startSubBlock("Konfiguration ändern", out, new String[]{"Name", "Wert"}); + startSubBlock("Konfiguration \xC4ndern", out, new String[] {"Name", "Wert"}); startSubRow(out); out.println("<td width=50%>Name der Konfiguration<br></td><td width=50%>"); out.print("CSE Configuration"); @@ -307,7 +256,7 @@ * @return the string */ private String generateInputFieldName(Setting setting) { - return "input_"+(setting.getName()).hashCode(); + return "input_" + setting.getId(); } /* (non-Javadoc) Modified: trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/web/WEB-INF/web.xml =================================================================== --- trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/web/WEB-INF/web.xml 2009-06-30 11:40:17 UTC (rev 281) +++ trunk/sandbox/lsf-adapter-demo/WebConfig/WebConfig-war/web/WEB-INF/web.xml 2009-06-30 19:13:00 UTC (rev 282) @@ -26,6 +26,6 @@ </session-timeout> </session-config> <welcome-file-list> - <welcome-file>/editConfigurationServlet</welcome-file> + <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |