Skip to content
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

add remote item metadata #6300

Merged
merged 1 commit into from
Jun 14, 2023
Merged

add remote item metadata #6300

merged 1 commit into from
Jun 14, 2023

Conversation

micbar
Copy link
Contributor

@micbar micbar commented May 12, 2023

Description

This adds the needed metadata to the remote item which represents the real location of a share in the storage space of the share owner.

This is needed to access shares via the storage-users provider to have the same URL for all participants of a share.

Related Issue

Motivation and Context

Access shares via the original Url of the owner

Examples

Admin shares Test/Test2/Test3 with Einstein

Einstein lists his drives an finds a share (driveType=mountpoint)

{
    "driveAlias":"mountpoint/test3",
    "driveType":"mountpoint",
    "id":"a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!storage-users-1:some-admin-user-id-0000-000000000000:405575a4-6543-47f5-badf-df0012074105",
    "name":"test3",
    "owner":{
        "user":{
            "displayName":"",
            "id":"some-admin-user-id-0000-000000000000"
        }
    },
    "quota":{
        "remaining":0,
        "state":"exceeded",
        "total":0,
        "used":0
    },
    "root":{
        "id":"a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!storage-users-1:some-admin-user-id-0000-000000000000:405575a4-6543-47f5-badf-df0012074105",
        "remoteItem":{
            "driveAlias":"personal/admin",
            "eTag":"\"bb78fbc89ef8bd249c558509ce87165e\"",
            "folder":{
                
            },
            "id":"storage-users-1$some-admin-user-id-0000-000000000000!2fc98624-c510-4bef-bdac-331d790b4db9",
            "lastModifiedDateTime":"2023-05-09T10:49:55.502298122+02:00",
            "name":"test3",
            "path":"/Test/Test2/test3",
            "rootId":"storage-users-1$some-admin-user-id-0000-000000000000!some-admin-user-id-0000-000000000000",
            "size":0,
            "webDavUrl":"https://localhost:9200/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000%21some-admin-user-id-0000-000000000000/Test/Test2/test3"
        },
        "webDavUrl":"https://localhost:9200/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668%21storage-users-1:some-admin-user-id-0000-000000000000:405575a4-6543-47f5-badf-df0012074105"
    },
    "webUrl":"https://localhost:9200/f/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668%21storage-users-1:some-admin-user-id-0000-000000000000:405575a4-6543-47f5-badf-df0012074105"
}

In the remoteItem we can no see 3 new properties:

  1. path The relative path of the item in the originating space (needed for web navigation)
  2. rootId The ID of the originating space
  3. driveAlias the drive alias of the originating space (needed for web navigation)
  4. webDavUrl the ready-to-use WebDAVURL to access the share

NOTE

This moves the access to the share away from the sharesstorageprovider and uses the normal storage-users provider of the share owner.

Example

curl -L -X PROPFIND 'https://localhost:9200/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000%21some-admin-user-id-0000-000000000000/Test/Test2/test3' \
-H 'Authorization: Basic ZWluc3RlaW46cmVsYXRpdml0eQ=='

Response

