Package org.apache.poi.openxml4j.exceptions

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


  public void setContentType(String contentType)
      throws InvalidFormatException {
    if (_container == null)
      this._contentType = new ContentType(contentType);
    else
      throw new InvalidOperationException(
          "You can't change the content type of a part.");
  }
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

  public static OPCPackage create(File file) {
    if (file == null || (file.exists() && file.isDirectory()))
      throw new IllegalArgumentException("file");

    if (file.exists()) {
      throw new InvalidOperationException(
          "This package (or file) already exists : use the open() method or delete the file.");
    }

    // Creates a new package
    OPCPackage pkg = null;
View Full Code Here

      try {
        thumbnailPartName = PackagingURIHelper
            .createPartName("/docProps/thumbnail"
                + path.substring(path.lastIndexOf(".") + 1));
      } catch (InvalidFormatException e2) {
        throw new InvalidOperationException(
            "Can't add a thumbnail file named '" + filename + "'");
      }
    }

    // Check if part already exist
    if (this.getPart(thumbnailPartName) != null)
      throw new InvalidOperationException(
          "You already add a thumbnail named '" + filename + "'");

    // Add the thumbnail part to this package.
    PackagePart thumbnailPart = this.createPart(thumbnailPartName,
        contentType, false);
View Full Code Here

   *             Throws if a writing operation is done on a read only package.
   * @see org.apache.poi.openxml4j.opc.PackageAccess
   */
  void throwExceptionIfReadOnly() throws InvalidOperationException {
    if (packageAccess == PackageAccess.READ)
      throw new InvalidOperationException(
          "Operation not allowed, document open in read only mode!");
  }
View Full Code Here

   *             Throws if a read operation is done on a write only package.
   * @see org.apache.poi.openxml4j.opc.PackageAccess
   */
  void throwExceptionIfWriteOnly() throws InvalidOperationException {
    if (packageAccess == PackageAccess.WRITE)
      throw new InvalidOperationException(
          "Operation not allowed, document open in write only mode!");
  }
View Full Code Here

    // relationship shall target the Core Properties part.
    // Note - POI will read files with more than one Core Properties, which
    //  Office sometimes produces, but is strict on generation
    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

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.