Refactor WebDav implementation
[lgpl/argeo-commons.git] / org.argeo.api.acr / src / org / argeo / api / acr / ContentNotFoundException.java
index b86c92c1ed300b1b80ae4217003400c2a7a886de..51efb3860a49d914b22e090be7750a10804ee91c 100644 (file)
@@ -1,16 +1,35 @@
 package org.argeo.api.acr;
 
-/** When a countent was requested which does not exists, equivalent to HTTP code 404.*/
+/**
+ * When a content was requested which does not exists, equivalent to HTTP code
+ * 404.
+ */
 public class ContentNotFoundException extends RuntimeException {
        private static final long serialVersionUID = -8629074900713760886L;
 
-       public ContentNotFoundException(String message, Throwable cause) {
-               super(message, cause);
+       private final String path;
+
+       public ContentNotFoundException(ContentSession session, String path, Throwable cause) {
+               super(message(session, path), cause);
+               this.path = path;
+               // we don't keep reference to the session for security reasons
+       }
+
+       public ContentNotFoundException(ContentSession session, String path) {
+               this(session, path, (String) null);
        }
 
-       public ContentNotFoundException(String message) {
-               super(message);
+       public ContentNotFoundException(ContentSession session, String path, String message) {
+               super(message != null ? message : message(session, path));
+               this.path = path;
+               // we don't keep reference to the session for security reasons
        }
 
-       
+       private static String message(ContentSession session, String path) {
+               return "Content " + path + "cannot be found.";
+       }
+
+       public String getPath() {
+               return path;
+       }
 }