-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAV endpoint for system tags #20786
DAV endpoint for system tags #20786
Conversation
By analyzing the blame information on this pull request, we identified @LukasReschke, @icewind1991 and @DeepDiver1975 to be potential reviewers |
Note: cadaver doesn't work on these endpoints, maybe because there is no mtime/size/etc |
Additional info: tag id is auto-generated and the tag info is a tuple of "tag name", "user visible" and "user assignable". So it's possible to have several tags with the same name but different flags. This is why I used the compound names. |
To test, create a file "propfind_tags.txt": <?xml version="1.0"?>
<a:propfind xmlns:a="DAV:" xmlns:oc="http://owncloud.org/ns">
<a:prop><oc:id/></a:prop>
<a:prop><oc:display-name/></a:prop>
<a:prop><oc:user-visible/></a:prop>
<a:prop><oc:user-assignable/></a:prop>
</a:propfind> Then with curl: curl -X PROPFIND -H "Content-Type: text/xml" --data-binary "@propfind_tags.txt" http://root:admin@localhost/owncloud/remote.php/dav/systemtags/root/by-id/ | xmllint --format - Might need to manually create some tags in the DB, for example: insert into oc_systemtag values (NULL, 'readonly', 1, 0); |
$this->tagManager->deleteTags($this->tag->getId()); | ||
} catch (TagNotFoundException $e) { | ||
// can happen if concurrent deletion occurred | ||
throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete operation is idempotent - deleting a not existing element has the same effect as deleting an existing element: it is gone after the request.
so - no excpetion shall be thrown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a misunderstanding of what idempotent means.
I'll look into the creating topic - PUT has to work - caldav and carddav also use put - principals as well |
b7244b2
to
4d1cd6a
Compare
PUT is fixable I think. It was more of a semantic question. |
PUT for me works with cadaver if I create a local file names test_1_1 🙈 Regarding the properties on creation: we can submit them in the request body - as in file content |
so - system tags are not related to the user - as a result having the principal in the url doesn't make sense |
*/ | ||
public function getName() { | ||
return $this->tag->getName() . '_' . | ||
($this->tag->isUserVisible() ? '1' : '0') . '_' . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visibility makes no sense, if it's not visible it should not be exposed via webdav
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admins should see them in order to allow modifications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
furthermore: since tags hold not content by itself - we could model them as collections as well ... |
Yes that's what I thought. However at some point the admins must be able to see the ones that are not user visible. Is it acceptable to have the endpoints deliver different results based on who is logged in then ? |
URL are unique identifiers to the resource since tags are not user related the user has no value in the url. With respect to accessibility: an user invisible tag does exist - but is simply not accessible by a user. What might be an approach to think about: encode the visibility in the url and the assignability as well /dav/system-tags/visible/assignable/test |
Or to have less endpoints, have an "admin" endpoint and "user" endpoint: /dav/system-tags/admin/by-id/$tagId Admin tags would be the ones that are not user visible. |
this would generate two differen URLs to the same resource - not nice |
Hey guys. Very cool commit! While I don't know exactly what system tags are, it's really awesome to see people using advance sabre stuff ;) The POST add-member stuff is something I'm definitely interested in having in sabredav. If you guys want this, I would be happy to include it in a minor 3.0.x release as I don't think this would introduce any sort of BC issues. What's the issue with |
To be a bit more precise: What does your PUT request contain in its request body, and what should its effect be? |
@evert a system-wide (aka global) tag is the tuple "tag name", "user visible", "user assignable". What is not clear is how to design the endpoints to allow for creation of tags using PUT. In other places in the code we need to work using the autoincrement $tagId, so I thought about having an additional read-only endpoint "by-id" to access tags by id. But as @DeepDiver1975 pointed out, a resource URL should actually be unique. What do you think ? Does that make sense ? |
Also, how to do pagination / server-side filtering ? |
How to filter by file id ? Maybe an endpoint "/dav/system-tags/admin/files/$fileid/" and the collection returns a list of tags assigned to this file ? |
going with to different endpoint "by-id" and "by-name" is fine for my understanding - my comment about uniqueness was related to the user component in the url.
We can define REPORTs for that - a well used mechanism in the area of dav. |
Another problem I see is with assigning tags to files and concurrency: A simple way to assign tags "one", "two" to a file "file1.txt" is PROPPATCH the file with Another solution would be to have an endpoint that represents the tag list as a collection for a file: "/dav/system-tags/files/$fileid/$tagId". Then assigning/unassigning tags is a matter of PUT/DELETE tag ids into the collection. Or MOVE/COPY ? We're not creating new tags, just using existing ones. Or is there a standard way to make PROPPATCH add sub-properties instead of replacing the whole set ? |
This will be protected by the If-Match header and the etag ... valid question: do we update the etag of a file as soon as tags got added/removed? This will trigger sync on the clients. Not what we want to have ..... |
@DeepDiver1975 regarding etag + metadata, related tickets: #16589 #20474 |
Please review @nickvergessen @blizzz @DeepDiver1975 @icewind1991 |
use OCP\SystemTag\TagNotFoundException; | ||
use OCP\SystemTag\TagAlreadyExistsException; | ||
|
||
class SystemTagNode implements \Sabre\DAV\INode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class description?
@blizzz adressed all the comments and added the precious "s" (which broke all the tests, took a while to fix them 😉) |
vim should have a plugin that shows you all usages of a method and/or to savely rename it. Or, use ack(-grep) for finding those calls :) |
OK, i am happy 👍 |
I did, but some of the mocks had the method name hard-coded in a string. So a regular |
Did basic testing, code looks good 👍 |
DAV endpoint for system tags
TODO: add endpoint to retrieve all files/folders tagged by a specific tag?TODO: allow MOVE for rename in "by-name", only if target name doesn't existBELOW is obsolete, jump to #20786 (comment)
@DeepDiver1975 @nickvergessen
Questions:
@evert mind helping with the PUT questions ? Are there any examples how to use non-files as sabre resources ?