Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fileoriginalpath_plugin4rosetta
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
fileoriginalpath_plugin4rosetta
Commits
2e0f161a
Commit
2e0f161a
authored
7 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- changed to use HashMap holding fileoriginalpath and filemodificationdate
parent
bcb53d35
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/org/slub/rosetta/plugins/repositoryTask/DnxMoveFileOriginalPathDublettesClean.java
+12
-10
12 additions, 10 deletions
...repositoryTask/DnxMoveFileOriginalPathDublettesClean.java
with
12 additions
and
10 deletions
src/org/slub/rosetta/plugins/repositoryTask/DnxMoveFileOriginalPathDublettesClean.java
+
12
−
10
View file @
2e0f161a
...
@@ -9,10 +9,7 @@ import com.exlibris.digitool.repository.api.RepositoryTaskPlugin;
...
@@ -9,10 +9,7 @@ import com.exlibris.digitool.repository.api.RepositoryTaskPlugin;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashSet
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -44,18 +41,20 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
...
@@ -44,18 +41,20 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
try
{
try
{
List
<
String
>
filePids
=
ieEditor
.
getFilesForRep
(
repPid
);
List
<
String
>
filePids
=
ieEditor
.
getFilesForRep
(
repPid
);
// for each rep pid mark all fileoriginalpaths to detect copies
// for each rep pid mark all fileoriginalpaths to detect copies
Set
<
String
>
filePaths
=
new
Hash
Set
<>();
Map
<
String
,
String
>
filePaths
WithModificationDate
=
new
Hash
Map
<>();
for
(
String
filePid
:
filePids
)
{
for
(
String
filePid
:
filePids
)
{
try
{
try
{
DnxDocumentHelper
ieDnxH
=
ieEditor
.
getDnxHelper
(
filePid
);
DnxDocumentHelper
ieDnxH
=
ieEditor
.
getDnxHelper
(
filePid
);
DnxDocumentHelper
.
GeneralFileCharacteristics
ieGfs
=
ieDnxH
.
getGeneralFileCharacteristics
();
DnxDocumentHelper
.
GeneralFileCharacteristics
ieGfs
=
ieDnxH
.
getGeneralFileCharacteristics
();
String
currentUpdateDate
=
ieGfs
.
getFileModificationDate
();
String
currentFileOriginalPath
=
ieGfs
.
getFileOriginalPath
();
String
currentFileOriginalPath
=
ieGfs
.
getFileOriginalPath
();
// workaround to check if fileOriginalPath has no "file://" because the replacement
// workaround to check if fileOriginalPath has no "file://" because the replacement
// always(!) starts with "file://"
// always(!) starts with "file://"
if
(
currentFileOriginalPath
.
startsWith
(
"file://"
)
)
{
if
(
currentFileOriginalPath
.
startsWith
(
"file://"
)
)
{
filePaths
.
add
(
currentFileOriginalPath
);
filePathsWithModificationDate
.
put
(
currentFileOriginalPath
,
currentUpdateDate
);
}
else
{
}
else
{
filePaths
.
add
(
"file://"
+
currentFileOriginalPath
);
filePaths
WithModificationDate
.
put
(
"file://"
+
currentFileOriginalPath
,
currentUpdateDate
);
}
}
}
catch
(
DigitoolException
e
)
{
}
catch
(
DigitoolException
e
)
{
IEsuccess
=
false
;
IEsuccess
=
false
;
...
@@ -70,7 +69,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
...
@@ -70,7 +69,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
for
(
String
filePid
:
filePids
)
{
for
(
String
filePid
:
filePids
)
{
try
{
try
{
if
(
replaceFileOriginalPath
(
ieEditor
,
repPid
,
filePid
,
filePaths
))
{
if
(
replaceFileOriginalPath
(
ieEditor
,
repPid
,
filePid
,
filePaths
WithModificationDate
))
{
countSuccess
++;
countSuccess
++;
}
}
taskResults
.
addResult
(
ieEditor
.
getIEPid
(),
null
,
true
,
"filepid="
+
filePid
+
" processed"
);
taskResults
.
addResult
(
ieEditor
.
getIEPid
(),
null
,
true
,
"filepid="
+
filePid
+
" processed"
);
...
@@ -136,10 +135,11 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
...
@@ -136,10 +135,11 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
/* replace file original path if it starts with "file://data/" or "/data/" */
/* replace file original path if it starts with "file://data/" or "/data/" */
private
boolean
replaceFileOriginalPath
(
IEEditor
ieEditor
,
String
repPid
,
String
filePid
,
Set
<
String
>
filePaths
)
throws
DigitoolException
,
FileOriginalPathCollisionException
{
private
boolean
replaceFileOriginalPath
(
IEEditor
ieEditor
,
String
repPid
,
String
filePid
,
Map
<
String
,
String
>
filePaths
WithModificationDate
)
throws
DigitoolException
,
FileOriginalPathCollisionException
{
DnxDocumentHelper
ieDnxH
=
ieEditor
.
getDnxHelper
(
filePid
);
DnxDocumentHelper
ieDnxH
=
ieEditor
.
getDnxHelper
(
filePid
);
DnxDocumentHelper
.
GeneralFileCharacteristics
ieGfs
=
ieDnxH
.
getGeneralFileCharacteristics
();
DnxDocumentHelper
.
GeneralFileCharacteristics
ieGfs
=
ieDnxH
.
getGeneralFileCharacteristics
();
String
currentFileOriginalPath
=
ieGfs
.
getFileOriginalPath
();
String
currentFileOriginalPath
=
ieGfs
.
getFileOriginalPath
();
String
currentModificationDate
=
ieGfs
.
getFileModificationDate
();
String
updatedFileOriginalPath
=
currentFileOriginalPath
;
/* default to current to avoid empty string */
String
updatedFileOriginalPath
=
currentFileOriginalPath
;
/* default to current to avoid empty string */
boolean
updated
=
false
;
boolean
updated
=
false
;
final
String
replacement
=
"file://"
;
final
String
replacement
=
"file://"
;
...
@@ -148,7 +148,8 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
...
@@ -148,7 +148,8 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
/* if something is updated */
/* if something is updated */
if
(
matcher
.
lookingAt
())
{
// update it
if
(
matcher
.
lookingAt
())
{
// update it
updatedFileOriginalPath
=
matcher
.
replaceFirst
(
replacement
);
updatedFileOriginalPath
=
matcher
.
replaceFirst
(
replacement
);
if
(
filePaths
.
contains
(
updatedFileOriginalPath
))
{
if
(
filePathsWithModificationDate
.
containsKey
(
updatedFileOriginalPath
))
{
// TODO: check Date!
throw
new
FileOriginalPathCollisionException
(
"update needed for IE "
+
ieEditor
.
getIEPid
()
+
" RepPid "
+
repPid
+
" FilePid "
+
filePid
+
throw
new
FileOriginalPathCollisionException
(
"update needed for IE "
+
ieEditor
.
getIEPid
()
+
" RepPid "
+
repPid
+
" FilePid "
+
filePid
+
" (old file_original_path='"
+
currentFileOriginalPath
+
"') to new file_original_path='"
+
" (old file_original_path='"
+
currentFileOriginalPath
+
"') to new file_original_path='"
+
updatedFileOriginalPath
+
"', but new file_original_path already exists!"
updatedFileOriginalPath
+
"', but new file_original_path already exists!"
...
@@ -164,6 +165,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
...
@@ -164,6 +165,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
log
.
info
(
"No update needed for IE "
+
ieEditor
.
getIEPid
()
+
" RepPid "
+
repPid
+
" FilePid "
+
log
.
info
(
"No update needed for IE "
+
ieEditor
.
getIEPid
()
+
" RepPid "
+
repPid
+
" FilePid "
+
filePid
+
" (file_original_path='"
+
currentFileOriginalPath
+
"')"
);
filePid
+
" (file_original_path='"
+
currentFileOriginalPath
+
"')"
);
}
}
// TODO: delete old entry!
ieGfs
.
setFileOriginalPath
(
updatedFileOriginalPath
);
ieGfs
.
setFileOriginalPath
(
updatedFileOriginalPath
);
ieDnxH
.
setGeneralFileCharacteristics
(
ieGfs
);
ieDnxH
.
setGeneralFileCharacteristics
(
ieGfs
);
ieEditor
.
setDnx
(
ieDnxH
,
filePid
);
/* necessary to commit changes on filePID */
ieEditor
.
setDnx
(
ieDnxH
,
filePid
);
/* necessary to commit changes on filePID */
...
...
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