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