Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SPB_Exchange_Repo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Amelin Konstantin
SPB_Exchange_Repo
Commits
a489d3b7
Commit
a489d3b7
authored
Jul 11, 2019
by
Amelin Konstantin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove output split, change sorting input - zip lastmodified
parent
6e748efd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
26 deletions
+11
-26
src/main/scala/Main.scala
+11
-26
No files found.
src/main/scala/Main.scala
View file @
a489d3b7
...
...
@@ -33,12 +33,12 @@ object Main {
var
logString
=
""
val
paths
=
Files
.
list
(
Paths
.
get
(
args
(
0
)))
.
filter
{
p
=>
!
Files
.
isDirectory
(
p
)
}
.
iterator
.
asScala
.
toStream
.
filter
{
p
=>
!
Files
.
isDirectory
(
p
)
}
val
start
=
LocalDateTime
.
now
.
toString
.
replace
(
":"
,
"."
)
...
...
@@ -48,22 +48,14 @@ object Main {
val
sourceNameNotValidated
=
s
"${args(0)}/${start}_not_validated"
val
sourceNotValidated
=
Try
{
Files
.
createDirectory
(
Paths
.
get
(
sourceNameNotValidated
))
}
val
sourceNameError
=
s
"${args(0)}/
${start}_error
"
val
sourceNameError
=
s
"${args(0)}/
error_$start
"
val
sourceError
=
Try
{
Files
.
createDirectory
(
Paths
.
get
(
sourceNameError
))
}
val
outputNameValidated
=
s
"${args(1)}/${start}_validated"
val
outputValidated
=
Try
{
Files
.
createDirectory
(
Paths
.
get
(
outputNameValidated
))
}
val
outputNameNotValidated
=
s
"${args(1)}/${start}_not_validated"
val
outputNotValidated
=
Try
{
Files
.
createDirectory
(
Paths
.
get
(
outputNameNotValidated
))
}
val
createDirRes
=
for
{
sv
<-
sourceValidated
snv
<-
sourceNotValidated
se
<-
sourceError
ov
<-
outputValidated
onv
<-
outputNotValidated
}
yield
onv
}
yield
se
createDirRes
match
{
case
Success
(
_
)
=>
...
...
@@ -88,7 +80,7 @@ object Main {
FileEntry
(
s
"${name}_${e.getName}"
,
//e.getName,
e
.
getLastModifiedTime
,
Files
.
getLastModifiedTime
(
p
)
,
Some
(
zip
.
getInputStream
(
e
)),
zip
.
getInputStream
(
e
),
Some
(
zip
),
...
...
@@ -143,22 +135,17 @@ object Main {
rtsXmlValid
,
p
)
}
match
{
case
Success
((
oXml
,
ti
))
if
ti
.
contains
(
"isn`t wellformed or invalid"
)
=>
XML
.
save
(
Paths
.
get
(
outputNameNotValidated
,
s
"converted_${f.name}"
).
toString
,
oXml
,
xmlDecl
=
true
)
logString
+=
s
"'$now'\n$ti"
Files
.
copy
(
f
.
streamMove
,
Paths
.
get
(
sourceNameNotValidated
,
f
.
name
))
case
Success
((
oXml
,
ti
))
=>
XML
.
save
(
Paths
.
get
(
outputNameValidated
,
s
"converted_${f.name}"
).
toString
,
Paths
.
get
(
args
(
1
)
,
s
"converted_${f.name}"
).
toString
,
oXml
,
xmlDecl
=
true
)
logString
+=
s
"'$now'\n$ti"
if
(
ti
.
contains
(
"isn`t wellformed or invalid"
))
Files
.
copy
(
f
.
streamMove
,
Paths
.
get
(
sourceNameNotValidated
,
f
.
name
))
else
Files
.
copy
(
f
.
streamMove
,
Paths
.
get
(
sourceNameValidated
,
f
.
name
))
case
Failure
(
ex
)
=>
...
...
@@ -199,8 +186,6 @@ object Main {
if
(
Files
.
list
(
sourceNotValidated
.
get
).
toArray
.
isEmpty
)
Files
.
delete
(
sourceNotValidated
.
get
)
if
(
Files
.
list
(
sourceError
.
get
).
toArray
.
isEmpty
)
Files
.
delete
(
sourceError
.
get
)
if
(
Files
.
list
(
outputValidated
.
get
).
toArray
.
isEmpty
)
Files
.
delete
(
outputValidated
.
get
)
if
(
Files
.
list
(
outputNotValidated
.
get
).
toArray
.
isEmpty
)
Files
.
delete
(
outputNotValidated
.
get
)
}
match
{
case
Success
(
_
)
=>
println
(
s
"Converting has been finished. $logFileName located in ${args(0)}"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment