Avoid a NPE.
authorpastith <devnull@localhost>
Mon, 23 Mar 2009 13:34:20 +0000 (13:34 +0000)
committerpastith <devnull@localhost>
Mon, 23 Mar 2009 13:34:20 +0000 (13:34 +0000)
gss/src/gr/ebs/gss/server/ejb/ExternalAPIBean.java

index 5cf83ca..af3f963 100644 (file)
@@ -2244,16 +2244,17 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                //CLEAR OLD VERSION IF FILE IS NOT VERSIONED AND GETS UPDATED
                if(!header.isVersioned() && header.getCurrentBody() != null){
                        header.setCurrentBody(null);
-                       Iterator<FileBody> it = header.getBodies().iterator();
-                       while(it.hasNext()){
-                               FileBody bo = it.next();
-                               File fileContents = new File(bo.getStoredFilePath());
-                               if (!fileContents.delete())
-                                       logger.error("Could not delete file " + bo.getStoredFilePath());
-                               it.remove();
-                               dao.delete(bo);
+                       if (header.getBodies() != null) {
+                               Iterator<FileBody> it = header.getBodies().iterator();
+                               while(it.hasNext()){
+                                       FileBody bo = it.next();
+                                       File fileContents = new File(bo.getStoredFilePath());
+                                       if (!fileContents.delete())
+                                               logger.error("Could not delete file " + bo.getStoredFilePath());
+                                       it.remove();
+                                       dao.delete(bo);
+                               }
                        }
-
                }
 
                Long quotaLeft = getQuotaLeft(owner.getId());