cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Share cm:name uniqueness

milhy
Champ in-the-making
Champ in-the-making
Hello everyone,
in Alfresco Share I need to upload multiple documents with the SAME FILENAME into one folder. I have different versions of file content, each one saved separatedly in the file with the same name. Differencies between files are managed through my custom metadata. From Alfresco Share I need to download each file with the given (same) name. I can't use file versioning, the requirement is to have files separatedly in one folder.
Problem is with the default attribute cm:name, which cannot be the same for objects in one folder. I tried to change the default ContentModel.xml file, where is section: <type name="cm:folder"> and I changed type association value <duplicate> from FALSE to TRUE. I know, that extending default content model by that is not the best way, but it works. From this time I can upload more files with the same filename into one folder. Unfortunatelly, side effect of this change is impossibility to create new sites in Alfresco Share. In my log is:


Method public org.alfresco.repo.jscript.ScriptableHashMap org.alfresco.repo.site.script.Site.listMembers(java.lang.String,java.lang.String,int,boolean) threw an exception when invoked on org.alfresco.repo.site.script.Site@15ac9ff with arguments of types [null,java.lang.String,java.lang.Integer,java.lang.Boolean,]
The problematic instruction:
———-
==> assignment: managers=site.listMembers(null, "SiteManager", 0, true)?keys [on line 48, column 17 in org/alfresco/repository/site/site.lib.ftl]
in user-directive siteJSONManagers [on line 2, column 1 in org/alfresco/repository/site/site.lib.ftl]
in user-directive siteLib.siteJSON [on line 2, column 1 in org/alfresco/repository/site/sites.post.json.ftl]


I know, that this is the result of enabling duplicates. I can normally create sites when I revert changes in the ContentModel.xml file.

Please, don't you have eny experience or recomendations, how to make my goal in some different way?
6 REPLIES 6

rjohnson
Star Contributor
Star Contributor
Rather that allowing duplicates in the name which clearly has side effects, and is a modification to the core which is at best unwise, would it not be better to extend / customise the document library display so that the document title is displayed where the document name is usually displayed? If you swapped these 2 fields around then you could retain unique document names and a standard core (and hence system integrity) but your display would show the documents as seemingly named the same.

Mechanism for extending / cusomising the document library display in this way is built into Alfresco from 4.0 onwards and is very strong in 4.2 - it takes a bit to get into your head but once there is very good and there are lots of examples on the web.

You may (dependent on your exact needs) also need to override the download action so that it downloaded the file using the title not the name. Again, overriding / extending actions is something with very good support in Alfresco 4.0+

Bob Johnson

can you please show me how to switch the cm:name with cm:title

milhy
Champ in-the-making
Champ in-the-making
Hi, thanks for very quick response. I already tried switching cm:name and cm:title in Documentlibrary, so everything in Share were displaying correctly. Problem, where I stopped was file download, where i logically already downloaded different filename based on cm:name. Thanks for confirming, that this is possible way, so the last step for me now is override the download action based on cm:title. Thanks again for your help!

mrogers
Star Contributor
Star Contributor
There is a unique constraint on the property name and the primary association name, which by convention is kept in sync with the name.   Its just a configuration change to remove that constraint and have multiple files with the same name however it may then affect quite a lot of functionality since most applications expect unix/windows file folder conventions which don't allow duplicate named files.   You are probably better off giving each file a unique name and using another property instead,  as the above post suggests using title or your own property.    

milhy
Champ in-the-making
Champ in-the-making
Thanks, I understand reasons for that constraint. I hoped that there can be some possibility to override without side effects.. Now I'm working on solution based on switching name and title in Alfresco Share and overriding Download action as mentioned above. Thanks again both of you for info!

zladuric
Champ on-the-rise
Champ on-the-rise
If you have switched name and title, you could just build a custom download script which would replace the name and title too. Well, depending on the download manner, of course, if you connect via CIFS or something, it's a no-go. But if you download from share, it could work.