Package buri.ddmsence.ddms

Examples of buri.ddmsence.ddms.InvalidDDMSException


    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);
  }
View Full Code Here


   * @throws InvalidDDMSException if there is no classification.
   */
  public void requireClassification() throws InvalidDDMSException {
    Util.requireDDMSValue(CLASSIFICATION_NAME, getClassification());
    if (getOwnerProducers().size() == 0)
      throw new InvalidDDMSException("At least 1 ownerProducer must exist.");
  }
View Full Code Here

   * @see AbstractRoleEntity#validate()
   */
  protected void validate() throws InvalidDDMSException {
    Util.requireDDMSQName(getXOMElement(), Organization.getName(getDDMSVersion()));
    if (!getDDMSVersion().isAtLeast("4.0.1") && !Util.isEmpty(getAcronym()))
      throw new InvalidDDMSException("An organization must not have an acronym until DDMS 4.0.1 or later.");
    if (getDDMSVersion().isAtLeast("5.0") && !getExtensibleAttributes().isEmpty())
      throw new InvalidDDMSException("ddms:" + getName() + " must not have extensible attributes after DDMS 4.1.");
    super.validate();
  }
View Full Code Here

    public BoundingBox commit() throws InvalidDDMSException {
      if (isEmpty())
        return (null);
      // Check for existence of values before casting to primitives.
      if (getWestBL() == null || getEastBL() == null || getSouthBL() == null || getNorthBL() == null)
        throw new InvalidDDMSException("A ddms:boundingBox must have two latitude and two longitude values.");
      return (new BoundingBox(getWestBL().doubleValue(), getEastBL().doubleValue(), getSouthBL().doubleValue(),
        getNorthBL().doubleValue()));
    }
View Full Code Here

   */
  protected void validate() throws InvalidDDMSException {
    Util.requireDDMSQName(getXOMElement(), BoundingGeometry.getName(getDDMSVersion()));
    if (!getDDMSVersion().isAtLeast("5.0")) {
      if (getGmlPolygons().size() + getGmlPoints().size() == 0) {
        throw new InvalidDDMSException("At least 1 of Polygon or Point must be used.");
      }
    }
    else {
      if (getGmlPolygons().size() + getGmlPoints().size() > 0) {
        throw new InvalidDDMSException("boundingGeometry must be defined with TSPI shapes.");
      }
      if (getTspiShapes().isEmpty())
        throw new InvalidDDMSException("At least 1 TSPI shape must exist.");
    }
    super.validate();
  }
View Full Code Here

    Util.requireDDMSValue(ID_NAME, getId());
    Util.requireValidNCName(getId());
    Util.requireDDMSValue("position", getPosition());
    String srsName = getPosition().getSRSAttributes().getSrsName();
    if (!Util.isEmpty(srsName) && !srsName.equals(getSRSAttributes().getSrsName()))
      throw new InvalidDDMSException("The srsName of the position must match the srsName of the Point.");
    super.validate();
  }
View Full Code Here

    List<Position> positions = getPositions();
    for (Position pos : positions) {
      if (pos.getSRSAttributes() != null) {
        String srsName = pos.getSRSAttributes().getSrsName();
        if (!Util.isEmpty(srsName) && !srsName.equals(getSRSAttributes().getSrsName()))
          throw new InvalidDDMSException(
            "The srsName of each position must match the srsName of the Polygon.");
      }
    }
    if (positions.size() < 4)
      throw new InvalidDDMSException("At least 4 positions must exist for a valid Polygon.");
    if (!positions.isEmpty() && !positions.get(0).equals(positions.get(positions.size() - 1))) {
      throw new InvalidDDMSException("The first and last position in the Polygon must be the same.");
    }
    super.validate();
  }
View Full Code Here

  protected void validate() throws InvalidDDMSException {
    Util.requireQName(getXOMElement(), getNamespace(), Position.getName(getDDMSVersion()));
    for (Double coordinate : getCoordinates())
      Util.requireDDMSValue("coordinate", coordinate);
    if (!Util.isBounded(getCoordinates().size(), 2, 3))
      throw new InvalidDDMSException("A position must be represented by either 2 or 3 coordinates.");
    Util.requireValidLatitude(getCoordinates().get(0));
    Util.requireValidLongitude(getCoordinates().get(1));
    super.validate();
  }
View Full Code Here

  protected void validate() throws InvalidDDMSException {
    requireAtLeastVersion("4.0.1");
    requireAtMostVersion("4.1");
    Util.requireDDMSQName(getXOMElement(), NoticeList.getName(getDDMSVersion()));
    if (getNotices().isEmpty())
      throw new InvalidDDMSException("At least one ism:Notice must exist within a ddms:noticeList element.");
    getSecurityAttributes().requireClassification();
    super.validate();
  }
View Full Code Here

    Util.requireDDMSValue("Subject element", subjectElement);
    String namespace = subjectElement.getNamespaceURI();
    int count = subjectElement.getChildElements(Keyword.getName(getDDMSVersion()), namespace).size()
      + subjectElement.getChildElements(Category.getName(getDDMSVersion()), namespace).size();
    if (count < 1)
      throw new InvalidDDMSException("At least 1 keyword or category must exist.");
    if (!getDDMSVersion().isAtLeast("3.0") && !getSecurityAttributes().isEmpty()) {
      throw new InvalidDDMSException(
        "Security attributes must not be applied to this component until DDMS 3.0 or later.");
    }
    super.validate();
  }
View Full Code Here

TOP

Related Classes of buri.ddmsence.ddms.InvalidDDMSException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.