From 0411e5daa22adf539a804812afd52e9ce15b31ab Mon Sep 17 00:00:00 2001 From: vforchi <vforchi@users.noreply.github.com> Date: Fri, 3 Mar 2017 13:45:44 +0100 Subject: [PATCH] simplified resolution of file paths --- .../config/ConfigurableServiceConnection.java | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/tap/config/ConfigurableServiceConnection.java b/src/tap/config/ConfigurableServiceConnection.java index 8dc4eeb..c92d01f 100644 --- a/src/tap/config/ConfigurableServiceConnection.java +++ b/src/tap/config/ConfigurableServiceConnection.java @@ -45,7 +45,6 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.net.URI; import java.util.*; import static tap.config.TAPConfiguration.*; @@ -258,38 +257,27 @@ public final class ConfigurableServiceConnection implements ServiceConnection { /** * <p>Resolve the given file name/path.</p> * - * <p>Only the URI protocol "file:" is allowed. If the protocol is different a {@link TAPException} is thrown.</p> - * * <p> - * If not an absolute URI, the given path may be either relative or absolute. A relative path is always considered + * If not an absolute path, the given path may be either relative or absolute. A relative path is always considered * as relative from the Web Application directory (supposed to be given in 2nd parameter). * </p> * - * @param filePath URI/Path/Name of the file to get. + * @param filePath Path/Name of the file to get. * @param webAppRootPath Web Application directory local path. * @param propertyName Name of the property which gives the given file path. * * @return The specified File instance. * - * @throws TAPException If the given URI is malformed or if the used URI scheme is different from "file:". */ - protected static final File getFile(final String filePath, final String webAppRootPath, final String propertyName) throws TAPException{ + protected static final File getFile(final String filePath, final String webAppRootPath, final String propertyName) { if (filePath == null) return null; - URI uri = new File(filePath).toURI(); - if (uri.isAbsolute()){ - if (uri.getScheme().equalsIgnoreCase("file")) - return new File(uri); - else - throw new TAPException("Incorrect file URI for the property \"" + propertyName + "\": \"" + filePath + "\"! Only URI with the protocol \"file:\" are allowed."); - }else{ - File f = new File(filePath); - if (f.isAbsolute()) - return f; - else - return new File(webAppRootPath, filePath); - } + File f = new File(filePath); + if (f.isAbsolute()) + return f; + else + return new File(webAppRootPath, filePath); } /** -- GitLab