You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Ian Boston <ie...@tfd.co.uk> on 2015/02/26 11:56:55 UTC

Adapt to Tenant ?

Hi,
Does sling support the following ?
I have looked at some running instances and not found adapter factories
that do.

Tenant tenant = resource.adaptTo(Tenant.class)

Where tenant is the tenant in which the resource resides or the tenant has
read access to. I guess in highly collaborative environments it could be
more than one Tenant, but lets not go there just yet.

and

Tenant tenant = resource.getResourceResolver().adaptTo(Tenant.class)

Where the tenant in this case the the tenant to which the user that created
the resource resolver belongs.

If Sling could support these 2 Adapt patterns I think it would greatly
simplify how application code learns about the tenant environment it exists
in.

If it already does, is there a pointer to where, I could not find it.

Best Regards
Ian

Re: Adapt to Tenant ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Feb 27, 2015 at 12:38 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> On 27 February 2015 at 07:05, Bertrand Delacretaz <bd...@apache.org>
> wrote:
>> ...FWIW this is how I'm doing it in my SLING-4386 prototype, but in that
>> case the resource is mapped to a tenant based on a property found in
>> the tenant's content subtree, instead of users.
>>...
> Will the capability be added to the existing AdapterFactory ?..

There are no plans so far but if people find this useful we can do that.

The SLING-4386 code just switches to a different script resolver for
resources that adapt to ContentTenant, so it doesn't change any
existing behavior.

OTOH we can also just implement this content-based tenant idea,
separately from the SLING-4386 dynamic search paths thing.

-Bertrand

Re: Adapt to Tenant ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Feb 27, 2015 at 2:12 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> ...do you look for the tenant property closest to the root to prevent someone
> with write permissions inside a tenant changing the tenant ID for some
> users or some content ?...

That happens in ContentDrivenTenantAdapterFactory [1] - currently I'm
looking for the closest sling:tenantRoot property in the tree, to
support nested content-driven tenants. I see your point though, you
could protect those properties by having them higher in the tree, or
in a shadow tree.

-Bertrand

[1] https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/multisling2015/cdtenants/src/main/java/org/apache/sling/ms2015/cdtenants/impl/ContentDrivenTenantAdapterFactory.java

Re: Adapt to Tenant ?

Posted by Ian Boston <ie...@tfd.co.uk>.
Hi,

On 27 February 2015 at 08:38, Ian Boston <ie...@tfd.co.uk> wrote:

> Hi,
>
>
> On 27 February 2015 at 07:05, Bertrand Delacretaz <bd...@apache.org>
> wrote:
>
>> Hi,
>>
>> On Thu, Feb 26, 2015 at 2:56 AM, Ian Boston <ie...@tfd.co.uk> wrote:
>> > ...Tenant tenant = resource.adaptTo(Tenant.class) ...
>>
>> FWIW this is how I'm doing it in my SLING-4386 prototype, but in that
>> case the resource is mapped to a tenant based on a property found in
>> the tenant's content subtree, instead of users.
>
>
> Thats a much better way of doing it.
> Will the capability be added to the existing AdapterFactory ?
>


just checking....
do you look for the tenant property closest to the root to prevent someone
with write permissions inside a tenant changing the tenant ID for some
users or some content ?

Best Regards
Ian



>
> Best Regards
> Ian
>
>
>>
>> -Bertrand
>>
>
>

Re: Adapt to Tenant ?

Posted by Ian Boston <ie...@tfd.co.uk>.
Hi,


On 27 February 2015 at 07:05, Bertrand Delacretaz <bd...@apache.org>
wrote:

> Hi,
>
> On Thu, Feb 26, 2015 at 2:56 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> > ...Tenant tenant = resource.adaptTo(Tenant.class) ...
>
> FWIW this is how I'm doing it in my SLING-4386 prototype, but in that
> case the resource is mapped to a tenant based on a property found in
> the tenant's content subtree, instead of users.
>

Thats a much better way of doing it.
Will the capability be added to the existing AdapterFactory ?

Best Regards
Ian


>
> -Bertrand
>

Re: Adapt to Tenant ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Thu, Feb 26, 2015 at 2:56 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> ...Tenant tenant = resource.adaptTo(Tenant.class) ...

FWIW this is how I'm doing it in my SLING-4386 prototype, but in that
case the resource is mapped to a tenant based on a property found in
the tenant's content subtree, instead of users.

-Bertrand

Re: Adapt to Tenant ?

Posted by Ian Boston <ie...@tfd.co.uk>.
Hi,
Thanks, Looks like what I need for both use cases as requested. Strange it
didn't turn up in the Web Console plugin I am looking at, perhaps I need to
upgrade.
Best Regards
Ian

On 26 February 2015 at 11:11, Roland Schaer <rs...@adobe.com> wrote:

> Hi Ian,
>
> there is an adapter factory [1] that tries to resolve the tenant by
> identifier configured with regular expressions via [2].
>
> [1]
> https://github.com/apache/sling/blob/trunk/contrib/extensions/tenant/src/main/java/org/apache/sling/tenant/internal/TenantAdapterFactory.java
> [2]
> http://localhost:4502/system/console/configMgr/org.apache.sling.tenant.internal.TenantProviderImpl
>
> ./Roland
>
> On 26 Feb 2015, at 07:56, Ian Boston <ie...@tfd.co.uk>>
> wrote:
>
> Hi,
> Does sling support the following ?
> I have looked at some running instances and not found adapter factories
> that do.
>
> Tenant tenant = resource.adaptTo(Tenant.class)
>
> Where tenant is the tenant in which the resource resides or the tenant has
> read access to. I guess in highly collaborative environments it could be
> more than one Tenant, but lets not go there just yet.
>
> and
>
> Tenant tenant = resource.getResourceResolver().adaptTo(Tenant.class)
>
> Where the tenant in this case the the tenant to which the user that created
> the resource resolver belongs.
>
> If Sling could support these 2 Adapt patterns I think it would greatly
> simplify how application code learns about the tenant environment it exists
> in.
>
> If it already does, is there a pointer to where, I could not find it.
>
> Best Regards
> Ian
>
>

Re: Adapt to Tenant ?

Posted by Roland Schaer <rs...@adobe.com>.
Hi Ian,

there is an adapter factory [1] that tries to resolve the tenant by identifier configured with regular expressions via [2].

[1] https://github.com/apache/sling/blob/trunk/contrib/extensions/tenant/src/main/java/org/apache/sling/tenant/internal/TenantAdapterFactory.java
[2] http://localhost:4502/system/console/configMgr/org.apache.sling.tenant.internal.TenantProviderImpl

./Roland

On 26 Feb 2015, at 07:56, Ian Boston <ie...@tfd.co.uk>> wrote:

Hi,
Does sling support the following ?
I have looked at some running instances and not found adapter factories
that do.

Tenant tenant = resource.adaptTo(Tenant.class)

Where tenant is the tenant in which the resource resides or the tenant has
read access to. I guess in highly collaborative environments it could be
more than one Tenant, but lets not go there just yet.

and

Tenant tenant = resource.getResourceResolver().adaptTo(Tenant.class)

Where the tenant in this case the the tenant to which the user that created
the resource resolver belongs.

If Sling could support these 2 Adapt patterns I think it would greatly
simplify how application code learns about the tenant environment it exists
in.

If it already does, is there a pointer to where, I could not find it.

Best Regards
Ian