|
24 | 24 | package org.opengrok.indexer.util;
|
25 | 25 |
|
26 | 26 | import java.io.File;
|
27 |
| -import java.io.FileNotFoundException; |
28 | 27 | import java.io.IOException;
|
29 | 28 | import java.nio.file.Files;
|
30 | 29 | import java.nio.file.InvalidPathException;
|
|
35 | 34 | import java.util.logging.Level;
|
36 | 35 | import java.util.logging.Logger;
|
37 | 36 |
|
38 |
| -import org.opengrok.indexer.configuration.RuntimeEnvironment; |
39 | 37 | import org.opengrok.indexer.logger.LoggerFactory;
|
40 | 38 |
|
41 | 39 | /**
|
@@ -183,44 +181,6 @@ private static boolean isAllowedSymlink(String canonicalFile,
|
183 | 181 | return false;
|
184 | 182 | }
|
185 | 183 |
|
186 |
| - /** |
187 |
| - * Returns a path relative to source root. This would just be a simple |
188 |
| - * substring operation, except we need to support symlinks outside the |
189 |
| - * source root. |
190 |
| - * |
191 |
| - * @param file A file to resolve |
192 |
| - * @return Path relative to source root |
193 |
| - * @throws IOException if an IO error occurs |
194 |
| - * @throws FileNotFoundException if the file is not relative to source root |
195 |
| - * @throws ForbiddenSymlinkException if symbolic-link checking encounters |
196 |
| - * an ineligible link |
197 |
| - * @throws InvalidPathException if the path cannot be decoded |
198 |
| - */ |
199 |
| - public static String getPathRelativeToSourceRoot(File file) |
200 |
| - throws IOException, ForbiddenSymlinkException, FileNotFoundException, |
201 |
| - InvalidPathException { |
202 |
| - RuntimeEnvironment env = RuntimeEnvironment.getInstance(); |
203 |
| - String sourceRoot = env.getSourceRootPath(); |
204 |
| - if (sourceRoot == null) { |
205 |
| - throw new FileNotFoundException("Source Root Not Found"); |
206 |
| - } |
207 |
| - |
208 |
| - String maybeRelPath = PathUtils.getRelativeToCanonical(file.getPath(), |
209 |
| - sourceRoot, env.getAllowedSymlinks()); |
210 |
| - File maybeRelFile = new File(maybeRelPath); |
211 |
| - if (!maybeRelFile.isAbsolute()) { |
212 |
| - // N.b. OpenGrok has a weird convention that |
213 |
| - // source-root "relative" paths must start with a '/' as they are |
214 |
| - // elsewhere directly appended to env.getSourceRootPath() and also |
215 |
| - // stored as such. |
216 |
| - maybeRelPath = File.separator + maybeRelPath; |
217 |
| - return maybeRelPath; |
218 |
| - } |
219 |
| - |
220 |
| - throw new FileNotFoundException("Failed to resolve [" + file.getPath() |
221 |
| - + "] relative to source root [" + sourceRoot + "]"); |
222 |
| - } |
223 |
| - |
224 | 184 | /** Private to enforce static. */
|
225 | 185 | private PathUtils() {
|
226 | 186 | }
|
|
0 commit comments