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

    return df.format(date);
  }

  @Override
  protected InputStream getInputStreamImpl() {
    throw new InvalidOperationException("Operation not authorized. This part may only be manipulated using the getters and setters on PackagePropertiesPart");
  }
View Full Code Here

    throw new InvalidOperationException("Operation not authorized. This part may only be manipulated using the getters and setters on PackagePropertiesPart");
  }

  @Override
  protected OutputStream getOutputStreamImpl() {
    throw new InvalidOperationException(
        "Can't use output stream to set properties !");
  }
View Full Code Here

        "Can't use output stream to set properties !");
  }

  @Override
  public boolean save(OutputStream zos) {
    throw new InvalidOperationException("Operation not authorized. This part may only be manipulated using the getters and setters on PackagePropertiesPart");
  }
View Full Code Here

    throw new InvalidOperationException("Operation not authorized. This part may only be manipulated using the getters and setters on PackagePropertiesPart");
  }

  @Override
  public boolean load(InputStream ios) {
    throw new InvalidOperationException("Operation not authorized. This part may only be manipulated using the getters and setters on PackagePropertiesPart");
  }
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 (PackagingURIHelper.PACKAGE_ROOT_URI.getPath() == partName.getURI()
        .getPath())
      return PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME;

    if (partName.isRelationshipPartURI())
      throw new InvalidOperationException("Can't be a relationship part");

    String fullPath = partName.getURI().getPath();
    String filename = getFilename(partName.getURI());
    fullPath = fullPath.substring(0, fullPath.length() - filename.length());
    fullPath = combine(fullPath,
View Full Code Here

    for (String seg : segments) {
      if (!seg.equals(""))
        concatSeg.append(PackagingURIHelper.FORWARD_SLASH_CHAR);
      concatSeg.append(seg);
      if (this.registerPartNameStr.contains(concatSeg.toString())) {
        throw new InvalidOperationException(
            "You can't add a part with a part name derived from another part ! [M1.11]");
      }
    }
    this.registerPartNameStr.add(partName.getName());
    return super.put(partName, 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.