From ff858758c2c7db3b075cce6e233600555a612935 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 10 Apr 2008 11:41:21 +0000 Subject: [PATCH] add URIGenerated git-svn-id: http://trooper/svn/projects/jSite/trunk@692 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/fcp/FcpAdapter.java | 8 +++++ src/net/pterodactylus/util/fcp/FcpConnection.java | 14 ++++++++ src/net/pterodactylus/util/fcp/FcpListener.java | 10 ++++++ src/net/pterodactylus/util/fcp/URIGenerated.java | 44 +++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 src/net/pterodactylus/util/fcp/URIGenerated.java diff --git a/src/net/pterodactylus/util/fcp/FcpAdapter.java b/src/net/pterodactylus/util/fcp/FcpAdapter.java index 3ffe986..ca078f7 100644 --- a/src/net/pterodactylus/util/fcp/FcpAdapter.java +++ b/src/net/pterodactylus/util/fcp/FcpAdapter.java @@ -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) */ diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index 9c88ea9..dffb110 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -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)) { diff --git a/src/net/pterodactylus/util/fcp/FcpListener.java b/src/net/pterodactylus/util/fcp/FcpListener.java index 70e834a..96c6d02 100644 --- a/src/net/pterodactylus/util/fcp/FcpListener.java +++ b/src/net/pterodactylus/util/fcp/FcpListener.java @@ -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 index 0000000..677823a --- /dev/null +++ b/src/net/pterodactylus/util/fcp/URIGenerated.java @@ -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 David Roden + * @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"); + } + +} -- 2.7.4