Skip to content

Commit

Permalink
Commons ip now working with version 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosjepard committed Aug 1, 2024
1 parent da1d34e commit 9df43a6
Show file tree
Hide file tree
Showing 52 changed files with 12,185 additions and 76 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/roda_project/commons_ip2/cli/Create.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Create implements Callable<Integer> {

@CommandLine.Option(names = {"-v",
"--version"}, description = "E-ARK SIP specification version (possible values: ${COMPLETION-CANDIDATES})")
CSIPVersion version = CSIPVersion.V210;
CSIPVersion version = CSIPVersion.V220;

@CommandLine.Option(names = {"-p", "--path"}, arity = "1", description = "Path where the E-ARK SIP should be saved")
String path = System.getProperty("user.dir");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Validate implements Callable<Integer> {
boolean verbose;

@CommandLine.Option(names = {"--specification-version"}, description = "E-ARK CSIP version")
String version = "2.1.0";
String version = "2.2.0";

@Override
public Integer call() throws ValidationException, CLIException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Miguel Guimarães <mguimaraes@keep.pt>
*/
public enum CSIPVersion {
V204("2.0.4"), V210("2.1.0");
V204("2.0.4"), V210("2.1.0"), V220("2.2.0");

private final String version;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class SIPBuilder {
private List<MetadataGroup> metadataArgs = new ArrayList<>();
private List<RepresentationGroup> representationArgs = new ArrayList<>();
private boolean targetOnly;
private CSIPVersion version = CSIPVersion.V210;
private CSIPVersion version = CSIPVersion.V220;
private String path;
private String submitterAgentName;
private String submitterAgentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public final class IPConstants {
// SIP Specification
public static final String SIP_SPEC_PROFILE = "https://earksip.dilcis.eu/profile/E-ARK-SIP.xml";

// AIP Specification
public static final String AIP_SPEC_PROFILE = "https://earkaip.dilcis.eu/profile/E-ARK-AIP.xml";

// RODA
public static final String RODA_STRUCTURAL_MAP = "RODA structural map";
public static final String RODA_DIV_LABEL = "RODA";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public class EARKAIP extends AIPWrap {
*/
public EARKAIP(final AIP aip, String version) {
super(aip);
if (version.equals("2.2.0")) {
setProfile(IPConstants.AIP_SPEC_PROFILE.replace(".xml", "-v" + version.replace(".", "-") + ".xml"));
}
else {
setProfile(IPConstants.AIP_SPEC_PROFILE);
}
METSGeneratorFactory factory = new METSGeneratorFactory();
metsCreator = factory.getGenerator(version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class EARKSIP extends SIP {
public EARKSIP() {
super();
setProfile(IPConstants.SIP_SPEC_PROFILE);

METSGeneratorFactory factory = new METSGeneratorFactory();
metsCreator = factory.getGenerator(DEFAULT_SIP_VERSION);
}
Expand All @@ -75,8 +74,12 @@ public EARKSIP(String sipId, IPContentType contentType, IPContentInformationType

public EARKSIP(String sipId, IPContentType contentType, IPContentInformationType contentInformationType, String version) {
super(sipId, contentType,contentInformationType);
setProfile(IPConstants.SIP_SPEC_PROFILE);

if (version.equals("2.2.0") || version.equals("2.1.0")) {
setProfile(IPConstants.SIP_SPEC_PROFILE.replace(".xml", "-v" + version.replace(".", "-") + ".xml"));
}
else {
setProfile(IPConstants.SIP_SPEC_PROFILE);
}
METSGeneratorFactory factory = new METSGeneratorFactory();
metsCreator = factory.getGenerator(version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,37 @@
import org.roda_project.commons_ip2.validator.components.StructureValidatorImpl;
import org.roda_project.commons_ip2.validator.components.administritiveMetadataComponent.AdministritiveMetadataComponentValidator204;
import org.roda_project.commons_ip2.validator.components.administritiveMetadataComponent.AdministritiveMetadataComponentValidator210;
import org.roda_project.commons_ip2.validator.components.administritiveMetadataComponent.AdministritiveMetadataComponentValidator220;
import org.roda_project.commons_ip2.validator.components.aipFileSectionComponent.AipFileSectionComponent204;
import org.roda_project.commons_ip2.validator.components.aipFileSectionComponent.AipFileSectionComponent210;
import org.roda_project.commons_ip2.validator.components.aipFileSectionComponent.AipFileSectionComponent220;
import org.roda_project.commons_ip2.validator.components.descriptiveMetadataComponent.DescriptiveMetadataComponentValidator204;
import org.roda_project.commons_ip2.validator.components.descriptiveMetadataComponent.DescriptiveMetadataComponentValidator210;
import org.roda_project.commons_ip2.validator.components.descriptiveMetadataComponent.DescriptiveMetadataComponentValidator220;
import org.roda_project.commons_ip2.validator.components.fileComponent.StructureComponentValidator204;
import org.roda_project.commons_ip2.validator.components.fileComponent.StructureComponentValidator210;
import org.roda_project.commons_ip2.validator.components.fileComponent.StructureComponentValidator220;
import org.roda_project.commons_ip2.validator.components.fileSectionComponent.FileSectionComponentValidator204;
import org.roda_project.commons_ip2.validator.components.fileSectionComponent.FileSectionComponentValidator210;
import org.roda_project.commons_ip2.validator.components.fileSectionComponent.FileSectionComponentValidator220;
import org.roda_project.commons_ip2.validator.components.metsRootComponent.metsHeaderValidator.MetsHeaderComponentValidator204;
import org.roda_project.commons_ip2.validator.components.metsRootComponent.metsHeaderValidator.MetsHeaderComponentValidator210;
import org.roda_project.commons_ip2.validator.components.metsRootComponent.metsHeaderValidator.MetsHeaderComponentValidator220;
import org.roda_project.commons_ip2.validator.components.metsRootComponent.metsValidator.MetsComponentValidator204;
import org.roda_project.commons_ip2.validator.components.metsRootComponent.metsValidator.MetsComponentValidator210;
import org.roda_project.commons_ip2.validator.components.metsRootComponent.metsValidator.MetsComponentValidator220;
import org.roda_project.commons_ip2.validator.components.sipFileSectionComponent.SipFileSectionComponent204;
import org.roda_project.commons_ip2.validator.components.sipFileSectionComponent.SipFileSectionComponent210;
import org.roda_project.commons_ip2.validator.components.sipFileSectionComponent.SipFileSectionComponent220;
import org.roda_project.commons_ip2.validator.components.sipMetsRootComponent.sipMetsComponent.SipMetsComponent204;
import org.roda_project.commons_ip2.validator.components.sipMetsRootComponent.sipMetsComponent.SipMetsComponent210;
import org.roda_project.commons_ip2.validator.components.sipMetsRootComponent.sipMetsComponent.SipMetsComponent220;
import org.roda_project.commons_ip2.validator.components.sipMetsRootComponent.sipMetsHdrComponent.SipMetsHdrComponent204;
import org.roda_project.commons_ip2.validator.components.sipMetsRootComponent.sipMetsHdrComponent.SipMetsHdrComponent210;
import org.roda_project.commons_ip2.validator.components.sipMetsRootComponent.sipMetsHdrComponent.SipMetsHdrComponent220;
import org.roda_project.commons_ip2.validator.components.structuralMapComponent.StructuralMapComponentValidator204;
import org.roda_project.commons_ip2.validator.components.structuralMapComponent.StructuralMapComponentValidator210;
import org.roda_project.commons_ip2.validator.components.structuralMapComponent.StructuralMapComponentValidator220;
import org.roda_project.commons_ip2.validator.constants.Constants;
import org.roda_project.commons_ip2.validator.constants.ConstantsCSIPspec;
import org.roda_project.commons_ip2.validator.observer.ValidationObserver;
Expand Down Expand Up @@ -94,9 +105,12 @@ public EARKSIPValidator(final ValidationReportOutputJson reportOutputJson, Strin
reportOutputJson.getSipPath().toAbsolutePath().normalize());
if (version.equals("2.1.0")) {
this.structureComponent = new StructureComponentValidator210();
} else {
} else if (version.equals("2.0.4")) {
this.structureComponent = new StructureComponentValidator204();
}
else {
this.structureComponent = new StructureComponentValidator220();
}
this.metsValidatorState = new MetsValidatorState();
setupComponents(version);
}
Expand Down Expand Up @@ -363,6 +377,10 @@ private void validateSIPComponents() throws IOException {
((SipFileSectionComponent210) component).setIsToValidate(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP58_ID));
}
if (component instanceof SipFileSectionComponent220 component1) {
((SipFileSectionComponent220) component).setIsToValidate(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP58_ID));
}
if (component instanceof SipMetsHdrComponent204) {
((SipMetsHdrComponent204) component).setIsToValidateMetsHdr(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP117_ID));
Expand All @@ -381,6 +399,15 @@ private void validateSIPComponents() throws IOException {
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP10_ID));
}
}
if (component instanceof SipMetsHdrComponent220) {
((SipMetsHdrComponent220) component).setIsToValidateMetsHdr(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP117_ID));
if (validationReportOutputJson.getResults()
.get(ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP10_ID) != null) {
((SipMetsHdrComponent220) component).setIsToValidateAgents(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP10_ID));
}
}
final Map<String, ReporterDetails> sipComponentResults = component.validate(structureValidatorState,
metsValidatorState);
ResultsUtils.mergeResults(validationReportOutputJson.getResults(), sipComponentResults);
Expand All @@ -405,6 +432,10 @@ private void validateAIPComponets() throws IOException {
((AipFileSectionComponent210) component).setIsToValidate(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP58_ID));
}
if (component instanceof AipFileSectionComponent220) {
((AipFileSectionComponent220) component).setIsToValidate(ResultsUtils.isResultValid(
validationReportOutputJson.getResults(), ConstantsCSIPspec.VALIDATION_REPORT_SPECIFICATION_CSIP58_ID));
}
final Map<String, ReporterDetails> aipComponentResults = component.validate(structureValidatorState,
metsValidatorState);
ResultsUtils.mergeResults(validationReportOutputJson.getResults(), aipComponentResults);
Expand Down Expand Up @@ -448,7 +479,7 @@ private List<MetsValidator> getComponentsForVersion(String version, String type)
} else {
values.add(new AipFileSectionComponent204());
}
} else {
} else if (version.equals("2.1.0")) {
if (type.equals("csipComponents")) {
values.add(new MetsComponentValidator210());
values.add(new MetsHeaderComponentValidator210());
Expand All @@ -463,6 +494,21 @@ private List<MetsValidator> getComponentsForVersion(String version, String type)
} else {
values.add(new AipFileSectionComponent210());
}
} else {
if (type.equals("csipComponents")) {
values.add(new MetsComponentValidator220());
values.add(new MetsHeaderComponentValidator220());
values.add(new DescriptiveMetadataComponentValidator220());
values.add(new AdministritiveMetadataComponentValidator220());
values.add(new FileSectionComponentValidator220());
values.add(new StructuralMapComponentValidator220());
} else if (type.equals("sipComponents")) {
values.add(new SipMetsComponent220());
values.add(new SipMetsHdrComponent220());
values.add(new SipFileSectionComponent220());
} else {
values.add(new AipFileSectionComponent220());
}
}
return values;
}
Expand Down
Loading

0 comments on commit 9df43a6

Please sign in to comment.