You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carsten Ziegeler <cz...@apache.org> on 2008/07/01 14:39:08 UTC

Making files referenceable during content loading

Hi,

Bryce shows an interesting use case in bug 
https://issues.apache.org/jira/browse/SLING-553 where he references html 
fragments from his pages through jcr references. As the fragments itself 
are imported during content loading as files, they're not referenceable 
but just nt:file.

Bryce suggestion is to make the nt:file (and nt:folder) 
mix:referenceable if a reference to such a node should be created.

Now, I understand the use case, but I'm not so happy about this special 
case handling. I personally would either
a) make all nodes mix:referenceable regardles of the type if they are 
referenced during content loading.
b) provide a different way of making the file mix:referenceable. For 
folders you currently can add a file with the same name as the folder 
and the ".json" extension and add the mixins there. We could allow the 
same mechanism for files as well.

Looking at the options, I think b) is the way to go, as this would allow 
to add other properties (whatever they might be) as well.

Thoughts?

Carsten
-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Making files referenceable during content loading

Posted by Torgeir Veimo <to...@pobox.com>.
On 2 Jul 2008, at 12:21, Bryce Ewing wrote:

> I understand what he is saying here, but I am curious as to why you  
> say CMS in particular?


My guess is that it comes down to flexibility. It's sort of the same  
argument that structure prohibits flexibility. Reference integrity is  
not very often needed, and causes much more headaches down the road.  
Imagine if you couldn't remove an article you created simply because  
some other article someone else created is linked to it.

Maybe you can store the actual UUID in a string instead of using a  
reference? It would be similar to a reference, as it uses the UUID  
internally, just that reference integrity is not maintained if the  
document the UUID belong to is deleted.

-- 
Torgeir Veimo
torgeir@pobox.com





Re: Making files referenceable during content loading

Posted by Carsten Ziegeler <cz...@apache.org>.
Bryce Ewing wrote:
> Thanks for the discussion on this, this has resolved the issue for me 
> anyway.  I was unaware that the jcr:content node off the file node was 
> referenceable, the references that I am making can go to that instead 
> for now and therefore I don't need the node of type nt:file or nt:folder 
> to be referenceable (nt:folder due to just setting it through a json file).
> 
Great, so I'll apply your patch without the special handling for nt:file.

Thanks
Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Making files referenceable during content loading

Posted by Bryce Ewing <br...@smx.co.nz>.
Thanks for the discussion on this, this has resolved the issue for me 
anyway.  I was unaware that the jcr:content node off the file node was 
referenceable, the references that I am making can go to that instead 
for now and therefore I don't need the node of type nt:file or nt:folder 
to be referenceable (nt:folder due to just setting it through a json file).

I didn't particularly want to have two files, myfile.jpg & 
myfile.jpg.json for each referenceable file which was why I didn't go 
down this route.

In regards to references being strongly discouraged in the repository 
(and CMS instances specifically) I presume this has something in regards 
to this: http://wiki.apache.org/jackrabbit/DavidsModel (#5)

I understand what he is saying here, but I am curious as to why you say 
CMS in particular?  Maybe a few of the cases that I am using references 
for I don't need to (one being site navigation).  One of the benefits 
that I saw for using references as a way of linking between pages in the 
site was that when a page is moved in the repository the references 
still point to the page, and the url will be automatically updated (also 
will stop links to dead pages since the page cannot be removed while it 
is referenced).

What are the thoughts around this?

Carsten Ziegeler wrote:
> Tobias Bocanegra wrote:
>> i haven't tried, but with a side-by-side json that should work, right?
>>
>> myfile.jpg
>> myfile.jpg.json
>> {
>>   jcr:mixinTypes: ["mix:referenceable"]
>> }
>>
>>
> No, this isn't implemented yet, just for folders - and implementing it 
> this way is actually my prefered option b) :)
>
>>>> btw: it's the jcr:content of an nt:file that is referenceable. so
>>>> that's also where the reference should point, to.
>>>>
>>>  But "jcr:content" is not by default referenceable I think, so you 
>>> still
>>> have the same problem.
>> yes it is, as long nt:resource is used, which is the default nodetype
>> that is used by the loader for files.
> Ah, yes, right - I just looked at the jcr:content node type definition 
> which is just nt:base. Thanks!
>
> Carsten
>

Re: Making files referenceable during content loading

