Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
d80592fc
Commit
d80592fc
authored
15 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
LMS-1389 canonicalize file path
SVN: 14746
parent
7d9e7485
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
common/source/java/ch/systemsx/cisd/common/highwatermark/HostAwareFileWithHighwaterMark.java
+18
-5
18 additions, 5 deletions
.../common/highwatermark/HostAwareFileWithHighwaterMark.java
with
18 additions
and
5 deletions
common/source/java/ch/systemsx/cisd/common/highwatermark/HostAwareFileWithHighwaterMark.java
+
18
−
5
View file @
d80592fc
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
ch.systemsx.cisd.common.highwatermark
;
package
ch.systemsx.cisd.common.highwatermark
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
...
@@ -113,7 +114,7 @@ public final class HostAwareFileWithHighwaterMark extends HostAwareFile
...
@@ -113,7 +114,7 @@ public final class HostAwareFileWithHighwaterMark extends HostAwareFile
assert
properties
!=
null
:
"Unspecified properties"
;
assert
properties
!=
null
:
"Unspecified properties"
;
assert
StringUtils
.
isNotBlank
(
hostFilePropertyKey
)
:
"Host-file property key is blank"
;
assert
StringUtils
.
isNotBlank
(
hostFilePropertyKey
)
:
"Host-file property key is blank"
;
final
String
hostFile
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
hostFilePropertyKey
);
final
String
hostFile
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
hostFilePropertyKey
);
final
String
file
Path
;
File
file
;
String
hostNameOrNull
=
null
;
String
hostNameOrNull
=
null
;
final
int
index
=
hostFile
.
indexOf
(
HOST_FILE_SEP
);
final
int
index
=
hostFile
.
indexOf
(
HOST_FILE_SEP
);
final
String
rsyncModuleOrNull
;
final
String
rsyncModuleOrNull
;
...
@@ -124,24 +125,36 @@ public final class HostAwareFileWithHighwaterMark extends HostAwareFile
...
@@ -124,24 +125,36 @@ public final class HostAwareFileWithHighwaterMark extends HostAwareFile
if
(
index2
>
-
1
)
if
(
index2
>
-
1
)
{
{
rsyncModuleOrNull
=
hostFile
.
substring
(
index
+
1
,
index2
);
rsyncModuleOrNull
=
hostFile
.
substring
(
index
+
1
,
index2
);
file
Path
=
hostFile
.
substring
(
index2
+
1
);
file
=
new
File
(
hostFile
.
substring
(
index2
+
1
)
)
;
}
else
}
else
{
{
rsyncModuleOrNull
=
null
;
rsyncModuleOrNull
=
null
;
file
Path
=
hostFile
.
substring
(
index
+
1
);
file
=
getCanonicalFile
(
hostFile
.
substring
(
index
+
1
)
)
;
}
}
}
else
}
else
{
{
rsyncModuleOrNull
=
null
;
rsyncModuleOrNull
=
null
;
file
Path
=
hostFile
;
file
=
getCanonicalFile
(
hostFile
)
;
}
}
final
long
highwaterMarkInKb
=
final
long
highwaterMarkInKb
=
PropertyUtils
.
getLong
(
properties
,
hostFilePropertyKey
.
concat
(
SEP
).
concat
(
PropertyUtils
.
getLong
(
properties
,
hostFilePropertyKey
.
concat
(
SEP
).
concat
(
HIGHWATER_MARK_PROPERTY_KEY
),
-
1L
);
HIGHWATER_MARK_PROPERTY_KEY
),
-
1L
);
return
new
HostAwareFileWithHighwaterMark
(
hostNameOrNull
,
new
File
(
filePath
)
,
return
new
HostAwareFileWithHighwaterMark
(
hostNameOrNull
,
file
,
rsyncModuleOrNull
,
highwaterMarkInKb
);
rsyncModuleOrNull
,
highwaterMarkInKb
);
}
}
private
static
File
getCanonicalFile
(
final
String
hostFile
)
{
File
file
=
new
File
(
hostFile
);
try
{
return
file
.
getCanonicalFile
();
}
catch
(
IOException
ex
)
{
throw
new
ConfigurationFailureException
(
"Unknown file "
+
file
.
getAbsolutePath
());
}
}
/**
/**
* Returns the high water mark for this file.
* Returns the high water mark for this file.
*/
*/
...
...
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