Skip to content

Share2.0 sharemanager - #19872

Merged
DeepDiver1975 merged 6 commits into
masterfrom
share2.0_sharemanager
Nov 5, 2015
Merged

DeepDiver1975 merged 6 commits into
masterfrom
share2.0_sharemanager

Conversation

@rullzer

@rullzer rullzer commented Oct 19, 2015

Copy link
Copy Markdown
Contributor

@schiesbn @DeepDiver1975 first draft is here.

for now we have a sharemanager object and a ishareprovider and that is it. So no share object. Basically everything goes trough the share manager.

The manager itself acts like some kind of middleware between the shareprovider and the OCS Share API. Making sure that arguments are in the right format (date for example). And making sure that the user we want to share with exists etc.

IShareProviders register themself at the sharemanager with a callback function. And then all the magic happens.

Many things in the code do not work as expected yet or are even plain wrong now. But if we agree this is the way to go I can start cleaning up and already write some simple unit tests for this part. And do some squashing of commits :P

So feedback please :)

@rullzer rullzer added this to the 9.0-next milestone Oct 19, 2015
@DeepDiver1975

Copy link
Copy Markdown
Contributor

@rullzer

PHP Fatal error:  Interface function OC\Share20\IShareProvider::share() cannot contain body in /ssd/jenkins/workspace/core-ci-linux@2/database/sqlite/label/SLAVE/lib/private/share20/ishareprovider.php on line 25

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@rullzer seriously get a proper IDE - and this is no recommendation - but an order 😉

bildschirmfoto von 2015-10-19 22-09-43

@rullzer

rullzer commented Oct 20, 2015

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 yeah I know it doesn't work. But I first wanted to agree if this was the way to go for the manager before I start to do all kinds of actual code and add unit tests etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the namespace Share20 ... we will find something better

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. For not is just there since OC\Share was taken

@rullzer

rullzer commented Oct 20, 2015

Copy link
Copy Markdown
Contributor Author

So as discussed with @schiesbn and @nickvergessen there is now a share object which is passed around so we keep the general logic in 1 place. This looks a lot cleaner than it was before. It keeps a lot of logic at the right place.

This means that the manager and providers now have create update and delete functions. That just take a share object and do their thing with it.

And that is enough share manager for today.

Comment thread lib/private/share20/manager.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

since merging these results has it's drawbacks we might want to consider getShares to be specific for the share type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah, the "TODO proper pagination" will teach you that merging arrays will not work together with paging, remember the sharee mess.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@nickvergessen that was my point exactly. Doing it properly means we either have to define an order ourself. i.e. user, group, link, remote.

Since I think just limiting them to the sharetype is not really what people expect (and will also break the current OCS API behaviour)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since I think just limiting them to the sharetype is not really what people expect (and will also break the current OCS API behaviour)

What is the existing behavior with respect to OCS API? Can it properly perform pagination?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What is the existing behavior with respect to OCS API? Can it properly perform pagination?

No selection on share type. No pagination just everything is returned.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

because the id (unique autoincrement from db) belongs to two different tables

the idea was to prefix these ids with a provider prefix ... but yes this design is kind of questinoable under the light of pagination

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Then the getShareById function should also require an shareType. Which means that routes like

shares/<ID> are no longer valid.

And they are now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shares/ are no longer valid.

What ID can that be? Fed shares as well? I don't think so - right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that can currently be any initiated sharing id. So if I share to you a federated share... and that on my side has id 5 I can get it via shares/5

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the code with how I think we can do proper pagination on this.

@rullzer
rullzer force-pushed the share2.0_sharemanager branch from 6806b69 to 69514d0 Compare October 21, 2015 13:21
@rullzer

rullzer commented Oct 21, 2015

Copy link
Copy Markdown
Contributor Author

I added the register functions back as dicussed with @schiesbn. Since we want our own implentations to be able to register themselfs so they can be used as fallback if the storage does not provide it.

Also I modified the manager a bit to allow for proper pagination of shares by ordering them by shareType.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

I added the register functions back as dicussed with @schiesbn. Since we want our own implentations to be able to register themselfs so they can be used as fallback if the storage does not provide it.

whatfor? the default implementation is provided by the default implementation of the home storage.
there is no need to provide any provider any other way.

@rullzer

rullzer commented Oct 21, 2015

Copy link
Copy Markdown
Contributor Author

whatfor?

With all the effort we spend moving core functionality to apps this seems logical.

@karlitschek

Copy link
Copy Markdown
Contributor

@rullzer Which effort to move core functionality to apps do you mean?

@rullzer

rullzer commented Oct 21, 2015

Copy link
Copy Markdown
Contributor Author

@rullzer Which effort to move core functionality to apps do you mean?

Well we move webdav to a separate app. There are efforts to get the preview generation out of core and only keep the manager etc.

@karlitschek

Copy link
Copy Markdown
Contributor

I'm not aware of any work to move previews out. So this is not a general theme or indication that we should do this ll over the place :-)

@schiessle

Copy link
Copy Markdown
Contributor

whatfor? the default implementation is provided by the default implementation of the home storage.
there is no need to provide any provider any other way.

we still have the "federated share provider" which will be a app and you don't want that the app manager need to know the app name, need to know what it does, need to check if the app is enabled and then call it. The other way around makes just much more sense.

