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
54e1cee8
Commit
54e1cee8
authored
17 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
Code Review: createMoveAndProcess() refactored to improve readability
SVN: 1430
parent
1504073b
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
datamover/source/java/ch/systemsx/cisd/datamover/MonitorStarter.java
+25
-25
25 additions, 25 deletions
...ource/java/ch/systemsx/cisd/datamover/MonitorStarter.java
with
25 additions
and
25 deletions
datamover/source/java/ch/systemsx/cisd/datamover/MonitorStarter.java
+
25
−
25
View file @
54e1cee8
...
@@ -96,16 +96,39 @@ public class MonitorStarter
...
@@ -96,16 +96,39 @@ public class MonitorStarter
private
IPathHandler
createIncomingMovingPathHandler
(
String
sourceHost
,
File
manualInterventionDir
,
private
IPathHandler
createIncomingMovingPathHandler
(
String
sourceHost
,
File
manualInterventionDir
,
RegexFileFilter
manualInterventionFilter
,
RegexFileFilter
cleansingFilter
)
RegexFileFilter
manualInterventionFilter
,
RegexFileFilter
cleansingFilter
)
{
{
IPathHandler
moveFromIncoming
=
createPathMoverToLocal
(
sourceHost
,
inProgressDir
);
IPathHandler
processMoved
=
IPathHandler
processMoved
=
createProcessMovedFile
(
readyToMoveDir
,
tempDir
,
parameters
.
tryGetExtraCopyStore
(),
factory
);
createProcessMovedFile
(
readyToMoveDir
,
tempDir
,
parameters
.
tryGetExtraCopyStore
(),
factory
);
IPathHandler
moveAndProcess
=
createMoveAndProcess
(
moveFromIncoming
,
inProgressDir
,
processMoved
);
IPathHandler
moveAndProcess
=
createMoveAndProcess
(
sourceHost
,
processMoved
);
IPathHandler
manualInterventionMover
=
createPathMoverToLocal
(
sourceHost
,
manualInterventionDir
);
IPathHandler
manualInterventionMover
=
createPathMoverToLocal
(
sourceHost
,
manualInterventionDir
);
CleansingPathHandlerDecorator
cleansingOrMover
=
CleansingPathHandlerDecorator
cleansingOrMover
=
new
CleansingPathHandlerDecorator
(
cleansingFilter
,
moveAndProcess
);
new
CleansingPathHandlerDecorator
(
cleansingFilter
,
moveAndProcess
);
return
new
GatePathHandlerDecorator
(
manualInterventionFilter
,
cleansingOrMover
,
manualInterventionMover
);
return
new
GatePathHandlerDecorator
(
manualInterventionFilter
,
cleansingOrMover
,
manualInterventionMover
);
}
}
private
IPathHandler
createMoveAndProcess
(
String
sourceHost
,
final
IPathHandler
processMoved
)
{
final
IPathHandler
moveFromIncoming
=
createPathMoverToLocal
(
sourceHost
,
inProgressDir
);
IPathHandler
moveAndProcess
=
new
IPathHandler
()
{
public
boolean
handle
(
File
path
)
{
boolean
ok
=
moveFromIncoming
.
handle
(
path
);
if
(
ok
)
{
// create path in destination directory
File
movedFile
=
new
File
(
inProgressDir
,
path
.
getName
());
File
markFile
=
new
File
(
inProgressDir
,
Constants
.
IS_FINISHED_PREFIX
+
path
.
getName
());
assert
movedFile
.
exists
();
assert
markFile
.
exists
();
markFile
.
delete
();
// process even if mark file could not be deleted
ok
=
processMoved
.
handle
(
movedFile
);
}
return
ok
;
}
};
return
moveAndProcess
;
}
private
static
IPathHandler
createProcessMovedFile
(
File
destDirectory
,
File
tempDir
,
private
static
IPathHandler
createProcessMovedFile
(
File
destDirectory
,
File
tempDir
,
FileStore
extraCopyStoreOrNull
,
IFileSysOperationsFactory
factory
)
FileStore
extraCopyStoreOrNull
,
IFileSysOperationsFactory
factory
)
{
{
...
@@ -159,29 +182,6 @@ public class MonitorStarter
...
@@ -159,29 +182,6 @@ public class MonitorStarter
};
};
}
}
private
static
IPathHandler
createMoveAndProcess
(
final
IPathHandler
moveFromIncoming
,
final
File
destinationDir
,
final
IPathHandler
processMovedFile
)
{
return
new
IPathHandler
()
{
public
boolean
handle
(
File
path
)
{
boolean
ok
=
moveFromIncoming
.
handle
(
path
);
if
(
ok
)
{
// create path in destination directory
File
movedFile
=
new
File
(
destinationDir
,
path
.
getName
());
File
markFile
=
new
File
(
destinationDir
,
Constants
.
IS_FINISHED_PREFIX
+
path
.
getName
());
assert
movedFile
.
exists
();
assert
markFile
.
exists
();
markFile
.
delete
();
// process even if mark file could not be deleted
ok
=
processMovedFile
.
handle
(
movedFile
);
}
return
ok
;
}
};
}
private
IPathHandler
createPathMoverToLocal
(
String
sourceHost
,
final
File
localDestDir
)
private
IPathHandler
createPathMoverToLocal
(
String
sourceHost
,
final
File
localDestDir
)
{
{
if
(
parameters
.
getTreatIncomingAsRemote
())
if
(
parameters
.
getTreatIncomingAsRemote
())
...
...
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