Missing 'DELETE' in server protocol?

Monday, 23 April 2018 · 6 messages · last reply 25 Apr 2018
BE
Ben Engbers23 Apr 2018 14:38 #
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
CG
Christian Grün23 Apr 2018 16:08 #
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
Quoted text · Ben Engbers · 22 lines
On Mon, Apr 23, 2018 at 2:38 PM, Ben Engbers <Ben.Engbers at 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 > >
BE
Ben Engbers24 Apr 2018 12:25 #
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:
Quoted text · Christian Grün · 1 line
> 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
Quoted text · Christian Grün · 9 lines
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
CG
Christian Grün24 Apr 2018 13:46 #
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/org/basex/examples/api/BaseXClient.java#L118-L120
Quoted text · Ben Engbers · 46 lines
On Tue, Apr 24, 2018 at 12:25 PM, Ben Engbers <Ben.Engbers at 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
BE
Ben Engbers24 Apr 2018 14:36 #
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 at 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
Quoted text · Christian Grün · 12 lines
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
CG
Christian Grün25 Apr 2018 10:05 #
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/basex/server/SessionTest.java
Quoted text · Ben Engbers · 64 lines
On Tue, Apr 24, 2018 at 2:36 PM, Ben Engbers <Ben.Engbers at 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 at 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

⚡Generated with XQuery