1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.bo.service.internal; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.io.FileFilter; |
20 |
|
import java.io.IOException; |
21 |
|
import java.io.Reader; |
22 |
|
import java.io.UnsupportedEncodingException; |
23 |
|
import java.net.MalformedURLException; |
24 |
|
import java.net.URL; |
25 |
|
import java.net.URLEncoder; |
26 |
|
import java.util.ArrayList; |
27 |
|
import java.util.Iterator; |
28 |
|
import java.util.List; |
29 |
|
|
30 |
|
import org.qedeq.base.io.IoUtility; |
31 |
|
import org.qedeq.base.io.LoadingListener; |
32 |
|
import org.qedeq.base.io.Parameters; |
33 |
|
import org.qedeq.base.io.SourceArea; |
34 |
|
import org.qedeq.base.io.TextInput; |
35 |
|
import org.qedeq.base.io.UrlUtility; |
36 |
|
import org.qedeq.base.trace.Trace; |
37 |
|
import org.qedeq.base.utility.StringUtility; |
38 |
|
import org.qedeq.kernel.bo.common.Element2Utf8; |
39 |
|
import org.qedeq.kernel.bo.common.Kernel; |
40 |
|
import org.qedeq.kernel.bo.common.KernelProperties; |
41 |
|
import org.qedeq.kernel.bo.common.QedeqBo; |
42 |
|
import org.qedeq.kernel.bo.common.ServiceJob; |
43 |
|
import org.qedeq.kernel.bo.log.QedeqLog; |
44 |
|
import org.qedeq.kernel.bo.module.InternalKernelServices; |
45 |
|
import org.qedeq.kernel.bo.module.InternalModuleServiceCall; |
46 |
|
import org.qedeq.kernel.bo.module.InternalServiceJob; |
47 |
|
import org.qedeq.kernel.bo.module.KernelQedeqBo; |
48 |
|
import org.qedeq.kernel.bo.module.ModuleArbiter; |
49 |
|
import org.qedeq.kernel.bo.module.ModuleLabels; |
50 |
|
import org.qedeq.kernel.bo.module.QedeqFileDao; |
51 |
|
import org.qedeq.kernel.bo.service.basis.ModuleFileNotFoundException; |
52 |
|
import org.qedeq.kernel.bo.service.basis.ModuleLabelsCreator; |
53 |
|
import org.qedeq.kernel.bo.service.basis.ModuleServiceExecutor; |
54 |
|
import org.qedeq.kernel.bo.service.basis.QedeqVoBuilder; |
55 |
|
import org.qedeq.kernel.bo.service.basis.ServiceErrors; |
56 |
|
import org.qedeq.kernel.bo.service.dependency.LoadDirectlyRequiredModulesPlugin; |
57 |
|
import org.qedeq.kernel.bo.service.dependency.LoadRequiredModulesPlugin; |
58 |
|
import org.qedeq.kernel.bo.service.logic.FormalProofCheckerPlugin; |
59 |
|
import org.qedeq.kernel.bo.service.logic.SimpleProofFinderPlugin; |
60 |
|
import org.qedeq.kernel.bo.service.logic.WellFormedCheckerPlugin; |
61 |
|
import org.qedeq.kernel.se.base.module.Qedeq; |
62 |
|
import org.qedeq.kernel.se.base.module.Specification; |
63 |
|
import org.qedeq.kernel.se.common.DefaultModuleAddress; |
64 |
|
import org.qedeq.kernel.se.common.ModuleAddress; |
65 |
|
import org.qedeq.kernel.se.common.ModuleDataException; |
66 |
|
import org.qedeq.kernel.se.common.ModuleService; |
67 |
|
import org.qedeq.kernel.se.common.Service; |
68 |
|
import org.qedeq.kernel.se.common.SourceFileException; |
69 |
|
import org.qedeq.kernel.se.common.SourceFileExceptionList; |
70 |
|
import org.qedeq.kernel.se.config.QedeqConfig; |
71 |
|
import org.qedeq.kernel.se.dto.module.QedeqVo; |
72 |
|
import org.qedeq.kernel.se.state.LoadingState; |
73 |
|
import org.qedeq.kernel.se.visitor.ContextChecker; |
74 |
|
import org.qedeq.kernel.se.visitor.DefaultContextChecker; |
75 |
|
import org.qedeq.kernel.se.visitor.InterruptException; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@author |
82 |
|
|
|
|
| 47.4% |
Uncovered Elements: 329 (626) |
Complexity: 157 |
Complexity Density: 0.34 |
|
83 |
|
public class DefaultInternalKernelServices implements Kernel, InternalKernelServices, |
84 |
|
Service { |
85 |
|
|
86 |
|
|
87 |
|
private static final Class CLASS = DefaultInternalKernelServices.class; |
88 |
|
|
89 |
|
|
90 |
|
private KernelQedeqBoStorage modules; |
91 |
|
|
92 |
|
|
93 |
|
private final QedeqConfig config; |
94 |
|
|
95 |
|
|
96 |
|
private final KernelProperties kernel; |
97 |
|
|
98 |
|
|
99 |
|
private final QedeqFileDao qedeqFileDao; |
100 |
|
|
101 |
|
|
102 |
|
private ModuleArbiter arbiter; |
103 |
|
|
104 |
|
|
105 |
|
private final PluginManager pluginManager; |
106 |
|
|
107 |
|
|
108 |
|
private ServiceProcessManager processManager; |
109 |
|
|
110 |
|
|
111 |
|
private boolean validate = true; |
112 |
|
|
113 |
|
|
114 |
|
private ContextChecker contextChecker; |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
@param |
121 |
|
@param |
122 |
|
@param |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
124 |
476
|
public DefaultInternalKernelServices(final QedeqConfig config, final KernelProperties kernel,... |
125 |
|
final QedeqFileDao loader) { |
126 |
476
|
this.config = config; |
127 |
476
|
this.kernel = kernel; |
128 |
476
|
this.qedeqFileDao = loader; |
129 |
476
|
pluginManager = new PluginManager(this); |
130 |
476
|
loader.setServices(this); |
131 |
|
|
132 |
|
|
133 |
476
|
pluginManager.addPlugin("org.qedeq.kernel.bo.service.unicode.Qedeq2UnicodeTextPlugin"); |
134 |
476
|
pluginManager.addPlugin("org.qedeq.kernel.bo.service.latex.Qedeq2LatexPlugin"); |
135 |
476
|
pluginManager.addPlugin("org.qedeq.kernel.bo.service.unicode.Qedeq2Utf8Plugin"); |
136 |
|
|
137 |
476
|
pluginManager.addPlugin("org.qedeq.kernel.bo.service.heuristic.DynamicHeuristicCheckerPlugin"); |
138 |
476
|
pluginManager.addPlugin(SimpleProofFinderPlugin.class.getName()); |
139 |
|
|
140 |
|
|
141 |
476
|
pluginManager.addPlugin(LoadDirectlyRequiredModulesPlugin.class.getName()); |
142 |
476
|
pluginManager.addPlugin(LoadRequiredModulesPlugin.class.getName()); |
143 |
476
|
pluginManager.addPlugin(WellFormedCheckerPlugin.class.getName()); |
144 |
476
|
pluginManager.addPlugin(FormalProofCheckerPlugin.class.getName()); |
145 |
|
} |
146 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
147 |
476
|
public synchronized void startupServices() {... |
148 |
476
|
modules = new KernelQedeqBoStorage(); |
149 |
476
|
arbiter = new ModuleArbiterImpl(); |
150 |
476
|
processManager = new ServiceProcessManager(pluginManager, arbiter); |
151 |
476
|
contextChecker = new DefaultContextChecker(); |
152 |
476
|
if (config.isAutoReloadLastSessionChecked()) { |
153 |
0
|
autoReloadLastSessionChecked(); |
154 |
|
} |
155 |
|
} |
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
157 |
476
|
public synchronized void shutdownServices() {... |
158 |
476
|
processManager.terminateAndRemoveAllServiceProcesses(); |
159 |
476
|
processManager = null; |
160 |
476
|
modules.removeAllModules(); |
161 |
476
|
modules = null; |
162 |
476
|
arbiter = null; |
163 |
|
|
164 |
476
|
Thread.interrupted(); |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
170 |
0
|
private void autoReloadLastSessionChecked() {... |
171 |
0
|
if (config.isAutoReloadLastSessionChecked()) { |
172 |
0
|
final Thread thread = new Thread() { |
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
173 |
0
|
public void run() {... |
174 |
0
|
final String method = "autoReloadLastSessionChecked.thread.run()"; |
175 |
0
|
try { |
176 |
0
|
Trace.begin(CLASS, this, method); |
177 |
0
|
QedeqLog.getInstance().logMessage( |
178 |
|
"Trying to load previously successfully loaded modules."); |
179 |
0
|
final int number = config.getPreviouslyLoadedModules().length; |
180 |
0
|
if (loadPreviouslySuccessfullyLoadedModules()) { |
181 |
0
|
QedeqLog.getInstance().logMessage( |
182 |
|
"Loading of " + number + " previously successfully loaded module" |
183 |
0
|
+ (number != 1 ? "s" : "") + " successfully done."); |
184 |
|
} else { |
185 |
0
|
QedeqLog.getInstance().logMessage( |
186 |
|
"Loading of all previously successfully checked modules failed. " |
187 |
0
|
+ number + " module" + (number != 1 ? "s" : "") |
188 |
|
+ " were tried."); |
189 |
|
} |
190 |
|
} catch (Exception e) { |
191 |
0
|
Trace.trace(CLASS, this, method, e); |
192 |
|
} finally { |
193 |
0
|
Trace.end(CLASS, this, method); |
194 |
|
} |
195 |
|
} |
196 |
|
}; |
197 |
0
|
thread.setDaemon(true); |
198 |
0
|
thread.start(); |
199 |
|
} |
200 |
|
} |
201 |
|
|
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 8 |
Complexity Density: 0.24 |
|
202 |
0
|
public boolean removeAllModules() {... |
203 |
0
|
final String method = "removeAllModules()"; |
204 |
0
|
Trace.begin(CLASS, this, method); |
205 |
|
|
206 |
0
|
InternalServiceJob proc = null; |
207 |
0
|
proc = processManager.createServiceProcess("remove all modules"); |
208 |
0
|
final List calls = new ArrayList(); |
209 |
0
|
final List m = getModules().getAllModules(); |
210 |
0
|
boolean ok = false; |
211 |
0
|
try { |
212 |
|
|
213 |
0
|
for (final Iterator iterator = m.iterator(); iterator.hasNext(); ) { |
214 |
0
|
final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) iterator.next(); |
215 |
0
|
final InternalModuleServiceCall call = processManager.createServiceCall(this, prop, Parameters.EMPTY, |
216 |
|
Parameters.EMPTY, proc); |
217 |
0
|
calls.add(call); |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
0
|
for (final Iterator iterator = m.iterator(); iterator.hasNext(); ) { |
222 |
0
|
final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) iterator.next(); |
223 |
0
|
removeModule(prop); |
224 |
|
} |
225 |
0
|
ok = true; |
226 |
|
} catch (final InterruptException e) { |
227 |
0
|
for (final Iterator iterator = calls.iterator(); iterator.hasNext(); ) { |
228 |
0
|
final InternalModuleServiceCall call = (InternalModuleServiceCall) iterator.next(); |
229 |
0
|
call.finishError("couldn't lock all modules"); |
230 |
0
|
processManager.endServiceCall(call); |
231 |
|
} |
232 |
0
|
QedeqLog.getInstance().logMessage("Remove all modules failed: " + e.getMessage()); |
233 |
0
|
proc.setInterruptedState(); |
234 |
|
} finally { |
235 |
0
|
for (final Iterator iterator = calls.iterator(); iterator.hasNext(); ) { |
236 |
0
|
final InternalModuleServiceCall call = (InternalModuleServiceCall) iterator.next(); |
237 |
0
|
call.finishOk(); |
238 |
0
|
processManager.endServiceCall(call); |
239 |
|
} |
240 |
0
|
if (ok) { |
241 |
0
|
proc.setSuccessState(); |
242 |
|
} else { |
243 |
0
|
proc.setFailureState(); |
244 |
|
} |
245 |
|
} |
246 |
0
|
if (validate) { |
247 |
0
|
modules.validateDependencies(); |
248 |
|
} |
249 |
0
|
Trace.end(CLASS, this, method); |
250 |
0
|
return ok; |
251 |
|
} |
252 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
253 |
0
|
public void removeModule(final ModuleAddress address) {... |
254 |
0
|
final KernelQedeqBo prop = getKernelQedeqBo(address); |
255 |
0
|
if (prop != null) { |
256 |
0
|
QedeqLog.getInstance().logRequest("Removing module", address.getUrl()); |
257 |
0
|
InternalServiceJob proc = processManager.createServiceProcess("remove module"); |
258 |
0
|
InternalModuleServiceCall call = null; |
259 |
0
|
try { |
260 |
0
|
call = processManager.createServiceCall(this, prop, Parameters.EMPTY, |
261 |
|
Parameters.EMPTY, proc); |
262 |
0
|
removeModule((DefaultKernelQedeqBo) prop); |
263 |
0
|
call.finishOk(); |
264 |
0
|
proc.setSuccessState(); |
265 |
|
} catch (final InterruptException e) { |
266 |
0
|
QedeqLog.getInstance().logFailureReply( |
267 |
|
"Remove failed", address.getUrl(), e.getMessage()); |
268 |
0
|
proc.setInterruptedState(); |
269 |
|
} finally { |
270 |
0
|
processManager.endServiceCall(call); |
271 |
|
} |
272 |
0
|
if (validate) { |
273 |
0
|
modules.validateDependencies(); |
274 |
|
} |
275 |
|
} |
276 |
|
} |
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
@param |
283 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
284 |
0
|
private void removeModule(final DefaultKernelQedeqBo prop) {... |
285 |
0
|
synchronized (prop) { |
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
0
|
prop.delete(); |
291 |
0
|
getModules().removeModule(prop); |
292 |
0
|
return; |
293 |
|
} |
294 |
|
} |
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
@return |
300 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.35 |
|
301 |
0
|
public boolean clearLocalBuffer() {... |
302 |
0
|
final String method = "clearLocalBuffer"; |
303 |
0
|
try { |
304 |
0
|
QedeqLog.getInstance().logMessage( |
305 |
|
"Clear local buffer from all QEDEQ files."); |
306 |
0
|
if (removeAllModules()) { |
307 |
0
|
final File bufferDir = getBufferDirectory().getCanonicalFile(); |
308 |
0
|
if (bufferDir.exists() && !IoUtility.deleteDir(bufferDir, new FileFilter() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
309 |
0
|
public boolean accept(final File pathname) {... |
310 |
0
|
return pathname.getName().endsWith(".xml"); |
311 |
|
} |
312 |
|
})) { |
313 |
0
|
throw new IOException("buffer could not be deleted: " + bufferDir); |
314 |
|
} |
315 |
0
|
QedeqLog.getInstance().logMessage("Local buffer was cleared."); |
316 |
0
|
return true; |
317 |
|
} |
318 |
0
|
QedeqLog.getInstance().logMessage("Local buffer was not cleared."); |
319 |
0
|
return false; |
320 |
|
} catch (IOException e) { |
321 |
0
|
Trace.fatal(CLASS, this, method, "IO access problem", e); |
322 |
0
|
QedeqLog.getInstance().logMessage( |
323 |
|
"Local buffer not cleared. IO access problem. " + e.getMessage()); |
324 |
0
|
return false; |
325 |
|
} catch (final RuntimeException e) { |
326 |
0
|
Trace.fatal(CLASS, this, method, "unexpected problem", e); |
327 |
0
|
QedeqLog.getInstance().logMessage( |
328 |
|
"Local buffer not cleared. " + e.getMessage()); |
329 |
0
|
return false; |
330 |
|
} |
331 |
|
} |
332 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
333 |
1368
|
public KernelQedeqBo loadKernelModule(final InternalServiceJob process, final ModuleAddress address)... |
334 |
|
throws InterruptException { |
335 |
1368
|
final String method = "loadModule(InternalServiceProcess, ModuleAddress)"; |
336 |
1368
|
final DefaultKernelQedeqBo prop = getModules().getKernelQedeqBo(this, address); |
337 |
1368
|
if (prop.isLoaded()) { |
338 |
1056
|
return prop; |
339 |
|
} |
340 |
312
|
final ModuleServiceExecutor executor = new ModuleServiceExecutor() { |
|
|
| 67.9% |
Uncovered Elements: 9 (28) |
Complexity: 6 |
Complexity Density: 0.25 |
|
341 |
312
|
public void executeService(final InternalModuleServiceCall call) throws InterruptException {... |
342 |
312
|
try { |
343 |
312
|
synchronized (prop) { |
344 |
312
|
if (prop.isLoaded()) { |
345 |
0
|
call.finishOk(); |
346 |
0
|
return; |
347 |
|
} |
348 |
312
|
QedeqLog.getInstance().logRequest("Load module", address.getUrl()); |
349 |
312
|
if (prop.getModuleAddress().isFileAddress()) { |
350 |
267
|
call.setAction("file loading"); |
351 |
267
|
loadLocalModule(call.getInternalServiceProcess(), prop); |
352 |
|
} else { |
353 |
|
|
354 |
45
|
try { |
355 |
45
|
getCanonicalReadableFile(prop); |
356 |
|
} catch (ModuleFileNotFoundException e) { |
357 |
|
|
358 |
0
|
call.setAction("web loading"); |
359 |
0
|
saveQedeqFromWebToBuffer(call, prop); |
360 |
0
|
call.setExecutionPercentage(50); |
361 |
|
} |
362 |
45
|
call.setAction("buffer loading"); |
363 |
45
|
loadBufferedModule(call.getInternalServiceProcess(), prop); |
364 |
|
} |
365 |
306
|
QedeqLog.getInstance().logSuccessfulReply( |
366 |
|
"Successfully loaded", address.getUrl()); |
367 |
306
|
call.finishOk(); |
368 |
|
} |
369 |
|
} catch (SourceFileExceptionList e) { |
370 |
6
|
Trace.trace(CLASS, this, method, e); |
371 |
6
|
QedeqLog.getInstance().logFailureState("Loading of module failed.", address.getUrl(), |
372 |
|
e.toString()); |
373 |
6
|
call.finishError("Loading of module failed."); |
374 |
|
} catch (final RuntimeException e) { |
375 |
0
|
Trace.fatal(CLASS, this, method, "unexpected problem", e); |
376 |
0
|
QedeqLog.getInstance().logFailureReply("Loading failed", address.getUrl(), e.getMessage()); |
377 |
0
|
call.finishError("Loading of module failed: " + e.getMessage()); |
378 |
|
} |
379 |
|
} |
380 |
|
|
381 |
|
}; |
382 |
312
|
this.processManager.executeService(new ModuleService() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
383 |
0
|
public String getServiceAction() {... |
384 |
0
|
return "load QEDEQ module"; |
385 |
|
} |
386 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
387 |
0
|
public String getServiceDescription() {... |
388 |
0
|
return "take QEDEQ module address and try to load and parse the content"; |
389 |
|
} |
390 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
391 |
312
|
public String getServiceId() {... |
392 |
312
|
return "" + hashCode(); |
393 |
|
} |
394 |
|
}, executor, prop, process); |
395 |
312
|
return prop; |
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
} |
429 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
430 |
247
|
public QedeqBo loadModule(final ModuleAddress address) {... |
431 |
247
|
final InternalServiceJob process = processManager.createServiceProcess("LoadModule"); |
432 |
247
|
final QedeqBo result = getQedeqBo(address); |
433 |
247
|
try { |
434 |
247
|
loadKernelModule(process, address); |
435 |
247
|
process.setSuccessState(); |
436 |
|
} catch (InterruptException e) { |
437 |
0
|
process.setInterruptedState(); |
438 |
|
} |
439 |
247
|
return result; |
440 |
|
} |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
@param |
446 |
|
@param |
447 |
|
@throws |
448 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 3 |
Complexity Density: 0.21 |
|
449 |
59
|
private void loadBufferedModule(final InternalServiceJob process,... |
450 |
|
final DefaultKernelQedeqBo prop) throws SourceFileExceptionList { |
451 |
59
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_BUFFER); |
452 |
59
|
final File localFile; |
453 |
59
|
try { |
454 |
59
|
localFile = getCanonicalReadableFile(prop); |
455 |
|
} catch (ModuleFileNotFoundException e) { |
456 |
6
|
final SourceFileExceptionList sfl = createSourceFileExceptionList( |
457 |
|
ServiceErrors.LOADING_FROM_FILE_BUFFER_FAILED_CODE, |
458 |
|
ServiceErrors.LOADING_FROM_FILE_BUFFER_FAILED_TEXT, |
459 |
|
prop.getUrl(), e); |
460 |
6
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, sfl); |
461 |
6
|
throw sfl; |
462 |
|
} |
463 |
|
|
464 |
53
|
prop.setQedeqFileDao(getQedeqFileDao()); |
465 |
53
|
final Qedeq qedeq; |
466 |
53
|
try { |
467 |
53
|
qedeq = getQedeqFileDao().loadQedeq(process, prop, localFile); |
468 |
|
} catch (SourceFileExceptionList sfl) { |
469 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, sfl); |
470 |
0
|
throw sfl; |
471 |
|
} |
472 |
53
|
setCopiedQedeq(process, prop, qedeq); |
473 |
|
} |
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
@param |
479 |
|
@param |
480 |
|
@throws |
481 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.21 |
|
482 |
464
|
private void loadLocalModule(final InternalServiceJob process,... |
483 |
|
final DefaultKernelQedeqBo prop) throws SourceFileExceptionList { |
484 |
464
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_LOCAL_FILE); |
485 |
464
|
final File localFile; |
486 |
464
|
try { |
487 |
464
|
localFile = getCanonicalReadableFile(prop); |
488 |
|
} catch (ModuleFileNotFoundException e) { |
489 |
23
|
final SourceFileExceptionList sfl = createSourceFileExceptionList( |
490 |
|
ServiceErrors.LOADING_FROM_LOCAL_FILE_FAILED_CODE, |
491 |
|
ServiceErrors.LOADING_FROM_LOCAL_FILE_FAILED_TEXT, |
492 |
|
prop.getUrl(), e); |
493 |
23
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_LOCAL_FILE_FAILED, sfl); |
494 |
23
|
throw sfl; |
495 |
|
} |
496 |
441
|
prop.setQedeqFileDao(getQedeqFileDao()); |
497 |
|
|
498 |
441
|
final Qedeq qedeq; |
499 |
441
|
try { |
500 |
441
|
qedeq = getQedeqFileDao().loadQedeq(process, prop, localFile); |
501 |
|
} catch (SourceFileExceptionList sfl) { |
502 |
4
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_LOCAL_FILE_FAILED, sfl); |
503 |
4
|
throw sfl; |
504 |
|
} |
505 |
437
|
setCopiedQedeq(process, prop, qedeq); |
506 |
|
} |
507 |
|
|
|
|
| 55.6% |
Uncovered Elements: 12 (27) |
Complexity: 5 |
Complexity Density: 0.2 |
|
508 |
490
|
private void setCopiedQedeq(final InternalServiceJob process, final DefaultKernelQedeqBo prop,... |
509 |
|
final Qedeq qedeq) throws SourceFileExceptionList { |
510 |
490
|
final String method = "setCopiedQedeq(DefaultKernelQedeqBo, Qedeq)"; |
511 |
490
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_INTO_MEMORY); |
512 |
490
|
QedeqVo vo = null; |
513 |
490
|
try { |
514 |
490
|
vo = QedeqVoBuilder.createQedeq(prop.getModuleAddress(), qedeq); |
515 |
|
} catch (RuntimeException e) { |
516 |
0
|
Trace.fatal(CLASS, this, method, "looks like a programming error", e); |
517 |
0
|
final SourceFileExceptionList xl = createSourceFileExceptionList( |
518 |
|
ServiceErrors.RUNTIME_ERROR_CODE, |
519 |
|
ServiceErrors.RUNTIME_ERROR_TEXT, |
520 |
|
prop.getModuleAddress().getUrl(), e); |
521 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, xl); |
522 |
0
|
throw xl; |
523 |
|
} catch (ModuleDataException e) { |
524 |
0
|
if (e.getCause() != null) { |
525 |
0
|
Trace.fatal(CLASS, this, method, "looks like a programming error", e.getCause()); |
526 |
|
} else { |
527 |
0
|
Trace.fatal(CLASS, this, method, "looks like a programming error", e); |
528 |
|
} |
529 |
0
|
final SourceFileExceptionList xl = prop.createSourceFileExceptionList(this, e, qedeq); |
530 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, xl); |
531 |
0
|
throw xl; |
532 |
|
} |
533 |
490
|
prop.setQedeqVo(vo); |
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
490
|
final ModuleLabelsCreator moduleNodesCreator = new ModuleLabelsCreator(this, prop); |
548 |
490
|
try { |
549 |
490
|
final ModuleLabels labels = new ModuleLabels(); |
550 |
490
|
final Element2LatexImpl converter = new Element2LatexImpl(labels); |
551 |
490
|
final Element2Utf8 textConverter = new Element2Utf8Impl(converter); |
552 |
490
|
moduleNodesCreator.createLabels(process, labels); |
553 |
488
|
prop.setLoaded(vo, labels, converter, textConverter); |
554 |
|
} catch (SourceFileExceptionList sfl) { |
555 |
2
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, sfl); |
556 |
2
|
throw sfl; |
557 |
|
} |
558 |
|
} |
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
|
564 |
|
@param |
565 |
|
@return |
566 |
|
@throws |
567 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
568 |
582
|
private File getCanonicalReadableFile(final QedeqBo prop) throws ModuleFileNotFoundException {... |
569 |
582
|
final String method = "getCanonicalReadableFile(File)"; |
570 |
582
|
final File localFile = getLocalFilePath(prop.getModuleAddress()); |
571 |
582
|
final File file; |
572 |
582
|
try { |
573 |
582
|
file = localFile.getCanonicalFile(); |
574 |
|
} catch (IOException e) { |
575 |
0
|
Trace.trace(CLASS, this, method, e); |
576 |
0
|
throw new ModuleFileNotFoundException("file path not correct: " + localFile); |
577 |
|
} |
578 |
582
|
if (!file.canRead()) { |
579 |
35
|
Trace.trace(CLASS, this, method, "file not readable=" + file); |
580 |
35
|
throw new ModuleFileNotFoundException("file not readable: " + file); |
581 |
|
} |
582 |
547
|
return file; |
583 |
|
} |
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
@param |
589 |
|
@param |
590 |
|
@param |
591 |
|
@return |
592 |
|
@throws |
593 |
|
@throws |
594 |
|
|
|
|
| 80.9% |
Uncovered Elements: 9 (47) |
Complexity: 11 |
Complexity Density: 0.31 |
|
595 |
268
|
public KernelQedeqBo loadKernelModule(final InternalServiceJob process, final ModuleAddress parent,... |
596 |
|
final Specification spec) throws SourceFileExceptionList, InterruptException { |
597 |
|
|
598 |
268
|
final String method = "loadModule(Module, Specification)"; |
599 |
268
|
Trace.begin(CLASS, this, method); |
600 |
268
|
Trace.trace(CLASS, this, method, spec); |
601 |
268
|
DefaultKernelQedeqBo prop = null; |
602 |
268
|
try { |
603 |
268
|
final ModuleAddress[] modulePaths; |
604 |
268
|
try { |
605 |
268
|
modulePaths = parent.getModulePaths(spec); |
606 |
|
} catch (IOException e) { |
607 |
0
|
Trace.fatal(CLASS, this, method, "getting module path failed", e); |
608 |
0
|
throw createSourceFileExceptionList( |
609 |
|
ServiceErrors.LOADING_FROM_FILE_BUFFER_FAILED_CODE, |
610 |
|
ServiceErrors.LOADING_FROM_FILE_BUFFER_FAILED_TEXT, |
611 |
|
parent.getUrl(), e); |
612 |
|
} |
613 |
|
|
614 |
|
|
615 |
294
|
for (int i = 0; i < modulePaths.length; i++) { |
616 |
294
|
prop = getModules().getKernelQedeqBo(this, modulePaths[i]); |
617 |
294
|
Trace.trace(CLASS, this, method, "synchronizing at prop=" + prop); |
618 |
294
|
if (prop.isLoaded()) { |
619 |
82
|
return (prop); |
620 |
|
} |
621 |
212
|
synchronized (prop) { |
622 |
212
|
if (prop.isLoaded()) { |
623 |
1
|
return (prop); |
624 |
|
} |
625 |
211
|
try { |
626 |
211
|
if (prop.getModuleAddress().isFileAddress()) { |
627 |
197
|
loadLocalModule(process, prop); |
628 |
|
} else { |
629 |
|
|
630 |
14
|
try { |
631 |
14
|
getCanonicalReadableFile(prop); |
632 |
|
} catch (ModuleFileNotFoundException e) { |
633 |
|
|
634 |
6
|
saveQedeqFromWebToBuffer((InternalModuleServiceCall) process.getModuleServiceCall(), |
635 |
|
prop); |
636 |
|
} |
637 |
14
|
loadBufferedModule(process, prop); |
638 |
|
} |
639 |
|
|
640 |
182
|
return prop; |
641 |
|
} catch (SourceFileExceptionList e) { |
642 |
29
|
Trace.trace(CLASS, this, method, e); |
643 |
29
|
if (i + 1 < modulePaths.length) { |
644 |
26
|
QedeqLog.getInstance().logMessage("trying alternate path"); |
645 |
|
|
646 |
|
} else { |
647 |
|
|
648 |
3
|
throw e; |
649 |
|
} |
650 |
|
} |
651 |
|
} |
652 |
|
} |
653 |
0
|
return prop; |
654 |
|
} catch (final RuntimeException e) { |
655 |
0
|
Trace.fatal(CLASS, this, method, "unexpected problem", e); |
656 |
0
|
QedeqLog.getInstance().logFailureReply("Loading failed", |
657 |
0
|
(prop != null ? prop.getUrl() : "unknownURL"), e.getMessage()); |
658 |
0
|
throw e; |
659 |
|
} finally { |
660 |
268
|
Trace.end(CLASS, this, method); |
661 |
|
} |
662 |
|
} |
663 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
664 |
476
|
public ModuleAddress[] getAllLoadedModules() {... |
665 |
476
|
return getModules().getAllLoadedModules(); |
666 |
|
} |
667 |
|
|
668 |
|
|
669 |
|
|
670 |
|
|
671 |
|
@return |
672 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
673 |
0
|
public boolean loadPreviouslySuccessfullyLoadedModules() {... |
674 |
0
|
final String[] list = config.getPreviouslyLoadedModules(); |
675 |
0
|
boolean errors = false; |
676 |
0
|
for (int i = 0; i < list.length; i++) { |
677 |
0
|
try { |
678 |
0
|
final ModuleAddress address = getModuleAddress(list[i]); |
679 |
0
|
final QedeqBo prop = loadModule(address); |
680 |
0
|
if (prop.hasErrors()) { |
681 |
0
|
errors = true; |
682 |
|
} |
683 |
|
} catch (IOException e) { |
684 |
0
|
Trace.fatal(CLASS, this, "loadPreviouslySuccessfullyLoadedModules", |
685 |
|
"internal error: " + "saved URLs are malformed", e); |
686 |
0
|
errors = true; |
687 |
|
} |
688 |
|
} |
689 |
0
|
return !errors; |
690 |
|
} |
691 |
|
|
692 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
693 |
0
|
public boolean loadAllModulesFromQedeq() {... |
694 |
0
|
final String prefix = "http://www.qedeq.org/" + kernel.getKernelVersionDirectory() + "/"; |
695 |
0
|
final String[] list = new String[] { |
696 |
|
prefix + "doc/math/qedeq_logic_v1.xml", |
697 |
|
prefix + "doc/math/qedeq_formal_logic_v1.xml", |
698 |
|
prefix + "doc/math/qedeq_set_theory_v1.xml", |
699 |
|
prefix + "doc/project/qedeq_basic_concept.xml", |
700 |
|
prefix + "doc/project/qedeq_logic_language.xml", |
701 |
|
prefix + "sample/qedeq_sample1.xml", |
702 |
|
prefix + "sample/qedeq_sample2.xml", |
703 |
|
prefix + "sample/qedeq_sample3.xml", |
704 |
|
prefix + "sample/qedeq_sample4.xml", |
705 |
|
prefix + "sample/qedeq_error_sample_00.xml", |
706 |
|
prefix + "sample/qedeq_error_sample_01.xml", |
707 |
|
prefix + "sample/qedeq_error_sample_02.xml", |
708 |
|
prefix + "sample/qedeq_error_sample_03.xml", |
709 |
|
prefix + "sample/qedeq_error_sample_04.xml", |
710 |
|
prefix + "sample/qedeq_error_sample_05.xml", |
711 |
|
prefix + "sample/qedeq_error_sample_12.xml", |
712 |
|
prefix + "sample/qedeq_error_sample_13.xml", |
713 |
|
prefix + "sample/qedeq_error_sample_14.xml", |
714 |
|
prefix + "sample/qedeq_error_sample_15.xml", |
715 |
|
prefix + "sample/qedeq_error_sample_16.xml", |
716 |
|
prefix + "sample/qedeq_error_sample_17.xml", |
717 |
|
prefix + "sample/qedeq_error_sample_18.xml"}; |
718 |
0
|
boolean errors = false; |
719 |
0
|
for (int i = 0; i < list.length; i++) { |
720 |
0
|
try { |
721 |
0
|
final ModuleAddress address = getModuleAddress(list[i]); |
722 |
0
|
final QedeqBo prop = loadModule(address); |
723 |
0
|
if (prop.hasErrors()) { |
724 |
0
|
errors = true; |
725 |
|
} |
726 |
|
} catch (final IOException e) { |
727 |
0
|
Trace.fatal(CLASS, this, "loadPreviouslySuccessfullyLoadedModules", |
728 |
|
"internal error: " + "saved URLs are malformed", e); |
729 |
0
|
errors = true; |
730 |
|
} |
731 |
|
} |
732 |
0
|
return !errors; |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
@param |
739 |
|
@param |
740 |
|
@throws |
741 |
|
@throws |
742 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
743 |
6
|
private void saveQedeqFromWebToBuffer(final InternalModuleServiceCall call, final DefaultKernelQedeqBo prop)... |
744 |
|
throws SourceFileExceptionList, InterruptException { |
745 |
6
|
final String method = "saveQedeqFromWebToBuffer(DefaultKernelQedeqBo)"; |
746 |
6
|
Trace.begin(CLASS, this, method); |
747 |
|
|
748 |
6
|
if (prop.getModuleAddress().isFileAddress()) { |
749 |
0
|
Trace.fatal(CLASS, this, method, "tried to make a local copy for a local module", null); |
750 |
0
|
Trace.end(CLASS, this, method); |
751 |
0
|
return; |
752 |
|
} |
753 |
|
|
754 |
6
|
final ModuleServiceExecutor executor = new ModuleServiceExecutor() { |
755 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.23 |
|
756 |
6
|
public void executeService(final InternalModuleServiceCall call) {... |
757 |
6
|
final File f = getLocalFilePath(prop.getModuleAddress()); |
758 |
6
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_WEB); |
759 |
6
|
try { |
760 |
6
|
UrlUtility.saveUrlToFile(prop.getUrl(), f, |
761 |
|
config.getHttpProxyHost(), config.getHttpProxyPort(), config.getHttpNonProxyHosts(), |
762 |
|
config.getConnectionTimeout(), config.getReadTimeout(), new LoadingListener() { |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
763 |
0
|
public void loadingCompletenessChanged(final double completeness) {... |
764 |
0
|
final double percentage = completeness * 100; |
765 |
0
|
call.setExecutionPercentage(percentage); |
766 |
0
|
prop.setLoadingCompleteness((int) percentage); |
767 |
|
} |
768 |
|
}); |
769 |
0
|
call.finishOk(); |
770 |
|
} catch (IOException e) { |
771 |
6
|
Trace.trace(CLASS, this, method, e); |
772 |
6
|
try { |
773 |
6
|
f.delete(); |
774 |
|
} catch (Exception ex) { |
775 |
0
|
Trace.trace(CLASS, this, method, ex); |
776 |
|
} |
777 |
6
|
final SourceFileExceptionList sfl = createSourceFileExceptionList( |
778 |
|
ServiceErrors.LOADING_FROM_WEB_FAILED_CODE, |
779 |
|
ServiceErrors.LOADING_FROM_WEB_FAILED_TEXT, |
780 |
|
prop.getUrl(), e); |
781 |
6
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_WEB_FAILED, sfl); |
782 |
6
|
Trace.trace(CLASS, this, method, "Couldn't access " + prop.getUrl()); |
783 |
6
|
call.finishError("Couldn't save URL " + prop.getUrl() + " to file: " + e.getMessage()); |
784 |
|
} |
785 |
|
} |
786 |
|
}; |
787 |
|
|
788 |
6
|
this.processManager.executeService(new ModuleService() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
789 |
0
|
public String getServiceAction() {... |
790 |
0
|
return "saving from web to file buffer"; |
791 |
|
} |
792 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
793 |
0
|
public String getServiceDescription() {... |
794 |
0
|
return "download QEDEQ module from web URL and save it to a local file"; |
795 |
|
} |
796 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
797 |
6
|
public String getServiceId() {... |
798 |
6
|
return "" + hashCode(); |
799 |
|
} |
800 |
|
}, executor, prop, call.getInternalServiceProcess()); |
801 |
6
|
Trace.end(CLASS, this, method); |
802 |
|
|
803 |
|
} |
804 |
|
|
|
|
| 81.6% |
Uncovered Elements: 7 (38) |
Complexity: 6 |
Complexity Density: 0.17 |
|
805 |
59673
|
public final File getLocalFilePath(final ModuleAddress address) {... |
806 |
59673
|
final String method = "getLocalFilePath(ModuleAddress)"; |
807 |
59673
|
URL url; |
808 |
59673
|
try { |
809 |
59673
|
url = new URL(address.getUrl()); |
810 |
|
} catch (MalformedURLException e) { |
811 |
0
|
Trace.fatal(CLASS, this, method, "Could not get local file path.", e); |
812 |
0
|
return null; |
813 |
|
} |
814 |
59673
|
Trace.param(CLASS, this, method, "protocol", url.getProtocol()); |
815 |
59673
|
Trace.param(CLASS, this, method, "host", url.getHost()); |
816 |
59673
|
Trace.param(CLASS, this, method, "port", url.getPort()); |
817 |
59673
|
Trace.param(CLASS, this, method, "path", url.getPath()); |
818 |
59673
|
Trace.param(CLASS, this, method, "file", url.getFile()); |
819 |
59673
|
if (address.isFileAddress()) { |
820 |
59335
|
try { |
821 |
59335
|
return UrlUtility.transformURLPathToFilePath(url); |
822 |
|
} catch (IllegalArgumentException e) { |
823 |
|
|
824 |
0
|
Trace.fatal(CLASS, this, method, "Loading failed of local file with URL=" + url, e); |
825 |
0
|
throw new RuntimeException(e); |
826 |
|
} |
827 |
|
} |
828 |
338
|
StringBuffer file = new StringBuffer(url.getFile()); |
829 |
338
|
StringUtility.replace(file, "_", "_1"); |
830 |
338
|
StringUtility.replace(file, "/", "_2"); |
831 |
338
|
String encoded = file.toString(); |
832 |
338
|
try { |
833 |
338
|
encoded = URLEncoder.encode(file.toString(), "UTF-8"); |
834 |
|
} catch (UnsupportedEncodingException e) { |
835 |
|
|
836 |
0
|
Trace.trace(CLASS, method, e); |
837 |
|
} |
838 |
338
|
file.setLength(0); |
839 |
338
|
file.append(encoded); |
840 |
338
|
StringUtility.replace(file, "#", "##"); |
841 |
338
|
StringUtility.replace(file, "_2", "#"); |
842 |
338
|
StringUtility.replace(file, "_1", "_"); |
843 |
|
|
844 |
|
|
845 |
338
|
final StringBuffer adr; |
846 |
338
|
try { |
847 |
338
|
adr = new StringBuffer(new URL(url.getProtocol(), url.getHost(), url.getPort(), file |
848 |
|
.toString()).toExternalForm()); |
849 |
|
} catch (MalformedURLException e) { |
850 |
0
|
Trace.fatal(CLASS, this, method, "unexpected", e); |
851 |
0
|
throw new RuntimeException(e); |
852 |
|
} |
853 |
|
|
854 |
338
|
StringUtility.replace(adr, "://", "_"); |
855 |
338
|
StringUtility.replace(adr, ":", "_"); |
856 |
338
|
return new File(getBufferDirectory(), adr.toString()); |
857 |
|
} |
858 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
859 |
338
|
public File getBufferDirectory() {... |
860 |
338
|
return config.getBufferDirectory(); |
861 |
|
} |
862 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
863 |
0
|
public File getGenerationDirectory() {... |
864 |
0
|
return config.getGenerationDirectory(); |
865 |
|
} |
866 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
867 |
44402
|
public KernelQedeqBo getKernelQedeqBo(final ModuleAddress address) {... |
868 |
44402
|
return getModules().getKernelQedeqBo(this, address); |
869 |
|
} |
870 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
871 |
44278
|
public QedeqBo getQedeqBo(final ModuleAddress address) {... |
872 |
44278
|
return getKernelQedeqBo(address); |
873 |
|
} |
874 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
875 |
274
|
public ModuleAddress getModuleAddress(final URL url) throws IOException {... |
876 |
274
|
return new DefaultModuleAddress(url); |
877 |
|
} |
878 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
879 |
0
|
public ModuleAddress getModuleAddress(final String url) throws IOException {... |
880 |
0
|
return new DefaultModuleAddress(url); |
881 |
|
} |
882 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
883 |
0
|
public ModuleAddress getModuleAddress(final File file) throws IOException {... |
884 |
0
|
return new DefaultModuleAddress(file); |
885 |
|
} |
886 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.44 |
|
887 |
0
|
public String getSource(final ModuleAddress address) throws IOException {... |
888 |
0
|
final KernelQedeqBo bo = getKernelQedeqBo(address); |
889 |
0
|
if (bo.getLoadingState().equals(LoadingState.STATE_UNDEFINED) |
890 |
|
|| bo.getLoadingState().equals(LoadingState.STATE_LOADING_FROM_WEB) |
891 |
|
|| bo.getLoadingState().equals(LoadingState.STATE_LOADING_FROM_WEB_FAILED)) { |
892 |
0
|
return null; |
893 |
|
} |
894 |
0
|
final StringBuffer buffer = new StringBuffer(); |
895 |
0
|
final Reader reader = getQedeqFileDao().getModuleReader(bo); |
896 |
0
|
try { |
897 |
0
|
IoUtility.loadReader(reader, buffer); |
898 |
|
} finally { |
899 |
0
|
IoUtility.close(reader); |
900 |
|
} |
901 |
0
|
return buffer.toString(); |
902 |
|
} |
903 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
904 |
124
|
public boolean loadRequiredModules(final ModuleAddress address) {... |
905 |
124
|
final KernelQedeqBo prop = getKernelQedeqBo(address); |
906 |
|
|
907 |
124
|
if (prop.hasLoadedRequiredModules()) { |
908 |
31
|
return true; |
909 |
|
} |
910 |
93
|
executePlugin(LoadRequiredModulesPlugin.class.getName(), prop.getModuleAddress(), null); |
911 |
93
|
return prop.hasLoadedRequiredModules(); |
912 |
|
} |
913 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
914 |
66
|
public boolean loadRequiredModules(final InternalServiceJob process, final KernelQedeqBo qedeq)... |
915 |
|
throws InterruptException { |
916 |
|
|
917 |
66
|
if (qedeq.hasLoadedRequiredModules()) { |
918 |
65
|
return true; |
919 |
|
} |
920 |
1
|
executePlugin(process, LoadRequiredModulesPlugin.class.getName(), qedeq, null); |
921 |
1
|
return qedeq.hasLoadedRequiredModules(); |
922 |
|
} |
923 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
924 |
261
|
public boolean checkWellFormedness(final ModuleAddress address) {... |
925 |
261
|
final DefaultKernelQedeqBo prop = modules.getKernelQedeqBo(this, address); |
926 |
|
|
927 |
261
|
if (prop.isWellFormed()) { |
928 |
62
|
return true; |
929 |
|
} |
930 |
199
|
executePlugin(WellFormedCheckerPlugin.class.getName(), prop.getModuleAddress(), null); |
931 |
199
|
return prop.isWellFormed(); |
932 |
|
} |
933 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
934 |
263
|
public boolean checkWellFormedness(final InternalServiceJob process, final KernelQedeqBo qedeq)... |
935 |
|
throws InterruptException { |
936 |
|
|
937 |
263
|
if (qedeq.isWellFormed()) { |
938 |
128
|
return true; |
939 |
|
} |
940 |
135
|
executePlugin(process, WellFormedCheckerPlugin.class.getName(), qedeq, null); |
941 |
135
|
return qedeq.isWellFormed(); |
942 |
|
} |
943 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
944 |
11
|
public boolean checkFormallyProved(final ModuleAddress address) {... |
945 |
11
|
final DefaultKernelQedeqBo prop = modules.getKernelQedeqBo(this, address); |
946 |
|
|
947 |
11
|
if (prop.isFullyFormallyProved()) { |
948 |
0
|
return true; |
949 |
|
} |
950 |
11
|
executePlugin(FormalProofCheckerPlugin.class.getName(), prop.getModuleAddress(), null); |
951 |
11
|
return prop.isFullyFormallyProved(); |
952 |
|
} |
953 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
954 |
0
|
public boolean checkFormallyProved(final InternalServiceJob process, final KernelQedeqBo qedeq)... |
955 |
|
throws InterruptException { |
956 |
|
|
957 |
0
|
if (qedeq.isFullyFormallyProved()) { |
958 |
0
|
return true; |
959 |
|
} |
960 |
0
|
executePlugin(process, FormalProofCheckerPlugin.class.getName(), qedeq, null); |
961 |
0
|
return qedeq.isFullyFormallyProved(); |
962 |
|
} |
963 |
|
|
964 |
|
|
965 |
|
|
966 |
|
|
967 |
|
@param |
968 |
|
@throws |
969 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
970 |
476
|
public void addPlugin(final String pluginClass) {... |
971 |
476
|
pluginManager.addPlugin(pluginClass); |
972 |
|
} |
973 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
974 |
0
|
public ModuleService[] getPlugins() {... |
975 |
0
|
return pluginManager.getNonInternalPlugins(); |
976 |
|
} |
977 |
|
|
978 |
|
|
|
|
| 66.7% |
Uncovered Elements: 5 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
979 |
318
|
public Object executePlugin(final String id, final ModuleAddress address, final Object data) {... |
980 |
318
|
final InternalServiceJob process = processManager.createServiceJob(id); |
981 |
318
|
try { |
982 |
318
|
final KernelQedeqBo qedeq = loadKernelModule(process, address); |
983 |
318
|
if (qedeq.isLoaded()) { |
984 |
318
|
return processManager.executePlugin(id, qedeq, data, process); |
985 |
|
} else { |
986 |
0
|
process.setFailureState(); |
987 |
|
} |
988 |
|
} catch (InterruptException e) { |
989 |
0
|
process.setInterruptedState(); |
990 |
|
} finally { |
991 |
318
|
process.setSuccessState(); |
992 |
318
|
if (validate) { |
993 |
318
|
modules.validateDependencies(); |
994 |
|
} |
995 |
|
} |
996 |
0
|
return null; |
997 |
|
} |
998 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
999 |
803
|
public Object executePlugin(final InternalServiceJob process, final String id, final KernelQedeqBo qedeq,... |
1000 |
|
final Object data) throws InterruptException { |
1001 |
803
|
if (process == null) { |
1002 |
0
|
throw new NullPointerException("process parameter must not be null"); |
1003 |
|
} |
1004 |
803
|
loadKernelModule(process, qedeq.getModuleAddress()); |
1005 |
803
|
return processManager.executePlugin(id, qedeq, data, process); |
1006 |
|
} |
1007 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1008 |
0
|
public void clearAllPluginResults(final ModuleAddress address) {... |
1009 |
0
|
pluginManager.clearAllPluginResults(getKernelQedeqBo(address)); |
1010 |
|
} |
1011 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1012 |
0
|
public ServiceJob[] getServiceProcesses() {... |
1013 |
0
|
return processManager.getServiceProcesses(); |
1014 |
|
} |
1015 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1016 |
0
|
public ServiceJob[] getRunningServiceProcesses() {... |
1017 |
0
|
return processManager.getRunningServiceProcesses(); |
1018 |
|
} |
1019 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1020 |
0
|
public void terminateAllServiceProcesses() {... |
1021 |
0
|
processManager.terminateAllServiceProcesses(); |
1022 |
|
} |
1023 |
|
|
1024 |
|
|
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
@return |
1029 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1030 |
46540
|
private KernelQedeqBoStorage getModules() {... |
1031 |
46540
|
return modules; |
1032 |
|
} |
1033 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1034 |
6
|
public SourceFileExceptionList createSourceFileExceptionList(final int code,... |
1035 |
|
final String message, final String address, final IOException e) { |
1036 |
6
|
return new SourceFileExceptionList(new SourceFileException(this, |
1037 |
|
code, message, e, new SourceArea(address), null)); |
1038 |
|
} |
1039 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1040 |
0
|
public SourceFileExceptionList createSourceFileExceptionList(final int code,... |
1041 |
|
final String message, final String address, final RuntimeException e) { |
1042 |
0
|
return new SourceFileExceptionList(new SourceFileException(this, |
1043 |
|
code, message, e, new SourceArea(address), null)); |
1044 |
|
} |
1045 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1046 |
29
|
public SourceFileExceptionList createSourceFileExceptionList(final int code,... |
1047 |
|
final String message, final String address, final Exception e) { |
1048 |
29
|
return new SourceFileExceptionList(new SourceFileException(this, |
1049 |
|
code, message, e, new SourceArea(address), null)); |
1050 |
|
} |
1051 |
|
|
1052 |
|
|
1053 |
|
|
1054 |
|
|
1055 |
|
@param |
1056 |
|
@return |
1057 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 8 |
Complexity Density: 0.22 |
|
1058 |
0
|
public String[] getSourceFileExceptionList(final ModuleAddress address) {... |
1059 |
0
|
final List list = new ArrayList(); |
1060 |
0
|
final KernelQedeqBo bo = getKernelQedeqBo(address); |
1061 |
0
|
final SourceFileExceptionList sfl = bo.getErrors(); |
1062 |
0
|
if (sfl.size() > 0) { |
1063 |
0
|
final StringBuffer buffer = new StringBuffer(); |
1064 |
0
|
do { |
1065 |
0
|
Reader reader = null; |
1066 |
0
|
try { |
1067 |
0
|
reader = getQedeqFileDao().getModuleReader(bo); |
1068 |
0
|
IoUtility.loadReader(reader, buffer); |
1069 |
|
} catch (IOException e) { |
1070 |
0
|
IoUtility.close(reader); |
1071 |
0
|
for (int i = 0; i < sfl.size(); i++) { |
1072 |
0
|
list.add(sfl.get(i).getDescription()); |
1073 |
|
} |
1074 |
0
|
break; |
1075 |
|
} |
1076 |
0
|
final TextInput input = new TextInput(buffer); |
1077 |
0
|
try { |
1078 |
0
|
input.setPosition(0); |
1079 |
0
|
final StringBuffer buf = new StringBuffer(); |
1080 |
0
|
for (int i = 0; i < sfl.size(); i++) { |
1081 |
0
|
buf.setLength(0); |
1082 |
0
|
final SourceFileException sf = sfl.get(i); |
1083 |
0
|
buf.append(sf.getDescription()); |
1084 |
0
|
try { |
1085 |
0
|
if (sf.getSourceArea() != null |
1086 |
|
&& sf.getSourceArea().getStartPosition() != null) { |
1087 |
0
|
buf.append("\n"); |
1088 |
0
|
input.setRow(sf.getSourceArea().getStartPosition().getRow()); |
1089 |
0
|
buf.append(StringUtility.replace(input.getLine(), "\t", " ")); |
1090 |
0
|
buf.append("\n"); |
1091 |
0
|
final StringBuffer whitespace = StringUtility.getSpaces(sf |
1092 |
|
.getSourceArea().getStartPosition().getColumn() - 1); |
1093 |
0
|
buffer.append(whitespace); |
1094 |
0
|
buffer.append("^"); |
1095 |
|
} |
1096 |
|
} catch (Exception e) { |
1097 |
0
|
Trace.trace(CLASS, this, "getSourceFileExceptionList(ModuleAddress)", e); |
1098 |
|
} |
1099 |
0
|
list.add(buf.toString()); |
1100 |
|
} |
1101 |
|
} finally { |
1102 |
0
|
IoUtility.close(input); |
1103 |
|
} |
1104 |
0
|
break; |
1105 |
|
} while (true); |
1106 |
|
} |
1107 |
0
|
return (String[]) list.toArray(new String[list.size()]); |
1108 |
|
} |
1109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1110 |
0
|
public String getServiceId() {... |
1111 |
0
|
return CLASS.getName(); |
1112 |
|
} |
1113 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1114 |
0
|
public String getServiceAction() {... |
1115 |
0
|
return "Basis"; |
1116 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1117 |
988
|
public QedeqFileDao getQedeqFileDao() {... |
1118 |
988
|
return qedeqFileDao; |
1119 |
|
} |
1120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1121 |
0
|
public String getServiceDescription() {... |
1122 |
0
|
return "provides basic services for loading QEDEQ modules"; |
1123 |
|
} |
1124 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1125 |
9579
|
public QedeqConfig getConfig() {... |
1126 |
9579
|
return config; |
1127 |
|
} |
1128 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1129 |
76
|
public String getKernelVersionDirectory() {... |
1130 |
76
|
return kernel.getKernelVersionDirectory(); |
1131 |
|
} |
1132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1133 |
0
|
public String getBuildId() {... |
1134 |
0
|
return kernel.getBuildId(); |
1135 |
|
} |
1136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1137 |
0
|
public String getDedication() {... |
1138 |
0
|
return kernel.getDedication(); |
1139 |
|
} |
1140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1141 |
0
|
public String getDescriptiveKernelVersion() {... |
1142 |
0
|
return kernel.getDescriptiveKernelVersion(); |
1143 |
|
} |
1144 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1145 |
0
|
public String getKernelCodeName() {... |
1146 |
0
|
return kernel.getKernelCodeName(); |
1147 |
|
} |
1148 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1149 |
0
|
public String getKernelVersion() {... |
1150 |
0
|
return kernel.getKernelVersion(); |
1151 |
|
} |
1152 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1153 |
0
|
public String getMaximalRuleVersion() {... |
1154 |
0
|
return kernel.getMaximalRuleVersion(); |
1155 |
|
} |
1156 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1157 |
0
|
public boolean isRuleVersionSupported(final String ruleVersion) {... |
1158 |
0
|
return kernel.isRuleVersionSupported(ruleVersion); |
1159 |
|
} |
1160 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1161 |
0
|
public boolean isSetConnectionTimeOutSupported() {... |
1162 |
0
|
return kernel.isSetConnectionTimeOutSupported(); |
1163 |
|
} |
1164 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1165 |
0
|
public boolean isSetReadTimeoutSupported() {... |
1166 |
0
|
return kernel.isSetReadTimeoutSupported(); |
1167 |
|
} |
1168 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1169 |
77306
|
public ContextChecker getContextChecker() {... |
1170 |
77306
|
return contextChecker; |
1171 |
|
} |
1172 |
|
|
1173 |
|
|
1174 |
|
|
1175 |
|
|
1176 |
|
@param |
1177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1178 |
476
|
public void setContextChecker(final ContextChecker contextChecker) {... |
1179 |
476
|
this.contextChecker = contextChecker; |
1180 |
|
} |
1181 |
|
|
1182 |
|
} |