use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method processIncludedFeatures.
void processIncludedFeatures(final ResolvedFeatureGroupConfig pushedFgConfig) throws ProvisioningException {
if (pushedFgConfig.includedFeatures.isEmpty()) {
return;
}
for (Map.Entry<ResolvedFeatureId, FeatureConfig> feature : pushedFgConfig.includedFeatures.entrySet()) {
final FeatureConfig includedFc = feature.getValue();
if (includedFc != null && includedFc.hasParams()) {
final ResolvedFeatureId includedId = feature.getKey();
if (pushedFgConfig.configStack.isFilteredOut(includedId.specId, includedId)) {
continue;
}
// make sure the included ID is in fact present on the feature group branch
if (!pushedFgConfig.configStack.includes(includedId)) {
throw new ProvisioningException(Errors.featureNotInScope(includedId, pushedFgConfig.fg.getId() == null ? "'anonymous'" : pushedFgConfig.fg.getId().toString(), currentOrigin == null ? null : currentOrigin.producer.getLocation().getFPID()));
}
resolveFeature(pushedFgConfig.configStack, includedFc);
}
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method resolveConfigLayer.
private ConfigModelStack resolveConfigLayer(ConfigId layerId) throws ProvisioningException {
ConfigModelStack layerStack = layers.get(layerId);
if (layerStack == null) {
layerStack = new ConfigModelStack(layerId, this);
boolean resolved = false;
for (FeaturePackConfig fpConfig : config.getFeaturePackDeps()) {
resolved |= resolveConfigLayer(fpConfig.getLocation().getProducer(), layerStack, layerId);
}
clearFlag(FeaturePackRuntimeBuilder.RESOLVE_LAYER);
if (!resolved) {
throw new ProvisioningException(Errors.layerNotFound(layerId));
}
layers = CollectionUtils.put(layers, layerId, layerStack);
}
return layerStack;
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method processConfigLayer.
private void processConfigLayer(ConfigModelStack configStack, FeatureGroupSupport layer) throws ProvisioningException {
this.configStack = configStack;
try {
if (layer.hasPackageDeps()) {
processPackageDeps(layer, null);
}
processConfigItemContainer(layer);
this.configStack = null;
} catch (ProvisioningException e) {
throw new ProvisioningException(Errors.failedToResolveConfigLayer(configStack.id.getModel(), layer.getName()), e);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FsDiff method addFsEntry.
private static Map<String, Boolean> addFsEntry(Path home, FsEntry added, Map<String, Boolean> undoTasks, MessageWriter log) throws ProvisioningException {
final Path target = home.resolve(added.getRelativePath());
char action = ADDED;
String warning = null;
if (Files.exists(target)) {
if (added.isDir()) {
for (FsEntry child : added.getChildren()) {
if (child.isDiffStatusSuppressed()) {
continue;
}
undoTasks = addFsEntry(home, child, undoTasks, log);
}
return undoTasks;
}
final byte[] targetHash;
try {
targetHash = HashUtils.hashPath(target);
} catch (IOException e) {
throw new ProvisioningException(Errors.hashCalculation(target), e);
}
if (Arrays.equals(added.getHash(), targetHash)) {
if (!addedPathMatchesExisting(added)) {
action = REPLAY_SKIP;
} else {
warning = MATCHES_THE_UPDATED_VERSION;
action = MODIFIED;
}
undoTasks = CollectionUtils.putLinked(undoTasks, added.getRelativePath(), true);
} else if (addedPathConflict(added) && !added.isDir()) {
warning = CONFLICTS_WITH_THE_UPDATED_VERSION;
glnew(target);
action = MODIFIED;
}
}
if (action != REPLAY_SKIP) {
log.print(formatMessage(action, added.getRelativePath(), warning));
try {
IoUtils.copy(added.getPath(), target);
} catch (IOException e) {
throw new ProvisioningException(Errors.copyFile(added.getPath(), target), e);
}
}
return undoTasks;
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FsDiff method replay.
public static Map<String, Boolean> replay(FsDiff diff, Path home, MessageWriter log) throws ProvisioningException {
log.print("Replaying your changes on top");
Map<String, Boolean> undoTasks = Collections.emptyMap();
if (diff.hasRemovedEntries()) {
for (FsEntry removed : diff.getRemovedEntries()) {
if (removed.isDiffStatusSuppressed()) {
continue;
}
final Path target = home.resolve(removed.getRelativePath());
if (Files.exists(target)) {
log.print(formatMessage(REMOVED, removed.getRelativePath(), null));
IoUtils.recursiveDelete(target);
} else {
log.verbose(formatMessage(REMOVED, removed.getRelativePath(), HAS_BEEN_REMOVED_FROM_THE_UPDATED_VERSION));
undoTasks = CollectionUtils.putLinked(undoTasks, removed.getRelativePath(), false);
}
}
}
if (diff.hasAddedEntries()) {
for (FsEntry added : diff.getAddedEntries()) {
if (added.isDiffStatusSuppressed()) {
continue;
}
undoTasks = addFsEntry(home, added, undoTasks, log);
}
}
if (diff.hasModifiedEntries()) {
for (FsEntry[] modified : diff.getModifiedEntries()) {
if (modified[0].isDiffStatusSuppressed()) {
continue;
}
final FsEntry update = modified[1];
final Path target = home.resolve(update.getRelativePath());
char action = MODIFIED;
String warning = null;
if (Files.exists(target)) {
final byte[] targetHash;
try {
targetHash = HashUtils.hashPath(target);
} catch (IOException e) {
throw new ProvisioningException(Errors.hashCalculation(target), e);
}
if (Arrays.equals(update.getHash(), targetHash)) {
if (!modifiedPathMatchesExisting(update)) {
action = REPLAY_SKIP;
}
undoTasks = CollectionUtils.putLinked(undoTasks, update.getRelativePath(), true);
} else if (!Arrays.equals(modified[0].getHash(), targetHash)) {
if (modifiedPathUpdated(update)) {
warning = HAS_CHANGED_IN_THE_UPDATED_VERSION;
glnew(target);
} else {
action = REPLAY_SKIP;
}
} else if (modifiedPathConflict(update)) {
glnew(target);
} else {
action = REPLAY_SKIP;
}
} else if (modifiedPathNotPresent(update)) {
warning = HAS_BEEN_REMOVED_FROM_THE_UPDATED_VERSION;
action = ADDED;
} else {
action = REPLAY_SKIP;
}
if (action != REPLAY_SKIP) {
log.print(formatMessage(action, update.getRelativePath(), warning));
try {
IoUtils.copy(update.getPath(), target);
} catch (IOException e) {
throw new ProvisioningException(Errors.copyFile(update.getPath(), target), e);
}
}
}
}
return undoTasks;
}
Aggregations