Hi,
It was only after starting to implement my R-client implementation in examples, that I noticed there is no 'DELETE'-command specified in the server protocol.
Is this a deliberate ommission?
I would guess that implementing such a command would come down to something like this: delete = function(name = name) { writeBin(as.raw(---BYTE---), private$sock) writeBin(private$raw_terminated_string(name), private$sock) return(list(info = private$info, success = self$bool_test_sock())) }
If this is correct, where can I find (a list with) the required byte-codes?
Ben Engbers
Hi Ben,
You are right, there is no DELETE entry in the client binding. The reason is that you can simply send a DELETE command [1], as there is no need to transfer additional binary data.
Does this help? Christian
[1] http://docs.basex.org/wiki/Commands#DELETE
On Mon, Apr 23, 2018 at 2:38 PM, Ben Engbers Ben.Engbers@be-logical.nl wrote:
Hi,
It was only after starting to implement my R-client implementation in examples, that I noticed there is no 'DELETE'-command specified in the server protocol.
Is this a deliberate ommission?
I would guess that implementing such a command would come down to something like this: delete = function(name = name) { writeBin(as.raw(---BYTE---), private$sock) writeBin(private$raw_terminated_string(name), private$sock) return(list(info = private$info, success = self$bool_test_sock())) }
If this is correct, where can I find (a list with) the required byte-codes?
Ben Engbers
Hi Christian,
Thanks for your answer. It helped.
Now I have another question.
According to the server protocol, I have coded the 'add'-command as follows: writeBin(as.raw(0x09), private$sock) writeBin(private$raw_terminated_string(name), private$sock) writeBin(private$raw_terminated_string(path), private$sock) writeBin(private$raw_terminated_string(input), private$sock) private$info <- self$str_receive() return(list(info = private$info, success = self$bool_test_sock()))
When executing these lines: Name1 <- "Name1.xml" Path1 <- "path/test" Simple <- "<x>Hello World!</x>" test <- Session$add(name = "Name1.xml", path = "path/test", input = Simple) I would expect that a new reource was created with name, path and content as specified by the parameters.
However I receive:
test
$info [1] ""Name1.xml.xml" (Line 1): Content is not allowed in prolog." $success [1] FALSE
Using Name1 <- "Name1" produces no error but still fails.
Can you give any clue in which direction i should search (using the debugger didn't help)
Ben
Op 23-04-18 om 16:08 schreef Christian Grün:
Hi Ben,
You are right, there is no DELETE entry in the client binding. The reason is that you can simply send a DELETE command [1], as there is no need to transfer additional binary data.
Does this help? Christian
Hi Ben,
I assume that this part of the server protocol is indeed outdated. I have just checked out our Java client, which only sends the target path to the server (which includes the name of the document) [1].
Could you check out if this solves the problem? If yes, I’ll be happy to update our documentation.
Best, Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/or...
On Tue, Apr 24, 2018 at 12:25 PM, Ben Engbers Ben.Engbers@be-logical.nl wrote:
Hi Christian,
Thanks for your answer. It helped.
Now I have another question.
According to the server protocol, I have coded the 'add'-command as follows: writeBin(as.raw(0x09), private$sock) writeBin(private$raw_terminated_string(name), private$sock) writeBin(private$raw_terminated_string(path), private$sock) writeBin(private$raw_terminated_string(input), private$sock) private$info <- self$str_receive() return(list(info = private$info, success = self$bool_test_sock()))
When executing these lines: Name1 <- "Name1.xml" Path1 <- "path/test" Simple <- "<x>Hello World!</x>" test <- Session$add(name = "Name1.xml", path = "path/test", input = Simple) I would expect that a new reource was created with name, path and content as specified by the parameters.
However I receive:
test
$info [1] ""Name1.xml.xml" (Line 1): Content is not allowed in prolog." $success [1] FALSE
Using Name1 <- "Name1" produces no error but still fails.
Can you give any clue in which direction i should search (using the debugger didn't help)
Ben
Op 23-04-18 om 16:08 schreef Christian Grün:
Hi Ben,
You are right, there is no DELETE entry in the client binding. The reason is that you can simply send a DELETE command [1], as there is no need to transfer additional binary data.
Does this help? Christian
Hi Christian,
I changed my code to: add = function(path = path, input = input) { writeBin(as.raw(0x09), private$sock) writeBin(private$raw_terminated_string(path), private$sock) writeBin(private$raw_terminated_string(input), private$sock) private$info <- self$str_receive() return(list(info = private$info, success = self$bool_test_sock())) } and tested the new code with: Path1 <- "Test1.xml" Path2 <- "test/Test1.xml" Simple1 <- "<x>Hello World!</x>" Simple2 <- "/home/bengbers/DataScience/RBaseX/Test1.xml" Simple3 <- "Test1.xml" Added <- Session$add(path = Path1, input = Simple1)
(Simple2 is Simple1 written to Test1.xml
When used with either Path1 or Path 2, Added$info returns: "Improper use? Potential bug? Your feedback is welcome:\nContact: basex-talk@mailman.uni-konstanz.de\nVersion: BaseX 9.0\nJava: Oracle Corporation, 1.8.0_162\nOS: Linux, amd64\nStack Trace: \njava.lang.RuntimeException: Learn: lock file does not exist.\n\tat org.basex.util.Util.notExpected(Util.java:61)\n\tat org.basex.data.DiskData.finishUpdate(DiskData.java:246)\n\tat org.basex.core.cmd.ACreate.update(ACreate.java:97)\n\tat org.basex.core.cmd.Add.run(Add.java:56)\n\tat org.basex.core.Command.run(Command.java:257)\n\tat org.basex.core.Command.execute(Command.java:93)\n\tat org.basex.core.Command.execute(Command.java:116)\n\tat org.basex.server.ClientListener.execute(ClientListener.java:343)\n\tat org.basex.server.ClientListener.add(ClientListener.java:314)\n\tat org.basex.server.ClientListener.run(ClientListener.java:96)\n"
With Path1/Simple2 or Path1/Simple3: ""Test1.xml.xml" (Line 1): Content is not allowed in prolog."
With Path2/Simple2 or Path2/Simple3: ""test/Test1.xml.xml" (Line 1): Content is not allowed in prolog."
In all cases Added$success returns FALSE
In an old mail someone suggested that maybe this was caused by the used encoding. I converted the encoding for Test1.xml from US-ASCII to UTF-8 but this had no effect.
Cheers, Ben
Op 24-04-18 om 13:46 schreef Christian Grün:
Hi Ben,
I assume that this part of the server protocol is indeed outdated. I have just checked out our Java client, which only sends the target path to the server (which includes the name of the document) [1].
Could you check out if this solves the problem? If yes, I’ll be happy to update our documentation.
Best, Christian
Hi Ben,
We have various JUnit tests for checking the correctness of our client API [1], so my guess is that the server protocol works correctly here. However, it may be due to your specific input file that an error is raised. Could you possibly try the Java client and see if it works with your XML document, or forward me the file in question?
Best, Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/test/java/org/ba...
On Tue, Apr 24, 2018 at 2:36 PM, Ben Engbers Ben.Engbers@be-logical.nl wrote:
Hi Christian,
I changed my code to: add = function(path = path, input = input) { writeBin(as.raw(0x09), private$sock) writeBin(private$raw_terminated_string(path), private$sock) writeBin(private$raw_terminated_string(input), private$sock) private$info <- self$str_receive() return(list(info = private$info, success = self$bool_test_sock())) } and tested the new code with: Path1 <- "Test1.xml" Path2 <- "test/Test1.xml" Simple1 <- "<x>Hello World!</x>" Simple2 <- "/home/bengbers/DataScience/RBaseX/Test1.xml" Simple3 <- "Test1.xml" Added <- Session$add(path = Path1, input = Simple1)
(Simple2 is Simple1 written to Test1.xml
When used with either Path1 or Path 2, Added$info returns: "Improper use? Potential bug? Your feedback is welcome:\nContact: basex-talk@mailman.uni-konstanz.de\nVersion: BaseX 9.0\nJava: Oracle Corporation, 1.8.0_162\nOS: Linux, amd64\nStack Trace: \njava.lang.RuntimeException: Learn: lock file does not exist.\n\tat org.basex.util.Util.notExpected(Util.java:61)\n\tat org.basex.data.DiskData.finishUpdate(DiskData.java:246)\n\tat org.basex.core.cmd.ACreate.update(ACreate.java:97)\n\tat org.basex.core.cmd.Add.run(Add.java:56)\n\tat org.basex.core.Command.run(Command.java:257)\n\tat org.basex.core.Command.execute(Command.java:93)\n\tat org.basex.core.Command.execute(Command.java:116)\n\tat org.basex.server.ClientListener.execute(ClientListener.java:343)\n\tat org.basex.server.ClientListener.add(ClientListener.java:314)\n\tat org.basex.server.ClientListener.run(ClientListener.java:96)\n"
With Path1/Simple2 or Path1/Simple3: ""Test1.xml.xml" (Line 1): Content is not allowed in prolog."
With Path2/Simple2 or Path2/Simple3: ""test/Test1.xml.xml" (Line 1): Content is not allowed in prolog."
In all cases Added$success returns FALSE
In an old mail someone suggested that maybe this was caused by the used encoding. I converted the encoding for Test1.xml from US-ASCII to UTF-8 but this had no effect.
Cheers, Ben
Op 24-04-18 om 13:46 schreef Christian Grün:
Hi Ben,
I assume that this part of the server protocol is indeed outdated. I have just checked out our Java client, which only sends the target path to the server (which includes the name of the document) [1].
Could you check out if this solves the problem? If yes, I’ll be happy to update our documentation.
Best, Christian
basex-talk@mailman.uni-konstanz.de