2006/unicorn/src/org/w3c/unicorn UnicornCall.java,1.17,1.18

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

Modified Files:
	UnicornCall.java 
Log Message:
new way to get the response from RequestThread, unicornCall is no longer passed as a parameter

Index: UnicornCall.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/UnicornCall.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- UnicornCall.java	18 Sep 2009 15:01:43 -0000	1.17
+++ UnicornCall.java	18 Sep 2009 17:12:26 -0000	1.18
@@ -434,12 +434,12 @@
 
 		final Map<String, Request> requests = requestList.getRequestMap();
 		// Creation of the thread list
-		ArrayList<Thread> threadsList = new ArrayList<Thread>();
+		ArrayList<RequestThread> threadsList = new ArrayList<RequestThread>();
 
 		for (final String obsID : requests.keySet()) {
 			// send request to observer
-			threadsList.add(new RequestThread(mapOfResponse, requests
-					.get(obsID), obsID, this));
+			//threadsList.add(new RequestThread(mapOfResponse, requests.get(obsID), obsID, this));
+			threadsList.add(new RequestThread(requests.get(obsID), obsID, this.getLang()));
 			logger.debug("Request " + requests.get(obsID) + " added to threadsList");
 		}
 		for (int i = 0; i < threadsList.size(); i++) {
@@ -450,6 +450,10 @@
 		for (int i = 0; i < threadsList.size(); i++) {
 			try {
 				threadsList.get(i).join();
+				Response resp = threadsList.get(i).getResponse();
+				mapOfResponse.put(threadsList.get(i).getObsID(), resp);
+				String outputParamName = Framework.mapOfObserver.get(resp.getObserverId()).getParamOutputName();
+				resp.setRequestUri(resp.getRequestUri().replaceAll("&?" + outputParamName + "=[^&]*", ""));
 				logger.debug("Request " + ((RequestThread)threadsList.get(i)).getObsID() + " terminated");
 			} catch (InterruptedException e) {
 				e.printStackTrace();
@@ -498,38 +502,38 @@
 	}
 	
 	public LinkedHashMap<String, Response> getObservationList() {
-		if (observationMap == null) {
-			observationMap = new LinkedHashMap<String, Response>();
-			
-			for (Group group : aTask.getOutput().getGroupList()) {
-				if (!group.isSetType()) {
-					for (String observerId : group.getObservationList()) {
-						if(mapOfResponse.get(observerId) != null) {
-							observationMap.put(observerId, mapOfResponse.get(observerId));
-						}
+		if (observationMap != null)
+			return observationMap;
+		
+		observationMap = new LinkedHashMap<String, Response>();
+		for (Group group : aTask.getOutput().getGroupList()) {
+			if (!group.isSetType()) {
+				for (String observerId : group.getObservationList()) {
+					if(mapOfResponse.get(observerId) != null) {
+						observationMap.put(observerId, mapOfResponse.get(observerId));
 					}
-				} else {
-					switch (group.getType()) {
-						case FIRSTPASSED:
-							String passedId = null;
-							for (String observerId : group.getObservationList()) {
-								if (mapOfResponse.get(observerId) == null) {
-									logger.error("unknown observer id (" + observerId + ") in output group of task: " + this.getTask().getID());
-									continue;
-								}
-								if (mapOfResponse.get(observerId).isPassed()) {
-									passedId = observerId;
-									break;
-								}
+				}
+			} else {
+				switch (group.getType()) {
+					case FIRSTPASSED:
+						String passedId = null;
+						for (String observerId : group.getObservationList()) {
+							if (mapOfResponse.get(observerId) == null) {
+								logger.error("unknown observer id (" + observerId + ") in output group of task: " + this.getTask().getID());
+								continue;
 							}
-							if (passedId == null) {
-								Response resp = mapOfResponse.get(group.getObservationList().get(0));
-								if (resp != null)
-									observationMap.put(group.getObservationList().get(0), resp);
+							if (mapOfResponse.get(observerId).isPassed()) {
+								passedId = observerId;
+								break;
 							}
-							else 
-								observationMap.put(passedId, mapOfResponse.get(passedId));
-					}
+						}
+						if (passedId == null) {
+							Response resp = mapOfResponse.get(group.getObservationList().get(0));
+							if (resp != null)
+								observationMap.put(group.getObservationList().get(0), resp);
+						}
+						else 
+							observationMap.put(passedId, mapOfResponse.get(passedId));
 				}
 			}
 		}
@@ -600,7 +604,6 @@
 	 *            defines the lang to configure
 	 */
 	public void setLang(final String sLang) {
-		logger.debug("setLang(" + sLang + ")");
 		this.sLang = sLang;
 	}
 

Received on Friday, 18 September 2009 17:12:36 UTC