cancel
Showing results for 
Search instead for 
Did you mean: 

[Share Extension] 'Compress and download' Action

bertrandf
Champ on-the-rise
Champ on-the-rise
Atol Conseils & Développements has recently launched a forge which lists all of our open source contributions: http://labs.atolcd.com highlighting some of our areas of expertise such as business intelligence (Pentaho, …), GIS (OpenLayers, GeoServer, …) and ECM (Alfresco, CMIS, …).


A new Share extension just made ​​its appearance on our forge.
This extension allows you to add action "Compress and download" in the document library of sites or in the Repository View.

With this action, you can easily download various contents (files and/or folders), all compressed into a ZIP archive.


This extension is now available for download (version 1.0): http://labs.atolcd.com/projects/zip-and-download (compatible with Alfresco 3.4 Enterprise Edition and Community Edition).

[img]http://labs.atolcd.com/attachments/download/25/Aper%C3%A7u_action_compresser_et_t%C3%A9l%C3%A9charge...[/img]
12 REPLIES 12

pitzalis
Champ in-the-making
Champ in-the-making
Useful extension!

I suggest a better italian translation for labels:
# Action name
menu.selected-items.zip-content=Comprimi e scarica

# Actions properties
zip-content-action.header=Comprimi e scarica
zip-content-action.cancel=Annulla
zip-content-action.download=Download
zip-content-action.filename.label=Nome del file:
zip-content-action.filename.mandatory-field=Specificare il nome del file
zip-content-action.no-accent.label=Ignora accenti (la codifica degli accenti puo` creare problemi con alcuni software di compressione)
Bye,
GP

jpfi
Champ in-the-making
Champ in-the-making
Hi,
a very nice extension. It would be useful to publish that on a more central place. From my point of view that should be added to http://code.google.com/p/share-extras/
best, jan

bertrandf
Champ on-the-rise
Champ on-the-rise
Thanks for italian translation.

Concerning http://code.google.com/p/share-extras/ how can I join the project ?

wabson
Star Contributor
Star Contributor
Hi Bertrand, if you're interested in contributing the extension to Share Extras then it would be a nice one to have on board. But it seems you are currently hosting it on your own Forge?

Alternatively if you want to keep it where it is I could create a new page within the project, linking to external add-ons like this.

Feel free to send me a PM if you want to discuss further!

Thanks,
Will.

bertrandf
Champ on-the-rise
Champ on-the-rise

pnacci
Champ in-the-making
Champ in-the-making
Addon will not work for "filelink" types:

ERROR [extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 05200002 Erreur lors de la génération de l'archive.

I made a patch to follow links and zip/download real content for filelink types:

Index: ZipContents.java
===================================================================
— ZipContents.java   (revisione 10)
+++ ZipContents.java   (local copy)
@@ -179,7 +180,11 @@
   }

   public void addToZip(NodeRef node, ZipOutputStream out, boolean noaccent, String path) throws IOException {
-      QName nodeQnameType = this.nodeService.getType(node);
+      // if this is a link follow it to get real node
+      QName nodeQnameType;
+      if(this.dictionaryService.isSubClass(this.nodeService.getType(node),ApplicationModel.TYPE_FILELINK))
+         node=(NodeRef) nodeService.getProperty(node,ContentModel.PROP_LINK_DESTINATION);
+      nodeQnameType = this.nodeService.getType(node);
      String nodeName = (String) nodeService.getProperty(node, ContentModel.PROP_NAME);

      nodeName = noaccent ? unAccent(nodeName) : nodeName;

bertrandf
Champ on-the-rise
Champ on-the-rise
Thanks for your feedback and the patch. I will fix the bug as soon as possible.

bertrandf
Champ on-the-rise
Champ on-the-rise
Fixed (version 1.0.1).
But I'm surprise that your error was due to "filelink" type because links does not contain content and files without content are ignored …

Maybe you have an older version that does not contain fix for the bug with empty spaces.

chrisokelly
Champ on-the-rise
Champ on-the-rise
Hi Bertrand,

Firstly, thanks very much for the time and effort you've put into this project, it certainly saved me alot of both.

In our situation, it suited more to have the action appear in the document library and document details sections (as we will almost always be using it with just one folder). Just wanted to point out that only a few changes are required to make this happen. In case anyone would like to use the addon in this way, here's how:

in tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml:

        <config evaluator="string-compare" condition="DocLibActions" replace="true">
                <actions>

                        <!– Zip folder –>
                        <action id="zip-folder" type="javascript" label="menu.selected-items.zip-content">
                                <param name="function">onActionZip</param>
                        </action>
                </actions>
                <actionGroups>

                        <actionGroup id="folder-browse">
                                <action index="230" id="zip-folder" icon="zipcontents" label="menu.selected-items.zip-content" />
                        </actionGroup>

                </actionGroups>

In my case I have made some changes to the default actions which require me to replace this section. I believe you would normally not need to do this (I think I have read somewhere that normally you put in your additions and it will be merged, but I can't guarantee this, I've only tested my own setup). if you use replace="true" you will need to copy the entire DocLibActions section from tomcat/webapps/share/WEB-INF/classes/alfresco/share-config.xml.
You can also add it to whichever action groups you want. I added it just to folder-browse, but you can copy the "<action index="230" id="zip-folder" icon="zipcontents" label="menu.selected-items.zip-content" />" line into any actionGroup element and just change the index to suit.
in the share-zip-contents-action jar, create the folder META-INF\components\documentlibrary\actions and copy the icon from META-INF\components\images into it.
Finally, make a small change to the javascript in share-zip-contents-action.jar\META-INF\components\documentlibrary:

    fn: function dlA_onActionZip(record) {
      var getNodeId = function(nodeRef) {
        return nodeRef.split('/').reverse()[0]; // Get only nodeId
      };
     var nodesRef = [];
     if (record instanceof Array)
      {
      for (var i=0, ii=record.length ; i<ii ; i++){
         nodesRef.push(getNodeId(record[i].nodeRef));
         }
      }
   else
      {
      nodesRef.push(getNodeId(record.nodeRef))
      }

      // Download Simple Dialog
      var downloadDlg = new YAHOO.widget.SimpleDialog(this.id + '-download-zip-dialog', {
make this change, minify it, jar it up and you should be rearing to go!