Package org.apache.poi.openxml4j.exceptions

Examples of org.apache.poi.openxml4j.exceptions.InvalidOperationException


    // A format consumer shall consider more than one core properties
    // relationship for a package to be an error. If present, the
    // relationship shall target the Core Properties part.
    if (contentType.equals(ContentTypes.CORE_PROPERTIES_PART)) {
      if (this.packageProperties != null)
        throw new InvalidOperationException(
            "OPC Compliance error [M4.1]: you try to add more than one core properties relationship in the package !");
    }

    /* End check OPC compliance */

 
View Full Code Here


      throw new IllegalArgumentException("part");
    }

    if (partList.containsKey(part._partName)) {
      if (!partList.get(part._partName).isDeleted()) {
        throw new InvalidOperationException(
            "A part with the name '"
                + part._partName.getName()
                + "' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]");
      }
      // If the specified partis flagged as deleted, we make it
View Full Code Here

    // A format consumer shall consider more than one core properties
    // relationship for a package to be an error. If present, the
    // relationship shall target the Core Properties part.
    if (relationshipType.equals(PackageRelationshipTypes.CORE_PROPERTIES)
        && this.packageProperties != null)
      throw new InvalidOperationException(
          "OPC Compliance error [M4.1]: can't add another core properties part ! Use the built-in package method instead.");

    /*
     * Check rule M1.25: The Relationships part shall not have relationships
     * to any other part. Package implementers shall enforce this
     * requirement upon the attempt to create such a relationship and shall
     * treat any such relationship as invalid.
     */
    if (targetPartName.isRelationshipPartURI()) {
      throw new InvalidOperationException(
          "Rule M1.25: The Relationships part shall not have relationships to any other part.");
    }

    /* End OPC compliance */

 
View Full Code Here

   * Validates the package compliance with the OPC specifications.
   *
   * @return <b>true</b> if the package is valid else <b>false</b>
   */
  public boolean validatePackage(OPCPackage pkg) throws InvalidFormatException {
    throw new InvalidOperationException("Not implemented yet !!!");
  }
View Full Code Here

    this.throwExceptionIfReadOnly();
   
    // You shouldn't save the the same file, do a close instead
    if(targetFile.exists() &&
            targetFile.getAbsolutePath().equals(this.originalPackagePath)) {
        throw new InvalidOperationException(
                "You can't call save(File) to save to the currently open " +
                "file. To save to the current file, please just call close()"
        );
    }
   
View Full Code Here

            deleteDefaultContentTypeFlag = false;
            break;
          }
        }
      } catch (InvalidFormatException e) {
        throw new InvalidOperationException(e.getMessage());
      }
    }

    // Remove the default content type, no other part use this content type.
    if (deleteDefaultContentTypeFlag) {
      this.defaultContentType.remove(extensionToDelete);
    }

    /*
     * Check rule 2.4: The package implementer shall require that the
     * Content Types stream contain one of the following for every part in
     * the package: One matching Default element One matching Override
     * element Both a matching Default element and a matching Override
     * element, in which case the Override element takes precedence.
     */
    if (this.container != null) {
      try {
        for (PackagePart part : this.container.getParts()) {
          if (!part.getPartName().equals(partName)
              && this.getContentType(part.getPartName()) == null)
            throw new InvalidOperationException(
                "Rule M2.4 is not respected: Nor a default element or override element is associated with the part: "
                    + part.getPartName().getName());
        }
      } catch (InvalidFormatException e) {
        throw new InvalidOperationException(e.getMessage());
      }
    }
  }
View Full Code Here

    if (relationshipType == null) {
      throw new IllegalArgumentException("relationshipType");
    }

    if (this._isRelationshipPart || targetPartName.isRelationshipPartURI()) {
      throw new InvalidOperationException(
          "Rule M1.25: The Relationships part shall not have relationships to any other part.");
    }

    if (_relationships == null) {
      _relationships = new PackageRelationshipCollection();
View Full Code Here

    // Try to retrieve the target part

    if (this._isRelationshipPart
        || PackagingURIHelper.isRelationshipPartURI(targetURI)) {
      throw new InvalidOperationException(
          "Rule M1.25: The Relationships part shall not have relationships to any other part.");
    }

    if (_relationships == null) {
      _relationships = new PackageRelationshipCollection();
View Full Code Here

      // Create a memory part
      PackagePart part = _container.createPart(this._partName,
          this._contentType.toString(), false);
      if (part == null) {
          throw new InvalidOperationException(
                  "Can't create a temporary part !");
      }
      part._relationships = this._relationships;
      outStream = part.getOutputStreamImpl();
    } else {
View Full Code Here

   *             If this part is a relationship part.
   */
  private void throwExceptionIfRelationship()
      throws InvalidOperationException {
    if (this._isRelationshipPart)
      throw new InvalidOperationException(
          "Can do this operation on a relationship part !");
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.openxml4j.exceptions.InvalidOperationException

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.