From: David ‘Bombe’ Roden Date: Sat, 23 May 2009 15:35:51 +0000 (+0200) Subject: Wrapped FCP API requests into jSite requests. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c9724dfaa5c1aeac0e39243981717c11e66b7f1f;p=jSite2.git Wrapped FCP API requests into jSite requests. --- 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)) {