Posted by Carsten Ziegeler <cz...@apache.org>.
Bertrand Delacretaz wrote:
> On Tue, Jul 1, 2008 at 3:29 PM, Carsten Ziegeler <cz...@apache.org> wrote:
>> Tobias Bocanegra wrote:
>>> ...
>>> myfile.jpg
>>> myfile.jpg.json
>>> {
>>>  jcr:mixinTypes: ["mix:referenceable"]
>>> }
>>>
>>>
>> No, this isn't implemented yet, just for folders - and implementing it this
>> way is actually my prefered option b) :)
> 
> I agree about choosing this option, if we ever need this.
Yes, as we don't need the feature at the moment, I won't implement it 
right now :)

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Making files referenceable during content loading

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Jul 1, 2008 at 3:29 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> Tobias Bocanegra wrote:
>> ...
>> myfile.jpg
>> myfile.jpg.json
>> {
>>  jcr:mixinTypes: ["mix:referenceable"]
>> }
>>
>>
> No, this isn't implemented yet, just for folders - and implementing it this
> way is actually my prefered option b) :)

I agree about choosing this option, if we ever need this.
-Bertrand

Re: Making files referenceable during content loading

Posted by Carsten Ziegeler <cz...@apache.org>.
Tobias Bocanegra wrote:
> i haven't tried, but with a side-by-side json that should work, right?
> 
> myfile.jpg
> myfile.jpg.json
> {
>   jcr:mixinTypes: ["mix:referenceable"]
> }
> 
> 
No, this isn't implemented yet, just for folders - and implementing it 
this way is actually my prefered option b) :)

>>> btw: it's the jcr:content of an nt:file that is referenceable. so
>>> that's also where the reference should point, to.
>>>
>>  But "jcr:content" is not by default referenceable I think, so you still
>> have the same problem.
> yes it is, as long nt:resource is used, which is the default nodetype
> that is used by the loader for files.
Ah, yes, right - I just looked at the jcr:content node type definition 
which is just nt:base. Thanks!

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Making files referenceable during content loading

Posted by Tobias Bocanegra <to...@day.com>.
On 7/1/08, Carsten Ziegeler <cz...@apache.org> wrote:
> Tobias Bocanegra wrote:
>
> > i want to mention, that using references in the repository is strongly
> > discouraged especially for CMS like applications.
> >
>  Yes, I know, but that doesn't mean that there are use cases for it :)
>
>
> > i would not add any
> > reference magic to the loader.
> >
>  Yes, that's why I tend to option b) - there is no magic then.
>
>  > if users want to make their nodes
>
> > referenceable, they need to provide the repsective .json or .xml.
> >
>  Which is a little bit hard for files - this works perfectly for folders.
i haven't tried, but with a side-by-side json that should work, right?

myfile.jpg
myfile.jpg.json
{
  jcr:mixinTypes: ["mix:referenceable"]
}


> > btw: it's the jcr:content of an nt:file that is referenceable. so
> > that's also where the reference should point, to.
> >
>  But "jcr:content" is not by default referenceable I think, so you still
> have the same problem.
yes it is, as long nt:resource is used, which is the default nodetype
that is used by the loader for files.

regards, toby

Re: Making files referenceable during content loading

Posted by Carsten Ziegeler <cz...@apache.org>.
Tobias Bocanegra wrote:
> i want to mention, that using references in the repository is strongly
> discouraged especially for CMS like applications. 
Yes, I know, but that doesn't mean that there are use cases for it :)

> i would not add any
> reference magic to the loader. 
Yes, that's why I tend to option b) - there is no magic then.

 > if users want to make their nodes
> referenceable, they need to provide the repsective .json or .xml.
Which is a little bit hard for files - this works perfectly for folders.

> 
> btw: it's the jcr:content of an nt:file that is referenceable. so
> that's also where the reference should point, to.
But "jcr:content" is not by default referenceable I think, so you still 
have the same problem.

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Making files referenceable during content loading

Posted by Tobias Bocanegra <to...@day.com>.
On 7/1/08, Carsten Ziegeler <cz...@apache.org> wrote:
> Hi,
>
>  Bryce shows an interesting use case in bug
> https://issues.apache.org/jira/browse/SLING-553 where he
> references html fragments from his pages through jcr references. As the
> fragments itself are imported during content loading as files, they're not
> referenceable but just nt:file.
>
>  Bryce suggestion is to make the nt:file (and nt:folder) mix:referenceable
> if a reference to such a node should be created.
>
>  Now, I understand the use case, but I'm not so happy about this special
> case handling. I personally would either
>  a) make all nodes mix:referenceable regardles of the type if they are
> referenced during content loading.
>  b) provide a different way of making the file mix:referenceable. For
> folders you currently can add a file with the same name as the folder and
> the ".json" extension and add the mixins there. We could allow the same
> mechanism for files as well.
>
>  Looking at the options, I think b) is the way to go, as this would allow to
> add other properties (whatever they might be) as well.

i want to mention, that using references in the repository is strongly
discouraged especially for CMS like applications. i would not add any
reference magic to the loader. if users want to make their nodes
referenceable, they need to provide the repsective .json or .xml.

btw: it's the jcr:content of an nt:file that is referenceable. so
that's also where the reference should point, to.

regards, toby