set type of request
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 14 May 2008 20:18:27 +0000 (20:18 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 14 May 2008 20:18:27 +0000 (20:18 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@884 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/core/RequestManager.java

index 3b98dc2..d2b1bde 100644 (file)
@@ -28,13 +28,17 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import net.pterodactylus.fcp.highlevel.GetRequestResult;
 import net.pterodactylus.fcp.highlevel.HighLevelCallback;
 import net.pterodactylus.fcp.highlevel.HighLevelCallbackListener;
 import net.pterodactylus.fcp.highlevel.HighLevelClient;
 import net.pterodactylus.fcp.highlevel.HighLevelProgress;
 import net.pterodactylus.fcp.highlevel.HighLevelProgressListener;
+import net.pterodactylus.fcp.highlevel.PutDirRequestResult;
+import net.pterodactylus.fcp.highlevel.PutRequestResult;
 import net.pterodactylus.fcp.highlevel.RequestListResult;
 import net.pterodactylus.fcp.highlevel.RequestResult;
+import net.pterodactylus.jsite.core.Request.Type;
 import net.pterodactylus.util.logging.Logging;
 
 /**
@@ -175,12 +179,23 @@ public class RequestManager implements NodeListener, HighLevelProgressListener {
                                for (RequestResult requestResult: requestListResult) {
                                                String identifier = requestResult.getIdentifier();
                                                logger.log(Level.FINER, "got identifier: " + identifier);
+                                               Request request = identifierRequests.get(identifier);
+                                               if (request == null) {
+                                                       request = new Request(node, identifier);
+                                               }
+                                               if (request.getType() == null) {
+                                                       if (requestResult instanceof GetRequestResult) {
+                                                               request.setType(Type.get);
+                                                       } else if (requestResult instanceof PutRequestResult) {
+                                                               request.setType(Type.put);
+                                                       } else if (requestResult instanceof PutDirRequestResult) {
+                                                               request.setType(Type.putDir);
+                                                       }
+                                               }
                                                if (identifierRequests.containsKey(identifier)) {
                                                        continue;
                                                }
-                                               Request request = new Request(node, identifier);
                                                identifierRequests.put(requestResult.getIdentifier(), request);
-                                               /* TODO - fill request */
                                                fireRequestAdded(request);
                                }
                        }