implement getting list of persistent requests
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 12 May 2008 20:43:45 +0000 (20:43 +0000)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 12 May 2008 20:43:45 +0000 (20:43 +0000)
git-svn-id: http://trooper/svn/projects/jFCPlib/branch/high-level-client@853 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/fcp/highlevel/GetRequestResult.java [new file with mode: 0644]
src/net/pterodactylus/fcp/highlevel/HighLevelClient.java
src/net/pterodactylus/fcp/highlevel/PutDirRequestResult.java [new file with mode: 0644]
src/net/pterodactylus/fcp/highlevel/PutRequestResult.java [new file with mode: 0644]
src/net/pterodactylus/fcp/highlevel/RequestListResult.java [new file with mode: 0644]
src/net/pterodactylus/fcp/highlevel/RequestResult.java [new file with mode: 0644]

diff --git a/src/net/pterodactylus/fcp/highlevel/GetRequestResult.java b/src/net/pterodactylus/fcp/highlevel/GetRequestResult.java
new file mode 100644 (file)
index 0000000..fc75610
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * jFCPlib-high-level-client - GetRequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import net.pterodactylus.fcp.Persistence;
+import net.pterodactylus.fcp.PersistentGet;
+import net.pterodactylus.fcp.Priority;
+import net.pterodactylus.fcp.ReturnType;
+import net.pterodactylus.fcp.Verbosity;
+
+/**
+ * A Get result result is generated by {@link HighLevelClient#getRequests()}.
+ * 
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ * @version $Id$
+ */
+public class GetRequestResult extends RequestResult {
+
+       /** The PersistentGet FCP message. */
+       private final PersistentGet persistentGet;
+
+       /**
+        * Creates a new Get request result.
+        * 
+        * @param persistentGet
+        *            The PersistentGet message wrapped by this result
+        */
+       public GetRequestResult(PersistentGet persistentGet) {
+               super(persistentGet.getIdentifier());
+               this.persistentGet = persistentGet;
+       }
+
+       /**
+        * Returns the client token associated with the request.
+        * 
+        * @return The client token
+        * @see net.pterodactylus.fcp.PersistentGet#getClientToken()
+        */
+       public String getClientToken() {
+               return persistentGet.getClientToken();
+       }
+
+       /**
+        * Returns the filename of the request.
+        * 
+        * @return The filename
+        * @see net.pterodactylus.fcp.PersistentGet#getFilename()
+        */
+       public String getFilename() {
+               return persistentGet.getFilename();
+       }
+
+       /**
+        * Returns the maximum number of retries for the request.
+        * 
+        * @return The maximum number of retries
+        * @see net.pterodactylus.fcp.PersistentGet#getMaxRetries()
+        */
+       public int getMaxRetries() {
+               return persistentGet.getMaxRetries();
+       }
+
+       /**
+        * Returns the persistence level of the request
+        * 
+        * @return The persistence level
+        * @see net.pterodactylus.fcp.PersistentGet#getPersistence()
+        */
+       public Persistence getPersistence() {
+               return persistentGet.getPersistence();
+       }
+
+       /**
+        * Returns the priority of the request.
+        * 
+        * @return The priority
+        * @see net.pterodactylus.fcp.PersistentGet#getPriority()
+        */
+       public Priority getPriority() {
+               return persistentGet.getPriority();
+       }
+
+       /**
+        * Returns the return type of the request.
+        * 
+        * @return The return type of the request
+        * @see net.pterodactylus.fcp.PersistentGet#getReturnType()
+        */
+       public ReturnType getReturnType() {
+               return persistentGet.getReturnType();
+       }
+
+       /**
+        * Returns the temporary filename of the request.
+        * 
+        * @return The temporary filename
+        * @see net.pterodactylus.fcp.PersistentGet#getTempFilename()
+        */
+       public String getTempFilename() {
+               return persistentGet.getTempFilename();
+       }
+
+       /**
+        * Returns the URI of the request.
+        * 
+        * @return The URI of the request
+        * @see net.pterodactylus.fcp.PersistentGet#getURI()
+        */
+       public String getURI() {
+               return persistentGet.getURI();
+       }
+
+       /**
+        * Returns the verbosity of the request.
+        * 
+        * @return The verbosity of the request
+        * @see net.pterodactylus.fcp.PersistentGet#getVerbosity()
+        */
+       public Verbosity getVerbosity() {
+               return persistentGet.getVerbosity();
+       }
+
+       /**
+        * Returns whether this request is on the global queue.
+        * 
+        * @return <code>true</code> if the request is on the global queue,
+        *         <code>false</code> if it is on the client-local queue
+        * @see net.pterodactylus.fcp.PersistentGet#isGlobal()
+        */
+       public boolean isGlobal() {
+               return persistentGet.isGlobal();
+       }
+
+}
index 5032eef..d139ce2 100644 (file)
@@ -33,6 +33,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import net.pterodactylus.fcp.AddPeer;
@@ -55,6 +56,7 @@ import net.pterodactylus.fcp.GenerateSSK;
 import net.pterodactylus.fcp.GetFailed;
 import net.pterodactylus.fcp.IdentifierCollision;
 import net.pterodactylus.fcp.ListPeers;
