Revize e608f492
Přidáno uživatelem Michal Horký před asi 4 roky(ů)
project/Deserializer/src/Converter.java | ||
---|---|---|
82 | 82 |
continue; |
83 | 83 |
} |
84 | 84 |
|
85 |
byte array[] = getBytes(inputFile.get(), query.get()); |
|
85 |
byte array[]; |
|
86 |
try { |
|
87 |
array = getBytes(inputFile.get(), query.get()); |
|
88 |
} catch (Exception e) { |
|
89 |
ui.loadingInputFileError(); |
|
90 |
continue; |
|
91 |
} |
|
92 |
|
|
86 | 93 |
StringBuilder html = new StringBuilder(); |
87 | 94 |
StringBuilder json = new StringBuilder(); |
88 | 95 |
|
96 |
boolean error = false; |
|
89 | 97 |
try { |
90 | 98 |
// Redirectovany system.out do null streamu. Mozno redirect do souboru |
91 |
System.setOut(FileWorker.createRedirectStream()); |
|
99 |
System.setOut(FileWorker.createRedirectStream(false)); |
|
100 |
System.setErr(FileWorker.createRedirectStream(true)); |
|
101 |
System.out.println("--- jdeserialize begins ---".toUpperCase()); |
|
92 | 102 |
convert(array, html, json); |
93 | 103 |
} catch (Exception e) { |
94 |
json.setLength(0);
|
|
95 |
html.setLength(0);
|
|
104 |
e.printStackTrace();
|
|
105 |
error = true;
|
|
96 | 106 |
} finally { |
107 |
System.out.println("--- jdeserialize ends ---".toUpperCase()); |
|
108 |
System.out.flush(); |
|
109 |
System.err.flush(); |
|
110 |
System.setErr(new PrintStream(new FileOutputStream(FileDescriptor.err))); |
|
97 | 111 |
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); |
98 | 112 |
} |
99 | 113 |
|
... | ... | |
112 | 126 |
} |
113 | 127 |
//test file output |
114 | 128 |
|
115 |
ui.completed(html.toString(), json.toString(), array == null ? null : new String(array));
|
|
129 |
ui.completed(error ? null : html.toString(), error ? null : json.toString(), array == null ? null : new String(array));
|
|
116 | 130 |
} |
117 | 131 |
} |
118 | 132 |
|
119 |
private byte[] getBytes(File file, DB_Messenger query) { |
|
133 |
private byte[] getBytes(File file, DB_Messenger query) throws Exception {
|
|
120 | 134 |
byte array[]; |
121 |
try { |
|
122 |
if (file != null) { |
|
123 |
array = FileWorker.loadFileContent(file); |
|
124 |
} else { |
|
125 |
array = Database.getBlobBytes(query); |
|
126 |
} |
|
127 |
array = FileWorker.unzipFile(array); |
|
128 |
} catch (IOException e) { |
|
129 |
e.printStackTrace(); |
|
130 |
ui.loadingInputFileError(); |
|
131 |
return null; |
|
135 |
if (file != null) { |
|
136 |
array = FileWorker.loadFileContent(file); |
|
137 |
} else { |
|
138 |
array = Database.getBlobBytes(query); |
|
132 | 139 |
} |
140 |
array = FileWorker.extractFileContent(array); |
|
133 | 141 |
return array; |
134 | 142 |
} |
135 | 143 |
|
Také k dispozici: Unified diff
re #7967
Zobrazení obsahu i u prázdného souboru. V případě nenačtení dat ze souboru, DB - vyskakovací okno s chybou. Úprava pro logovací soubory (rozdělení na out a err).