Package org.openxml4j.exceptions

Examples of org.openxml4j.exceptions.InvalidOperationException


  /**
   * Save this document in the specified file.
   */
  public void save(File file) throws IOException {
    throw new InvalidOperationException("Method not implemented !");
  }
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

  ZipPackage(String path, PackageAccess access) throws InvalidFormatException {
    super(access);
   
    ZipFile zipFile = ZipHelper.openZipFile(path);
    if (zipFile == null)
      throw new InvalidOperationException(
          "Can't open the specified file: '" + path + "'");
    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

            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

      // Create a memory part
      PackagePart part = container.createPart(this.partName,
          this.contentType.toString(), false);
      part.relationships = this.relationships;
      if (part == null) {
        throw new InvalidOperationException(
            "Can't create a temporary part !");
      }
      outStream = part.getOutputStreamImpl();
    } else {
      outStream = this.getOutputStreamImpl();
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

  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

TOP

Related Classes of org.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.