boolean isAtLeast30 = version.isAtLeast("3.0");
boolean isAtLeast31 = version.isAtLeast("3.1");
if (!isAtLeast31) {
if (!getAtomicEnergyMarkings().isEmpty())
throw new InvalidDDMSException(
"The atomicEnergyMarkings attribute must not be used until DDMS 3.1 or later.");
if (!getDisplayOnlyTo().isEmpty())
throw new InvalidDDMSException("The displayOnlyTo attribute must not be used until DDMS 3.1 or later.");
if (!getNonUSControls().isEmpty())
throw new InvalidDDMSException("The nonUSControls attribute must not be used until DDMS 3.1 or later.");
}
if (!isAtLeast30 && !Util.isEmpty(getCompilationReason()))
throw new InvalidDDMSException("The compilationReason attribute must not be used until DDMS 3.0 or later.");
if (isAtLeast31 && getDateOfExemptedSource() != null)
throw new InvalidDDMSException("The dateOfExemptedSource attribute must only be used in DDMS 2.0 or 3.0.");
if (isAtLeast31 && !Util.isEmpty(getTypeOfExemptedSource()))
throw new InvalidDDMSException("The typeOfExemptedSource attribute must only be used in DDMS 2.0 or 3.0.");
if (isAtLeast30 && getDeclassManualReview() != null)
throw new InvalidDDMSException("The declassManualReview attribute must only be used in DDMS 2.0.");
for (String atomic : getAtomicEnergyMarkings())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_ATOMIC_ENERGY_MARKINGS, atomic);
if (!Util.isEmpty(getClassification())) {
if (isAtLeast30 || !ISMVocabulary.usingOldClassification(getClassification()))
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_ALL_CLASSIFICATIONS, getClassification());
}
if (!Util.isEmpty(getDeclassException())) {
if (isDDMS20) {
// In DDMS 2.0, this can be a list of tokens.
for (String value : Util.getXsListAsList(getDeclassException()))
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_DECLASS_EXCEPTION, value);
}
else
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_DECLASS_EXCEPTION, getDeclassException());
}
for (String display : getDisplayOnlyTo())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_DISPLAY_ONLY_TO, display);
for (String dissemination : getDisseminationControls())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_DISSEMINATION_CONTROLS, dissemination);
for (String fgiSourceOpen : getFGIsourceOpen())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_FGI_SOURCE_OPEN, fgiSourceOpen);
for (String fgiSourceProtected : getFGIsourceProtected())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_FGI_SOURCE_PROTECTED, fgiSourceProtected);
for (String nonIC : getNonICmarkings())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_NON_IC_MARKINGS, nonIC);
for (String nonUS : getNonUSControls())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_NON_US_CONTROLS, nonUS);
for (String op : getOwnerProducers())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_OWNER_PRODUCERS, op);
for (String releasableTo : getReleasableTo())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_RELEASABLE_TO, releasableTo);
for (String sarId : getSARIdentifier())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_SAR_IDENTIFIER, sarId);
for (String sciControls : getSCIcontrols())
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_SCI_CONTROLS, sciControls);
if (!Util.isEmpty(getTypeOfExemptedSource())) {
if (isDDMS20) {
// In DDMS 2.0, this can be a list of tokens.
for (String value : Util.getXsListAsList(getTypeOfExemptedSource()))
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_TYPE_EXEMPTED_SOURCE, value);
}
else if ("3.0".equals(version.getVersion())) {
ISMVocabulary.validateEnumeration(ISMVocabulary.CVE_TYPE_EXEMPTED_SOURCE, getTypeOfExemptedSource());
}
}
if (getDateOfExemptedSource() != null
&& !getDateOfExemptedSource().getXMLSchemaType().equals(DatatypeConstants.DATE))
throw new InvalidDDMSException(
"The dateOfExemptedSource attribute must be in the xs:date format (YYYY-MM-DD).");
if (getDeclassDate() != null && !getDeclassDate().getXMLSchemaType().equals(DatatypeConstants.DATE))
throw new InvalidDDMSException("The declassDate must be in the xs:date format (YYYY-MM-DD).");
super.validate(version);
}