← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3316: Centralized action for loading documents from file system

 

------------------------------------------------------------
revno: 3316
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-04-07 15:48:56 +0200
message:
  Centralized action for loading documents from file system
removed:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/data_mart_export.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/LoadDocumentFromFileSystemAction.java
added:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/LoadDocumentAction.java
modified:
  dhis-2/dhis-web/dhis-web-commons/pom.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/document.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm
  labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/pom.xml'
--- dhis-2/dhis-web/dhis-web-commons/pom.xml	2011-03-02 00:23:51 +0000
+++ dhis-2/dhis-web/dhis-web-commons/pom.xml	2011-04-07 13:48:56 +0000
@@ -68,6 +68,10 @@
     </dependency>
     <dependency>
       <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-reporting</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-support-test</artifactId>
     </dependency>
     <dependency>

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/LoadDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/LoadDocumentAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/LoadDocumentAction.java	2011-04-07 13:48:56 +0000
@@ -0,0 +1,113 @@
+package org.hisp.dhis.commons.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.document.Document;
+import org.hisp.dhis.document.DocumentService;
+import org.hisp.dhis.external.location.LocationManager;
+import org.hisp.dhis.util.StreamActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class LoadDocumentAction
+    extends StreamActionSupport
+{
+    private static final Log log = LogFactory.getLog( LoadDocumentAction.class );
+    
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private LocationManager locationManager;
+
+    public void setLocationManager( LocationManager locationManager )
+    {
+        this.locationManager = locationManager;
+    }
+
+    private DocumentService documentService;
+
+    public void setDocumentService( DocumentService documentService )
+    {
+        this.documentService = documentService;
+    }   
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }   
+    
+    private Document document;
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    protected String execute( HttpServletResponse response, OutputStream out )
+        throws Exception
+    {
+        document = documentService.getDocument( id );
+        
+        InputStream in = locationManager.getInputStream( document.getUrl(), DocumentService.DIR );
+        
+        IOUtils.copy( in, out );
+        
+        log.info( "Document " + document.getName() + ", " + document.getUrl() + ", " + document.getContentType() );
+        
+        return SUCCESS;
+    }
+
+    @Override
+    protected String getContentType()
+    {
+        return document != null ? document.getContentType() : null;
+    }
+
+    @Override
+    protected String getFilename()
+    {
+        return document != null ? document.getUrl() : null;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2011-04-07 12:42:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2011-04-07 13:48:56 +0000
@@ -437,6 +437,11 @@
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
 
+	<bean id="org.hisp.dhis.commons.action.LoadDocumentAction" class="org.hisp.dhis.commons.action.LoadDocumentAction" scope="prototype">
+		<property name="locationManager" ref="locationManager"/>
+		<property name="documentService" ref="org.hisp.dhis.document.DocumentService"/>
+	</bean>
+  
 	<bean id="org.hisp.dhis.commons.action.NoAction" class="org.hisp.dhis.commons.action.NoAction" />
 
 	<!-- Interceptor -->

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-04-06 12:17:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-04-07 13:48:56 +0000
@@ -608,6 +608,17 @@
 		
 	</package>
 
+    <!-- Stream -->
+    
+    <package name="dhis-web-commons-stream" extends="dhis-web-commons"
+		namespace="/dhis-web-commons-stream">
+    
+		<action name="loadDocument" class="org.hisp.dhis.commons.action.LoadDocumentAction">
+			<result name="success" type="outputStreamResult"/>
+		</action>    
+		
+	</package>
+	
 	<!-- About -->
 
 	<package name="dhis-web-commons-about" extends="dhis-web-commons"

=== removed file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/data_mart_export.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/data_mart_export.vm	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/data_mart_export.vm	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-
-<table class="contentProviderTable">
-    <tr>
-    	<th colspan="2">$i18n.getString( "data_mart_export" )</th>
-    </tr>
-    #foreach ( $export in $dataMartExports )
-    <tr>
-    	<td>
-    		<a href="../dhis-web-datamart/exportDataMartExport.action?id=${export.id}">$export.name</a>
-    	</td>    	
-        <td style="width:16px">
-            <a href="javascript:window.location.href='removeDataMartExport.action?id=$export.id'" title="$i18n.getString( 'remove' )">
-            <img src="../images/close.png" alt="$i18n.getString( 'remove' )"></a>
-        </td>
-    </tr>
-    #end
-</table>

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/document.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/document.vm	2009-03-07 13:10:38 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/document.vm	2011-04-07 13:48:56 +0000
@@ -9,7 +9,7 @@
             #if ( $document.external )
                 <a href="$document.url">
             #else
-                <a href="javascript:window.location.href='../dhis-web-reporting/loadDocument.action?id=$document.id'">
+                <a href="javascript:window.location.href='../dhis-web-commons-stream/loadDocument.action?id=$document.id'">
             #end
             $document.name</a>
         </td>

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/LoadDocumentFromFileSystemAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/LoadDocumentFromFileSystemAction.java	2010-09-20 08:49:55 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/LoadDocumentFromFileSystemAction.java	1970-01-01 00:00:00 +0000
@@ -1,113 +0,0 @@
-package org.hisp.dhis.reporting.document.action;
-
-/*
- * Copyright (c) 2004-2010, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.document.Document;
-import org.hisp.dhis.document.DocumentService;
-import org.hisp.dhis.external.location.LocationManager;
-import org.hisp.dhis.util.StreamActionSupport;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class LoadDocumentFromFileSystemAction
-    extends StreamActionSupport
-{
-    private static final Log log = LogFactory.getLog( LoadDocumentFromFileSystemAction.class );
-    
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private LocationManager locationManager;
-
-    public void setLocationManager( LocationManager locationManager )
-    {
-        this.locationManager = locationManager;
-    }
-
-    private DocumentService documentService;
-
-    public void setDocumentService( DocumentService documentService )
-    {
-        this.documentService = documentService;
-    }   
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }   
-    
-    private Document document;
-    
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected String execute( HttpServletResponse response, OutputStream out )
-        throws Exception
-    {
-        document = documentService.getDocument( id );
-        
-        InputStream in = locationManager.getInputStream( document.getUrl(), DocumentService.DIR );
-        
-        IOUtils.copy( in, out );
-        
-        log.info( "Document " + document.getName() + ", " + document.getUrl() + ", " + document.getContentType() );
-        
-        return SUCCESS;
-    }
-
-    @Override
-    protected String getContentType()
-    {
-        return document != null ? document.getContentType() : null;
-    }
-
-    @Override
-    protected String getFilename()
-    {
-        return document != null ? document.getUrl() : null;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-04-01 11:19:55 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-04-07 13:48:56 +0000
@@ -24,14 +24,6 @@
       ref="org.hisp.dhis.document.DocumentService"/>
   </bean>
   
-  <bean id="org.hisp.dhis.reporting.document.action.LoadDocumentFromFileSystemAction"
-    class="org.hisp.dhis.reporting.document.action.LoadDocumentFromFileSystemAction"
-    scope="prototype">
-    <property name="locationManager" ref="locationManager"/>
-    <property name="documentService"
-      ref="org.hisp.dhis.document.DocumentService"/>
-  </bean>
-  
   <bean id="org.hisp.dhis.reporting.document.action.RemoveDocumentAction"
     class="org.hisp.dhis.reporting.document.action.RemoveDocumentAction"
     scope="prototype">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-03-23 02:40:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-04-07 13:48:56 +0000
@@ -55,10 +55,6 @@
       <param name="onExceptionReturn">plainTextError</param>
     </action>
     
-    <action name="loadDocument" class="org.hisp.dhis.reporting.document.action.LoadDocumentFromFileSystemAction">
-      <result name="success" type="outputStreamResult"/>
-    </action>
-    
     <!-- Chart -->
         
     <action name="saveChart" class="org.hisp.dhis.reporting.chart.action.SaveChartAction">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm	2011-03-28 20:09:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm	2011-04-07 13:48:56 +0000
@@ -39,7 +39,7 @@
 						#if ( $document.external )
                     	   <a href="$document.url" title="$i18n.getString( 'view_report' )">
                     	#else
-                    	   <a href="javascript:window.location.href='loadDocument.action?id=$document.id'" title="$i18n.getString( 'view_report' )">
+                    	   <a href="javascript:window.location.href='../dhis-web-commons-stream/loadDocument.action?id=$document.id'" title="$i18n.getString( 'view_report' )">
                     	#end
                     	<img src="../images/start_process.png" alt="$i18n.getString( 'view_report' )"></a>                    
                     	<a href="displayAddDocumentForm.action?id=$!document.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>

=== modified file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css'
--- labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css	2011-04-07 13:30:46 +0000
+++ labs/dhis-web-light/src/main/webapp/dhis-web-light/style/dhis-web-light.css	2011-04-07 13:48:56 +0000
@@ -92,7 +92,7 @@
 
 .listTable td {
   padding: 0.2em;
-  white-space:nowrap;
+  white-space: nowrap;
 }
 
 .listRow {