Author: saces
Date: 2007-04-01 13:17:39 +0000 (Sun, 01 Apr 2007)
New Revision: 12508

Added:
   trunk/freenet/src/freenet/node/fcp/TestDDADeleteTestFileMessage.java
   trunk/freenet/src/freenet/node/fcp/TestDDAResult.java
   trunk/freenet/src/freenet/node/fcp/TestDDAResultMessage.java
Modified:
   trunk/freenet/src/freenet/node/fcp/TestDDAMessage.java
Log:
empty frame for TestDDA 

Added: trunk/freenet/src/freenet/node/fcp/TestDDADeleteTestFileMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/TestDDADeleteTestFileMessage.java        
                        (rev 0)
+++ trunk/freenet/src/freenet/node/fcp/TestDDADeleteTestFileMessage.java        
2007-04-01 13:17:39 UTC (rev 12508)
@@ -0,0 +1,66 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+package freenet.node.fcp;
+
+import java.io.File;
+
+import freenet.node.Node;
+import freenet.node.TestDDAManager;
+import freenet.support.SimpleFieldSet;
+
+/**
+ * DeleteDDATestFile
+ * Identifier=indent123unique  [mandatory]
+ * ClientToken=clientid         [mandatory]                    test owner
+ * 
+ */
+public class TestDDADeleteTestFileMessage extends FCPMessage {
+       
+       static final String name = "DeleteDDATestFile";
+       
+       private static final String FN_IDENTIFIER = "Identifier";
+       
+       private final String _ident; // unique id
+       
+       /** 
+        * @throws MessageInvalidException 
+        */
+       public TestDDADeleteTestFileMessage(SimpleFieldSet fs) throws 
MessageInvalidException {
+               _ident = fs.get(FN_IDENTIFIER);
+               if(_ident == null)
+                       throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Identifier", 
null, false);
+       }
+       
+       public SimpleFieldSet getFieldSet() {
+               SimpleFieldSet fs = new SimpleFieldSet(true);
+               fs.putSingle("Identifier", _ident);
+               return fs;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void run(FCPConnectionHandler handler, Node node)
+                       throws MessageInvalidException {
+               handler.getClientName();
+               TestDDAManager tm = null;// FIXME 
node.clientCore.testDDAManager;
+               TestDDAResult tr = tm.getTestResult(_ident);
+               if (tr == null) {
+                       throw new 
MessageInvalidException(ProtocolErrorMessage.NO_SUCH_IDENTIFIER, "No such test 
identifier", _ident, false);
+               }
+               if (!tr.isConfirmed) {
+                       throw new 
MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, "You need to 
confirm the test first", _ident, false);
+               }
+               File tf = tm.getTestWriteFile(_ident);
+               
+               FCPMessage msg;
+               
+               if (tf == null) {
+                       msg = new 
ProtocolErrorMessage(ProtocolErrorMessage.INTERNAL_ERROR, false, "Not a write 
test", _ident, false); 
+               }
+               
+               handler.outputHandler.queue(this);
+       }
+}

Modified: trunk/freenet/src/freenet/node/fcp/TestDDAMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/TestDDAMessage.java      2007-04-01 
01:57:09 UTC (rev 12507)
+++ trunk/freenet/src/freenet/node/fcp/TestDDAMessage.java      2007-04-01 
13:17:39 UTC (rev 12508)
@@ -14,6 +14,7 @@
 import java.util.Random;

 import freenet.node.Node;
+import freenet.node.NodeClientCore;
 import freenet.support.HexUtil;
 import freenet.support.SimpleFieldSet;

@@ -22,20 +23,11 @@
  * Identifier=indent123unique  [mandatory]
  * DirToTest=/path/to/dir       [mandatory]                    the dir to test
  * TestList=true               [default: false]                        can we 
list the dir?
- * ReadFilename=fileindir.ext          the filename for read test
- *                                                                     
readtest skipped if missing or empty
- *              the read test file needs to be an existing regular file 
- *              and must have size != 0!
- * WriteFilename=hallo.test                    the filename for write test
- * WriteFilename=                                      the node will generate 
an unique filename (recommended)
- *                                                                     
writetest skipped on missing
- *                             if a name is given, the client have to make 
sure the file doesn't exist!
+ * TestRead=fileindir.ext                      the filename for read test
+ *                                                                     
readtest skipped if missing
+ * TestWrite=true                                      the node will generate 
an unique filename
+ *                                                                     
writetest skipped if missing or not true
  * 
- * DeleteTestFile=             [default: true]
- *                             the testfile is only left if the read test was 
ok. 
- * 
- * 
- * 
  */
 public class TestDDAMessage extends FCPMessage {

@@ -43,42 +35,49 @@

        static final String name = "TestDDA";

+       private static final String FN_IDENTIFIER = "Identifier";
+       private static final String FN_TEST2DIR = "DirToTest";
+       private static final String FN_TESTLIST = "TestList";
+       private static final String FN_TESTREAD = "TestRead";
+       private static final String FN_TESTWRITE = "TestWrite";
+       
        private boolean resultList = false;
        private boolean resultWrite = false;

-       private String writeTestFilename = null; // set if it is generated
        private String readResult = null;
        private String writeResult = null;
-       final boolean testlist;
-       final String identifier;
-       final String dir2test;
-       final String readfilename;
-       final String writefilename;
-       
-       private final boolean deleteFile;
+       private final boolean _testlist;
+       private final boolean _testwrite;
+       private final String identifier; // unique id
+       private final String dir2test;   // the dir to test
+       private final String _readfilename;

+       private String writefilename;
+       
        /** 
         * @throws MessageInvalidException 
         */
        public TestDDAMessage(SimpleFieldSet fs) throws MessageInvalidException 
{
-               identifier = fs.get("Identifier");
+               identifier = fs.get(FN_IDENTIFIER);
                if(identifier == null)
                        throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Identifier", 
null, false);

-               dir2test = fs.get("DirToTest");
+               dir2test = fs.get(FN_TEST2DIR);
                if(dir2test == null)
-                       throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Identifier", 
identifier, false);
+                       throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Dir to test 
given", identifier, false);
                if(dir2test.trim().length() == 0)
                        throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "DirToTest can't be 
empty!", identifier, false);

-               String rfn = fs.get("ReadFilename");
+               String rfn = fs.get(FN_TESTREAD);
                if(rfn != null)
                        if (rfn.trim().length() > 0)
-                               readfilename = rfn;
+                               _readfilename = rfn;
                        else
                                throw new 
MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Read test filename 
can't be empty!", identifier, false);
-               else readfilename = null;
+               else _readfilename = null;

+               _testwrite = fs.getBoolean(FN_TESTWRITE, false);
+               
                String wfn = fs.get("WriteFilename");

                if (wfn == null) 
@@ -86,9 +85,7 @@
                else 
                        writefilename = wfn;

-               deleteFile = fs.getBoolean("DeleteTestFile", true);
-       
-               testlist = fs.getBoolean("TestList", false);
+               _testlist = fs.getBoolean(FN_TESTLIST, false);
        }

        public SimpleFieldSet getFieldSet() {
@@ -97,12 +94,12 @@
                fs.putSingle("TestedDir", dir2test);
                fs.putSingle("Status", getStatus());
                if (status == 0) { 
-                       if (testlist)
+                       if (_testlist)
                                fs.putSingle("ListTest", 
getResultName(resultList));
                        else
                                fs.putSingle("ListTest", "Skipped");

-                       if (readfilename != null) {
+                       if (_readfilename != null) {
                                if (readResult == null) { 
                                        fs.putSingle("ReadTest", 
getResultName(false));
                                } else {
@@ -113,11 +110,11 @@
                                fs.putSingle("ReadTest", "Skipped");

                        if (writefilename != null) {
-                               if (writeTestFilename != null) {
-                                       fs.putSingle("WriteFileName", 
writeTestFilename);
-                               } else {
+//                             if (writeTestFilename != null) {
+//                                     fs.putSingle("WriteFileName", 
writeTestFilename);
+//                             } else {
                                        fs.putSingle("WriteFileName", 
writefilename);
-                               }
+//                             }
                                fs.putSingle("WriteData", writeResult);
                                fs.putSingle("WriteTest", 
getResultName(resultWrite));
                        } else
@@ -137,6 +134,8 @@

        public void run(FCPConnectionHandler handler, Node node)
                        throws MessageInvalidException {
+               handler.getClientName();
+               NodeClientCore core = node.clientCore;
                realTest();
                handler.outputHandler.queue(this);
        }
@@ -167,9 +166,9 @@
                resultList = (t_dirList != null);

                // read
-               if (readfilename != null) {
+               if (_readfilename != null) {

-                       File t_read = new File(dir, readfilename);
+                       File t_read = new File(dir, _readfilename);

                        if (!t_read.isFile())
                                throw new 
MessageInvalidException(ProtocolErrorMessage.FILE_NOT_FOUND, "Read test 
filename must be an existing regular file!", identifier, false);
@@ -206,7 +205,7 @@
                                if (writefilename.trim().length() == 0) {
                                        //generate one
                                        f = File.createTempFile("NodeDDAtest", 
".dat", dir);
-                                       writeTestFilename = f.getName();
+                               //      writeTestFilename = f.getName();
                                } else { 
                                        f = new File(dir, writefilename);
                                        if (f.exists()) {
@@ -229,10 +228,7 @@

                                writeResult= HexUtil.bytesToHex(bb, 0 ,8);
                                resultWrite = Arrays.equals(b, bb);
-                               
-                               if (deleteFile) 
-                                       f.delete();
-                               
+                       
                        } catch (IOException ioe) {
                        }
                }

Added: trunk/freenet/src/freenet/node/fcp/TestDDAResult.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/TestDDAResult.java                       
        (rev 0)
+++ trunk/freenet/src/freenet/node/fcp/TestDDAResult.java       2007-04-01 
13:17:39 UTC (rev 12508)
@@ -0,0 +1,14 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+package freenet.node.fcp;
+
+
+/**
+ * 
+ */
+public class TestDDAResult {
+       
+       boolean isConfirmed;
+       
+}

Added: trunk/freenet/src/freenet/node/fcp/TestDDAResultMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/TestDDAResultMessage.java                
                (rev 0)
+++ trunk/freenet/src/freenet/node/fcp/TestDDAResultMessage.java        
2007-04-01 13:17:39 UTC (rev 12508)
@@ -0,0 +1,59 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+package freenet.node.fcp;
+
+import freenet.node.Node;
+import freenet.support.SimpleFieldSet;
+
+/**
+ * TestDDA
+ * Identifier=indent123unique  [mandatory]
+ * DirToTest=/path/to/dir       [mandatory]                    the dir to test
+ * TestList=true               [default: false]                        can we 
list the dir?
+ * TestRead=fileindir.ext                      the filename for read test
+ *                                                                     
readtest skipped if missing
+ * TestWrite=true                                      the node will generate 
an unique filename
+ *                                                                     
writetest skipped if missing or not true
+ * 
+ */
+public class TestDDAResultMessage extends FCPMessage {
+       
+       static final String name = "TestDDAResult";
+       
+       private static final String FN_IDENTIFIER = "Identifier";
+
+       private final String _ident; // unique id
+       private final String _msg; 
+
+       /** 
+        * @throws MessageInvalidException 
+        */
+//     public TestDDAResultMessage(SimpleFieldSet fs) throws 
MessageInvalidException {
+//             _ident = fs.get(FN_IDENTIFIER);
+//             if(_ident == null)
+//                     throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Identifier", 
null, false);
+//     
+//     }
+
+       private TestDDAResultMessage(String ident, String msg) {
+               _ident = ident;
+               _msg = msg;
+       }
+
+       public SimpleFieldSet getFieldSet() {
+               SimpleFieldSet fs = new SimpleFieldSet(true);
+               fs.putSingle("Identifier", _ident);
+               return fs;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void run(FCPConnectionHandler handler, Node node)
+                       throws MessageInvalidException {
+               throw new 
MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, "SimpleProgress 
goes from server to client not the other way around", _ident, false);
+       }
+
+}


Reply via email to