add TestDDAComplete message
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 10 Apr 2008 08:23:54 +0000 (08:23 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 10 Apr 2008 08:23:54 +0000 (08:23 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@686 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/TestDDAComplete.java [new file with mode: 0644]

index 62adc9e..cdfbe03 100644 (file)
@@ -96,6 +96,14 @@ public class FcpAdapter implements FcpListener {
        }
 
        /**
+        * @see net.pterodactylus.util.fcp.FcpListener#receivedTestDDAComplete(net.pterodactylus.util.fcp.FcpConnection,
+        *      net.pterodactylus.util.fcp.TestDDAComplete)
+        */
+       public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete) {
+               /* empty. */
+       }
+
+       /**
         * @see net.pterodactylus.util.fcp.FcpListener#receivedMessage(net.pterodactylus.util.fcp.FcpConnection,
         *      net.pterodactylus.util.fcp.FcpMessage)
         */
index 6cd71b4..07a0916 100644 (file)
@@ -271,6 +271,18 @@ public class FcpConnection {
        }
 
        /**
+        * Notifies all listeners that a “TestDDAComplete” message was received.
+        * 
+        * @param testDDAComplete
+        *            The “TestDDAComplete” message
+        */
+       private void fireReceivedTestDDAComplete(TestDDAComplete testDDAComplete) {
+               for (FcpListener fcpListener: fcpListeners) {
+                       fcpListener.receivedTestDDAComplete(this, testDDAComplete);
+               }
+       }
+
+       /**
         * Notifies all registered listeners that a message has been received.
         * 
         * @see FcpListener#receivedMessage(FcpConnection, FcpMessage)
@@ -360,6 +372,8 @@ public class FcpConnection {
                        fireReceivedNodeData(new NodeData(fcpMessage));
                } else if ("TestDDAReply".equals(messageName)) {
                        fireReceivedTestDDAReply(new TestDDAReply(fcpMessage));
+               } else if ("TestDDAComplete".equals(messageName)) {
+                       fireReceivedTestDDAComplete(new TestDDAComplete(fcpMessage));
                } else if ("NodeHello".equals(messageName)) {
                        fireReceivedNodeHello(new NodeHello(fcpMessage));
                } else if ("CloseConnectionDuplicateClientName".equals(messageName)) {
index f34cd0d..50156ab 100644 (file)
@@ -131,6 +131,16 @@ public interface FcpListener extends EventListener {
        public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply);
 
        /**
+        * Notifies a listener that a “TestDDAComplete” was received.
+        * 
+        * @param fcpConnection
+        *            The connection that received the message
+        * @param testDDAComplete
+        *            The “TestDDAComplete” message
+        */
+       public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete);
+
+       /**
         * Notifies a listener that a message has been received. This method is only
         * called if {@link FcpConnection#handleMessage(FcpMessage)} does not
         * recognize the message. Should that ever happen, please file a bug report!
diff --git a/src/net/pterodactylus/util/fcp/TestDDAComplete.java b/src/net/pterodactylus/util/fcp/TestDDAComplete.java
new file mode 100644 (file)
index 0000000..f43b18d
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+/**
+ * The “TestDDAComplete” message signals that the node has finished checking
+ * your read and write access to a certain directory.
+ * 
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class TestDDAComplete extends BaseMessage {
+
+       /**
+        * Creates a new “TestDDAComplete” message that wraps the received message.
+        * 
+        * @param receivedMessage
+        *            The received message
+        */
+       public TestDDAComplete(FcpMessage receivedMessage) {
+               super(receivedMessage);
+       }
+
+       /**
+        * Returns the directory the authorization is given for.
+        * 
+        * @return The directory that was tested for read and/or write access
+        */
+       public String getDirectory() {
+               return getField("Directory");
+       }
+
+       /**
+        * Returns whether read access to the directory is allowed.
+        * 
+        * @return <code>true</code> if the client is allowed to read from that
+        *         directory, <code>false</code> otherwise
+        */
+       public boolean isReadDirectoryAllowed() {
+               return Boolean.valueOf(getField("ReadDirectoryAllowed"));
+       }
+
+       /**
+        * Returns whether write access to the directory is allowed.
+        * 
+        * @return <code>true</code> if the client is allowed to write into that
+        *         directory, <code>false</code> otherwise
+        */
+       public boolean isWriteDirectoryAllowed() {
+               return Boolean.valueOf(getField("WriteDirectoryAllowed"));
+       }
+
+}