portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r553254 - in /portals/jetspeed-2/trunk: applications/j2-admin/ applications/j2-admin/src/java/org/apache/jetspeed/portlets/site/ components/portal/src/java/org/apache/jetspeed/layout/impl/
Date Wed, 04 Jul 2007 16:19:55 GMT
Author: taylor
Date: Wed Jul  4 09:19:54 2007
New Revision: 553254

URL: http://svn.apache.org/viewvc?view=rev&rev=553254
Log:
https://issues.apache.org/jira/browse/JS2-716
patch from Vivek Kumar
completed this feature for 2.1.1
Feature includes:
* import single files from browser file system into any folder
* import (recursively) zipped up folder into any folder
* export single files 
* export recursively folders to a zip file

Modified:
    portals/jetspeed-2/trunk/applications/j2-admin/pom.xml
    portals/jetspeed-2/trunk/applications/j2-admin/project.xml
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/ExportObject.java

Modified: portals/jetspeed-2/trunk/applications/j2-admin/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/pom.xml?view=diff&rev=553254&r1=553253&r2=553254
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/pom.xml (original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/pom.xml Wed Jul  4 09:19:54 2007
@@ -87,6 +87,11 @@
             <artifactId>commons-logging</artifactId>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.3.1</version>            
+        </dependency>
+        <dependency>
             <groupId>commons-fileupload</groupId>
             <artifactId>commons-fileupload</artifactId>
         </dependency>

Modified: portals/jetspeed-2/trunk/applications/j2-admin/project.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/project.xml?view=diff&rev=553254&r1=553253&r2=553254
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/project.xml (original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/project.xml Wed Jul  4 09:19:54 2007
@@ -200,6 +200,13 @@
       </properties>    
     </dependency>        
     <dependency>
+      <id>commons-io</id>
+      <version>1.3.1</version>
+      <properties>
+            <war.bundle>true</war.bundle>
+      </properties>    
+    </dependency>        
+    <dependency>
         <id>commons-logging</id>
         <version>${commons.logging.version}</version>
         <type>jar</type>

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java?view=diff&rev=553254&r1=553253&r2=553254
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
Wed Jul  4 09:19:54 2007
@@ -305,6 +305,7 @@
 
     private boolean  unzipfile(String file,String destination,String sepreator) {
       Enumeration entries;
+      String filePath="";
       try {
           ZipFile zipFile = new ZipFile(destination+sepreator+file);
 
@@ -312,24 +313,29 @@
 
         while(entries.hasMoreElements()) {
           ZipEntry entry = (ZipEntry)entries.nextElement();
-
-          if(entry.isDirectory()) {
-            (new File(destination+sepreator+entry.getName())).mkdir();
-            continue;
-          }
-
-          System.out.println("Extracting file: " + entry.getName());
+          filePath = destination+sepreator+entry.getName();
+          createPath(filePath);
           copyInputStream(zipFile.getInputStream(entry),
-             new BufferedOutputStream(new FileOutputStream(destination+sepreator+entry.getName())));
+             new BufferedOutputStream(new FileOutputStream(filePath)));
         }
 
         zipFile.close();
         return true;
       } catch (IOException ioe) {
-        System.err.println("Unhandled exception:");
         ioe.printStackTrace();
         return false;
       }
+    }
+    
+    private void createPath(String filePath) {
+        String parentPath="";
+        File file = new File(filePath);
+        File parent = new File(file.getParent());
+        if (!parent.exists()) {
+            parentPath = parent.getPath();
+            createPath(parentPath);
+            parent.mkdir();
+        }
     }
     private Folder importFolders(Folder srcFolder,String userName,String destination) throws
JetspeedException {
         Folder dstFolder = lookupFolder(srcFolder.getPath());

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/ExportObject.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/ExportObject.java?view=diff&rev=553254&r1=553253&r2=553254
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/ExportObject.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/ExportObject.java
Wed Jul  4 09:19:54 2007
@@ -87,7 +87,7 @@
 				if (objectType.equalsIgnoreCase("folder")) {
 					Folder folder = pageManager.getFolder(objectPath);
 					if (isRecursive) {
-							importFolder(folder,userName);
+							importFolder(folder,userName,getRealPath(folder.getPath()));
 					} else {
 						Folder destFolder = castorPageManager.copyFolder(folder, getUserFolder(userName, true)
 								+ objectName);
@@ -242,16 +242,18 @@
 		}
 	}
 
-	private Folder importFolder(Folder srcFolder,String userName) throws JetspeedException {
-		Folder dstFolder = lookupFolder(srcFolder.getPath());
-		dstFolder = castorPageManager.copyFolder(srcFolder, getUserFolder(userName, true) + srcFolder.getPath());
+	private Folder importFolder(Folder srcFolder,String userName,String destination) throws
JetspeedException {
+        String newPath="";
+        Folder dstFolder = lookupFolder(srcFolder.getPath());
+		dstFolder = castorPageManager.copyFolder(srcFolder, getUserFolder(userName, true) + destination);
 		castorPageManager.updateFolder(dstFolder);
 
 		Iterator pages = srcFolder.getPages().iterator();
 		while (pages.hasNext()) {
 			Page srcPage = (Page) pages.next();
 			Page dstPage = lookupPage(srcPage.getPath());
-			dstPage = castorPageManager.copyPage(srcPage, getUserFolder(userName, true) +srcPage.getPath());
+            newPath = getUserFolder(userName, true) +destination+ getRealPath(srcPage.getPath());

+			dstPage = castorPageManager.copyPage(srcPage, newPath);
 			castorPageManager.updatePage(dstPage);
 		}
 
@@ -259,13 +261,15 @@
 		while (links.hasNext()) {
 			Link srcLink = (Link) links.next();
 			Link dstLink = lookupLink(srcLink.getPath());
-			dstLink = castorPageManager.copyLink(srcLink, getUserFolder(userName, true) +srcLink.getPath());
+            newPath = getUserFolder(userName, true) +destination+ getRealPath(srcLink.getPath());
+			dstLink = castorPageManager.copyLink(srcLink,newPath);
 			castorPageManager.updateLink(dstLink);
 		}
 		Iterator folders = srcFolder.getFolders().iterator();
 		while (folders.hasNext()) {
 			Folder folder = (Folder) folders.next();
-			importFolder(folder,userName);
+            newPath = destination+getRealPath(folder.getPath());
+			importFolder(folder,userName,newPath);
 		}
 
 		return dstFolder;
@@ -294,4 +298,13 @@
 			return null;
 		}
 	}
+    private String getRealPath(String path){
+        int index = path.lastIndexOf("/");
+        if (index>0)
+        {
+            return path.substring(index);
+        }
+        return path;
+         
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message