Example usage for org.apache.poi.openxml4j.opc OPCPackage getParts

List of usage examples for org.apache.poi.openxml4j.opc OPCPackage getParts

Introduction

In this page you can find the example usage for org.apache.poi.openxml4j.opc OPCPackage getParts.

Prototype

public ArrayList<PackagePart> getParts() throws InvalidFormatException 

Source Link

Document

Load the parts of the archive if it has not been done yet.

Usage

From source file:test.unit.be.fedict.eid.applet.service.signer.OOXMLSignatureVerifierTest.java

License:Open Source License

@Test
public void testOPC() throws Exception {
    // setup// w  w w.  j  a v a  2s  .com
    InputStream inputStream = OOXMLSignatureVerifierTest.class.getResourceAsStream("/hello-world-signed.docx");

    // operate
    OPCPackage opcPackage = OPCPackage.open(inputStream);

    ArrayList<PackagePart> parts = opcPackage.getParts();
    for (PackagePart part : parts) {
        LOG.debug("part name: " + part.getPartName().getName());
        LOG.debug("part content type: " + part.getContentType());
    }

    ArrayList<PackagePart> signatureParts = opcPackage
            .getPartsByContentType("application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml");
    assertFalse(signatureParts.isEmpty());

    PackagePart signaturePart = signatureParts.get(0);
    LOG.debug("signature part class type: " + signaturePart.getClass().getName());

    PackageDigitalSignatureManager packageDigitalSignatureManager = new PackageDigitalSignatureManager();
    // yeah... POI implementation still missing
}