Find the WEB-INF dir by looking up in the directory tree. This is used if no explicit docbase is set, but only files. @param f The path from which it will start looking
(File f)
| 1880 | * @param f The path from which it will start looking |
| 1881 | */ |
| 1882 | protected void locateUriRoot(File f) { |
| 1883 | String tUriBase = uriBase; |
| 1884 | if (tUriBase == null) { |
| 1885 | tUriBase = "/"; |
| 1886 | } |
| 1887 | try { |
| 1888 | if (f.exists()) { |
| 1889 | f = new File(f.getAbsolutePath()); |
| 1890 | while (true) { |
| 1891 | File g = new File(f, "WEB-INF"); |
| 1892 | if (g.exists() && g.isDirectory()) { |
| 1893 | uriRoot = f.getCanonicalPath(); |
| 1894 | uriBase = tUriBase; |
| 1895 | if (log.isInfoEnabled()) { |
| 1896 | log.info(Localizer.getMessage("jspc.implicit.uriRoot", uriRoot)); |
| 1897 | } |
| 1898 | break; |
| 1899 | } |
| 1900 | if (f.exists() && f.isDirectory()) { |
| 1901 | tUriBase = "/" + f.getName() + "/" + tUriBase; |
| 1902 | } |
| 1903 | |
| 1904 | String fParent = f.getParent(); |
| 1905 | if (fParent == null) { |
| 1906 | break; |
| 1907 | } else { |
| 1908 | f = new File(fParent); |
| 1909 | } |
| 1910 | |
| 1911 | // If there is no acceptable candidate, uriRoot will |
| 1912 | // remain null. |
| 1913 | } |
| 1914 | |
| 1915 | if (uriRoot != null) { |
| 1916 | File froot = new File(uriRoot); |
| 1917 | uriRoot = froot.getCanonicalPath(); |
| 1918 | } |
| 1919 | } |
| 1920 | } catch (IOException ignore) { |
| 1921 | // Missing uriRoot will be handled in the caller. |
| 1922 | } |
| 1923 | } |
| 1924 | |
| 1925 | /** |
| 1926 | * Resolves the relative or absolute pathname correctly in both Ant and command-line situations. If Ant launched us, |
no test coverage detected