-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fee73f5
commit 9a28fc6
Showing
12 changed files
with
188 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ public static IPStatus parse(String value) { | |
} | ||
|
||
public enum SipType { | ||
EARK2S, EARK2 | ||
EARK2S, EARK2, ERMS | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.roda_project.commons_ip2.cli.model.ExitCodes; | ||
import org.roda_project.commons_ip2.cli.model.enums.ReportType; | ||
import org.roda_project.commons_ip2.cli.model.enums.ReportTypeEnums; | ||
import org.roda_project.commons_ip2.cli.model.exception.CLIException; | ||
import org.roda_project.commons_ip2.cli.model.exception.ValidationException; | ||
import org.roda_project.commons_ip2.cli.utils.CLI.ValidateCommandUtils; | ||
|
@@ -27,6 +27,9 @@ | |
|
||
import picocli.CommandLine; | ||
|
||
import static org.roda_project.commons_ip2.cli.model.enums.ReportTypeEnums.ReportType.COMMONS_IP; | ||
import static org.roda_project.commons_ip2.cli.model.enums.ReportTypeEnums.ReportType.PYIP; | ||
|
||
/** | ||
* @author Miguel Guimarães <[email protected]> | ||
*/ | ||
|
@@ -48,7 +51,7 @@ public class Validate implements Callable<Integer> { | |
|
||
@CommandLine.Option(names = {"-r", | ||
"--reporter-type"}, paramLabel = "<type>", description = "Report type (possible values: ${COMPLETION-CANDIDATES})") | ||
ReportType reportType = ReportType.COMMONS_IP; | ||
ReportTypeEnums.ReportType reportType = COMMONS_IP; | ||
|
||
@CommandLine.Option(names = {"-v", | ||
"--verbose"}, description = "Verbose command line output with all validation steps") | ||
|
@@ -72,7 +75,7 @@ public Integer call() throws ValidationException, CLIException { | |
return ExitCodes.EXIT_CODE_OK; | ||
} | ||
|
||
private void handleSipValidation(final String sip, final String reportPathDir, final ReportType reportType, | ||
private void handleSipValidation(final String sip, final String reportPathDir, final ReportTypeEnums.ReportType reportType, | ||
final boolean verbose) | ||
throws IOException, ParserConfigurationException, SAXException, CLIException, NoSuchAlgorithmException { | ||
final Path sipPath = Paths.get(sip); | ||
|
@@ -83,27 +86,25 @@ private void handleSipValidation(final String sip, final String reportPathDir, f | |
|
||
LogSystem.logOperatingSystemInfo(); | ||
LOGGER.debug("command executed: {}", commandLineString); | ||
switch (reportType) { | ||
case COMMONS_IP -> { | ||
final OutputStream outputStream = ValidateCommandUtils.createReportOutputStream(reportPath); | ||
if (outputStream != null) { | ||
final ValidationReportOutputJson jsonReporter = new ValidationReportOutputJson(sipPath, outputStream); | ||
final EARKSIPValidator earksipValidator = new EARKSIPValidator(jsonReporter, version); | ||
if (verbose) { | ||
earksipValidator.addObserver(new ProgressValidationLoggerObserver()); | ||
} | ||
earksipValidator.validate(version); | ||
} | ||
} | ||
case PYIP -> { | ||
final ValidationReportOutputJSONPyIP jsonReporter = new ValidationReportOutputJSONPyIP(reportPath, sipPath); | ||
final EARKPyIPValidator earkPyIPValidator = new EARKPyIPValidator(jsonReporter, version); | ||
if (reportType.equals(COMMONS_IP)) { | ||
final OutputStream outputStream = ValidateCommandUtils.createReportOutputStream(reportPath); | ||
if (outputStream != null) { | ||
final ValidationReportOutputJson jsonReporter = new ValidationReportOutputJson(sipPath, outputStream); | ||
final EARKSIPValidator earksipValidator = new EARKSIPValidator(jsonReporter, version); | ||
if (verbose) { | ||
earkPyIPValidator.addObserver(new ProgressValidationLoggerObserver()); | ||
earksipValidator.addObserver(new ProgressValidationLoggerObserver()); | ||
} | ||
earkPyIPValidator.validate(); | ||
earksipValidator.validate(version); | ||
} | ||
} else if (reportType.equals(PYIP)) { | ||
final ValidationReportOutputJSONPyIP jsonReporter = new ValidationReportOutputJSONPyIP(reportPath, sipPath); | ||
final EARKPyIPValidator earkPyIPValidator = new EARKPyIPValidator(jsonReporter, version); | ||
if (verbose) { | ||
earkPyIPValidator.addObserver(new ProgressValidationLoggerObserver()); | ||
} | ||
default -> throw new CLIException("Unexpected value: " + reportType); | ||
earkPyIPValidator.validate(); | ||
} else { | ||
throw new CLIException("Unexpected value: " + reportType); | ||
} | ||
new CommandLine(this).getOut().printf("E-ARK SIP validation report at '%s'%n", | ||
reportPath.normalize().toAbsolutePath()); | ||
|
19 changes: 0 additions & 19 deletions
19
src/main/java/org/roda_project/commons_ip2/cli/model/enums/ReportType.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/java/org/roda_project/commons_ip2/cli/model/enums/ReportTypeEnums.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.roda_project.commons_ip2.cli.model.enums; | ||
|
||
/** | ||
* @author Miguel Guimarães <[email protected]> | ||
*/ | ||
public class ReportTypeEnums { | ||
public enum ReportType { | ||
COMMONS_IP("commons-ip"), PYIP("eark-validator"); | ||
|
||
private final String type; | ||
|
||
ReportType(String type) { | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return type; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters