Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgeiger committed Mar 31, 2016
1 parent 1c217f4 commit d583e48
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/java/de/uniba/dsg/bpmnspector/BPMNspector.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import de.uniba.dsg.bpmnspector.common.util.FileUtils;
import de.uniba.dsg.bpmnspector.refcheck.BPMNReferenceValidator;
import de.uniba.dsg.bpmnspector.schematron.SchematronBPMNValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.nio.file.Path;
Expand All @@ -22,6 +24,8 @@
*/
public class BPMNspector implements Validator {

private static final Logger LOGGER = LoggerFactory.getLogger(BPMNspector.class.getSimpleName());

private final SchematronBPMNValidator extValidator;
private final BPMNReferenceValidator refValidator;
private final ProcessImporter bpmnImporter;
Expand Down Expand Up @@ -53,7 +57,9 @@ public ValidationResult inspectFile(Path file, List<ValidationOption> validation
BPMNProcess process = bpmnImporter
.importProcessFromPath(file, result);

if(process!=null) {
if(process==null) {
LOGGER.info("Process could not parsed correctly. Further processing is skipped.");
} else {
if (validationOptions.contains(ValidationOption.REF)) {
refValidator.validate(process, result);
}
Expand All @@ -62,6 +68,9 @@ public ValidationResult inspectFile(Path file, List<ValidationOption> validation
}
}

String resultString = result.isValid() ? "valid" : "invalid";
LOGGER.info("Overall result for '{}': {}", file.getFileName().toString(), resultString);

return result;
}

Expand All @@ -81,11 +90,14 @@ public ValidationResult validate(InputStream source, String resourceName) throws
BPMNProcess process = bpmnImporter.importProcessFromStreamSource(source, resourceName, result);


if(process!=null) {
if(process==null) {
LOGGER.info("Process could not parsed correctly. Further processing is skipped.");
} else {
refValidator.validate(process, result);
extValidator.validate(process, result);
}

String resultString = result.isValid() ? "valid" : "invalid";
LOGGER.info("Overall result for '{}': {}", resourceName, resultString);
return result;
}
}

0 comments on commit d583e48

Please sign in to comment.