Lines 597-604
Link Here
|
597 |
} |
597 |
} |
598 |
|
598 |
|
599 |
/** |
599 |
/** |
600 |
* Load the parts of the archive if it has not been done yet The |
600 |
* Load the parts of the archive if it has not been done yet. The |
601 |
* relationships of each part are not loaded |
601 |
* relationships of each part are not loaded. |
|
|
602 |
* NOTE: Compliance with Rule M4.1 has been relaxed. The first |
603 |
* CoreProperties part encountered will be used; any further |
604 |
* CoreProperties parts are silently ignored. |
602 |
* |
605 |
* |
603 |
* @return All this package's parts. |
606 |
* @return All this package's parts. |
604 |
*/ |
607 |
*/ |
Lines 612-639
Link Here
|
612 |
// Ensure rule M4.1 -> A format consumer shall consider more than |
615 |
// Ensure rule M4.1 -> A format consumer shall consider more than |
613 |
// one core properties relationship for a package to be an error |
616 |
// one core properties relationship for a package to be an error |
614 |
boolean hasCorePropertiesPart = false; |
617 |
boolean hasCorePropertiesPart = false; |
|
|
618 |
boolean needCorePropertiesPart = true; |
615 |
|
619 |
|
616 |
PackagePart[] parts = this.getPartsImpl(); |
620 |
PackagePart[] parts = this.getPartsImpl(); |
617 |
this.partList = new PackagePartCollection(); |
621 |
this.partList = new PackagePartCollection(); |
618 |
for (PackagePart part : parts) { |
622 |
for (PackagePart part : parts) { |
619 |
if (partList.containsKey(part._partName)) |
623 |
if (partList.containsKey(part._partName)) |
620 |
throw new InvalidFormatException( |
624 |
throw new InvalidFormatException( |
621 |
"A part with the name '" |
625 |
"A part with the name '" + |
622 |
+ part._partName |
626 |
part._partName + |
623 |
+ "' already exist : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]"); |
627 |
"' already exist : Packages shall not contain equivalent " + |
|
|
628 |
"part names and package implementers shall neither create " + |
629 |
"nor recognize packages with equivalent part names. [M1.12]"); |
624 |
|
630 |
|
625 |
// Check OPC compliance rule M4.1 |
631 |
// Check OPC compliance rule M4.1 |
626 |
if (part.getContentType().equals( |
632 |
if (part.getContentType().equals( |
627 |
ContentTypes.CORE_PROPERTIES_PART)) { |
633 |
ContentTypes.CORE_PROPERTIES_PART)) { |
628 |
if (!hasCorePropertiesPart) |
634 |
if (!hasCorePropertiesPart) |
629 |
hasCorePropertiesPart = true; |
635 |
hasCorePropertiesPart = true; |
630 |
else |
636 |
//else |
631 |
throw new InvalidFormatException( |
637 |
// throw new InvalidFormatException( |
632 |
"OPC Compliance error [M4.1]: there is more than one core properties relationship in the package !"); |
638 |
// "OPC Compliance error [M4.1]: there is more than one core properties relationship in the package !"); |
633 |
} |
639 |
} |
634 |
|
640 |
|
635 |
PartUnmarshaller partUnmarshaller = partUnmarshallers |
641 |
PartUnmarshaller partUnmarshaller = partUnmarshallers.get(part._contentType); |
636 |
.get(part._contentType); |
|
|
637 |
|
642 |
|
638 |
if (partUnmarshaller != null) { |
643 |
if (partUnmarshaller != null) { |
639 |
UnmarshallContext context = new UnmarshallContext(this, |
644 |
UnmarshallContext context = new UnmarshallContext(this, |
Lines 643-651
Link Here
|
643 |
.unmarshall(context, part.getInputStream()); |
648 |
.unmarshall(context, part.getInputStream()); |
644 |
partList.put(unmarshallPart._partName, unmarshallPart); |
649 |
partList.put(unmarshallPart._partName, unmarshallPart); |
645 |
|
650 |
|
646 |
// Core properties case |
651 |
// Core properties case-- use first CoreProperties part we come across |
647 |
if (unmarshallPart instanceof PackagePropertiesPart) |
652 |
// and ignore any subsequent ones |
|
|
653 |
if (unmarshallPart instanceof PackagePropertiesPart && |
654 |
hasCorePropertiesPart && |
655 |
needCorePropertiesPart) { |
648 |
this.packageProperties = (PackagePropertiesPart) unmarshallPart; |
656 |
this.packageProperties = (PackagePropertiesPart) unmarshallPart; |
|
|
657 |
needCorePropertiesPart = false; |
658 |
} |
649 |
} catch (IOException ioe) { |
659 |
} catch (IOException ioe) { |
650 |
logger.log(POILogger.WARN, "Unmarshall operation : IOException for " |
660 |
logger.log(POILogger.WARN, "Unmarshall operation : IOException for " |
651 |
+ part._partName); |
661 |
+ part._partName); |