private FeatureParameterSpec(Builder builder) throws ProvisioningDescriptionException { if (builder.featureId && builder.nillable) { throw new ProvisioningDescriptionException("ID parameter " + builder.name + " cannot be nillable."); } this.name = builder.name; this.featureId = builder.featureId; this.nillable = builder.nillable; this.defaultValue = builder.defaultValue; this.type = builder.type; }
public UniverseSpec getUniverseSpec(String name) throws ProvisioningDescriptionException { final UniverseSpec universe = name == null ? defaultUniverse : universeSpecs.get(name); if(universe == null) { throw new ProvisioningDescriptionException((name == null ? "The default" : name) + " universe was not configured"); } return universe; }
public String getElement(String elem, boolean required) throws ProvisioningDescriptionException { final String value = elems.get(elem); if(value == null) { if(required) { throw new ProvisioningDescriptionException("Annotation " + name + " is missing required element " + elem); } return null; } return value; }
public static Path getLayerSpecXml(Path fpDir, String model, String name, boolean existing) throws ProvisioningDescriptionException { Path p = fpDir.resolve(Constants.LAYERS); if(model != null) { p = p.resolve(model); } p = p.resolve(name).resolve(Constants.LAYER_SPEC_XML); if(existing && !Files.exists(p)) { throw new ProvisioningDescriptionException("Failed to locate XML file describing configuration layer " + name + " at " + p); } return p; }
public Builder removeIncludedPackage(String pkg) throws ProvisioningDescriptionException { if (!includedPackages.containsKey(pkg)) { throw new ProvisioningDescriptionException("Package " + pkg + " is not included into the configuration"); } includedPackages = CollectionUtils.remove(includedPackages, pkg); return this; }
public FeatureReferenceSpec getFeatureRef(String name) throws ProvisioningDescriptionException { final FeatureReferenceSpec ref = featureRefs.get(name); if(ref == null) { throw new ProvisioningDescriptionException(Errors.featureRefNotInSpec(name, this.name)); } return ref; }
public FeatureParameterSpec getParam(String name) throws ProvisioningDescriptionException { final FeatureParameterSpec paramSpec = params.get(name); if(paramSpec == null) { throw new ProvisioningDescriptionException(Errors.unknownFeatureParameter(this.name, name)); } return paramSpec; }
@SuppressWarnings("unchecked") public B removeExcludedDefaultConfig(ConfigId configId) throws ProvisioningDescriptionException { if (!excludedConfigs.contains(configId)) { throw new ProvisioningDescriptionException("Config model with id " + configId + " is not excluded from the configuration"); } excludedConfigs = CollectionUtils.remove(excludedConfigs, configId); return (B) this; }
public Builder removePatch(FPID patchId) throws ProvisioningDescriptionException { final int size = patches.size(); patches = CollectionUtils.remove(patches, patchId); if(size == patches.size()) { throw new ProvisioningDescriptionException("Patch " + patchId + " was not configured for " + fpl); } return this; }
private static void assertDirectory(Path dir) throws ProvisioningDescriptionException { if(!Files.isDirectory(dir)) { throw new ProvisioningDescriptionException(Errors.notADir(dir)); } }
public FeaturePackSpec build() throws ProvisioningDescriptionException { try { return new FeaturePackSpec(this); } catch(ProvisioningDescriptionException e) { throw new ProvisioningDescriptionException("Failed to build feature-pack spec for " + fpid, e); } } }
public FeatureSpec loadFeatureSpec(String name) throws ProvisioningException { final Path specXml = dir.resolve(Constants.FEATURES).resolve(name).resolve(Constants.SPEC_XML); if (!Files.exists(specXml)) { return null; } try (BufferedReader reader = Files.newBufferedReader(specXml)) { return FeatureSpecXmlParser.getInstance().parse(reader); } catch (Exception e) { throw new ProvisioningDescriptionException(Errors.parseXml(specXml), e); } }
@SuppressWarnings("unchecked") public B excludeSpec(String spec) throws ProvisioningDescriptionException { final SpecId specId = SpecId.fromString(spec); if(includedSpecs.contains(specId)) { throw new ProvisioningDescriptionException(specId + " spec has been inplicitly excluded"); } excludedSpecs = CollectionUtils.add(excludedSpecs, specId); return (B) this; }
@SuppressWarnings("unchecked") public B includeSpec(String spec) throws ProvisioningDescriptionException { final SpecId specId = SpecId.fromString(spec); if(excludedSpecs.contains(specId)) { throw new ProvisioningDescriptionException(specId + " spec has been explicitly excluded"); } includedSpecs = CollectionUtils.addLinked(includedSpecs, specId); return (B) this; }
public FeaturePackBuilder addFeatureSpec(FeatureSpec spec) throws ProvisioningDescriptionException { if (specs.isEmpty()) { specs = new HashMap<>(); } if (specs.put(spec.getName(), spec) != null) { throw new ProvisioningDescriptionException("Feature-pack " + fpBuilder.getFPID() + ": duplicate spec name " + spec.getName()); } return this; }
/** * NOTE: this method will change the current origin to the origin of the group! */ private FeatureGroup getFeatureGroupSpec(String name) throws ProvisioningException { final FeatureGroup fg = getFeatureGroupSpec(currentOrigin, name); clearVisitedFPs(); if(fg == null) { throw new ProvisioningDescriptionException("Failed to locate feature group '" + name + "' in " + (currentOrigin == null ? "the provisioning configuration" : currentOrigin.producer + " and its dependencies")); } return fg; }
public ProvisioningPlan install(FeaturePackConfig fpConfig) throws ProvisioningDescriptionException { final ProducerSpec producer = fpConfig.getLocation().getProducer(); if(uninstall.contains(producer) || updates.containsKey(producer)) { throw new ProvisioningDescriptionException(producer + " has already been added to the plan"); } install = CollectionUtils.putLinked(install, producer, fpConfig); return this; }
public ProvisioningPlan update(FeaturePackUpdatePlan fpPlan) throws ProvisioningDescriptionException { final ProducerSpec producer = fpPlan.getInstalledLocation().getProducer(); if(install.containsKey(producer) || uninstall.contains(producer)) { throw new ProvisioningDescriptionException(producer + " has already been added to the plan"); } updates = CollectionUtils.putLinked(updates, producer, fpPlan); return this; }
public Builder excludeLayer(String layerName) throws ProvisioningDescriptionException { if(includedLayers.contains(layerName)) { throw new ProvisioningDescriptionException(Errors.configLayerCanEitherBeIncludedOrExcluded(model, getName(), layerName)); } excludedLayers = CollectionUtils.addLinked(excludedLayers, layerName); return this; }
public Builder includeLayer(String layerName) throws ProvisioningDescriptionException { if(excludedLayers.contains(layerName)) { throw new ProvisioningDescriptionException(Errors.configLayerCanEitherBeIncludedOrExcluded(model, getName(), layerName)); } includedLayers = CollectionUtils.addLinked(includedLayers, layerName); return this; }