@SuppressWarnings("unchecked") public T setUniverseFactoryLoader(UniverseFactoryLoader ufl) throws ProvisioningException { if(this.ufl != null) { throw new ProvisioningException("Universe factory loader has already been initialized"); } this.ufl = ufl; return (T) this; }
@Override protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException { try { ProvisioningManager mgr = getManager(invoc.getPmSession()); if (!mgr.persistChanges()) { invoc.println("No changes to persist"); } } catch (ProvisioningException ex) { throw new CommandExecutionException(ex.getMessage()); } }
@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()); } }
public Builder setUniverseResolver(UniverseResolver resolver) throws ProvisioningException { if(ufl != null) { throw new ProvisioningException("Universe factory loader has already been initialized which conflicts with the initialization of universe resolver"); } if(layoutFactory != null) { throw new ProvisioningException("Provisioning layout factory has already been initialized which conflicts with the initialization of universe resolver"); } this.resolver = resolver; return this; }
public Builder setLayoutFactory(ProvisioningLayoutFactory layoutFactory) throws ProvisioningException { if(ufl != null) { throw new ProvisioningException("Universe factory loader has already been initialized which conflicts with the initialization of provisioning layout factory"); } if(resolver != null) { throw new ProvisioningException("Universe resolver has already been initialized which conflicts with the initialization of provisioning layout factory"); } this.layoutFactory = layoutFactory; return this; }
@Override public String getLatestBuild(FeaturePackLocation fpl) throws ProvisioningException { throw new ProvisioningException("Failed to determine the latest build for " + fpl + ": operation not supported"); }
void setBatch(boolean batch) throws ProvisioningException { if(!list.isEmpty()) { throw new ProvisioningException("Can't start batch in the middle of a branch"); } this.batch = batch; }
Path getWorkDir() throws ProvisioningException { if(workDir == null) { try { workDir = Files.createTempDirectory(GLN_FP_INSTALLER); } catch (IOException e) { throw new ProvisioningException("Failed to create a tmp dir"); } } return workDir; }
private RepositoryArtifactResolver getArtifactResolver(String repositoryId) throws ProvisioningException { final RepositoryArtifactResolver artifactResolver = artifactResolvers.get(repositoryId); if(artifactResolver == null) { throw new ProvisioningException("Repository artifact resolver " + repositoryId + " has not been configured"); } return artifactResolver; }
private UniverseFactory getUniverseFactory(String factoryId) throws ProvisioningException { final UniverseFactory factory = factories.get(factoryId); if(factory == null) { throw new ProvisioningException("Universe factory " + factoryId + " has not been installed"); } return factory; }
@Override protected UniverseFactoryLoader getUfl() throws ProvisioningException { if(layoutFactory != null) { throw new ProvisioningException("Provisioning layout factory has already been initialized which conflicts with the initialization of universe factory loader"); } if(resolver != null) { throw new ProvisioningException("Universe resolver has already been initialized which conflicts with the initialization of universe factory loader"); } return super.getUfl(); } public Builder setMessageWriter(MessageWriter messageWriter) {
protected Path getResource(String... path) throws ProvisioningException { if(resourcesDir == null) { throw new ProvisioningException("Configuration does not include resources"); } if(path.length == 0) { throw new IllegalArgumentException("Resource path is null"); } if(path.length == 1) { return resourcesDir.resolve(path[0]); } Path p = resourcesDir; for(String name : path) { p = p.resolve(name); } return p; }
private static void mkdirs(final Path stagedHistoryDir) throws ProvisioningException { try { Files.createDirectories(stagedHistoryDir); } catch (IOException e) { throw new ProvisioningException(Errors.mkdirs(stagedHistoryDir), e); } }
private String toStringElem(Object elem) throws ProvisioningException { if(elem == null) { throw new ProvisioningException(Errors.illegalCapabilityElement(capSpec, null, capBuf.toString())); } final String str = elem.toString().trim(); if(str.isEmpty()) { throw new ProvisioningException(Errors.illegalCapabilityElement(capSpec, str, capBuf.toString())); } return str; } }
void setBranch(ConfigFeatureBranch branch) throws ProvisioningException { if(this.branch != null) { throw new ProvisioningException("The branch has already been set for " + spec.id); } this.branch = branch; branch.setSpecBranch(); }
private static void glnew(final Path target) throws ProvisioningException { try { IoUtils.copy(target, target.getParent().resolve(target.getFileName() + Constants.DOT_GLNEW)); } catch (IOException e) { throw new ProvisioningException("Failed to persist " + target.getParent().resolve(target.getFileName() + Constants.DOT_GLNEW), e); } }
@Override public Path resolve(String location) throws ProvisioningException { final Path path = getArtifactPath(location); if(!Files.exists(path)) { throw new ProvisioningException("Artifact " + location + " not found in the repository at " + path); } return path; }
public void removeRemoteRepository(String name) throws XMLStreamException, IOException, ProvisioningException { MavenRemoteRepository rep = repositories.remove(name); if (rep == null) { throw new ProvisioningException("Repository " + name + " doesn't exist"); } advertise(); }
private static ProvisionedConfig getRequiredProvisionedConfig(List<ProvisionedConfig> list, String model, String name) throws ProvisioningException { final ProvisionedConfig config = getProvisionedConfig(list, model, name); if(config == null) { throw new ProvisioningException("Failed to locate provisioned config " + model + "/" + name); } return config; }
private static String getModel(String model, Map<String, Map<String, Set<String>>> layersMap) throws ProvisioningException { if (model == null) { if (layersMap.isEmpty()) { throw new ProvisioningException(CliErrors.noLayers()); } if (layersMap.size() != 1) { throw new ProvisioningException(CliErrors.tooMuchModels()); } model = layersMap.keySet().iterator().next(); } return model; }