use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class SpecOnlyConfigArranger method orderFeatures.
public List<ResolvedFeature> orderFeatures(ConfigModelStack stack) throws ProvisioningException {
this.specFeatures = stack.specFeatures;
this.features = stack.features;
try {
doOrder(stack.rt);
} catch (ProvisioningException e) {
throw new ProvisioningException(Errors.failedToBuildConfigSpec(stack.id.getModel(), stack.id.getName()), e);
}
return orderedFeatures;
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class LegacyGalleon1FeaturePackInstaller method install.
@Override
public void install(Universe<?> universe, FeaturePackLocation.FPID fpid, Path fpZip) throws ProvisioningException {
final LegacyGalleon1Universe mvnUni = (LegacyGalleon1Universe) universe;
final ChannelSpec channel = fpid.getChannel();
final LegacyGalleon1Producer producer = mvnUni.getProducer(channel.getProducer());
// make sure the channel exists
producer.getChannel(channel.getName());
if (!(mvnUni.artifactResolver instanceof RepositoryArtifactInstaller)) {
throw new ProvisioningException(mvnUni.artifactResolver.getClass().getName() + " is not an instance of " + LegacyGalleon1RepositoryManager.class.getName());
}
((RepositoryArtifactInstaller) mvnUni.artifactResolver).install(LegacyGalleon1Universe.toMavenCoords(fpid.getLocation()), fpZip);
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class LegacyGalleon1RepositoryManager method install.
public void install(String coords, Path artifact) throws ProvisioningException {
try {
final Path path = getArtifactPath(coords);
Files.createDirectories(path.getParent());
if (Files.isDirectory(artifact)) {
ZipUtils.zip(artifact, path);
} else {
Files.copy(artifact, path, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException ex) {
throw new ProvisioningException("Failed to install artifact " + coords + " to " + artifact, ex);
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class StateHistoryUtils method addNewUndoConfig.
public static void addNewUndoConfig(Path installDir, Path stagedDir, Map<String, Boolean> undoTasks, MessageWriter log) throws ProvisioningException {
final Path installedConfig = PathsUtils.getProvisioningXml(installDir);
if (!Files.exists(installedConfig)) {
return;
}
final Path stagedHistoryDir = PathsUtils.getStateHistoryDir(stagedDir);
mkdirs(stagedHistoryDir);
final Path installedHistoryDir = PathsUtils.getStateHistoryDir(installDir);
List<String> installedHistory = Collections.emptyList();
if (Files.exists(installedHistoryDir)) {
final Path installHistoryList = installedHistoryDir.resolve(Constants.HISTORY_LIST);
if (Files.exists(installHistoryList)) {
try {
installedHistory = Files.readAllLines(installHistoryList);
} catch (IOException e) {
throw new ProvisioningException(Errors.readFile(installHistoryList), e);
}
}
}
final int historyLimit = installedHistory.isEmpty() ? STATE_HISTORY_LIMIT : Integer.parseInt(installedHistory.get(0));
final String newStateId = UUID.randomUUID().toString();
try (BufferedWriter writer = Files.newBufferedWriter(stagedHistoryDir.resolve(Constants.HISTORY_LIST))) {
writer.write(String.valueOf(historyLimit));
writer.newLine();
if (!installedHistory.isEmpty()) {
int offset = installedHistory.size() - historyLimit + 1;
if (offset < 1) {
offset = 1;
}
int missingStates = 0;
while (offset < installedHistory.size()) {
final String stateId = installedHistory.get(offset++);
final Path stateFile = installedHistoryDir.resolve(stateId);
if (!Files.exists(stateFile)) {
++missingStates;
continue;
}
IoUtils.copy(stateFile, stagedHistoryDir.resolve(stateId));
writer.write(stateId);
writer.newLine();
}
if (missingStates > 0) {
log.error("The state history of the current installation is corrupted referencing " + missingStates + " missing states!");
}
}
if (historyLimit > 0) {
writer.write(newStateId);
}
} catch (IOException e) {
throw new ProvisioningException(Errors.writeFile(stagedHistoryDir.resolve(Constants.HISTORY_LIST)), e);
}
final Path stateDir = stagedHistoryDir.resolve(newStateId);
try {
Files.createDirectory(stateDir);
} catch (IOException e) {
throw new ProvisioningException(Errors.mkdirs(stateDir));
}
try {
IoUtils.copy(installedConfig, stateDir.resolve(Constants.PROVISIONING_XML));
} catch (IOException e) {
throw new ProvisioningException(Errors.copyFile(installedConfig, stateDir.resolve(Constants.PROVISIONING_XML)), e);
}
if (!undoTasks.isEmpty()) {
log.verbose("Persisting undo tasks: ");
try (BufferedWriter writer = Files.newBufferedWriter(stateDir.resolve(Constants.UNDO_TASKS))) {
for (Map.Entry<String, Boolean> entry : undoTasks.entrySet()) {
final String action = entry.getValue() ? Constants.KEEP : Constants.REMOVE;
log.verbose(" - %s %s", entry.getKey(), action);
writer.write(entry.getKey());
writer.newLine();
writer.write(action);
writer.newLine();
}
} catch (IOException e) {
throw new ProvisioningException(Errors.writeFile(stateDir.resolve(Constants.UNDO_TASKS)), e);
}
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class StateHistoryUtils method removeLastUndoConfig.
public static void removeLastUndoConfig(Path installDir, Path stagedDir, MessageWriter log) throws ProvisioningException {
final Path installedConfig = PathsUtils.getProvisioningXml(installDir);
if (!Files.exists(installedConfig)) {
return;
}
final Path installedHistoryDir = PathsUtils.getStateHistoryDir(installDir);
List<String> installedHistory = Collections.emptyList();
if (Files.exists(installedHistoryDir)) {
final Path installHistoryList = installedHistoryDir.resolve(Constants.HISTORY_LIST);
if (Files.exists(installHistoryList)) {
try {
installedHistory = Files.readAllLines(installHistoryList);
} catch (IOException e) {
throw new ProvisioningException(Errors.readFile(installHistoryList), e);
}
}
}
if (installedHistory.size() < 2) {
return;
}
final Path stagedHistoryDir = PathsUtils.getStateHistoryDir(stagedDir);
mkdirs(stagedHistoryDir);
final int historyLimit = installedHistory.isEmpty() ? STATE_HISTORY_LIMIT : Integer.parseInt(installedHistory.get(0));
try (BufferedWriter writer = Files.newBufferedWriter(stagedHistoryDir.resolve(Constants.HISTORY_LIST))) {
writer.write(String.valueOf(historyLimit));
writer.newLine();
if (!installedHistory.isEmpty()) {
int offset = installedHistory.size() - historyLimit - 1;
if (offset < 1) {
offset = 1;
}
int missingStates = 0;
while (offset < installedHistory.size() - 1) {
final String stateId = installedHistory.get(offset++);
final Path stateDir = installedHistoryDir.resolve(stateId);
if (!Files.exists(stateDir)) {
++missingStates;
continue;
}
IoUtils.copy(stateDir, stagedHistoryDir.resolve(stateId));
writer.write(stateId);
writer.newLine();
}
if (missingStates > 0) {
log.error("The state history of the current installation is corrupted referencing " + missingStates + " missing states!");
}
}
} catch (IOException e) {
throw new ProvisioningException(Errors.writeFile(stagedHistoryDir.resolve(Constants.HISTORY_LIST)), e);
}
}
Aggregations