Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vollt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sonia Zorba
vollt
Commits
0411e5da
Commit
0411e5da
authored
8 years ago
by
vforchi
Browse files
Options
Downloads
Patches
Plain Diff
simplified resolution of file paths
parent
8b2d8575
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tap/config/ConfigurableServiceConnection.java
+8
-20
8 additions, 20 deletions
src/tap/config/ConfigurableServiceConnection.java
with
8 additions
and
20 deletions
src/tap/config/ConfigurableServiceConnection.java
+
8
−
20
View file @
0411e5da
...
@@ -45,7 +45,6 @@ import java.io.File;
...
@@ -45,7 +45,6 @@ import java.io.File;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.net.URI
;
import
java.util.*
;
import
java.util.*
;
import
static
tap
.
config
.
TAPConfiguration
.*;
import
static
tap
.
config
.
TAPConfiguration
.*;
...
@@ -258,38 +257,27 @@ public final class ConfigurableServiceConnection implements ServiceConnection {
...
@@ -258,38 +257,27 @@ public final class ConfigurableServiceConnection implements ServiceConnection {
/**
/**
* <p>Resolve the given file name/path.</p>
* <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>
* <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).
* as relative from the Web Application directory (supposed to be given in 2nd parameter).
* </p>
* </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 webAppRootPath Web Application directory local path.
* @param propertyName Name of the property which gives the given file path.
* @param propertyName Name of the property which gives the given file path.
*
*
* @return The specified File instance.
* @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
)
if
(
filePath
==
null
)
return
null
;
return
null
;
URI
uri
=
new
File
(
filePath
).
toURI
();
File
f
=
new
File
(
filePath
);
if
(
uri
.
isAbsolute
()){
if
(
f
.
isAbsolute
())
if
(
uri
.
getScheme
().
equalsIgnoreCase
(
"file"
))
return
f
;
return
new
File
(
uri
);
else
else
return
new
File
(
webAppRootPath
,
filePath
);
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
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment