Author: keith
Date: Fri Jan 25 21:03:21 2008
New Revision: 12941

Log:

Fixing Mashup-603. We dont zip up the contents in _private



Modified:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Fri Jan 25 21:03:21 2008
@@ -120,4 +120,6 @@
     public static final String SIGNIN = "signin";
 
     public static final int MIN_PASSWORD_LENGTH = 5;
+
+    public static String MASHUP_PRIVATE_FOLBER_NAME = "_private"; 
 }

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
      (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
      Fri Jan 25 21:03:21 2008
@@ -32,10 +32,11 @@
 import org.apache.axis2.rpc.client.RPCServiceClient;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.wso2.javascript.rhino.JavaScriptEngineConstants;
+import org.wso2.mashup.MashupConstants;
 import org.wso2.mashup.MashupFault;
+import org.wso2.usermanager.UserManagerException;
 import org.wso2.utils.ArchiveManipulator;
 import org.wso2.wsas.ServerConstants;
-import org.wso2.usermanager.UserManagerException;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
@@ -333,4 +334,41 @@
             throw new MashupFault("Cannot find the repository in the Mashup 
server.");
         }
     }
+
+    // This was copied from org.wso2.utils.ArchiveManipulator, had to copy it 
over cause we want to skip zipping up a
+    // particullar folder
+    protected void zipDir(File zipDir, ZipOutputStream zos) throws IOException 
{
+        //get a listing of the directory content
+        String[] dirList = zipDir.list();
+        byte[] readBuffer = new byte[40960];
+        int bytesIn = 0;
+        //loop through dirList, and zip the files
+        for (int i = 0; i < dirList.length; i++) {
+            String dir = dirList[i];
+            // If its the private directory we dont need to zip it up
+            if (MashupConstants.MASHUP_PRIVATE_FOLBER_NAME.equals(dir)) {
+                continue;
+            }
+            File f = new File(zipDir, dir);
+            //place the zip entry in the ZipOutputStream object
+            zos.putNextEntry(new ZipEntry(getZipEntryPath(f)));
+            if (f.isDirectory()) {
+                //if the File object is a directory, call this
+                //function again to add its content recursively
+                zipDir(f, zos);
+                //loop again
+                continue;
+            }
+            //if we reached here, the File object f was not a directory
+            //create a FileInputStream on top of f
+            FileInputStream fis = new FileInputStream(f);
+
+            //now write the content of the file to the ZipOutputStream
+            while ((bytesIn = fis.read(readBuffer)) != -1) {
+                zos.write(readBuffer, 0, bytesIn);
+            }
+            //close the Stream
+            fis.close();
+        }
+    }
 }

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to