* @throws PackageException if an error occurrs.
* @throws IOException if an error occurrs.
*/
private JcrPackage snapshot(ExportOptions opts, boolean replace, AccessControlHandling acHandling)
throws RepositoryException, PackageException, IOException {
PackageId id = getSnapshotId();
Node packNode = getPackageNode(id);
if (packNode != null) {
if (!replace) {
log.warn("Refusing to recreate snapshot {}, already exists.", id);
return null;
} else {
packNode.remove();
node.getSession().save();
}
}
log.info("Creating snapshot for {}.", id);
JcrPackageManagerImpl packMgr = new JcrPackageManagerImpl(node.getSession());
String path = id.getInstallationPath();
String parentPath = Text.getRelativeParent(path, 1);
Node folder = packMgr.mkdir(parentPath, true);
JcrPackage snap = JcrPackageImpl.createNew(folder, id, null, true);
JcrPackageDefinitionImpl snapDef = (JcrPackageDefinitionImpl) snap.getDefinition();
JcrPackageDefinitionImpl myDef = (JcrPackageDefinitionImpl) getDefinition();