/**
* {@inheritDoc}
*/
public void rewrap(JcrPackage pack, ProgressTrackerListener listener)
throws PackageException, RepositoryException, IOException {
VaultPackage src = pack.getPackage();
Calendar now = Calendar.getInstance();
pack.verifyId(true, false);
JcrPackageDefinitionImpl def = (JcrPackageDefinitionImpl) pack.getDefinition();
def.sealForRewrap(now, true);
ExportOptions opts = new ExportOptions();
opts.setMetaInf(def.getMetaInf());
opts.setListener(listener);
opts.setPostProcessor(def.getInjectProcessor());
VaultPackage dst = rewrap(opts, src, (File) null);
// update this content
Node packNode = pack.getNode();
Node contentNode = packNode.getNode(JcrConstants.JCR_CONTENT);
InputStream in;
try {
in = FileUtils.openInputStream(dst.getFile());
} catch (IOException e) {
throw new PackageException(e);
}
// stay jcr 1.0 compatible
//noinspection deprecation
contentNode.setProperty(JcrConstants.JCR_DATA, in);
contentNode.setProperty(JcrConstants.JCR_LASTMODIFIED, now);
contentNode.setProperty(JcrConstants.JCR_MIMETYPE, JcrPackage.MIME_TYPE);
packNode.save();
dst.close();
}