use of org.jboss.galleon.diff.FsDiff in project galleon by wildfly.
the class FsEntriesTestBase method assertIdentical.
protected void assertIdentical(FsEntry expected, FsEntry actual) throws ProvisioningException {
final FsDiff diff = FsDiff.diff(expected, actual);
if (diff.isEmpty()) {
return;
}
fail(diff.toString());
}
use of org.jboss.galleon.diff.FsDiff in project galleon by wildfly.
the class GetChangesCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
try {
ProvisioningManager mgr = getManager(invoc.getPmSession());
FsDiff diff = mgr.getFsDiff();
if (diff.isEmpty()) {
invoc.println("No changes detected");
} else {
Path workingDir = Paths.get(invoc.getConfiguration().getAeshContext().getCurrentWorkingDirectory().getAbsolutePath());
Path installation = mgr.getInstallationHome();
PathResolver resolver = new PathResolver() {
@Override
public String resolve(String relativePath) {
Path absPath = Paths.get(installation.toString(), relativePath);
return workingDir.relativize(absPath).toString();
}
};
FsDiff.log(diff, new Consumer<String>() {
@Override
public void accept(String msg) {
invoc.println(msg);
}
}, resolver);
}
} catch (ProvisioningException ex) {
throw new CommandExecutionException(ex.getMessage());
}
}
use of org.jboss.galleon.diff.FsDiff in project galleon by wildfly.
the class ProvisioningManager method getDiffMergedConfig.
private ProvisioningDiffProvider getDiffMergedConfig() throws ProvisioningException {
final FsDiff diff = getFsDiff();
if (diff == null || diff.isEmpty()) {
return null;
}
try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = layoutFactory.newConfigLayout(getProvisioningConfig(), ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
final ProvisioningDiffProvider diffProvider = ProvisioningDiffProvider.newInstance(layout, getProvisionedState(), diff, log);
layout.visitPlugins(new FeaturePackPluginVisitor<StateDiffPlugin>() {
@Override
public void visitPlugin(StateDiffPlugin plugin) throws ProvisioningException {
plugin.diff(diffProvider);
}
}, StateDiffPlugin.class);
return diffProvider;
}
}
use of org.jboss.galleon.diff.FsDiff in project galleon by wildfly.
the class ProvisioningManager method getFsDiff.
/**
* Returns the status of the filesystem describing which files have been
* added, removed and modified since the last provisioning state transition.
*
* @return current status of the filesystem
* @throws ProvisioningException in case of an error during the status check
*/
public FsDiff getFsDiff() throws ProvisioningException {
final ProvisioningConfig config = getProvisioningConfig();
if (config == null || !config.hasFeaturePackDeps()) {
return null;
}
log.verbose("Detecting user changes");
final Path hashesDir = LayoutUtils.getHashesDir(getInstallationHome());
if (Files.exists(hashesDir)) {
final FsEntry originalState = new FsEntry(null, hashesDir);
readHashes(originalState, new ArrayList<>());
final FsEntry currentState = getDefaultFsEntryFactory().forPath(getInstallationHome());
return FsDiff.diff(originalState, currentState);
}
try (ProvisioningRuntime rt = getRuntime(config)) {
rt.provision();
final FsEntryFactory fsFactory = getDefaultFsEntryFactory();
final FsEntry originalState = fsFactory.forPath(rt.getStagedDir());
final FsEntry currentState = fsFactory.forPath(getInstallationHome());
final long startTime = log.isVerboseEnabled() ? System.nanoTime() : -1;
final FsDiff fsDiff = FsDiff.diff(originalState, currentState);
if (startTime != -1) {
log.verbose(Errors.tookTime(" filesystem diff", startTime));
}
return fsDiff;
}
}
use of org.jboss.galleon.diff.FsDiff in project galleon by wildfly.
the class FsDiffTestBase method assertIdentical.
protected void assertIdentical(FsEntry expected, FsEntry actual) throws ProvisioningException {
final FsDiff diff = FsDiff.diff(expected, actual);
if (diff.isEmpty()) {
return;
}
fail(diff.toString());
}
Aggregations