1 package nl.hippo.cms.workflows.shared; 2 3 import java.io.IOException ; 4 import nl.hippo.cocoon.webdav.WebDAVHelper; 5 import org.apache.commons.httpclient.HttpState; 6 7 public class URIUtil 8 { 9 10 public static String getLiveURI(String uri) 11 { 12 return uri.replaceFirst("\\.preview/", ".www/"); 13 } 14 15 public static String getHistoryURI(String uri) 16 { 17 return uri.replaceFirst("\\.preview/", ".history/"); 18 } 19 20 public static String getArchiveURI(String uri) 21 { 22 return uri.replaceFirst("\\.preview/", ".archive/"); 23 } 24 25 public static String getHTTPURI(String uri) 26 { 27 String result; 28 if (uri.startsWith("webdav:")) 29 { 30 result = "http:" + uri.substring(7); 31 } 32 else 33 { 34 result = uri; 35 } 36 return result; 37 } 38 39 public static String getPrettyPath(String uri, String baseUri, HttpState httpState) throws IOException 40 { 41 String caption = WebDAVHelper.propfindAsString(uri, "http://hippo.nl/cms/1.0", "caption", httpState); 42 String displayname = WebDAVHelper.propfindAsString(uri, "DAV:", "displayname", httpState); 43 String prettyPath = (caption == null || caption.equals("")) ? displayname : caption; 44 45 uri = uri.substring(0, uri.lastIndexOf('/') + 1); 46 while (!uri.equals(baseUri)) 47 { 48 caption = WebDAVHelper.propfindAsString(uri, "http://hippo.nl/cms/1.0", "caption", httpState); 49 displayname = WebDAVHelper.propfindAsString(uri, "DAV:", "displayname", httpState); 50 prettyPath = ((caption == null || caption.equals("")) ? displayname : caption) + " > " + prettyPath; 51 52 int startOfLastPathPart = uri.lastIndexOf('/', uri.length() - 2) + 1; 53 uri = uri.substring(0, startOfLastPathPart); 54 } 55 return prettyPath; 56 } 57 58 private URIUtil() 59 { 60 super(); 61 } 62 63 } 64 | Popular Tags |