2006/unicorn/src/org/w3c/unicorn/action IndexAction.java,1.12,1.13 Action.java,1.4,1.5 ObserveAction.java,1.13,1.14

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv18974/src/org/w3c/unicorn/action

Modified Files:
	IndexAction.java Action.java ObserveAction.java 
Log Message:
changed signature of getLanguage avec getTask
+ added getRequestParameters function to ObserveAction

Index: IndexAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/IndexAction.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- IndexAction.java	7 Sep 2009 16:33:49 -0000	1.12
+++ IndexAction.java	7 Sep 2009 17:35:20 -0000	1.13
@@ -37,8 +37,8 @@
 		
 		ArrayList<Message> messages = new ArrayList<Message>();
 		String paramPrefix = Property.get("UNICORN_PARAMETER_PREFIX");
-		String lang = getLanguage(req, messages);
-		String task = getTask(req, lang, null);
+		String lang = getLanguage(req.getParameter(paramPrefix + "lang"), req, messages);
+		String task = getTask(req.getParameter(paramPrefix + "task"), lang, null);
 		String queryString = getQueryStringWithout(paramPrefix + "lang", req);
 		
 		if (req.getAttribute("unicorn_message") != null)

Index: ObserveAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/ObserveAction.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- ObserveAction.java	7 Sep 2009 16:33:49 -0000	1.13
+++ ObserveAction.java	7 Sep 2009 17:35:21 -0000	1.14
@@ -60,6 +60,32 @@
 		logger.debug("Created a ServletFileUpload with repository set to: " + Property.get("UPLOADED_FILES_REPOSITORY"));
 	}
 	
+	private Map<String, Object> getRequestParameters(HttpServletRequest req) throws FileUploadException {
+		
+		Hashtable<String, Object> params = new Hashtable<String, Object>();
+			
+		if (req.getMethod().equals("POST") && ServletFileUpload.isMultipartContent(new ServletRequestContext(req))) {
+
+			List<?> listOfItem = upload.parseRequest(req);
+			for (Object fileItem : listOfItem) {
+				FileItem aFileItem = (FileItem) fileItem;
+				if (aFileItem.isFormField()) {
+					params.put(aFileItem.getFieldName(), aFileItem.getString());
+				} else if (aFileItem.getFieldName().equals(Property.get("UNICORN_PARAMETER_PREFIX") + "file")) {
+					params.put(aFileItem.getFieldName(), aFileItem);
+				}
+			}
+			
+			return params;
+		}
+		
+		for (Object key : req.getParameterMap().keySet()) {
+			params.put(key.toString(), req.getParameter(key.toString()));
+		}
+		return params;
+		
+	}
+	
 	@Override
 	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
 			throws ServletException, IOException {
@@ -71,9 +97,11 @@
 		Map<String, String> mapOfOutputParameter = new Hashtable<String, String>();
 		ArrayList<Message> messages = new ArrayList<Message>();
 		
+		//Map<String, String> reqParameters = getRequestParameters(req);
+		
 		String paramPrefix = Property.get("UNICORN_PARAMETER_PREFIX");
-		String lang = getLanguage(req, null);
-		String task = getTask(req, lang, messages);
+		String lang = getLanguage(req.getParameter(paramPrefix + "lang"), req, null);
+		String task = getTask(req.getParameter(paramPrefix + "task"), lang, messages);
 		String queryString = getQueryStringWithout(paramPrefix + "lang", req);
 		
 		mapOfStringObject.put("queryString", queryString);
@@ -109,7 +137,6 @@
 				// Process the uploaded items
 				for (Iterator<?> aIterator = listOfItem.iterator(); aIterator.hasNext();) {
 					FileItem aFileItem = (FileItem) aIterator.next();
-					logger.error("TOM: " + aFileItem);
 					if (aFileItem.isFormField()) {
 						addParameter(aFileItem.getFieldName(), aFileItem.getString(),
 								aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter);
@@ -118,7 +145,6 @@
 						aUnicornCall.setDocumentName(aFileItemUploaded.getName());
 						aUnicornCall.setInputParameterValue(aFileItemUploaded);
 						aUnicornCall.setEnumInputMethod(EnumInputMethod.UPLOAD);
-						break;
 					}
 				}
 			} catch (final FileUploadException aFileUploadException) {
@@ -159,7 +185,7 @@
 			throws ServletException, IOException {
 		doGet(req, resp);
 	}
-
+	
 	/**
 	 * Adds a parameter at the correct call.
 	 * 
@@ -282,11 +308,6 @@
 		resp.setContentType(mapOfOutputParameter.get("mimetype") + "; charset=" + mapOfOutputParameter.get("charset"));
 
 		mapOfStringObject.put("unicorncall", aUnicornCall);
-
-		logger.debug("Request output formater with parameters: " 
-				+ mapOfOutputParameter.get("format") + " "
-				+ mapOfOutputParameter.get("lang") + " "
-				+ mapOfOutputParameter.get("mimetype"));
 		
 		OutputFormater aOutputFormater = OutputFactory
 				.createOutputFormater(mapOfOutputParameter.get("format"),

Index: Action.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Action.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Action.java	7 Sep 2009 16:33:49 -0000	1.4
+++ Action.java	7 Sep 2009 17:35:21 -0000	1.5
@@ -2,6 +2,8 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Map;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -51,9 +53,9 @@
 		return queryString;
 	}
 	
-	public String getLanguage(HttpServletRequest req, ArrayList<Message> messages) {
+	public String getLanguage(String langParameter, HttpServletRequest req, ArrayList<Message> messages) {
 		
-		String langParameter = req.getParameter(Property.get("UNICORN_PARAMETER_PREFIX") + "lang");
+		//String langParameter = req.getParameter(Property.get("UNICORN_PARAMETER_PREFIX") + "lang");
 		String lang;
 		if (langParameter == null || !Framework.getLanguageProperties().containsKey(langParameter))
 			lang = Language.negociate(req.getLocales());
@@ -71,9 +73,9 @@
 		return lang;
 	}
 
-	public String getTask(HttpServletRequest req, String lang, ArrayList<Message> messages) {
+	public String getTask(String taskParameter, String lang, ArrayList<Message> messages) {
 		
-		String taskParameter = req.getParameter(Property.get("UNICORN_PARAMETER_PREFIX") + "task");
+		//String taskParameter = req.getParameter(Property.get("UNICORN_PARAMETER_PREFIX") + "task");
 		String task;
 		if (taskParameter == null || !Framework.mapOfTask.containsKey(taskParameter))
 			task = Framework.mapOfTask.getDefaultTaskId();

Received on Monday, 7 September 2009 17:35:33 UTC