public static void clearStateHistory(Path installDir, MessageWriter log) throws ProvisioningException { final Path installedHistoryDir = PathsUtils.getStateHistoryDir(installDir); if (!Files.exists(installedHistoryDir)) { return; } int limit = readStateHistoryLimit(installDir, log); final Path installedHistoryList = installedHistoryDir.resolve(Constants.HISTORY_LIST); try (BufferedWriter writer = Files.newBufferedWriter(installedHistoryList)) { writer.write(String.valueOf(limit)); writer.newLine(); } catch (IOException e) { throw new ProvisioningException(Errors.writeFile(installedHistoryList), e); } deleteHistoryFiles(installedHistoryDir); }
throw new ProvisioningException(Errors.writeFile(stagedHistoryDir.resolve(Constants.HISTORY_LIST)), e);
/** * Add named universe spec to the provisioning configuration * * @param name universe name * @param universeSpec universe spec * @throws ProvisioningException in case of an error */ public void addUniverse(String name, UniverseSpec universeSpec) throws ProvisioningException { final ProvisioningConfig config = ProvisioningConfig.builder(getProvisioningConfig()).addUniverse(name, universeSpec).build(); try { ProvisioningXmlWriter.getInstance().write(config, PathsUtils.getProvisioningXml(home)); } catch (Exception e) { throw new ProvisioningException(Errors.writeFile(PathsUtils.getProvisioningXml(home)), e); } this.provisioningConfig = config; }
/** * Removes universe spec associated with the name from the provisioning configuration * @param name name of the universe spec or null for the default universe spec * @throws ProvisioningException in case of an error */ public void removeUniverse(String name) throws ProvisioningException { ProvisioningConfig config = getProvisioningConfig(); if(config == null || !config.hasUniverse(name)) { return; } config = ProvisioningConfig.builder(config).removeUniverse(name).build(); try { ProvisioningXmlWriter.getInstance().write(config, PathsUtils.getProvisioningXml(home)); } catch (Exception e) { throw new ProvisioningException(Errors.writeFile(PathsUtils.getProvisioningXml(home)), e); } this.provisioningConfig = config; }
ProvisioningXmlWriter.getInstance().write(config, PathsUtils.getProvisioningXml(stagedDir)); } catch (XMLStreamException | IOException e) { throw new FeaturePackInstallException(Errors.writeFile(PathsUtils.getProvisioningXml(stagedDir)), e); ProvisionedStateXmlWriter.getInstance().write(this, PathsUtils.getProvisionedStateXml(stagedDir)); } catch (XMLStreamException | IOException e) { throw new FeaturePackInstallException(Errors.writeFile(PathsUtils.getProvisionedStateXml(stagedDir)), e);