cancel
Showing results for 
Search instead for 
Did you mean: 

Return the content of an associated node when reading another

technaton
Champ in-the-making
Champ in-the-making
Hello fellow developers,

I'm currently developing a Alfresco extension to mimick Linux/Unix syslinks in Alfresco. I've developed a Share action that creates nodes of the type
app:filelink
and sets all properties correctly.

However, when reading the node via CIFS (JLAN), it opens as a text file. Which is the right format for a link, but not the intended behaviour of a symlink.

So I'm trying to create a custom content type that subclasses
app:filelink
but reads the destination node's (
d:destination
) content instead of that of the node. How can I do this?

I worked myself through the custom content types tutorial and know of the Policy/Behaviour model. I can resolve the destination node in Java. But I do not know how to point the "content reader" at the destination node's content instead of the link's text representation.

Is there perhaps a way to "wrap" the read call? Or should I change the
cm:content
property on the fly…?

And pointers or hints are welcome!

Thanks alot in advance,
— Eric
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
In alfresco 'd default implementation ,A link must extends  'cm:link' type("app:filelink"  for file ,"app:folderlink" for folder). "cm:link" type has single NodeRef value property ContentModel.PROP_LINK_DESTINATION which is used to save the node that should be linked to.

When you try to open a file on SMB/CIFS the file system.
1.alfresco will first try to fetch  the node at the specified path,
2.and then check whether this node has "cm:destination" property,
3.if this node has "cm:destination" property, then it is a link node ,A file Whose content is the url link of the target node will return to you
4.if this node dose not have "cm:destination" property, then it is a common node ,A temp file with a copy of the content of node will return to you.


So if you want to return the  content of target node instead of url link of the target node,In my opoinon you should  customize a new filesystem driver class(for example extends org.alfresco.filesys.repo.ContentDiskDriver2),and override openFile method.
In you openFile method implementation ,check node type,if it's your custom  link type, return the content of link target node instead of url link .

technaton
Champ in-the-making
Champ in-the-making
kaynezhang,

thank you for your reply.

<cite>if this node has "cm:destination" property, then it is a link node ,A file Whose content is the url link of the target node will return to you</cite>

The problem is that this does not happen. I always get an InternetLink text file in return, like this one:

[InternetShortcut]
URL=file://172.16.100.90/Alfresco/Sites/ifo/documentLibrary/Testsperren.xlsx


There seems to be some kind of dynamic handling here, because the IP address is replaced with the DNS hostname on some hosts. I guess I'll dig in the source code. Overwriting the ContentDiskDriver2's openFile meothd does not sound like anything that is easily maintainable. Smiley Sad

Thanks again!
— Eric

kaynezhang
World-Class Innovator
World-Class Innovator
I have traced the source code before,In my opinion to implement your requirement,you should replace or extend ContentDiskDriver2.
Maybe I'm wrong and others have any other good solutions