add URIGenerated
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 10 Apr 2008 11:41:21 +0000 (11:41 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 10 Apr 2008 11:41:21 +0000 (11:41 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@692 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/util/fcp/FcpAdapter.java
src/net/pterodactylus/util/fcp/FcpConnection.java
src/net/pterodactylus/util/fcp/FcpListener.java
src/net/pterodactylus/util/fcp/URIGenerated.java [new file with mode: 0644]

index 3ffe986..ca078f7 100644 (file)
@@ -120,6 +120,14 @@ public class FcpAdapter implements FcpListener {
        }
 
        /**
+        * @see net.pterodactylus.util.fcp.FcpListener#receivedURIGenerated(net.pterodactylus.util.fcp.FcpConnection,
+        *      net.pterodactylus.util.fcp.URIGenerated)
+        */
+       public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated) {
+               /* empty. */
+       }
+
+       /**
         * @see net.pterodactylus.util.fcp.FcpListener#receivedProtocolError(net.pterodactylus.util.fcp.FcpConnection,
         *      net.pterodactylus.util.fcp.ProtocolError)
         */
index 9c88ea9..dffb110 100644 (file)
@@ -311,6 +311,18 @@ public class FcpConnection {
        }
 
        /**
+        * Notifies all listeners that a “URIGenerated” message was received.
+        * 
+        * @param uriGenerated
+        *            The “URIGenerated” message
+        */
+       private void fireReceivedURIGenerated(URIGenerated uriGenerated) {
+               for (FcpListener fcpListener: fcpListeners) {
+                       fcpListener.receivedURIGenerated(this, uriGenerated);
+               }
+       }
+
+       /**
         * Notifies all listeners that a “ProtocolError” message was received.
         * 
         * @param protocolError
@@ -400,6 +412,8 @@ public class FcpConnection {
                        fireReceivedProtocolError(new ProtocolError(fcpMessage));
                } else if ("PersistentPut".equals(messageName)) {
                        fireReceivedPersistentPut(new PersistentPut(fcpMessage));
+               } else if ("URIGenerated".equals(messageName)) {
+                       fireReceivedURIGenerated(new URIGenerated(fcpMessage));
                } else if ("EndListPersistentRequests".equals(messageName)) {
                        fireReceivedEndListPersistentRequests(new EndListPersistentRequests(fcpMessage));
                } else if ("Peer".equals(messageName)) {
index 70e834a..96c6d02 100644 (file)
@@ -161,6 +161,16 @@ public interface FcpListener extends EventListener {
        public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests);
 
        /**
+        * Notifies a listener that a “URIGenerated” was received.
+        * 
+        * @param fcpConnection
+        *            The connection that received the message
+        * @param uriGenerated
+        *            The “URIGenerated” message
+        */
+       public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated);
+
+       /**
         * Notifies a listener that a “ProtocolError” was received.
         * 
         * @param fcpConnection
diff --git a/src/net/pterodactylus/util/fcp/URIGenerated.java b/src/net/pterodactylus/util/fcp/URIGenerated.java
new file mode 100644 (file)
index 0000000..677823a
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+/**
+ * The “URIGenerated” message signals the client that an URI was generated for a
+ * {@link ClientPut} (or {@link ClientPutDiskDir} or {@link ClientPutComplexDir})
+ * request.
+ * 
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class URIGenerated extends BaseMessage {
+
+       /**
+        * Creates a new “URIGenerated” message that wraps the received message.
+        * 
+        * @param receivedMessage
+        *            The received message
+        */
+       public URIGenerated(FcpMessage receivedMessage) {
+               super(receivedMessage);
+       }
+
+       /**
+        * Returns the identifier of the request that generated an URI.
+        * 
+        * @return The identifier of the request
+        */
+       public String getIdentifier() {
+               return getField("Identifier");
+       }
+
+       /**
+        * Returns the URI that was generated by the request.
+        * 
+        * @return The URI that was generated by the request
+        */
+       public String getURI() {
+               return getField("URI");
+       }
+
+}