Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
7720966b
Commit
7720966b
authored
4 months ago
by
Riegel
Browse files
Options
Download
Email Patches
Plain Diff
Refactor: Move handling of ZipEntry copy to CityGmlZipEntry
parent
a2e711c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java
+2
-2
...e/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java
+27
-7
.../hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java
with
29 additions
and
9 deletions
+29
-9
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java
+
2
-
2
View file @
7720966b
...
...
@@ -42,13 +42,13 @@ public class CityGmlArchive {
}
if
(
entry
.
getName
().
endsWith
(
".gml"
))
{
InputStream
is
=
zipFileObj
.
getInputStream
(
entry
);
Files
.
copy
(
is
,
Path
.
of
(
tmpDir
.
toString
(),
entry
.
getName
()));
archiveEntries
.
add
(
CityGmlZipEntry
.
of
(
entry
,
config
,
zipFile
,
tmpDir
));
archiveEntries
.
add
(
CityGmlZipEntry
.
of
(
entry
,
config
,
zipFile
,
tmpDir
,
is
));
}
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
Exception
e
){
// Catch and rethrow Exception to ensure tmpDir deletion
throw
e
;
}
finally
{
if
(
tmpDir
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java
+
27
-
7
View file @
7720966b
...
...
@@ -10,15 +10,20 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Enumeration
;
import
java.util.zip.ZipEntry
;
public
class
CityGmlZipEntry
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
CityGmlZipEntry
.
class
);
public
enum
ZipEntryErrorType
{
INVALID_CITY_GML_FILE
,
EXCESSIVE_FILESIZE
,
IO_ERROR
}
private
String
fileName
;
private
String
archivePath
;
...
...
@@ -27,18 +32,29 @@ public class CityGmlZipEntry {
private
boolean
erroneousEntry
=
false
;
private
boolean
isLibraryObject
=
false
;
private
boolean
validated
=
false
;
private
ZipEntryErrorType
errorType
=
null
;
public
static
CityGmlZipEntry
of
(
ZipEntry
entry
,
ParserConfiguration
config
,
String
archivePath
,
Path
tempDir
){
public
static
CityGmlZipEntry
of
(
ZipEntry
entry
,
ParserConfiguration
config
,
String
archivePath
,
Path
tempDir
,
InputStream
is
){
CityGmlZipEntry
cgzEntry
=
new
CityGmlZipEntry
();
cgzEntry
.
fileName
=
entry
.
getName
();
cgzEntry
.
archivePath
=
archivePath
;
try
{
CityGmlParser
.
gagLogger
(
true
);
cgzEntry
.
model
=
CityGmlParser
.
parseCityGmlFile
(
tempDir
.
toString
()
+
"\\"
+
entry
.
getName
(),
config
);
}
catch
(
CityGmlParseException
|
InvalidGmlFileException
e
)
{
logger
.
error
(
e
);
if
((
double
)
entry
.
getSize
()
/
1024
/
1024
>
20
)
{
cgzEntry
.
erroneousEntry
=
true
;
cgzEntry
.
errorType
=
ZipEntryErrorType
.
EXCESSIVE_FILESIZE
;
}
else
{
try
{
Files
.
copy
(
is
,
Path
.
of
(
tempDir
.
toString
(),
entry
.
getName
()));
CityGmlParser
.
gagLogger
(
true
);
cgzEntry
.
model
=
CityGmlParser
.
parseCityGmlFile
(
tempDir
.
toString
()
+
"\\"
+
entry
.
getName
(),
config
);
}
catch
(
CityGmlParseException
|
InvalidGmlFileException
e
)
{
logger
.
error
(
e
);
cgzEntry
.
erroneousEntry
=
true
;
cgzEntry
.
errorType
=
ZipEntryErrorType
.
INVALID_CITY_GML_FILE
;
}
catch
(
IOException
e
){
logger
.
error
(
e
);
cgzEntry
.
erroneousEntry
=
true
;
cgzEntry
.
errorType
=
ZipEntryErrorType
.
IO_ERROR
;
}
}
return
cgzEntry
;
}
...
...
@@ -72,6 +88,10 @@ public class CityGmlZipEntry {
return
model
;
}
public
ZipEntryErrorType
getErrorType
()
{
return
errorType
;
}
public
boolean
isLibraryObject
()
{
return
isLibraryObject
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets