/**
* {@inheritDoc}
*/
public void uninstall(ImportOptions opts) throws RepositoryException, PackageException, IOException {
JcrPackage snap = getSnapshot();
if (snap == null) {
throw new PackageException("Unable to uninstall package. No snapshot present.");
}
if (opts.getListener() != null) {
opts.getListener().onMessage(ProgressTrackerListener.Mode.TEXT, "Uninstalling package from snapshot " + snap.getDefinition().getId(), "");
}
Session s = getNode().getSession();
// check for recursive unininstall
if (!opts.isNonRecursive()) {
Node defNode = snap.getDefNode();
LinkedList<PackageId> subPackages = new LinkedList<PackageId>();
if (defNode.hasProperty(JcrPackageDefinition.PN_SUB_PACKAGES)) {
Value[] subIds = defNode.getProperty(JcrPackageDefinition.PN_SUB_PACKAGES).getValues();
for (Value v: subIds) {
// reverse installation order
subPackages.addLast(PackageId.fromString(v.getString()));
}
}
if (subPackages.size() > 0) {
JcrPackageManagerImpl packMgr = new JcrPackageManagerImpl(s);
for (PackageId id: subPackages) {
JcrPackage pack = packMgr.open(id);
if (pack != null) {
pack.uninstall(opts);
}
}
}
}