1 17 package com.sslexplorer.vfs.webdav; 18 19 import java.io.IOException ; 20 import java.io.PrintWriter ; 21 import java.net.URI ; 22 23 import com.sslexplorer.vfs.VFSResource; 24 25 26 33 public class DAVRedirection extends DAVException { 34 35 private VFSResource location = null; 36 37 40 public DAVRedirection(boolean permanent, VFSResource location) { 41 super(permanent? 301: 302, "Redirection requested"); 42 this.location = location; 43 } 44 45 48 public VFSResource getLocation() { 49 return this.location; 50 } 51 52 56 public void write(DAVTransaction transaction) 57 throws IOException { 58 transaction.setContentType("text/html; charset=\"utf-8\""); 59 transaction.setStatus(this.getStatus()); 60 61 62 PrintWriter out = transaction.write("utf-8"); 63 out.println("<html>"); 64 out.print("<head><title>Redirection requested</title></head>"); 65 out.println("<body>"); 66 out.print("<p><b>The requested resource has moved "); 67 out.print(this.getStatus() == 301? "permanently": "temporarily"); 68 out.println("</b></p>"); 69 70 if(this.location != null) { 71 transaction.setHeader("Location", location.getFullURI().toASCIIString()); 72 out.print("<p>The location for the requested resource is <a HREF=\""); 73 out.print("/fs" + location.getFullURI().toASCIIString()); 74 out.println("\">"); 75 out.print("/fs" + location.getFullPath()); 76 out.println("</a></p>"); 77 } 78 out.println("</body>"); 79 out.println("</html>"); 80 out.flush(); 81 } 82 } 83 | Popular Tags |