From c9724dfaa5c1aeac0e39243981717c11e66b7f1f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 23 May 2009 17:35:51 +0200 Subject: [PATCH] Wrapped FCP API requests into jSite requests. --- .../pterodactylus/jsite/core/RequestManager.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/net/pterodactylus/jsite/core/RequestManager.java b/src/net/pterodactylus/jsite/core/RequestManager.java index cc381cf..23184b9 100644 --- a/src/net/pterodactylus/jsite/core/RequestManager.java +++ b/src/net/pterodactylus/jsite/core/RequestManager.java @@ -23,13 +23,13 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import net.pterodactylus.fcp.highlevel.FcpClient; import net.pterodactylus.fcp.highlevel.FcpException; -import net.pterodactylus.fcp.highlevel.Request; import net.pterodactylus.jsite.util.IdGenerator; import net.pterodactylus.util.number.Hex; @@ -99,6 +99,23 @@ public class RequestManager implements NodeListener { return true; } + /** + * Wraps the requests of the FCP API into jSite requests. + * + * @param requests + * The requests to wrap + * @return The wrapped requests + */ + private Collection wrapRequests(Collection requests) { + Collection wrappedRequests = new HashSet(); + for (net.pterodactylus.fcp.highlevel.Request request : requests) { + Request wrappedRequest = new Request(request.getIdentifier()); + wrappedRequest.setClientToken(request.getClientToken()); + wrappedRequests.add(wrappedRequest); + } + return wrappedRequests; + } + // // INTERFACE NodeListener // @@ -120,7 +137,7 @@ public class RequestManager implements NodeListener { return; } try { - Collection requests = fcpClient.getRequests(true); + Collection requests = wrapRequests(fcpClient.getRequests(true)); for (Request request : requests) { String clientToken = request.getClientToken(); if ((clientToken == null) || (clientToken.trim().length() == 0)) { -- 2.7.4