+import net.pterodactylus.fcp.ListPersistentRequests;
 import net.pterodactylus.fcp.NodeData;
 import net.pterodactylus.fcp.NodeHello;
 import net.pterodactylus.fcp.NodeRef;
@@ -87,7 +89,7 @@ import net.pterodactylus.fcp.UnknownPeerNoteType;
 /**
  * A high-level client that allows simple yet full-featured access to a Freenet
  * node.
- *
+ * 
  * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
  * @version $Id$
  */
@@ -135,10 +137,13 @@ public class HighLevelClient {
        /** Mapping from request identifiers to download callbacks. */
        private Map<String, HighLevelProgressCallback<DownloadResult>> downloadCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelProgressCallback<DownloadResult>>());
 
+       /** The callback for {@link #getRequests()}. */
+       private HighLevelCallback<RequestListResult> requestListCallback;
+
        /**
         * Creates a new high-level client that connects to a node on
         * <code>localhost</code>.
-        *
+        * 
         * @param clientName
         *            The name of the client
         * @throws UnknownHostException
@@ -151,7 +156,7 @@ public class HighLevelClient {
        /**
         * Creates a new high-level client that connects to a node on the given
         * host.
-        *
+        * 
         * @param clientName
         *            The name of the client
         * @param host
@@ -166,7 +171,7 @@ public class HighLevelClient {
        /**
         * Creates a new high-level client that connects to a node on the given
         * host.
-        *
+        * 
         * @param clientName
         *            The name of the client
         * @param host
@@ -183,7 +188,7 @@ public class HighLevelClient {
        /**
         * Creates a new high-level client that connects to a node at the given
         * address.
-        *
+        * 
         * @param clientName
         *            The name of the client
         * @param address
@@ -203,7 +208,7 @@ public class HighLevelClient {
 
        /**
         * Adds the given high-level client listener to list of listeners.
-        *
+        * 
         * @param highLevelClientListener
         *            The listener to add
         */
