click here for details... Sakai Executive Director Position Search now open
Issue Details (XML | Word | Printable)

Key: SAK-5584
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Brian Jorgensen
Reporter: Thomas Amsler
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Sakai

Samigo File Upload Question Type: While retrieving the uploaded file, it throws an exception

Created: 14-Jul-2006 09:21   Updated: 23-Oct-2008 11:16
Component/s: Tests & Quizzes (Samigo)
Affects Version/s: 2.1.x
Fix Version/s: 2.1.x, 2.3.0

Time Tracking:
Not Specified

File Attachments: 1. File sakai-2-1-x-Samigo-SAK-5584.diff (1 kB)

Environment: Samigo File Upload Question Type
Issue Links:
Depend
 

2.6.x Status: None
2.5.x Status: None
2.4.x Status: None


 Description  « Hide
Configure Samigo so that it stores uploaded files in the file system instead the database:

sam/tool/sakai-samigo/webapp/WEB-INF/web.xml
<init-param>
      <param-name>com.corejsf.UploadFilter.saveMediaToDb</param-name>
      <param-value>false</param-value>
</init-param>

1. Create question type of File Upload
2. As a student take the test and upload a simple text file
3. After the student took the test, click on the test's score link and go to the file upload question. There you should see a link to the uploaded file. Click on the file link to view it and Samigo throws an exception:

Exception:
INFO: **mediaId = 1 (2006-07-14 08:44:41,261 http-8443-Processor20_org.sakaiproject.tool.assessment.ui.servlet.delivery.ShowMediaServlet)
INFO: ****1. media file size=13 (2006-07-14 08:44:41,268 http-8443-Processor20_org.sakaiproject.tool.assessment.ui.servlet.delivery.ShowMediaServlet)
WARN: (2006-07-14 08:44:41,270 http-8443-Processor20_org.sakaiproject.util.RequestFilter)
java.lang.NullPointerException
        at org.sakaiproject.tool.assessment.ui.servlet.delivery.ShowMediaServlet.doPost(ShowMediaServlet.java:77)
        at org.sakaiproject.tool.assessment.ui.servlet.delivery.ShowMediaServlet.doGet(ShowMediaServlet.java:62)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:535)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)


 All   Comments   Work Log   Change History   Subversion Commits   git Commits      Sort Order: Ascending order - Click to sort in descending order
Thomas Amsler added a comment - 14-Jul-2006 13:37
First potential fix where we make sure that mediaData is never null even if the content is stored in the File System:


Index: /home/thomas/sakai-2-1-x/sam/component/src/java/org/sakaiproject/tool/assessment/facade/AssessmentGradingFacadeQueries.java
===================================================================
--- /home/thomas/sakai-2-1-x/sam/component/src/java/org/sakaiproject/tool/assessment/facade/AssessmentGradingFacadeQueries.java (revision 12327)
+++ /home/thomas/sakai-2-1-x/sam/component/src/java/org/sakaiproject/tool/assessment/facade/AssessmentGradingFacadeQueries.java (working copy)
@@ -452,9 +452,16 @@
     MediaData mediaData = (MediaData) getHibernateTemplate().load(MediaData.class, mediaId);
     if (mediaData != null){
       String mediaLocation = mediaData.getLocation();
+
+ // Test if content is in DB or File System
+
+ // DB case:
       if (mediaLocation == null || (mediaLocation.trim()).equals("")){
         mediaData.setMedia(getMediaStream(mediaId));
       }
+ else {// File system
+ mediaData.setMedia(new byte[0]);
+ }
     }
     return mediaData;
   }

Thomas Amsler added a comment - 14-Jul-2006 13:51
Second potential fix where we comment the getMedia() API and the test the content byte array for null and assign a zero length byte array if necessary.

Index: /home/thomas/sakai-2-1-x/sam/tool/src/java/org/sakaiproject/tool/assessment/ui/servlet/delivery/ShowMediaServlet.java
===================================================================
--- /home/thomas/sakai-2-1-x/sam/tool/src/java/org/sakaiproject/tool/assessment/ui/servlet/delivery/ShowMediaServlet.java (revision 12329)
+++ /home/thomas/sakai-2-1-x/sam/tool/src/java/org/sakaiproject/tool/assessment/ui/servlet/delivery/ShowMediaServlet.java (working copy)
@@ -73,6 +73,9 @@
     String mediaLocation = mediaData.getLocation();
     int fileSize = mediaData.getFileSize().intValue();
     byte[] media = mediaData.getMedia();
+ if(null == media) {
+ media = new byte[0];
+ }
     log.info("****1. media file size="+mediaData.getFileSize());
     log.info("****2. media length="+media.length);
 

Index: /home/thomas/sakai-2-1-x/sam/api/src/java/org/sakaiproject/tool/assessment/data/ifc/grading/MediaIfc.java
===================================================================
--- /home/thomas/sakai-2-1-x/sam/api/src/java/org/sakaiproject/tool/assessment/data/ifc/grading/MediaIfc.java (revision 12171)
+++ /home/thomas/sakai-2-1-x/sam/api/src/java/org/sakaiproject/tool/assessment/data/ifc/grading/MediaIfc.java (working copy)
@@ -36,6 +36,12 @@
 
   void setItemGradingData(ItemGradingIfc itemGradingData);
 
+ /*
+ * Get content data, which is either stored in the
+ * database or in the file system
+ * @return byte array if content is stored in database,
+ * null if content is stored in the file system
+ */
   byte[] getMedia();
 
   void setMedia(byte[] media);

Thomas Amsler added a comment - 14-Jul-2006 14:36
Bugfix patch

Lydia Li added a comment - 14-Jul-2006 14:59
Just wanted to add that this only affects 2.1.x.

Lydia Li added a comment - 17-Jul-2006 14:20
David, can you get the patched file from Thomas and merge it in 2.1.x?

Peter A. Knoop added a comment - 15-Aug-2006 07:00
Has this issue also been addressed for 2.2, or is not a problem in that branch?

Lydia Li added a comment - 30-Aug-2006 12:34
This is not a problem in 2.2.
 

Lydia Li added a comment - 10-Oct-2006 13:36
Closing this as this is not an issue in 2.3. Linking this to SAK-5405

Brian Jorgensen added a comment - 26-Oct-2006 15:01
Fixed in 2.1.x r17484.

Huong Nguyen added a comment - 27-Oct-2006 10:55
verified on qa-nl.