When last_modified is not in valid format the date will be set to null
authorChristos Stathis <chstath@ebs.gr>
Thu, 13 Oct 2011 13:51:53 +0000 (16:51 +0300)
committerChristos Stathis <chstath@ebs.gr>
Thu, 13 Oct 2011 13:51:53 +0000 (16:51 +0300)
src/gr/grnet/pithos/web/client/FileList.java
src/gr/grnet/pithos/web/client/FilePropertiesDialog.java
src/gr/grnet/pithos/web/client/foldertree/Folder.java
src/gr/grnet/pithos/web/client/foldertree/Resource.java

index 7ac22ae..566d2ff 100644 (file)
@@ -297,7 +297,7 @@ public class FileList extends Composite {
         aColumn = new Column<File,String>(new TextCell()) {
                        @Override
                        public String getValue(File object) {
-                               return formatter.format(object.getLastModified());
+                               return object.getLastModified() != null ? formatter.format(object.getLastModified()) : "";
                        }
                };
         aheader = new SortableHeader("Last Modified");
@@ -500,7 +500,9 @@ public class FileList extends Composite {
                             } else if (sortingProperty.equals("owner")) {
                                     return arg0.getOwner().compareTo(arg1.getOwner());
                             } else if (sortingProperty.equals("date")) {
-                                    return arg0.getLastModified().compareTo(arg1.getLastModified());
+                                       if (arg0.getLastModified() != null && arg1.getLastModified() != null)
+                                               return arg0.getLastModified().compareTo(arg1.getLastModified());
+                                       return 0;
                             } else if (sortingProperty.equals("size")) {
                                     return (int) (arg0.getBytes() - arg1.getBytes());
                             } else if (sortingProperty.equals("name")) {
index a582560..a018e7f 100644 (file)
@@ -216,7 +216,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
         generalTable.setText(2, 1, file.getOwner());\r
 \r
         final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");\r
-        generalTable.setText(3, 1, formatter.format(file.getLastModified()));\r
+        generalTable.setText(3, 1, file.getLastModified() != null ? formatter.format(file.getLastModified()) : "");\r
 \r
                StringBuffer tagsBuffer = new StringBuffer();\r
         for (String t : file.getTags())\r
index 0a2a9d6..3e73b16 100644 (file)
@@ -43,6 +43,7 @@ import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
+import com.google.gwt.core.client.GWT;
 import com.google.gwt.http.client.Response;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
@@ -105,10 +106,6 @@ public class Folder extends Resource {
         return bytesUsed;
     }
 
-    public void setLastModified(Date lastModified) {
-        this.lastModified = lastModified;
-    }
-
     public Set<Folder> getSubfolders() {
         return subfolders;
     }
@@ -156,7 +153,12 @@ public class Folder extends Resource {
         this.owner = _owner;
         String header = response.getHeader("Last-Modified");
         if (header != null)
-            lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header);
+                       try {
+                               lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header);
+                       } catch (IllegalArgumentException e) {
+                               GWT.log("Last-Modified will be set to null", e);
+                               lastModified = null;
+                       }
 
         header = response.getHeader("X-Container-Bytes-Used");
         if (header != null && header.length() > 0)
index e424719..09a29d9 100644 (file)
@@ -35,6 +35,7 @@
 
 package gr.grnet.pithos.web.client.foldertree;
 
+import com.google.gwt.core.client.GWT;
 import com.google.gwt.http.client.Response;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
@@ -84,7 +85,11 @@ public abstract class Resource {
         if(obj.get(key) != null) {
             JSONString s = obj.get(key).isString();
             if (s != null)
-                return DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(s.stringValue());
+                               try {
+                                       return DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(s.stringValue());
+                               } catch (IllegalArgumentException e) {
+                                       GWT.log("", e);
+                               }
         }
         return null;
     }