[jboss-svn-commits] JBoss Portal SVN: r5607 - in trunk: cms/src/main/org/jboss/portal/cms/impl/jcr/command core/src/main/org/jboss/portal/core/portlet/cms/admin core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 8 15:00:35 EST 2006


Author: roy.russo at jboss.com
Date: 2006-11-08 15:00:32 -0500 (Wed, 08 Nov 2006)
New Revision: 5607

Added:
   trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/exportarchive_pickup_error.jsp
Modified:
   trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/GetArchiveCommand.java
   trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
Log:
JBPORTAL-1085 - fixed Exception if empty folder archive export

Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/GetArchiveCommand.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/GetArchiveCommand.java	2006-11-08 18:05:58 UTC (rev 5606)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/GetArchiveCommand.java	2006-11-08 20:00:32 UTC (rev 5607)
@@ -69,7 +69,10 @@
          java.io.File tmpFile = java.io.File.createTempFile("jbportal_", "_cmsexport.zip");
          ZipOutputStream outStream = new ZipOutputStream(new FileOutputStream(tmpFile.getCanonicalPath()));
          outStream = this.zipFiles(this.msRootPath, outStream);
-         outStream.close();
+         if (outStream != null)
+         {
+            outStream.close();
+         }
 
          return tmpFile;
       }
@@ -109,17 +112,21 @@
                ZipEntry entry = new ZipEntry(this.rootFolderName + node.getPath());
                zos.putNextEntry(entry);
                Content content = childFile.getContent();
-               BufferedInputStream is = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
 
-               //
-               int count;
-               byte[] data = new byte[BUFFER_SIZE];
-               while ((count = is.read(data, 0, BUFFER_SIZE)) != -1)
+               if (content != null)
                {
-                  zos.write(data, 0, count);
+                  BufferedInputStream is = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
+
+                  //
+                  int count;
+                  byte[] data = new byte[BUFFER_SIZE];
+                  while ((count = is.read(data, 0, BUFFER_SIZE)) != -1)
+                  {
+                     zos.write(data, 0, count);
+                  }
+                  is.close();
+                  zos.closeEntry();
                }
-               is.close();
-               zos.closeEntry();
             }
          }
       }

Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java	2006-11-08 18:05:58 UTC (rev 5606)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java	2006-11-08 20:00:32 UTC (rev 5607)
@@ -48,6 +48,7 @@
 import org.jboss.portlet.JBossRenderResponse;
 
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.PortletSession;
 import javax.portlet.UnavailableException;
 import java.io.IOException;
@@ -343,12 +344,19 @@
          String sPath = rReq.getParameter("path");
          String sPickupFile = rReq.getParameter("filepath");
 
-         PortletSession pSession = rReq.getPortletSession();
-         pSession.setAttribute("pickupfile", sPickupFile, PortletSession.APPLICATION_SCOPE);
-
          rRes.setContentType("text/html");
+         PortletRequestDispatcher prd = null;
+         if (sPickupFile != null)
+         {
+            PortletSession pSession = rReq.getPortletSession();
+            pSession.setAttribute("pickupfile", sPickupFile, PortletSession.APPLICATION_SCOPE);
+            prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/exportarchive_pickup.jsp");
+         }
+         else
+         {
+            prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/exportarchive_pickup_error.jsp");
+         }
          rReq.setAttribute("currpath", sPath);
-         javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/exportarchive_pickup.jsp");
          prd.include(rReq, rRes);
       }
    }
@@ -831,7 +839,10 @@
                aRes.setRenderParameter("op", CMSAdminConstants.OP_EXPORTARCHIVE_PICKUP);
                try
                {
-                  aRes.setRenderParameter("filepath", zipOut.getCanonicalPath());
+                  if (zipOut != null)
+                  {
+                     aRes.setRenderParameter("filepath", zipOut.getCanonicalPath());
+                  }
                }
                catch (IOException ioe)
                {
@@ -868,7 +879,6 @@
    /**
     * Rewrites urls. Typically, this is used for image src calls from the html, so they route thru the
     * CMSObjectCommandMapper and invoke the StreamObjectCommand.
-    * <p/>
     * TODO : need to make this not a hack
     */
    public String buildURL(JBossRenderRequest req, String path)

Added: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/exportarchive_pickup_error.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/exportarchive_pickup_error.jsp	2006-11-08 18:05:58 UTC (rev 5606)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/exportarchive_pickup_error.jsp	2006-11-08 20:00:32 UTC (rev 5607)
@@ -0,0 +1,32 @@
+<%@ page import="org.jboss.portal.core.portlet.cms.admin.CMSAdminConstants" %>
+<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
+<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
+<%@ page isELIgnored="false" %>
+
+<portlet:defineObjects/>
+
+<%
+   String sCurrPath = (String)request.getAttribute("currpath");
+%>
+
+<table width="100%">
+   <th class="portlet-section-header" align="center">${n:i18n("CMS_EXPORTARCHIVE")}</th>
+   <tr>
+      <td align="left">
+         <table width="100%">
+            <tr>
+               <td align="center"><font color="red">ERROR processing export request!</font></td>
+            </tr>
+         </table>
+      </td>
+   </tr>
+</table>
+
+<a href="<portlet:renderURL>
+                <portlet:param name="op" value="<%= CMSAdminConstants.OP_MAIN %>"/>
+                <portlet:param name="path"
+                  value="<%= sCurrPath %>"/>
+              </portlet:renderURL>">
+   <img src="<%= renderRequest.getContextPath() + CMSAdminConstants.DEFAULT_IMAGES_PATH%>/browse.gif" border="0"
+        alt="${n:i18n("CMS_BACKTOBROWSER")}"></a>




More information about the jboss-svn-commits mailing list