portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r333097 - in /portals/jetspeed-2/trunk/applications: demo/src/webapp/WEB-INF/portlet.xml gems/src/java/org/apache/portals/gems/file/FilePortlet.java
Date Sun, 13 Nov 2005 18:44:21 GMT
Author: taylor
Date: Sun Nov 13 10:44:19 2005
New Revision: 333097

URL: http://svn.apache.org/viewcvs?rev=333097&view=rev
Log:
simplifying the extension rules to take any file ending in .xxx or .xxxx except psml

Modified:
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml?rev=333097&r1=333096&r2=333097&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml Sun Nov 13 10:44:19
2005
@@ -709,6 +709,10 @@
         <mime-type>application/zip</mime-type>
         <portlet-mode>VIEW</portlet-mode>
     </supports>            
+    <supports>
+        <mime-type>text/csv</mime-type>
+        <portlet-mode>VIEW</portlet-mode>
+    </supports>                
     <supported-locale>en</supported-locale>      	
 	<portlet-info>
         <title>Content Viewer</title>

Modified: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java?rev=333097&r1=333096&r2=333097&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
Sun Nov 13 10:44:19 2005
@@ -68,6 +68,7 @@
 
     protected void setContentType(String path, RenderResponse response)
     {
+        // Note these content types need to be added to the portlet.xml        
         if (path.endsWith(".html"))
         {
             response.setContentType("text/html");
@@ -79,7 +80,11 @@
         else if (path.endsWith(".zip"))
         {
             response.setContentType("application/zip");
-        }        
+        }
+        else if (path.endsWith(".csv"))
+        {
+            response.setContentType("text/csv");
+        }                
         else
         {
             response.setContentType("text/html");
@@ -90,6 +95,12 @@
     throws PortletException, IOException
     {
         InputStream is = this.getPortletContext().getResourceAsStream(fileName);
+        if (is == null)
+        {
+            byte [] bytes = ("File " + fileName + " not found.").getBytes();
+            response.getPortletOutputStream().write(bytes);
+            return;
+        }
         drain(is, response.getPortletOutputStream());
         response.getPortletOutputStream().flush();
         is.close();        
@@ -100,24 +111,23 @@
 
     public static void drain(InputStream r,OutputStream w) throws IOException
     {
-        byte[] bytes=new byte[BLOCK_SIZE];
+        byte[] bytes = new byte[BLOCK_SIZE];
         try
         {
-          int length=r.read(bytes);
-          while(length!=-1)
-          {
-              if(length!=0)
-                  {
-                      w.write(bytes,0,length);
-                  }
-              length=r.read(bytes);
-          }
-      }
-      finally
-      {
-        bytes=null;
-      }
-
+            int length = r.read(bytes);
+            while (length != -1)
+            {
+                if (length != 0)
+                {
+                    w.write(bytes, 0, length);
+                }
+                length = r.read(bytes);
+            }
+        }
+        finally
+        {
+            bytes = null;
+        }
     }
    
     



---------------------------------------------------------------------
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