@@ -213,7 +218,7 @@ public class HighLevelClient {
 
        /**
         * Removes the given high-level client listener from the list of listeners.
-        *
+        * 
         * @param highLevelClientListener
         *            The listener to remove
         */
@@ -232,7 +237,7 @@ public class HighLevelClient {
 
        /**
         * Notifies all listeners that a client has disconnected.
-        *
+        * 
         * @param throwable
         *            The exception that caused the disconnect, or <code>null</code>
         *            if there was no exception
@@ -251,7 +256,7 @@ public class HighLevelClient {
         * Returns the FCP connection that backs this high-level client. This method
         * should be used with care as fiddling around with the FCP connection can
         * easily break the high-level client if you don’t know what you’re doing!
-        *
+        * 
         * @return The FCP connection of this client
         */
        public FcpConnection getFcpConnection() {
@@ -264,7 +269,7 @@ public class HighLevelClient {
 
        /**
         * Connects the client.
-        *
+        * 
         * @return A callback with a connection result
         * @throws IOException
         *             if an I/O error occurs communicating with the node
@@ -288,7 +293,7 @@ public class HighLevelClient {
 
        /**
         * Generates a new SSK keypair.
-        *
+        * 
         * @return A callback with the keypair
         * @throws IOException
         *             if an I/O error occurs communicating with the node
@@ -304,7 +309,7 @@ public class HighLevelClient {
 
        /**
         * Gets a list of all peers from the node.
-        *
+        * 
         * @return A callback with the peer list
         * @throws IOException
         *             if an I/O error occurs with the node
@@ -320,7 +325,7 @@ public class HighLevelClient {
 
        /**
         * Adds the peer whose noderef is stored in the given file.
-        *
+        * 
         * @param nodeRefFile
         *            The name of the file the peer’s noderef is stored in
         * @return A peer callback
@@ -338,7 +343,7 @@ public class HighLevelClient {
 
        /**
         * Adds the peer whose noderef is stored in the given file.
-        *
+        * 
         * @param nodeRefURL
         *            The URL where the peer’s noderef is stored
         * @return A peer callback
@@ -356,7 +361,7 @@ public class HighLevelClient {
 
        /**
         * Adds the peer whose noderef is stored in the given file.
-        *
+        * 
         * @param nodeRef
         *            The peer’s noderef
         * @return A peer callback
@@ -376,7 +381,7 @@ public class HighLevelClient {
         * Checks whether direct disk access for the given directory is possible.
         * You have to perform this check before you can upload or download anything
         * from or the disk directly!
-        *
+        * 
         * @param directory
         *            The directory to check
         * @param wantRead
@@ -398,7 +403,7 @@ public class HighLevelClient {
         * Starts a download. Files can either be download to disk or streamed from
         * the node. When downloading to disk you have to perform a direct disk
         * access check for the directory you want to put the downloaded file in!
-        *
+        * 
         * @see #checkDirectDiskAccess(String, boolean, boolean)
         * @param uri
         *            The URI to get
@@ -422,13 +427,33 @@ public class HighLevelClient {
                return downloadCallback;
        }
 
+       /**
+        * Requests a list of all running requests from the node.
+        * 
+        * @return The request list result
+        * @throws IOException
+        *             if an I/O errors communicating with the node
+        */
+       public HighLevelCallback<RequestListResult> getRequests() throws IOException {
+               String identifier = generateIdentifier("list-persistent-requests");
+               ListPersistentRequests listPersistentRequests = new ListPersistentRequests();
+               synchronized (syncObject) {
+                       if (requestListCallback != null) {
+                               logger.log(Level.SEVERE, "getRequests() called with request still running!");
+                       }
+                       requestListCallback = new HighLevelCallback<RequestListResult>(new RequestListResult(identifier));
+               }
+               fcpConnection.sendMessage(listPersistentRequests);
+               return requestListCallback;
+       }
+
        //
        // PRIVATE METHODS
        //
 
        /**
         * Generates an identifier for the given function.
-        *
+        * 
         * @param function
         *            The name of the function
         * @return An identifier
@@ -440,7 +465,7 @@ public class HighLevelClient {
        /**
         * Disconnects the client from the node, handing the given Throwable to
         * {@link #fireClientDisconnected(Throwable)}.
-        *
+        * 
         * @param throwable
         *            The exception that caused the disconnect, or <code>null</code>
         *            if there was no exception
@@ -452,7 +477,7 @@ public class HighLevelClient {
 
        /**
         * FCP listener for {@link HighLevelClient}.
-        *
+        * 
         * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
         * @version $Id$
         */
@@ -475,7 +500,7 @@ public class HighLevelClient {
                /**
                 * Searches all callback collections for a callback with the given
                 * identifier and cancels it.
-                *
+                * 
                 * @param identifier
                 *            The identifier to search for, or <code>null</code> to
                 *            cancel all pending requests
@@ -488,6 +513,11 @@ public class HighLevelClient {
                                        connectCallback.setDone();
                                        connectCallback = null;
                                }
+                               if (requestListCallback != null) {
+                                       requestListCallback.getIntermediaryResult().setFailed(true);
+                                       requestListCallback.setDone();
+                                       requestListCallback = null;
+                               }
                        }
                        if (identifier == null) {
                                /* key generation callbacks */
@@ -556,7 +586,7 @@ public class HighLevelClient {
 
                /**
                 * Reads the given file and returns the first line of the file.
-                *
+                * 
                 * @param readFilename
                 *            The name of the file to read
                 * @return The content of the file
@@ -580,7 +610,7 @@ public class HighLevelClient {
 
                /**
                 * Writes the given content to the given file.
-                *
+                * 
                 * @param directDiskAccessResult
                 *            The DDA result
                 * @param writeFilename
@@ -606,7 +636,7 @@ public class HighLevelClient {
 
                /**
                 * Cleans up any files that written for the given result.
-                *
+                * 
                 * @param directDiskAccessResult
                 *            The direct disk access result
                 */
@@ -698,8 +728,19 @@ public class HighLevelClient {
                 * @see net.pterodactylus.fcp.FcpListener#receivedEndListPersistentRequests(net.pterodactylus.fcp.FcpConnection,
                 *      net.pterodactylus.fcp.EndListPersistentRequests)
                 */
+               @SuppressWarnings("synthetic-access")
                public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests) {
-                       /* TODO */
+                       if (fcpConnection != HighLevelClient.this.fcpConnection) {
+                               return;
+                       }
+                       synchronized (syncObject) {
+                               if (HighLevelClient.this.requestListCallback == null) {
+                                       logger.log(Level.WARNING, "got EndListPersistentRequests without running request!");
+                                       return;
+                               }
+                               requestListCallback.setDone();
+                               requestListCallback = null;
+                       }
                }
 
                /**
@@ -823,9 +864,16 @@ public class HighLevelClient {
                        if (fcpConnection != HighLevelClient.this.fcpConnection) {
                                return;
                        }
+                       synchronized (syncObject) {
+                               if (requestListCallback != null) {
+                                       RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
+                                       requestListResult.addRequestResult(new GetRequestResult(persistentGet));
+                                       return;
+                               }
+                       }
                        String identifier = persistentGet.getIdentifier();
                        if (downloadCallbacks.containsKey(identifier)) {
-                               /* ignore, because a download does not care about this. */
+                               /* TODO */
                                return;
                        }
                }
@@ -834,16 +882,36 @@ public class HighLevelClient {
                 * @see net.pterodactylus.fcp.FcpListener#receivedPersistentPut(net.pterodactylus.fcp.FcpConnection,
                 *      net.pterodactylus.fcp.PersistentPut)
                 */
+               @SuppressWarnings("synthetic-access")
                public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut) {
-                       /* TODO */
+                       if (fcpConnection != HighLevelClient.this.fcpConnection) {
+                               return;
+                       }
+                       synchronized (syncObject) {
+                               if (requestListCallback != null) {
+                                       RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
+                                       requestListResult.addRequestResult(new PutRequestResult(persistentPut));
+                                       return;
+                               }
+                       }
                }
 
                /**
                 * @see net.pterodactylus.fcp.FcpListener#receivedPersistentPutDir(net.pterodactylus.fcp.FcpConnection,
                 *      net.pterodactylus.fcp.PersistentPutDir)
                 */
+               @SuppressWarnings("synthetic-access")
                public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir) {
-                       /* TODO */
+                       if (fcpConnection != HighLevelClient.this.fcpConnection) {
+                               return;
+                       }
+                       synchronized (syncObject) {
+                               if (requestListCallback != null) {
+                                       RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
+                                       requestListResult.addRequestResult(new PutDirRequestResult(persistentPutDir));
+                                       return;
+                               }
+                       }
                }
 
                /**
diff --git a/src/net/pterodactylus/fcp/highlevel/PutDirRequestResult.java b/src/net/pterodactylus/fcp/highlevel/PutDirRequestResult.java
new file mode 100644 (file)
index 0000000..55fc468
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * jFCPlib-high-level-client - PutDirRequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import net.pterodactylus.fcp.PersistentPutDir;
+import net.pterodactylus.fcp.Priority;
+import net.pterodactylus.fcp.UploadFrom;
+import net.pterodactylus.fcp.Verbosity;
+
+/**
+ * A PutDir request result is generated by {@link HighLevelClient#getRequests()}.
+ * 
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ * @version $Id$
+ */
+public class PutDirRequestResult extends RequestResult {
+
+       /** The wrapped PersistentPutDir FCP message. */
+       private final PersistentPutDir persistentPutDir;
+
+       /**
+        * Creates a new PutDir request result.
+        * 
+        * @param persistentPutDir
+        *            The PersistentPutDir FCP message to wrap
+        */
+       public PutDirRequestResult(PersistentPutDir persistentPutDir) {
+               super(persistentPutDir.getIdentifier());
+               this.persistentPutDir = persistentPutDir;
+       }
+
+       /**
+        * Returns the number of files in the request.
+        * 
+        * @return The number of files
+        * @see net.pterodactylus.fcp.PersistentPutDir#getFileCount()
+        */
+       public int getFileCount() {
+               return persistentPutDir.getFileCount();
+       }
+
+       /**
+        * Returns the length of the file at the given index.
+        * 
+        * @param fileIndex
+        *            The index of the file
+        * @return The length of the file
+        * @see net.pterodactylus.fcp.PersistentPutDir#getFileDataLength(int)
+        */
+       public long getFileDataLength(int fileIndex) {
+               return persistentPutDir.getFileDataLength(fileIndex);
+       }
+
+       /**
+        * Returns the name of the file at the given index.
+        * 
+        * @param fileIndex
+        *            The index of the file
+        * @return The name of the file
+        * @see net.pterodactylus.fcp.PersistentPutDir#getFileFilename(int)
+        */
+       public String getFileFilename(int fileIndex) {
+               return persistentPutDir.getFileFilename(fileIndex);
+       }
+
+       /**
+        * Returns the content type of the file at the given index.
+        * 
+        * @param fileIndex
+        *            The index of the file
+        * @return The content type of the file
+        * @see net.pterodactylus.fcp.PersistentPutDir#getFileMetadataContentType(int)
+        */
+       public String getFileMetadataContentType(int fileIndex) {
+               return persistentPutDir.getFileMetadataContentType(fileIndex);
+       }
+
+       /**
+        * Returns the name of the file at the given index.
+        * 
+        * @param fileIndex
+        *            The index of the file
+        * @return The name of the file
+        * @see net.pterodactylus.fcp.PersistentPutDir#getFileName(int)
+        */
+       public String getFileName(int fileIndex) {
+               return persistentPutDir.getFileName(fileIndex);
+       }
+
+       /**
+        * Returns the upload source of the file at the given index.
+        * 
+        * @param fileIndex
+        *            The index of the file
+        * @return The upload source of the file
+        * @see net.pterodactylus.fcp.PersistentPutDir#getFileUploadFrom(int)
+        */
+       public UploadFrom getFileUploadFrom(int fileIndex) {
+               return persistentPutDir.getFileUploadFrom(fileIndex);
+       }
+
+       /**
+        * Returns the maximum number of retries for failed blocks.
+        * 
+        * @return The maximum number of retries
+        * @see net.pterodactylus.fcp.PersistentPutDir#getMaxRetries()
+        */
+       public int getMaxRetries() {
+               return persistentPutDir.getMaxRetries();
+       }
+
+       /**
+        * Returns the priority of the request.
+        * 
+        * @return The priority
+        * @see net.pterodactylus.fcp.PersistentPutDir#getPriority()
+        */
+       public Priority getPriority() {
+               return persistentPutDir.getPriority();
+       }
+
+       /**
+        * Returns the URI of the request.
+        * 
+        * @return The URI of the request
+        * @see net.pterodactylus.fcp.PersistentPutDir#getURI()
+        */
+       public String getURI() {
+               return persistentPutDir.getURI();
+       }
+
+       /**
+        * Returns the verbosity of the request.
+        * 
+        * @return The verbosity
+        * @see net.pterodactylus.fcp.PersistentPutDir#getVerbosity()
+        */
+       public Verbosity getVerbosity() {
+               return persistentPutDir.getVerbosity();
+       }
+
+       /**
+        * Returns whether the request is on the global queue.
+        * 
+        * @return <code>true</code> if the request is on the global queue,
+        *         <code>false</code> if it is on the client-local queue
+        * @see net.pterodactylus.fcp.PersistentPutDir#isGlobal()
+        */
+       public boolean isGlobal() {
+               return persistentPutDir.isGlobal();
+       }
+
+}
diff --git a/src/net/pterodactylus/fcp/highlevel/PutRequestResult.java b/src/net/pterodactylus/fcp/highlevel/PutRequestResult.java
new file mode 100644 (file)
index 0000000..be5f882
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * jFCPlib-high-level-client - PutRequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import net.pterodactylus.fcp.Persistence;
+import net.pterodactylus.fcp.PersistentPut;
+import net.pterodactylus.fcp.Priority;
+import net.pterodactylus.fcp.UploadFrom;
+import net.pterodactylus.fcp.Verbosity;
+
+/**
+ * A put request result will be contained in a {@link RequestListResult}.
+ * 
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ * @version $Id$
+ */
+public class PutRequestResult extends RequestResult {
+
+       /** The wrapped PersistentPut FCP message. */
+       private final PersistentPut persistentPut;
+
+       /**
+        * Creates a new put request result.
+        * 
+        * @param persistentPut
+        *            The PersistentPut FCP message to wrap
+        */
+       public PutRequestResult(PersistentPut persistentPut) {
+               super(persistentPut.getIdentifier());
+               this.persistentPut = persistentPut;
+       }
+
+       /**
+        * Returns the client token associated with the request.
+        * 
+        * @return The client token
+        * @see net.pterodactylus.fcp.PersistentPut#getClientToken()
+        */
+       public String getClientToken() {
+               return persistentPut.getClientToken();
+       }
+
+       /**
+        * Returns the length of the data to be inserted.
+        * 
+        * @return The length of the data
+        * @see net.pterodactylus.fcp.PersistentPut#getDataLength()
+        */
+       public long getDataLength() {
+               return persistentPut.getDataLength();
+       }
+
+       /**
+        * Returns the maximum number of retries for failed blocks.
+        * 
+        * @return The maximum number of retries
+        * @see net.pterodactylus.fcp.PersistentPut#getMaxRetries()
+        */
+       public int getMaxRetries() {
+               return persistentPut.getMaxRetries();
+       }
+
+       /**
+        * Returns the content type of the data.
+        * 
+        * @return The content type of the data
+        * @see net.pterodactylus.fcp.PersistentPut#getMetadataContentType()
+        */
+       public String getMetadataContentType() {
+               return persistentPut.getMetadataContentType();
+       }
+
+       /**
+        * Returns the persistence level of the request.
+        * 
+        * @return The persistence level
+        * @see net.pterodactylus.fcp.PersistentPut#getPersistence()
+        */
+       public Persistence getPersistence() {
+               return persistentPut.getPersistence();
+       }
+
+       /**
+        * Returns the priority of the request.
+        * 
+        * @return The priority
+        * @see net.pterodactylus.fcp.PersistentPut#getPriority()
+        */
+       public Priority getPriority() {
+               return persistentPut.getPriority();
+       }
+
+       /**
+        * Returns the target filename of the request
+        * 
+        * @return The target filename
+        * @see net.pterodactylus.fcp.PersistentPut#getTargetFilename()
+        */
+       public String getTargetFilename() {
+               return persistentPut.getTargetFilename();
+       }
+
+       /**
+        * Returns the upload source of the request.
+        * 
+        * @return The upload source
+        * @see net.pterodactylus.fcp.PersistentPut#getUploadFrom()
+        */
+       public UploadFrom getUploadFrom() {
+               return persistentPut.getUploadFrom();
+       }
+
+       /**
+        * Returns the URI of the request.
+        * 
+        * @return The URI
+        * @see net.pterodactylus.fcp.PersistentPut#getURI()
+        */
+       public String getURI() {
+               return persistentPut.getURI();
+       }
+
+       /**
+        * Returns the verbosity of the request.
+        * 
+        * @return The verbosity
+        * @see net.pterodactylus.fcp.PersistentPut#getVerbosity()
+        */
+       public Verbosity getVerbosity() {
+               return persistentPut.getVerbosity();
+       }
+
+       /**
+        * Returns whether the request is on the global queue.
+        * 
+        * @return <code>true</code> if the request is on the global queue,
+        *         <code>false</code> if it is on the client-local queue
+        * @see net.pterodactylus.fcp.PersistentPut#isGlobal()
+        */
+       public boolean isGlobal() {
+               return persistentPut.isGlobal();
+       }
+
+       /**
+        * Returns whether the request has already started.
+        * 
+        * @return <code>true</code> if the request has started,
+        *         <code>false</code> otherwise
+        * @see net.pterodactylus.fcp.PersistentPut#isStarted()
+        */
+       public boolean isStarted() {
+               return persistentPut.isStarted();
+       }
+
+}
diff --git a/src/net/pterodactylus/fcp/highlevel/RequestListResult.java b/src/net/pterodactylus/fcp/highlevel/RequestListResult.java
new file mode 100644 (file)
index 0000000..fd1de34
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * jFCPlib-high-level-client - RequestListResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The request list results lists all currently running requests on a node.
+ * 
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ * @version $Id$
+ */
+public class RequestListResult extends HighLevelResult implements Iterable<RequestResult> {
+
+       /** The request results. */
+       private List<RequestResult> requestResults = Collections.synchronizedList(new ArrayList<RequestResult>());
+
+       /**
+        * Creates a new request list result.
+        * 
+        * @param identifier
+        *            The identifier of the request
+        */
+       RequestListResult(String identifier) {
+               super(identifier);
+       }
+
+       /**
+        * Adds a request result.
+        * 
+        * @param requestResult
+        *            The request result to add
+        */
+       void addRequestResult(RequestResult requestResult) {
+               requestResults.add(requestResult);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public Iterator<RequestResult> iterator() {
+               return requestResults.iterator();
+       }
+
+       /**
+        * Returns the request result at the given index.
+        * 
+        * @param index
+        *            The index of the request result
+        * @return The request result
+        */
+       public RequestResult get(int index) {
+               return requestResults.get(index);
+       }
+
+       /**
+        * Returns the number of request results in this request list.
+        * 
+        * @return The number of request results
+        */
+       public int size() {
+               return requestResults.size();
+       }
+
+}
diff --git a/src/net/pterodactylus/fcp/highlevel/RequestResult.java b/src/net/pterodactylus/fcp/highlevel/RequestResult.java
new file mode 100644 (file)
index 0000000..f24d053
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * jFCPlib-high-level-client - RequestResult.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.fcp.highlevel;
+
+/**
+ * A request result is the result of different operations, e.g.
+ * {@link HighLevelClient#getRequests()}.
+ * 
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ * @version $Id$
+ */
+public class RequestResult extends HighLevelResult {
+
+       /**
+        * Creates a new request result.
+        * 
+        * @param identifier
+        *            The identifier of the request
+        */
+       RequestResult(String identifier) {
+               super(identifier);
+       }
+
+}