java - Download as Zip folder with custom folder type -


when download folders zip type not cm:folder empty zip archive. folders cm:content type , documents works properly.

more details:

in our project have created custom folder type parent's type cm:folder:

<type name="ef:folder">   <title>parent of folders</title>   <parent>cm:folder</parent>   <mandatory-aspects>     <aspect>ef:typed</aspect>   </mandatory-aspects> </type> 

the problem when press download zip button selected folder(s) empty zip file. comes startnode method of zipdownloadexporter.java:

@override public void startnode(noderef noderef) {   this.currentname = (string)nodeservice.getproperty(noderef, contentmodel.prop_name);   path.push(new pair<string, noderef>(currentname, noderef));   if (contentmodel.type_folder.equals(nodeservice.gettype(noderef)))   {     string path = getpath() + path_separator;     ziparchiveentry archiveentry = new ziparchiveentry(path);     try     {       zipstream.putarchiveentry(archiveentry);       zipstream.closearchiveentry();     }     catch (ioexception e)     {       throw new exporterexception("unexpected ioexception adding folder entry", e);     }   } } 

since custom folder has type ef:folder check returns false:

if (contentmodel.type_folder.equals(nodeservice.gettype(noderef))) 

and folder not added zip.

is bug (maybe proper solution check not node's type parent type)?

how fixed without creating custom exporter custom folder types?

due project restriction type of folder couldn't changed cm:folder.

i had fix same problem. in order fix indeed need check subtype of cm:folder , need have dictionaryservice inside class. doing quite tedious, here solution:

override bean id "createdownloadarchiveaction", , ingest serviceregistry it=>

 <bean id="createdownloadarchiveaction" class="org.alfresco.repo.download.createdownloadarchiveactionsr" parent="action-executer">   <property name="checkoutcheckinserivce" ref="checkoutcheckinservice"/>   <property name="contentservicehelper" ref="downloadcontentservicehelper" />   <property name="downloadstorage" ref="downloadstorage" />   <property name="exporterservice" ref="exportercomponent" />   <property name="maximumcontentsize" value="${download.maxcontentsize}" />   <property name="nodeservice" ref="nodeservice" />   <property name="publicaction" value="false"/>   <property name="transactionhelper" ref="retryingtransactionhelper"/>   <property name="updateservice" ref="downloadstatusupdateservice"/>   <property name="serviceregistry">     <ref bean="serviceregistry" />   </property> 

in new class, have forward serviceregistry zipdownloadexporter =>

private void createdownload(final noderef actioneduponnoderef, exportercrawlerparameters crawlerparameters, sizeestimator estimator)     {         // perform actual export         final file tempfile = tempfileprovider.createtempfile(temp_file_prefix, temp_file_suffix);         final myzipdownloadexporter handler = new myzipdownloadexporter (tempfile, checkoutcheckinservice, nodeservice, transactionhelper, updateservice, downloadstorage,serviceregistry, actioneduponnoderef, estimator.getsize(), estimator.getfilecount()); 

in class myzipdownloadexporter can subtype check:

 public void startnode(noderef noderef)     {         this.currentname = (string)nodeservice.getproperty(noderef, contentmodel.prop_name);         path.push(new pair<string, noderef>(currentname, noderef));         if (this.sr.getdictionaryservice().issubclass((nodeservice.gettype(noderef), contentmodel.type_folder))         { .... 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -