private RelationshipsPart getRelationshipsPartFromZip(Base p, ZipFile zf, String partName) throws Docx4JException { // Document contents = null; // try { // contents = getDocumentFromZippedPart( zf, partName); // } catch (Exception e) { // e.printStackTrace(); // throw new Docx4JException("Error getting document from Zipped Part", e); // // } // // debugPrint(contents); // // TODO - why don't any of the part names in this document start with "/"? // return new RelationshipsPart( p, new PartName("/" + partName), contents ); RelationshipsPart rp = null; InputStream is = null; try { is = getInputStreamFromZippedPart(zf, partName); // thePart = new RelationshipsPart( p, new PartName("/" + partName), is ); rp = new RelationshipsPart(new PartName("/" + partName)); rp.setSourceP(p); rp.unmarshal(is); } catch (Exception e) { e.printStackTrace(); throw new Docx4JException("Error getting document from Zipped Part:" + partName, e); } finally { if (is != null) { try { is.close(); } catch (IOException exc) { exc.printStackTrace(); } } } return rp; // debugPrint(contents); // TODO - why don't any of the part names in this document start with "/"? }
private RelationshipsPart getRelationshipsPartFromZip(Base p, String partName) throws Docx4JException { RelationshipsPart rp = null; InputStream is = null; try { is = partStore.loadPart(partName); if (is == null) { return null; // that's ok } rp = new RelationshipsPart(new PartName("/" + partName)); rp.setSourceP(p); rp.unmarshal(is); } catch (Exception e) { e.printStackTrace(); throw new Docx4JException("Error getting document from Zipped Part:" + partName, e); } finally { IOUtils.closeQuietly(is); } return rp; }