<d:multistatus xmlns:s="http://sabredav.org/ns" xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
    <d:response>
        <d:href>/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000%21some-admin-user-id-0000-000000000000/Test/Test2/test3/</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>storage-users-1$some-admin-user-id-0000-000000000000!2fc98624-c510-4bef-bdac-331d790b4db9</oc:id>
                <oc:fileid>storage-users-1$some-admin-user-id-0000-000000000000!2fc98624-c510-4bef-bdac-331d790b4db9</oc:fileid>
                <oc:spaceid>some-admin-user-id-0000-000000000000</oc:spaceid>
                <oc:file-parent>storage-users-1$some-admin-user-id-0000-000000000000!0cd66714-605b-4398-a1b4-755408aa7859</oc:file-parent>
                <oc:name>test3</oc:name>
                <d:getetag>"bb78fbc89ef8bd249c558509ce87165e"</d:getetag>
                <oc:permissions>SRDNVCK</oc:permissions>
                <d:resourcetype>
                    <d:collection/>
                </d:resourcetype>
                <oc:size>0</oc:size>
                <d:getlastmodified>Tue, 09 May 2023 08:49:55 GMT</d:getlastmodified>
                <oc:tags></oc:tags>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
  <d:response>
        <d:href>/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000%21some-admin-user-id-0000-000000000000/Test/Test2/test3/File.md</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>storage-users-1$some-admin-user-id-0000-000000000000!1fe3eb41-9950-45b1-97ad-dd6a5af40758</oc:id>
                <oc:fileid>storage-users-1$some-admin-user-id-0000-000000000000!1fe3eb41-9950-45b1-97ad-dd6a5af40758</oc:fileid>
                <oc:spaceid>some-admin-user-id-0000-000000000000</oc:spaceid>
                <oc:file-parent>storage-users-1$some-admin-user-id-0000-000000000000!2fc98624-c510-4bef-bdac-331d790b4db9</oc:file-parent>
                <oc:name>File.md</oc:name>
                <d:getetag>"06951524a15b155593fca499b77600e6"</d:getetag>
                <oc:permissions>RDNVW</oc:permissions>
                <d:resourcetype></d:resourcetype>
                <d:getcontentlength>10</d:getcontentlength>
                <d:getcontenttype>text/markdown</d:getcontenttype>
                <d:getlastmodified>Mon, 15 May 2023 20:40:49 GMT</d:getlastmodified>
                <oc:checksums>
                    <oc:checksum>SHA1:7372e8a68e32dd9f22d0365736d5d0531baa0110 MD5:7a3626e690c0df52aafe3784210f991c ADLER32:0ff1035e</oc:checksum>
                </oc:checksums>
                <oc:tags></oc:tags>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

Download the file

curl -L 'https://localhost:9200/dav/spaces/storage-users-1$some-admin-user-id-0000-000000000000%21some-admin-user-id-0000-000000000000/Test/Test2/test3/File.md' \
-H 'Authorization: Basic ZWluc3RlaW46cmVsYXRpdml0eQ=='

Response

# Headline

How Has This Been Tested?

  • Manually (see examples)

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@update-docs
Copy link

update-docs bot commented May 12, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@ownclouders
Copy link
Contributor

ownclouders commented May 12, 2023

💥 Acceptance test localApiTests-apiGraph-ocis failed. Further test are cancelled...

@micbar micbar force-pushed the remote-item branch 4 times, most recently from 8f93d1b to b0b2e24 Compare May 15, 2023 15:11
services/graph/pkg/service/v0/driveitems.go Outdated Show resolved Hide resolved
@micbar micbar force-pushed the remote-item branch 2 times, most recently from ed9b62b to dde48a5 Compare May 16, 2023 14:31
@micbar micbar force-pushed the remote-item branch 2 times, most recently from 8f2539c to e4e1bb4 Compare June 13, 2023 08:07
@micbar micbar marked this pull request as ready for review June 13, 2023 08:07
Copy link
Collaborator

@kobergj kobergj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix the potential panics

services/graph/pkg/service/v0/driveitems.go Outdated Show resolved Hide resolved
services/graph/pkg/service/v0/driveitems.go Show resolved Hide resolved
Signed-off-by: Michael Barz <mbarz@owncloud.com>
@micbar micbar requested a review from kobergj June 14, 2023 09:21
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@kulmann kulmann dismissed their stale review June 14, 2023 12:28

already reviewed by julian

@micbar micbar merged commit 0109105 into master Jun 14, 2023
@delete-merged-branch delete-merged-branch bot deleted the remote-item branch June 14, 2023 12:31
ownclouders pushed a commit that referenced this pull request Jun 14, 2023
@micbar micbar mentioned this pull request Jul 24, 2023
68 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants