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 (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

      ZipFile zipFile = null;

      try {
        zipFile = ZipHelper.openZipFile(path);
      } catch (IOException e) {
        throw new InvalidOperationException(
            "Can't open the specified file: '" + path + "'", e);
      }

      this.zipArchive = new ZipFileZipEntrySource(zipFile);
    }
View Full Code Here

      ZipFile zipFile = null;

      try {
        zipFile = ZipHelper.openZipFile(file);
      } catch (IOException e) {
        throw new InvalidOperationException(
            "Can't open the specified file: '" + file + "'", e);
      }

      this.zipArchive = new ZipFileZipEntrySource(zipFile);
    }
View Full Code Here

                    + targetFile.getAbsolutePath()
                    + "' cannot be deleted ! Make sure that no other application use it.");
          }
        }
      } else {
        throw new InvalidOperationException(
            "Can't close a package not previously open with the open() method !");
      }
    }
  }
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.