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());
}
}
}