| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.qedeq.kernel.bo.service; |
| 17 |
|
|
| 18 |
|
import java.io.File; |
| 19 |
|
import java.io.FileFilter; |
| 20 |
|
import java.io.FileNotFoundException; |
| 21 |
|
import java.io.FileOutputStream; |
| 22 |
|
import java.io.IOException; |
| 23 |
|
import java.io.InputStream; |
| 24 |
|
import java.io.Reader; |
| 25 |
|
import java.io.UnsupportedEncodingException; |
| 26 |
|
import java.lang.reflect.InvocationTargetException; |
| 27 |
|
import java.net.HttpURLConnection; |
| 28 |
|
import java.net.MalformedURLException; |
| 29 |
|
import java.net.URL; |
| 30 |
|
import java.net.URLConnection; |
| 31 |
|
import java.net.URLEncoder; |
| 32 |
|
import java.util.ArrayList; |
| 33 |
|
import java.util.List; |
| 34 |
|
import java.util.Map; |
| 35 |
|
|
| 36 |
|
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler; |
| 37 |
|
import org.apache.commons.httpclient.HttpClient; |
| 38 |
|
import org.apache.commons.httpclient.HttpStatus; |
| 39 |
|
import org.apache.commons.httpclient.methods.GetMethod; |
| 40 |
|
import org.apache.commons.httpclient.params.HttpMethodParams; |
| 41 |
|
import org.qedeq.base.io.IoUtility; |
| 42 |
|
import org.qedeq.base.io.SourceArea; |
| 43 |
|
import org.qedeq.base.io.SourcePosition; |
| 44 |
|
import org.qedeq.base.io.TextInput; |
| 45 |
|
import org.qedeq.base.trace.Trace; |
| 46 |
|
import org.qedeq.base.utility.StringUtility; |
| 47 |
|
import org.qedeq.base.utility.YodaUtility; |
| 48 |
|
import org.qedeq.kernel.base.module.Qedeq; |
| 49 |
|
import org.qedeq.kernel.base.module.Specification; |
| 50 |
|
import org.qedeq.kernel.bo.QedeqBo; |
| 51 |
|
import org.qedeq.kernel.bo.context.KernelContext; |
| 52 |
|
import org.qedeq.kernel.bo.context.KernelProperties; |
| 53 |
|
import org.qedeq.kernel.bo.context.KernelServices; |
| 54 |
|
import org.qedeq.kernel.bo.log.QedeqLog; |
| 55 |
|
import org.qedeq.kernel.bo.module.InternalKernelServices; |
| 56 |
|
import org.qedeq.kernel.bo.module.KernelQedeqBo; |
| 57 |
|
import org.qedeq.kernel.bo.module.QedeqFileDao; |
| 58 |
|
import org.qedeq.kernel.common.DefaultModuleAddress; |
| 59 |
|
import org.qedeq.kernel.common.DefaultSourceFileExceptionList; |
| 60 |
|
import org.qedeq.kernel.common.LoadingState; |
| 61 |
|
import org.qedeq.kernel.common.ModuleAddress; |
| 62 |
|
import org.qedeq.kernel.common.ModuleDataException; |
| 63 |
|
import org.qedeq.kernel.common.Plugin; |
| 64 |
|
import org.qedeq.kernel.common.SourceFileException; |
| 65 |
|
import org.qedeq.kernel.common.SourceFileExceptionList; |
| 66 |
|
import org.qedeq.kernel.dto.module.QedeqVo; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@author |
| 73 |
|
|
|
|
|
| 35.6% |
Uncovered Elements: 378 (587) |
Complexity: 140 |
Complexity Density: 0.32 |
|
| 74 |
|
public class DefaultInternalKernelServices implements KernelServices, InternalKernelServices, Plugin { |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
private static final Class CLASS = DefaultInternalKernelServices.class; |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
private static final Object MONITOR = new Object(); |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
private volatile int processCounter = 0; |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
private final KernelQedeqBoStorage modules; |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
private final KernelProperties kernel; |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
private final QedeqFileDao qedeqFileDao; |
| 93 |
|
|
| 94 |
|
|
| 95 |
|
private final PluginManager pluginManager; |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
private boolean validate = true; |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
@param |
| 104 |
|
@param |
| 105 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 106 |
54
|
public DefaultInternalKernelServices(final KernelProperties kernel, final QedeqFileDao loader) {... |
| 107 |
54
|
modules = new KernelQedeqBoStorage(); |
| 108 |
54
|
pluginManager = new PluginManager(); |
| 109 |
54
|
pluginManager.addPlugin("org.qedeq.kernel.bo.service.latex.Qedeq2LatexPlugin"); |
| 110 |
54
|
this.kernel = kernel; |
| 111 |
54
|
this.qedeqFileDao = loader; |
| 112 |
54
|
loader.setServices(this); |
| 113 |
|
} |
| 114 |
|
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 115 |
54
|
public void startupServices() {... |
| 116 |
54
|
if (kernel.getConfig().isAutoReloadLastSessionChecked()) { |
| 117 |
0
|
autoReloadLastSessionChecked(); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 124 |
0
|
public void autoReloadLastSessionChecked() {... |
| 125 |
0
|
if (kernel.getConfig().isAutoReloadLastSessionChecked()) { |
| 126 |
0
|
final Thread thread = new Thread() { |
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 127 |
0
|
public void run() {... |
| 128 |
0
|
final String method = "autoReloadLastSessionChecked.thread.run()"; |
| 129 |
0
|
try { |
| 130 |
0
|
Trace.begin(CLASS, this, method); |
| 131 |
0
|
QedeqLog.getInstance().logMessage( |
| 132 |
|
"Trying to load previously successfully loaded modules."); |
| 133 |
0
|
final int number = kernel.getConfig().getPreviouslyCheckedModules().length; |
| 134 |
0
|
if (loadPreviouslySuccessfullyLoadedModules()) { |
| 135 |
0
|
QedeqLog.getInstance().logMessage( |
| 136 |
|
"Loading of " + number + " previously successfully loaded module" |
| 137 |
0
|
+ (number != 1 ? "s" : "") + " successfully done."); |
| 138 |
|
} else { |
| 139 |
0
|
QedeqLog.getInstance().logMessage( |
| 140 |
|
"Loading of all previously successfully checked modules failed. " |
| 141 |
0
|
+ number + " module" + (number != 1 ? "s" : "") |
| 142 |
|
+ " were tried."); |
| 143 |
|
} |
| 144 |
|
} catch (Exception e) { |
| 145 |
0
|
Trace.trace(CLASS, this, method, e); |
| 146 |
|
} finally { |
| 147 |
0
|
Trace.end(CLASS, this, method); |
| 148 |
|
} |
| 149 |
|
} |
| 150 |
|
}; |
| 151 |
0
|
thread.setDaemon(true); |
| 152 |
0
|
thread.start(); |
| 153 |
|
} |
| 154 |
|
} |
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 156 |
0
|
public void removeAllModules() {... |
| 157 |
0
|
do { |
| 158 |
0
|
synchronized (this) { |
| 159 |
0
|
if (processCounter == 0) { |
| 160 |
0
|
getModules().removeAllModules(); |
| 161 |
0
|
return; |
| 162 |
|
} |
| 163 |
|
} |
| 164 |
|
|
| 165 |
0
|
synchronized (MONITOR) { |
| 166 |
0
|
try { |
| 167 |
0
|
MONITOR.wait(10000); |
| 168 |
|
} catch (InterruptedException e) { |
| 169 |
|
} |
| 170 |
|
} |
| 171 |
|
} while (true); |
| 172 |
|
|
| 173 |
|
} |
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
@param |
| 179 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 180 |
0
|
public void removeModule(final ModuleAddress address) {... |
| 181 |
0
|
final QedeqBo prop = getQedeqBo(address); |
| 182 |
0
|
if (prop != null) { |
| 183 |
0
|
removeModule(getModules().getKernelQedeqBo(this, address)); |
| 184 |
0
|
if (validate) { |
| 185 |
0
|
modules.validateDependencies(); |
| 186 |
|
} |
| 187 |
|
} |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
@param |
| 195 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 196 |
0
|
private void removeModule(final DefaultKernelQedeqBo prop) {... |
| 197 |
0
|
do { |
| 198 |
0
|
synchronized (this) { |
| 199 |
0
|
if (processCounter == 0) { |
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
0
|
prop.delete(); |
| 205 |
0
|
getModules().removeModule(prop); |
| 206 |
0
|
return; |
| 207 |
|
} |
| 208 |
|
} |
| 209 |
|
|
| 210 |
0
|
synchronized (MONITOR) { |
| 211 |
0
|
try { |
| 212 |
0
|
MONITOR.wait(10000); |
| 213 |
|
} catch (InterruptedException e) { |
| 214 |
|
} |
| 215 |
|
} |
| 216 |
|
} while (true); |
| 217 |
|
|
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
@throws |
| 224 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 225 |
0
|
public void clearLocalBuffer() throws IOException {... |
| 226 |
0
|
removeAllModules(); |
| 227 |
0
|
final File bufferDir = getBufferDirectory().getCanonicalFile(); |
| 228 |
0
|
if (bufferDir.exists() && !IoUtility.deleteDir(bufferDir, new FileFilter() { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 229 |
0
|
public boolean accept(final File pathname) {... |
| 230 |
0
|
return pathname.getName().endsWith(".xml"); |
| 231 |
|
} |
| 232 |
|
})) { |
| 233 |
0
|
throw new IOException("buffer could not be deleted: " + bufferDir); |
| 234 |
|
} |
| 235 |
|
} |
| 236 |
|
|
|
|
|
| 85.2% |
Uncovered Elements: 4 (27) |
Complexity: 6 |
Complexity Density: 0.26 |
|
| 237 |
160
|
public QedeqBo loadModule(final ModuleAddress address) throws SourceFileExceptionList {... |
| 238 |
160
|
final String method = "loadModule(ModuleAddress)"; |
| 239 |
160
|
processInc(); |
| 240 |
160
|
final DefaultKernelQedeqBo prop = getModules().getKernelQedeqBo(this, address); |
| 241 |
160
|
try { |
| 242 |
160
|
synchronized (prop) { |
| 243 |
160
|
if (prop.isLoaded()) { |
| 244 |
98
|
return prop; |
| 245 |
|
} |
| 246 |
62
|
QedeqLog.getInstance().logRequest("Load module \"" + IoUtility.easyUrl(address.getUrl()) + "\""); |
| 247 |
62
|
if (prop.getModuleAddress().isFileAddress()) { |
| 248 |
52
|
loadLocalModule(prop); |
| 249 |
|
} else { |
| 250 |
|
|
| 251 |
10
|
try { |
| 252 |
10
|
getCanonicalReadableFile(prop); |
| 253 |
|
} catch (ModuleFileNotFoundException e) { |
| 254 |
|
|
| 255 |
0
|
saveQedeqFromWebToBuffer(prop); |
| 256 |
|
} |
| 257 |
10
|
loadBufferedModule(prop); |
| 258 |
|
} |
| 259 |
56
|
QedeqLog.getInstance().logSuccessfulReply( |
| 260 |
|
"Module \"" + prop.getModuleAddress().getFileName() |
| 261 |
|
+ "\" was successfully loaded."); |
| 262 |
|
} |
| 263 |
|
} catch (SourceFileExceptionList e) { |
| 264 |
6
|
Trace.trace(CLASS, this, method, e); |
| 265 |
6
|
QedeqLog.getInstance().logFailureState("Loading of module failed!", IoUtility.easyUrl(address.getUrl()), |
| 266 |
|
e.toString()); |
| 267 |
6
|
throw e; |
| 268 |
|
} catch (final RuntimeException e) { |
| 269 |
0
|
Trace.fatal(CLASS, this, method, "unexpected problem", e); |
| 270 |
0
|
QedeqLog.getInstance().logFailureReply("Loading failed", e.getMessage()); |
| 271 |
0
|
throw e; |
| 272 |
|
} finally { |
| 273 |
160
|
processDec(); |
| 274 |
|
} |
| 275 |
56
|
return prop; |
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
@param |
| 282 |
|
@throws |
| 283 |
|
|
|
|
|
| 64.3% |
Uncovered Elements: 5 (14) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 284 |
10
|
private void loadBufferedModule(final DefaultKernelQedeqBo prop)... |
| 285 |
|
throws SourceFileExceptionList { |
| 286 |
10
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_BUFFER); |
| 287 |
10
|
final File localFile; |
| 288 |
10
|
try { |
| 289 |
10
|
localFile = getCanonicalReadableFile(prop); |
| 290 |
|
} catch (ModuleFileNotFoundException e) { |
| 291 |
0
|
final SourceFileExceptionList sfl = createSourceFileExceptionList(prop.getUrl(), e); |
| 292 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, sfl); |
| 293 |
0
|
throw sfl; |
| 294 |
|
} |
| 295 |
|
|
| 296 |
10
|
prop.setQedeqFileDao(getQedeqFileDao()); |
| 297 |
10
|
final Qedeq qedeq; |
| 298 |
10
|
try { |
| 299 |
10
|
qedeq = getQedeqFileDao().loadQedeq(prop, localFile); |
| 300 |
|
} catch (SourceFileExceptionList sfl) { |
| 301 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, sfl); |
| 302 |
0
|
throw sfl; |
| 303 |
|
} |
| 304 |
10
|
setCopiedQedeq(prop, qedeq); |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
@param |
| 311 |
|
@throws |
| 312 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 313 |
140
|
private void loadLocalModule(final DefaultKernelQedeqBo prop) throws SourceFileExceptionList {... |
| 314 |
140
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_LOCAL_FILE); |
| 315 |
140
|
final File localFile; |
| 316 |
140
|
try { |
| 317 |
140
|
localFile = getCanonicalReadableFile(prop); |
| 318 |
|
} catch (ModuleFileNotFoundException e) { |
| 319 |
3
|
final SourceFileExceptionList sfl = createSourceFileExceptionList(prop.getUrl(), e); |
| 320 |
3
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_LOCAL_FILE_FAILED, sfl); |
| 321 |
3
|
throw sfl; |
| 322 |
|
} |
| 323 |
137
|
prop.setQedeqFileDao(getQedeqFileDao()); |
| 324 |
|
|
| 325 |
137
|
final Qedeq qedeq; |
| 326 |
137
|
try { |
| 327 |
137
|
qedeq = getQedeqFileDao().loadQedeq(prop, localFile); |
| 328 |
|
} catch (SourceFileExceptionList sfl) { |
| 329 |
4
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_LOCAL_FILE_FAILED, sfl); |
| 330 |
4
|
throw sfl; |
| 331 |
|
} |
| 332 |
133
|
setCopiedQedeq(prop, qedeq); |
| 333 |
|
} |
| 334 |
|
|
|
|
|
| 73.3% |
Uncovered Elements: 4 (15) |
Complexity: 3 |
Complexity Density: 0.2 |
|
| 335 |
143
|
private void setCopiedQedeq(final DefaultKernelQedeqBo prop, final Qedeq qedeq)... |
| 336 |
|
throws SourceFileExceptionList { |
| 337 |
143
|
final String method = "setCopiedQedeq(DefaultKernelQedeqBo, Qedeq)"; |
| 338 |
143
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_INTO_MEMORY); |
| 339 |
143
|
QedeqVo vo = null; |
| 340 |
143
|
try { |
| 341 |
143
|
vo = QedeqVoBuilder.createQedeq(prop.getModuleAddress(), qedeq); |
| 342 |
|
} catch (ModuleDataException e) { |
| 343 |
0
|
Trace.trace(CLASS, this, method, e); |
| 344 |
0
|
final SourceFileExceptionList xl = prop.createSourceFileExceptionList(this, e, qedeq); |
| 345 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, xl); |
| 346 |
0
|
throw xl; |
| 347 |
|
} |
| 348 |
143
|
prop.setQedeqVo(vo); |
| 349 |
143
|
ModuleLabelsCreator moduleNodesCreator = new ModuleLabelsCreator(this, prop); |
| 350 |
143
|
try { |
| 351 |
143
|
prop.setLoaded(vo, moduleNodesCreator.createLabels()); |
| 352 |
|
} catch (SourceFileExceptionList sfl) { |
| 353 |
2
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, sfl); |
| 354 |
2
|
throw sfl; |
| 355 |
|
} |
| 356 |
|
} |
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
|
|
| 362 |
|
@param |
| 363 |
|
@return |
| 364 |
|
@throws |
| 365 |
|
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 366 |
160
|
private File getCanonicalReadableFile(final QedeqBo prop) throws ModuleFileNotFoundException {... |
| 367 |
160
|
final String method = "getCanonicalReadableFile(File)"; |
| 368 |
160
|
final File localFile = getLocalFilePath(prop.getModuleAddress()); |
| 369 |
160
|
final File file; |
| 370 |
160
|
try { |
| 371 |
160
|
file = localFile.getCanonicalFile(); |
| 372 |
|
} catch (IOException e) { |
| 373 |
0
|
Trace.trace(CLASS, this, method, e); |
| 374 |
0
|
throw new ModuleFileNotFoundException("file path not correct: " + localFile); |
| 375 |
|
} |
| 376 |
160
|
if (!file.canRead()) { |
| 377 |
3
|
Trace.trace(CLASS, this, method, "file not readable=" + file); |
| 378 |
3
|
throw new ModuleFileNotFoundException("file not readable: " + file); |
| 379 |
|
} |
| 380 |
157
|
return file; |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
@param |
| 387 |
|
@param |
| 388 |
|
@return |
| 389 |
|
@throws |
| 390 |
|
|
|
|
|
| 67.4% |
Uncovered Elements: 14 (43) |
Complexity: 9 |
Complexity Density: 0.26 |
|
| 391 |
161
|
public KernelQedeqBo loadModule(final ModuleAddress parent, final Specification spec)... |
| 392 |
|
throws SourceFileExceptionList { |
| 393 |
|
|
| 394 |
161
|
final String method = "loadModule(Module, Specification)"; |
| 395 |
161
|
Trace.begin(CLASS, this, method); |
| 396 |
161
|
Trace.trace(CLASS, this, method, spec); |
| 397 |
161
|
processInc(); |
| 398 |
161
|
DefaultKernelQedeqBo prop = null; |
| 399 |
161
|
try { |
| 400 |
161
|
final ModuleAddress[] modulePaths; |
| 401 |
161
|
try { |
| 402 |
161
|
modulePaths = parent.getModulePaths(spec); |
| 403 |
|
} catch (IOException e) { |
| 404 |
0
|
Trace.trace(CLASS, this, method, e); |
| 405 |
0
|
throw createSourceFileExceptionList(parent.getUrl(), e); |
| 406 |
|
} |
| 407 |
|
|
| 408 |
|
|
| 409 |
161
|
for (int i = 0; i < modulePaths.length; i++) { |
| 410 |
161
|
prop = getModules().getKernelQedeqBo(this, modulePaths[i]); |
| 411 |
161
|
Trace.trace(CLASS, this, method, "synchronizing at prop=" + prop); |
| 412 |
161
|
synchronized (prop) { |
| 413 |
161
|
if (prop.isLoaded()) { |
| 414 |
73
|
return (prop); |
| 415 |
|
} |
| 416 |
88
|
try { |
| 417 |
88
|
if (prop.getModuleAddress().isFileAddress()) { |
| 418 |
88
|
loadLocalModule(prop); |
| 419 |
|
} else { |
| 420 |
|
|
| 421 |
0
|
try { |
| 422 |
0
|
getCanonicalReadableFile(prop); |
| 423 |
|
} catch (ModuleFileNotFoundException e) { |
| 424 |
|
|
| 425 |
0
|
saveQedeqFromWebToBuffer(prop); |
| 426 |
|
} |
| 427 |
0
|
loadBufferedModule(prop); |
| 428 |
|
} |
| 429 |
|
|
| 430 |
85
|
return prop; |
| 431 |
|
} catch (SourceFileExceptionList e) { |
| 432 |
3
|
Trace.trace(CLASS, this, method, e); |
| 433 |
3
|
if (i + 1 < modulePaths.length) { |
| 434 |
0
|
QedeqLog.getInstance().logMessage("trying alternate path"); |
| 435 |
|
|
| 436 |
|
} else { |
| 437 |
|
|
| 438 |
3
|
throw e; |
| 439 |
|
} |
| 440 |
|
} |
| 441 |
|
} |
| 442 |
|
} |
| 443 |
0
|
return prop; |
| 444 |
|
} catch (final RuntimeException e) { |
| 445 |
0
|
Trace.fatal(CLASS, this, method, "unexpected problem", e); |
| 446 |
0
|
QedeqLog.getInstance().logFailureReply("Loading failed", e.getMessage()); |
| 447 |
0
|
throw e; |
| 448 |
|
} finally { |
| 449 |
161
|
processDec(); |
| 450 |
161
|
Trace.end(CLASS, this, method); |
| 451 |
|
} |
| 452 |
|
} |
| 453 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 454 |
54
|
public ModuleAddress[] getAllLoadedModules() {... |
| 455 |
54
|
return getModules().getAllLoadedModules(); |
| 456 |
|
} |
| 457 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 458 |
70
|
public void loadRequiredModules(final ModuleAddress address) throws SourceFileExceptionList {... |
| 459 |
70
|
final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) loadModule(address); |
| 460 |
70
|
if (prop.hasBasicFailures()) { |
| 461 |
2
|
throw prop.getErrors(); |
| 462 |
|
} |
| 463 |
68
|
LoadRequiredModules.loadRequired(this, prop); |
| 464 |
|
} |
| 465 |
|
|
| 466 |
|
|
| 467 |
|
|
| 468 |
|
|
| 469 |
|
@return |
| 470 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 471 |
0
|
public boolean loadPreviouslySuccessfullyLoadedModules() {... |
| 472 |
0
|
processInc(); |
| 473 |
0
|
try { |
| 474 |
0
|
final String[] list = kernel.getConfig().getPreviouslyCheckedModules(); |
| 475 |
0
|
boolean errors = false; |
| 476 |
0
|
for (int i = 0; i < list.length; i++) { |
| 477 |
0
|
try { |
| 478 |
0
|
final ModuleAddress address = getModuleAddress(list[i]); |
| 479 |
0
|
final QedeqBo prop = loadModule(address); |
| 480 |
0
|
if (prop.hasErrors()) { |
| 481 |
0
|
errors = true; |
| 482 |
|
} |
| 483 |
|
} catch (IOException e) { |
| 484 |
0
|
Trace.fatal(CLASS, this, "loadPreviouslySuccessfullyLoadedModules", |
| 485 |
|
"internal error: " + "saved URLs are malformed", e); |
| 486 |
0
|
errors = true; |
| 487 |
|
} catch (SourceFileExceptionList e) { |
| 488 |
0
|
Trace.fatal(CLASS, this, "loadPreviouslySuccessfullyLoadedModules", |
| 489 |
|
"loading error: " + "module could not be loaded", e); |
| 490 |
0
|
errors = true; |
| 491 |
|
} |
| 492 |
|
} |
| 493 |
0
|
return !errors; |
| 494 |
|
} finally { |
| 495 |
0
|
processDec(); |
| 496 |
|
} |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.29 |
|
| 500 |
0
|
public boolean loadAllModulesFromQedeq() {... |
| 501 |
0
|
processInc(); |
| 502 |
0
|
try { |
| 503 |
0
|
final String prefix = "http://www.qedeq.org/" + kernel.getKernelVersionDirectory() + "/"; |
| 504 |
0
|
final String[] list = new String[] { |
| 505 |
|
prefix + "doc/math/qedeq_logic_v1.xml", |
| 506 |
|
prefix + "doc/math/qedeq_set_theory_v1.xml", |
| 507 |
|
prefix + "doc/project/qedeq_basic_concept.xml", |
| 508 |
|
prefix + "doc/project/qedeq_logic_language.xml", |
| 509 |
|
prefix + "sample/qedeq_sample1.xml", prefix + "sample/qedeq_error_sample_00.xml", |
| 510 |
|
prefix + "sample/qedeq_error_sample_01.xml", |
| 511 |
|
prefix + "sample/qedeq_error_sample_02.xml", |
| 512 |
|
prefix + "sample/qedeq_error_sample_03.xml", |
| 513 |
|
prefix + "sample/qedeq_error_sample_04.xml", |
| 514 |
|
prefix + "sample/qedeq_sample2_error.xml", |
| 515 |
|
prefix + "sample/qedeq_sample3_error.xml", |
| 516 |
|
prefix + "sample/qedeq_sample4_error.xml", |
| 517 |
|
prefix + "sample/qedeq_sample5_error.xml", |
| 518 |
|
prefix + "sample/qedeq_sample6_error.xml", |
| 519 |
|
prefix + "sample/qedeq_sample7_error.xml", |
| 520 |
|
prefix + "sample/qedeq_sample8_error.xml", }; |
| 521 |
0
|
boolean errors = false; |
| 522 |
0
|
for (int i = 0; i < list.length; i++) { |
| 523 |
0
|
try { |
| 524 |
0
|
final ModuleAddress address = getModuleAddress(list[i]); |
| 525 |
0
|
final QedeqBo prop = loadModule(address); |
| 526 |
0
|
if (prop.hasErrors()) { |
| 527 |
0
|
errors = true; |
| 528 |
|
} |
| 529 |
|
} catch (IOException e) { |
| 530 |
0
|
Trace.fatal(CLASS, this, "loadPreviouslySuccessfullyLoadedModules", |
| 531 |
|
"internal error: " + "saved URLs are malformed", e); |
| 532 |
0
|
errors = true; |
| 533 |
|
} catch (SourceFileExceptionList e) { |
| 534 |
0
|
Trace.fatal(CLASS, this, "loadPreviouslySuccessfullyLoadedModules", |
| 535 |
|
"loading error: " + "module could not be loaded", e); |
| 536 |
0
|
errors = true; |
| 537 |
|
} |
| 538 |
|
} |
| 539 |
0
|
return !errors; |
| 540 |
|
} finally { |
| 541 |
0
|
processDec(); |
| 542 |
|
} |
| 543 |
|
} |
| 544 |
|
|
| 545 |
|
|
| 546 |
|
|
| 547 |
|
|
| 548 |
|
@param |
| 549 |
|
@throws |
| 550 |
|
|
|
|
|
| 0% |
Uncovered Elements: 107 (107) |
Complexity: 23 |
Complexity Density: 0.31 |
|
| 551 |
0
|
private void saveQedeqFromWebToBuffer(final DefaultKernelQedeqBo prop)... |
| 552 |
|
throws SourceFileExceptionList { |
| 553 |
0
|
final String method = "saveQedeqFromWebToBuffer(DefaultKernelQedeqBo)"; |
| 554 |
0
|
Trace.begin(CLASS, this, method); |
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
0
|
if (!KernelContext.getInstance().isSetConnectionTimeOutSupported() |
| 559 |
|
&& !IoUtility.isWebStarted()) { |
| 560 |
0
|
saveQedeqFromWebToBufferApache(prop); |
| 561 |
0
|
Trace.end(CLASS, this, method); |
| 562 |
0
|
return; |
| 563 |
|
} |
| 564 |
|
|
| 565 |
|
|
| 566 |
0
|
if (!IoUtility.isWebStarted()) { |
| 567 |
0
|
if (kernel.getConfig().getHttpProxyHost() != null) { |
| 568 |
0
|
System.setProperty("http.proxyHost", kernel.getConfig().getHttpProxyHost()); |
| 569 |
|
} |
| 570 |
0
|
if (kernel.getConfig().getHttpProxyPort() != null) { |
| 571 |
0
|
System.setProperty("http.proxyPort", kernel.getConfig().getHttpProxyPort()); |
| 572 |
|
} |
| 573 |
0
|
if (kernel.getConfig().getHttpNonProxyHosts() != null) { |
| 574 |
0
|
System.setProperty("http.nonProxyHosts", kernel.getConfig().getHttpNonProxyHosts()); |
| 575 |
|
} |
| 576 |
|
} |
| 577 |
|
|
| 578 |
0
|
if (prop.getModuleAddress().isFileAddress()) { |
| 579 |
0
|
Trace.fatal(CLASS, this, method, "tried to make a local copy for a local module", null); |
| 580 |
0
|
Trace.end(CLASS, this, method); |
| 581 |
0
|
return; |
| 582 |
|
} |
| 583 |
0
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_WEB); |
| 584 |
|
|
| 585 |
0
|
FileOutputStream out = null; |
| 586 |
0
|
InputStream in = null; |
| 587 |
0
|
final File f = getLocalFilePath(prop.getModuleAddress()); |
| 588 |
0
|
try { |
| 589 |
0
|
final URLConnection connection = new URL(prop.getUrl()).openConnection(); |
| 590 |
|
|
| 591 |
0
|
if (connection instanceof HttpURLConnection) { |
| 592 |
0
|
final HttpURLConnection httpConnection = (HttpURLConnection) connection; |
| 593 |
|
|
| 594 |
0
|
if (KernelContext.getInstance().isSetConnectionTimeOutSupported()) { |
| 595 |
0
|
try { |
| 596 |
0
|
YodaUtility.executeMethod(httpConnection, "setConnectTimeout", |
| 597 |
|
new Class[] {Integer.TYPE}, new Object[] {new Integer( |
| 598 |
|
kernel.getConfig().getConnectTimeout())}); |
| 599 |
|
} catch (NoSuchMethodException e) { |
| 600 |
0
|
Trace.fatal(CLASS, this, method, |
| 601 |
|
"URLConnection.setConnectTimeout was previously found", e); |
| 602 |
|
} catch (InvocationTargetException e) { |
| 603 |
0
|
Trace.fatal(CLASS, this, method, |
| 604 |
|
"URLConnection.setConnectTimeout throwed an error", e); |
| 605 |
|
} |
| 606 |
|
} |
| 607 |
|
|
| 608 |
0
|
if (KernelContext.getInstance().isSetReadTimeoutSupported()) { |
| 609 |
0
|
try { |
| 610 |
0
|
YodaUtility.executeMethod(httpConnection, "setReadTimeout", |
| 611 |
|
new Class[] {Integer.TYPE}, new Object[] {new Integer( |
| 612 |
|
kernel.getConfig().getReadTimeout())}); |
| 613 |
|
} catch (NoSuchMethodException e) { |
| 614 |
0
|
Trace.fatal(CLASS, this, method, |
| 615 |
|
"URLConnection.setReadTimeout was previously found", e); |
| 616 |
|
} catch (InvocationTargetException e) { |
| 617 |
0
|
Trace.fatal(CLASS, this, method, |
| 618 |
|
"URLConnection.setReadTimeout throwed an error", e); |
| 619 |
|
} |
| 620 |
|
} |
| 621 |
0
|
int responseCode = httpConnection.getResponseCode(); |
| 622 |
0
|
if (responseCode == 200) { |
| 623 |
0
|
in = httpConnection.getInputStream(); |
| 624 |
|
} else { |
| 625 |
0
|
in = httpConnection.getErrorStream(); |
| 626 |
0
|
final String errorText = IoUtility.loadStreamWithoutException(in, 1000); |
| 627 |
0
|
throw new IOException("Response code from HTTP server was " + responseCode |
| 628 |
0
|
+ (errorText.length() > 0 ? "\nResponse text from HTTP server was:\n" |
| 629 |
|
+ errorText : "")); |
| 630 |
|
} |
| 631 |
|
} else { |
| 632 |
0
|
Trace.paramInfo(CLASS, this, method, "connection.getClass", connection.getClass() |
| 633 |
|
.toString()); |
| 634 |
0
|
in = connection.getInputStream(); |
| 635 |
|
} |
| 636 |
|
|
| 637 |
0
|
if (!prop.getUrl().equals(connection.getURL().toString())) { |
| 638 |
0
|
throw new FileNotFoundException("\"" + prop.getUrl() + "\" was substituted by " |
| 639 |
|
+ "\"" + connection.getURL() + "\" from server"); |
| 640 |
|
} |
| 641 |
0
|
final int maximum = connection.getContentLength(); |
| 642 |
0
|
IoUtility.createNecessaryDirectories(f); |
| 643 |
0
|
out = new FileOutputStream(f); |
| 644 |
0
|
final byte[] buffer = new byte[4096]; |
| 645 |
0
|
int bytesRead; |
| 646 |
0
|
int position = 0; |
| 647 |
|
|
| 648 |
0
|
while ((bytesRead = in.read(buffer)) != -1) { |
| 649 |
0
|
position += bytesRead; |
| 650 |
0
|
out.write(buffer, 0, bytesRead); |
| 651 |
0
|
if (maximum > 0) { |
| 652 |
0
|
long completeness = (long) (position * 100 / maximum); |
| 653 |
0
|
if (completeness < 0) { |
| 654 |
0
|
completeness = 0; |
| 655 |
|
} |
| 656 |
0
|
if (completeness > 100) { |
| 657 |
0
|
completeness = 100; |
| 658 |
|
} |
| 659 |
0
|
prop.setLoadingCompleteness((int) completeness); |
| 660 |
|
} |
| 661 |
|
} |
| 662 |
0
|
prop.setLoadingCompleteness(100); |
| 663 |
|
} catch (IOException e) { |
| 664 |
0
|
Trace.trace(CLASS, this, method, e); |
| 665 |
0
|
IoUtility.close(out); |
| 666 |
0
|
out = null; |
| 667 |
0
|
try { |
| 668 |
0
|
f.delete(); |
| 669 |
|
} catch (Exception ex) { |
| 670 |
0
|
Trace.trace(CLASS, this, method, ex); |
| 671 |
|
} |
| 672 |
0
|
final SourceFileExceptionList sfl = createSourceFileExceptionList(prop.getUrl(), e); |
| 673 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_WEB_FAILED, sfl); |
| 674 |
0
|
Trace.trace(CLASS, this, method, "Couldn't access " + prop.getUrl()); |
| 675 |
0
|
throw sfl; |
| 676 |
|
} finally { |
| 677 |
0
|
IoUtility.close(out); |
| 678 |
0
|
IoUtility.close(in); |
| 679 |
0
|
Trace.end(CLASS, this, method); |
| 680 |
|
} |
| 681 |
|
} |
| 682 |
|
|
| 683 |
|
|
| 684 |
|
|
| 685 |
|
|
| 686 |
|
|
| 687 |
|
|
| 688 |
|
|
| 689 |
|
@param |
| 690 |
|
@throws |
| 691 |
|
|
|
|
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 10 |
Complexity Density: 0.26 |
|
| 692 |
0
|
private void saveQedeqFromWebToBufferApache(final DefaultKernelQedeqBo prop)... |
| 693 |
|
throws SourceFileExceptionList { |
| 694 |
0
|
final String method = "saveQedeqFromWebToBufferOld(DefaultKernelQedeqBo)"; |
| 695 |
0
|
Trace.begin(CLASS, this, method); |
| 696 |
|
|
| 697 |
0
|
if (prop.getModuleAddress().isFileAddress()) { |
| 698 |
0
|
Trace.fatal(CLASS, this, method, "tried to make a local copy for a local module", null); |
| 699 |
0
|
Trace.end(CLASS, this, method); |
| 700 |
0
|
return; |
| 701 |
|
} |
| 702 |
0
|
prop.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_WEB); |
| 703 |
|
|
| 704 |
0
|
final File f = getLocalFilePath(prop.getModuleAddress()); |
| 705 |
|
|
| 706 |
0
|
HttpClient client = new HttpClient(); |
| 707 |
|
|
| 708 |
|
|
| 709 |
0
|
if (!IoUtility.isWebStarted() && kernel.getConfig().getHttpProxyHost() != null) { |
| 710 |
0
|
final String pHost = kernel.getConfig().getHttpProxyHost(); |
| 711 |
0
|
int pPort = 80; |
| 712 |
0
|
if (kernel.getConfig().getHttpProxyPort() != null) { |
| 713 |
0
|
try { |
| 714 |
0
|
pPort = Integer.parseInt(kernel.getConfig().getHttpProxyPort()); |
| 715 |
|
} catch (RuntimeException e) { |
| 716 |
0
|
Trace.fatal(CLASS, this, method, "proxy port not numeric: " |
| 717 |
|
+ kernel.getConfig().getHttpProxyPort(), e); |
| 718 |
|
} |
| 719 |
|
} |
| 720 |
0
|
if (pHost.length() > 0) { |
| 721 |
0
|
client.getHostConfiguration().setProxy(pHost, pPort); |
| 722 |
|
} |
| 723 |
|
} |
| 724 |
|
|
| 725 |
|
|
| 726 |
0
|
GetMethod httpMethod = new GetMethod(prop.getUrl()); |
| 727 |
|
|
| 728 |
0
|
try { |
| 729 |
|
|
| 730 |
0
|
httpMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, |
| 731 |
|
new DefaultHttpMethodRetryHandler(3, false)); |
| 732 |
|
|
| 733 |
0
|
httpMethod.getParams().setSoTimeout(kernel.getConfig().getConnectTimeout()); |
| 734 |
|
|
| 735 |
|
|
| 736 |
0
|
int statusCode = client.executeMethod(httpMethod); |
| 737 |
|
|
| 738 |
0
|
if (statusCode != HttpStatus.SC_OK) { |
| 739 |
0
|
throw new FileNotFoundException("Problems loading: " + prop.getUrl() + "\n" |
| 740 |
|
+ httpMethod.getStatusLine()); |
| 741 |
|
} |
| 742 |
|
|
| 743 |
|
|
| 744 |
0
|
byte[] responseBody = httpMethod.getResponseBody(); |
| 745 |
0
|
IoUtility.createNecessaryDirectories(f); |
| 746 |
0
|
IoUtility.saveFileBinary(f, responseBody); |
| 747 |
0
|
prop.setLoadingCompleteness(100); |
| 748 |
|
} catch (IOException e) { |
| 749 |
0
|
Trace.trace(CLASS, this, method, e); |
| 750 |
0
|
try { |
| 751 |
0
|
f.delete(); |
| 752 |
|
} catch (Exception ex) { |
| 753 |
0
|
Trace.trace(CLASS, this, method, ex); |
| 754 |
|
} |
| 755 |
0
|
final SourceFileExceptionList sfl = createSourceFileExceptionList(prop.getUrl(), e); |
| 756 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_WEB_FAILED, sfl); |
| 757 |
0
|
Trace.trace(CLASS, this, method, "Couldn't access " + prop.getUrl()); |
| 758 |
0
|
throw sfl; |
| 759 |
|
} finally { |
| 760 |
|
|
| 761 |
0
|
httpMethod.releaseConnection(); |
| 762 |
0
|
Trace.end(CLASS, this, method); |
| 763 |
|
} |
| 764 |
|
} |
| 765 |
|
|
| 766 |
|
|
| 767 |
|
|
| 768 |
|
|
| 769 |
|
|
| 770 |
|
@param |
| 771 |
|
@return |
| 772 |
|
|
|
|
|
| 83.8% |
Uncovered Elements: 6 (37) |
Complexity: 6 |
Complexity Density: 0.17 |
|
| 773 |
25891
|
public final File getLocalFilePath(final ModuleAddress address) {... |
| 774 |
25891
|
final String method = "getLocalFilePath(ModuleAddress)"; |
| 775 |
25891
|
URL url; |
| 776 |
25891
|
try { |
| 777 |
25891
|
url = new URL(address.getUrl()); |
| 778 |
|
} catch (MalformedURLException e) { |
| 779 |
0
|
throw new RuntimeException(e); |
| 780 |
|
} |
| 781 |
25891
|
Trace.param(CLASS, this, method, "protocol", url.getProtocol()); |
| 782 |
25891
|
Trace.param(CLASS, this, method, "host", url.getHost()); |
| 783 |
25891
|
Trace.param(CLASS, this, method, "port", url.getPort()); |
| 784 |
25891
|
Trace.param(CLASS, this, method, "path", url.getPath()); |
| 785 |
25891
|
Trace.param(CLASS, this, method, "file", url.getFile()); |
| 786 |
25891
|
if (address.isFileAddress()) { |
| 787 |
25835
|
try { |
| 788 |
25835
|
return IoUtility.toFile(url.getFile()); |
| 789 |
|
} catch (IllegalArgumentException e) { |
| 790 |
|
|
| 791 |
0
|
Trace.fatal(CLASS, this, method, "Loading failed of local file with URL=" + url, e); |
| 792 |
0
|
throw new RuntimeException(e); |
| 793 |
|
} |
| 794 |
|
} |
| 795 |
56
|
StringBuffer file = new StringBuffer(url.getFile()); |
| 796 |
56
|
StringUtility.replace(file, "_", "_1"); |
| 797 |
56
|
StringUtility.replace(file, "/", "_2"); |
| 798 |
56
|
String encoded = file.toString(); |
| 799 |
56
|
try { |
| 800 |
56
|
encoded = URLEncoder.encode(file.toString(), "UTF-8"); |
| 801 |
|
} catch (UnsupportedEncodingException e) { |
| 802 |
|
|
| 803 |
0
|
Trace.trace(CLASS, method, e); |
| 804 |
|
} |
| 805 |
56
|
file.setLength(0); |
| 806 |
56
|
file.append(encoded); |
| 807 |
56
|
StringUtility.replace(file, "#", "##"); |
| 808 |
56
|
StringUtility.replace(file, "_2", "#"); |
| 809 |
56
|
StringUtility.replace(file, "_1", "_"); |
| 810 |
|
|
| 811 |
|
|
| 812 |
56
|
final StringBuffer adr; |
| 813 |
56
|
try { |
| 814 |
56
|
adr = new StringBuffer(new URL(url.getProtocol(), url.getHost(), url.getPort(), file |
| 815 |
|
.toString()).toExternalForm()); |
| 816 |
|
} catch (MalformedURLException e) { |
| 817 |
0
|
Trace.fatal(CLASS, this, method, "unexpected", e); |
| 818 |
0
|
throw new RuntimeException(e); |
| 819 |
|
} |
| 820 |
|
|
| 821 |
56
|
StringUtility.replace(adr, "://", "_"); |
| 822 |
56
|
StringUtility.replace(adr, ":", "_"); |
| 823 |
56
|
return new File(getBufferDirectory(), adr.toString()); |
| 824 |
|
} |
| 825 |
|
|
| 826 |
|
|
| 827 |
|
|
| 828 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 829 |
321
|
private synchronized void processInc() {... |
| 830 |
321
|
this.processCounter++; |
| 831 |
|
} |
| 832 |
|
|
| 833 |
|
|
| 834 |
|
|
| 835 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 836 |
321
|
private synchronized void processDec() {... |
| 837 |
321
|
this.processCounter--; |
| 838 |
|
} |
| 839 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 840 |
56
|
public File getBufferDirectory() {... |
| 841 |
56
|
return kernel.getConfig().getBufferDirectory(); |
| 842 |
|
} |
| 843 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 844 |
0
|
public File getGenerationDirectory() {... |
| 845 |
0
|
return kernel.getConfig().getGenerationDirectory(); |
| 846 |
|
} |
| 847 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 848 |
6
|
public KernelQedeqBo getKernelQedeqBo(final ModuleAddress address) {... |
| 849 |
6
|
return getModules().getKernelQedeqBo(this, address); |
| 850 |
|
} |
| 851 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 852 |
58
|
public QedeqBo getQedeqBo(final ModuleAddress address) {... |
| 853 |
58
|
return getModules().getKernelQedeqBo(this, address); |
| 854 |
|
} |
| 855 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 856 |
51
|
public ModuleAddress getModuleAddress(final URL url) throws IOException {... |
| 857 |
51
|
return new DefaultModuleAddress(url); |
| 858 |
|
} |
| 859 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 860 |
0
|
public ModuleAddress getModuleAddress(final String url) throws IOException {... |
| 861 |
0
|
return new DefaultModuleAddress(url); |
| 862 |
|
} |
| 863 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 864 |
2
|
public ModuleAddress getModuleAddress(final File file) throws IOException {... |
| 865 |
2
|
return new DefaultModuleAddress(file); |
| 866 |
|
} |
| 867 |
|
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 868 |
2
|
public String getSource(final ModuleAddress address) throws IOException {... |
| 869 |
2
|
final KernelQedeqBo bo = getKernelQedeqBo(address); |
| 870 |
2
|
if (bo.getLoadingState().equals(LoadingState.STATE_UNDEFINED) |
| 871 |
|
|| bo.getLoadingState().equals(LoadingState.STATE_LOADING_FROM_WEB) |
| 872 |
|
|| bo.getLoadingState().equals(LoadingState.STATE_LOADING_FROM_WEB_FAILED)) { |
| 873 |
0
|
return null; |
| 874 |
|
} |
| 875 |
2
|
final StringBuffer buffer = new StringBuffer(); |
| 876 |
2
|
final Reader reader = getQedeqFileDao().getModuleReader(bo); |
| 877 |
2
|
try { |
| 878 |
2
|
IoUtility.loadReader(reader, buffer); |
| 879 |
|
} finally { |
| 880 |
2
|
IoUtility.close(reader); |
| 881 |
|
} |
| 882 |
2
|
return buffer.toString(); |
| 883 |
|
} |
| 884 |
|
|
|
|
|
| 62.9% |
Uncovered Elements: 13 (35) |
Complexity: 7 |
Complexity Density: 0.26 |
|
| 885 |
91
|
public boolean checkModule(final ModuleAddress address) {... |
| 886 |
91
|
final String method = "checkModule(ModuleAddress)"; |
| 887 |
91
|
final DefaultKernelQedeqBo prop = modules.getKernelQedeqBo(this, address); |
| 888 |
|
|
| 889 |
91
|
if (prop.isChecked()) { |
| 890 |
38
|
return true; |
| 891 |
|
} |
| 892 |
53
|
try { |
| 893 |
53
|
QedeqLog.getInstance().logRequest( |
| 894 |
|
"Check logical correctness for \"" + IoUtility.easyUrl(prop.getUrl()) + "\""); |
| 895 |
53
|
loadModule(address); |
| 896 |
53
|
if (!prop.isLoaded()) { |
| 897 |
0
|
final String msg = "Check of logical correctness failed for \"" + address.getUrl() |
| 898 |
|
+ "\""; |
| 899 |
0
|
QedeqLog.getInstance().logFailureReply(msg, "Module could not even be loaded."); |
| 900 |
0
|
return false; |
| 901 |
|
} |
| 902 |
53
|
LoadRequiredModules.loadRequired(this, prop); |
| 903 |
53
|
if (!prop.hasLoadedRequiredModules()) { |
| 904 |
0
|
final String msg = "Check of logical correctness failed for \"" + IoUtility.easyUrl(address.getUrl()) |
| 905 |
|
+ "\""; |
| 906 |
0
|
QedeqLog.getInstance().logFailureReply(msg, "Not all required modules could be loaded."); |
| 907 |
0
|
return false; |
| 908 |
|
} |
| 909 |
|
|
| 910 |
53
|
QedeqBoFormalLogicChecker.check(prop); |
| 911 |
38
|
QedeqLog.getInstance().logSuccessfulReply( |
| 912 |
|
"Check of logical correctness successful for \"" + IoUtility.easyUrl(prop.getUrl()) + "\""); |
| 913 |
|
} catch (final SourceFileExceptionList e) { |
| 914 |
15
|
final String msg = "Check of logical correctness failed for \"" + IoUtility.easyUrl(address.getUrl()) |
| 915 |
|
+ "\""; |
| 916 |
15
|
QedeqLog.getInstance().logFailureReply(msg, e.getMessage()); |
| 917 |
|
} catch (final RuntimeException e) { |
| 918 |
0
|
final String msg = "Check of logical correctness failed for \"" + IoUtility.easyUrl(address.getUrl()) |
| 919 |
|
+ "\""; |
| 920 |
0
|
Trace.fatal(CLASS, this, method, msg, e); |
| 921 |
0
|
QedeqLog.getInstance().logFailureReply(msg, e.getMessage()); |
| 922 |
0
|
throw e; |
| 923 |
|
} finally { |
| 924 |
53
|
if (validate) { |
| 925 |
53
|
modules.validateDependencies(); |
| 926 |
|
} |
| 927 |
|
} |
| 928 |
53
|
return prop.isChecked(); |
| 929 |
|
} |
| 930 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 931 |
4
|
public Object executePlugin(final String pluginName, final ModuleAddress address,... |
| 932 |
|
final Map parameters) { |
| 933 |
4
|
return pluginManager.executePlugin(pluginName, getKernelQedeqBo(address), parameters); |
| 934 |
|
} |
| 935 |
|
|
| 936 |
|
|
| 937 |
|
|
| 938 |
|
|
| 939 |
|
@return |
| 940 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 941 |
439
|
private KernelQedeqBoStorage getModules() {... |
| 942 |
439
|
return modules; |
| 943 |
|
} |
| 944 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 945 |
0
|
public SourceFileExceptionList createSourceFileExceptionList(final String address,... |
| 946 |
|
final IOException e) { |
| 947 |
0
|
return new DefaultSourceFileExceptionList(new SourceFileException(this, |
| 948 |
|
ServiceErrors.IO_ERROR, ServiceErrors.IO_ERROR_TEXT, |
| 949 |
|
e, new SourceArea(address, SourcePosition.BEGIN, SourcePosition.BEGIN), null)); |
| 950 |
|
} |
| 951 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 952 |
0
|
public SourceFileExceptionList createSourceFileExceptionList(final String address,... |
| 953 |
|
final RuntimeException e) { |
| 954 |
0
|
return new DefaultSourceFileExceptionList(new SourceFileException(this, |
| 955 |
|
ServiceErrors.RUNTIME_ERROR, ServiceErrors.RUNTIME_ERROR_TEXT, |
| 956 |
|
e, new SourceArea(address, SourcePosition.BEGIN, SourcePosition.BEGIN), null)); |
| 957 |
|
} |
| 958 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 959 |
3
|
public SourceFileExceptionList createSourceFileExceptionList(final String address,... |
| 960 |
|
final Exception e) { |
| 961 |
3
|
return new DefaultSourceFileExceptionList(new SourceFileException(this, |
| 962 |
|
ServiceErrors.EXCEPTION_ERROR, ServiceErrors.EXCEPTION_ERROR_TEXT, |
| 963 |
|
e, new SourceArea(address, SourcePosition.BEGIN, SourcePosition.BEGIN), null)); |
| 964 |
|
} |
| 965 |
|
|
| 966 |
|
|
| 967 |
|
|
| 968 |
|
|
| 969 |
|
@param |
| 970 |
|
@return |
| 971 |
|
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 9 |
Complexity Density: 0.25 |
|
| 972 |
0
|
public String[] getSourceFileExceptionList(final ModuleAddress address) {... |
| 973 |
0
|
final List list = new ArrayList(); |
| 974 |
0
|
final KernelQedeqBo bo = getKernelQedeqBo(address); |
| 975 |
0
|
final SourceFileExceptionList sfl = bo.getErrors(); |
| 976 |
0
|
if (sfl != null) { |
| 977 |
0
|
final StringBuffer buffer = new StringBuffer(); |
| 978 |
0
|
do { |
| 979 |
0
|
Reader reader = null; |
| 980 |
0
|
try { |
| 981 |
0
|
reader = getQedeqFileDao().getModuleReader(bo); |
| 982 |
0
|
IoUtility.loadReader(reader, buffer); |
| 983 |
|
} catch (IOException e) { |
| 984 |
0
|
IoUtility.close(reader); |
| 985 |
0
|
for (int i = 0; i < sfl.size(); i++) { |
| 986 |
0
|
list.add(sfl.get(i).getDescription()); |
| 987 |
|
} |
| 988 |
0
|
break; |
| 989 |
|
} |
| 990 |
0
|
final TextInput input = new TextInput(buffer); |
| 991 |
0
|
try { |
| 992 |
0
|
input.setPosition(0); |
| 993 |
0
|
final StringBuffer buf = new StringBuffer(); |
| 994 |
0
|
for (int i = 0; i < sfl.size(); i++) { |
| 995 |
0
|
buf.setLength(0); |
| 996 |
0
|
final SourceFileException sf = sfl.get(i); |
| 997 |
0
|
buf.append(sf.getDescription()); |
| 998 |
0
|
try { |
| 999 |
0
|
if (sf.getSourceArea() != null |
| 1000 |
|
&& sf.getSourceArea().getStartPosition() != null) { |
| 1001 |
0
|
buf.append("\n"); |
| 1002 |
0
|
input.setRow(sf.getSourceArea().getStartPosition().getRow()); |
| 1003 |
0
|
buf.append(StringUtility.replace(input.getLine(), "\t", " ")); |
| 1004 |
0
|
buf.append("\n"); |
| 1005 |
0
|
final StringBuffer whitespace = StringUtility.getSpaces(sf |
| 1006 |
|
.getSourceArea().getStartPosition().getColumn() - 1); |
| 1007 |
0
|
buffer.append(whitespace); |
| 1008 |
0
|
buffer.append("^"); |
| 1009 |
|
} |
| 1010 |
|
} catch (Exception e) { |
| 1011 |
0
|
Trace.trace(CLASS, this, "getSourceFileExceptionList(ModuleAddress)", e); |
| 1012 |
|
} |
| 1013 |
0
|
list.add(buf.toString()); |
| 1014 |
|
} |
| 1015 |
|
} finally { |
| 1016 |
0
|
IoUtility.close(input); |
| 1017 |
|
} |
| 1018 |
0
|
break; |
| 1019 |
|
} while (true); |
| 1020 |
|
} |
| 1021 |
0
|
return (String[]) list.toArray(new String[list.size()]); |
| 1022 |
|
} |
| 1023 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1024 |
0
|
public String getPluginId() {... |
| 1025 |
0
|
return CLASS.getName(); |
| 1026 |
|
} |
| 1027 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1028 |
0
|
public String getPluginName() {... |
| 1029 |
0
|
return "Basis"; |
| 1030 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1031 |
296
|
public QedeqFileDao getQedeqFileDao() {... |
| 1032 |
296
|
return qedeqFileDao; |
| 1033 |
|
} |
| 1034 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1035 |
0
|
public String getPluginDescription() {... |
| 1036 |
0
|
return "provides basic services for loading QEDEQ modules"; |
| 1037 |
|
} |
| 1038 |
|
|
| 1039 |
|
} |