01: /*
02: * $Id : $
03: * $Source : $
04: * $Log: UnRewriter.java,v $
05: * Revision 1.4 2005/11/30 11:27:26 ss150821
06: * 6356996 - Srap Code base needs to save files in the unix file format and not windows
07: *
08: * Revision 1.3 2005/02/23 09:03:11 ss150821
09: * RFE 6223490 - SRA Should use JDK based logging
10: *
11: * Revision 1.2 2004/07/27 12:56:19 vt126379
12: * RFE#5075809, CRT#99
13: *
14: * Revision 1.1 2003/04/15 05:22:11 mm132998
15: * WebDAV support
16: *
17: *
18: */
19:
20: package com.sun.portal.rproxy.connectionhandler.webdav;
21:
22: import java.util.logging.Logger;
23:
24: import com.sun.portal.log.common.PortalLogger;
25:
26: /*
27: *
28: * @author Mridul Muralidharan
29: *
30: * Created on January 28, 2003, 2:16 PM
31: */
32: public class UnRewriter {
33:
34: // private static Logger logger =
35: // Logger.getLogger("com.sun.portal.sra.rproxy");
36: private static Logger logger = PortalLogger
37: .getLogger(UnRewriter.class);
38:
39: public static String unrewrite(String tStr) {
40:
41: String unrewrittenStr = tStr;
42:
43: // Start should be http:// or https://
44: if (tStr.regionMatches(true, 0, "http:/", 0, 7)
45: || tStr.regionMatches(true, 0, "https:/", 0, 8)) {
46: int indx = tStr.indexOf(":/");
47: if (indx != -1) {
48: int indx1 = tStr.lastIndexOf('/', indx);
49: if (indx1 != -1) {
50: // Ok strip off the prepended part.
51: // CAUTION : With gateway chaining - this may blow sky high
52: // !!
53: // Have to test it properly when that gets tested.
54: unrewrittenStr = tStr.substring(indx1 + 1);
55: }
56: // else is impossible to have :)
57: } else {
58: // logger.info("Unrewrite Parser - starts with http:// or
59: // https:// but does not have a path after that !! - rewriting
60: // issues ??");
61: logger.info("PSSRRPROXY_CSPRCW002");
62: }
63: } else {
64: // Maybe client stripped the protocol://host:port/ part of URL ??
65: int indx = tStr.indexOf(":/");
66: if (indx != -1) {
67: int indx1 = tStr.lastIndexOf('/', indx);
68: if (indx1 != -1) {
69: // Ok strip off the prepended part.
70: // CAUTION : With gateway chaining - this may blow sky high
71: // !!
72: // Have to test it properly when that gets tested.
73: unrewrittenStr = tStr.substring(indx1 + 1);
74: }
75: // else strange !!
76: else {
77: // logger.severe("Unrewrite Parser - does not start with
78: // http:// or https:// but also does not have a '/' before
79: // '://' !!");
80: logger.severe("PSSRRPROXY_CSPRCW003");
81: }
82: }
83: }
84: return unrewrittenStr;
85: }
86: }
|