Also I'm not sure yet if the default share provider for user, group and link share should be implemented as part of our home storage because we also need it as fall back if a different storage is used but didn't implement a share provider. In such a case it makes much more sense if we have a "federated share provider" and a "oc default internal share provider" both implemented as app and which register them self at the share manager. The share manager can additionally ask the storage "getShareProvider()". If something is returned fine, then we use it. But it can also happen that the storage will just return false because the storage doesn't provide his own share provider, in this case we will fall back to the "oc default internal share provider" but this is only possible if this share provider is available independent from a storage implementation.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

I'm not aware of any work to move previews out. So this is not a general theme or indication that we should do this ll over the place :-)

@karlitschek with 8.2 we started to allow additional preview generators to be added by apps using public api. So it's possible to have new preview generators in apps and even move e.g. the libreoffice based preview generators to aps on their own which is encouraged by @LukasReschke if I recann correctly due to potential vulnerabilities.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@schiesbn point taken regarding the fed sharing - given the all the discussions above I don't yet finally know where this all fits together ... let's see.

regarding the homestorage based share provider:

interface IStorage {
  function getSharePoriver();
}

class Common implemets IStorage {
  function getShareProvider() {
    return new DefaultImplementation();
  }
}

class ObjectStore extends Common {
  function getShareProvider() {
    return new MyVeryOwnImplementation();
  }
}

class StorageWhichUsesDefault extends Common {
  // simply don't implement the method
}

class ShareManager {
  function getShareProvider($path) {
    $this->getStorageForPath()->getShareProvider();
  }
}

@rullzer

rullzer commented Oct 22, 2015

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975

class ShareManager {
  function getShareProvider($path) {
    $this->getStorageForPath()->getShareProvider();
  }
}

Just to clarify, do we then expect the storage to take care of all the magic with finding the right provider? E.g. You have a file on external storage, which does not handle its own sharing. Will it then still give us the primary storage implementation?

And if the primary storage does not provide an implementation does it then automagically fetch our default implementation.

I like the abstraction here, and it makes our share manager a lot simpler. But will most likely make the storage backend a little bit more complicated.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Just to clarify, do we then expect the storage to take care of all the magic with finding the right provider? E.g. You have a file on external storage, which does not handle its own sharing. Will it then still give us the primary storage implementation?

as for now we anyhow only support the homestorage/primary storage to specify the one and only share provider. as for now we do not support additional providers on e.g. external storages - which could be an interesting thing in the future

@rullzer
rullzer force-pushed the share2.0_sharemanager branch from a00e2d6 to 5dd9bc4 Compare November 3, 2015 07:08
@DeepDiver1975

Copy link
Copy Markdown
Contributor

Haha - no db likes you now! 🙊

@rullzer
rullzer force-pushed the share2.0_sharemanager branch 2 times, most recently from 629010f to c40fbd5 Compare November 3, 2015 09:48
@rullzer

rullzer commented Nov 3, 2015

Copy link
Copy Markdown
Contributor Author

Oracle is happy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should trigger the hooks by the manager and not by the provider. To make sure that the hooks are always triggered, no matter which share provider is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that is cleaner as well. But then we should also make sure that the deletion of children is actually handled from the manager. Else we would need callbacks from the providers to the manager and you have the same issue.

I agree. But lets do this in a followup PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. But lets do this in a followup PR.

fine with me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bwt we can pass objects in hooks? would it make more sense to send around the IShare?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can. But lets do that in a later stage. Because then we would not to change all listners to unshare as well.

@schiessle

Copy link
Copy Markdown
Contributor

beside the hooks which would move the the manager, as described here #19872 (comment) I would merge it so that we can move on. We can still adjust if needed during the next development steps 👍

@rullzer

rullzer commented Nov 4, 2015

Copy link
Copy Markdown
Contributor Author

One more reviewer needed... lets get this in so sharing2.0 work can continue!

CC @DeepDiver1975 @nickvergessen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

class name should be upper case (something for later)

@nickvergessen

Copy link
Copy Markdown
Contributor

fine by me, remaining stuff can be fixed in follow up.

Especially the license needs to be done ;)

👍

@rullzer
rullzer force-pushed the share2.0_sharemanager branch from 508787f to 15f1d6b Compare November 5, 2015 11:07
* Added sharemanager class

This is the central class where all API calls talk to (OCS/Activity).
This in turn talks to the share providers to get the actual sharing
done.

It uses all ShareObjects

* Added share class

Simple class to hold all the share properties that is passed around

* Added IShareProvider interface

Interface that providers os a share have to implement.
OCS -> ShareManager -> DefaultShareProvider
@rullzer
rullzer force-pushed the share2.0_sharemanager branch from 15f1d6b to 532b8a1 Compare November 5, 2015 14:59
@rullzer

rullzer commented Nov 5, 2015

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 Integration tests are happy :)
Only oracle is having backgroundjob failures again.

DeepDiver1975 added a commit that referenced this pull request Nov 5, 2015
@DeepDiver1975
DeepDiver1975 merged commit 3ae5a98 into master Nov 5, 2015
@DeepDiver1975
DeepDiver1975 deleted the share2.0_sharemanager branch November 5, 2015 21:34
@rullzer rullzer mentioned this pull request Nov 12, 2015
35 of 43 tasks
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants