public static FeatureConfig newConfig(FeatureId id) throws ProvisioningDescriptionException { final FeatureConfig config = new FeatureConfig(id.getSpec()); for(Map.Entry<String, String> param : id.getParams().entrySet()) { config.setParam(param.getKey(), param.getValue()); } return config; }
private Set<ResolvedFeatureId> resolveExcludedIds(Set<ResolvedFeatureId> resolvedIds, Map<FeatureId, String> features) throws ProvisioningException { for (Map.Entry<FeatureId, String> excluded : features.entrySet()) { final FeatureId excludedId = excluded.getKey(); final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(excludedId.getSpec().getName()); if(parentFeature != null) { resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, excluded.getValue(), excludedId.getParams())); } else { resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveFeatureId(excludedId.getParams())); } } return resolvedIds; }
@SuppressWarnings("unchecked") public B removeFeature(FeatureId id) throws ProvisioningDescriptionException { int index = -1; // Although that is a list, we have a single ConfigModel for a given ConfigId for (int i = 0; i < items.size(); i++) { ConfigItem ci = items.get(i); if (ci instanceof FeatureConfig) { FeatureConfig conf = (FeatureConfig) ci; if (conf.getSpecId().equals(id.getSpec())) { boolean eq = true; for (Entry<String, String> entry : id.getParams().entrySet()) { String val = conf.getParam(entry.getKey()); if (val == null || !val.equals(entry.getValue())) { eq = false; break; } } if (eq) { index = i; break; } } } } if (index == -1) { throw new ProvisioningDescriptionException("Feature " + id + " is not added"); } items = CollectionUtils.remove(items, index); return (B) this; }
@SuppressWarnings("unchecked") public B includeFeature(FeatureId featureId, FeatureConfig feature) throws ProvisioningDescriptionException { if(feature != null && feature.getOrigin() != null) { final String origin = feature.getOrigin(); feature.setOrigin(null); getExternalFgConfig(origin).includeFeature(featureId, feature); return (B) this; } if(excludedFeatures.containsKey(featureId)) { throw new ProvisioningDescriptionException(featureId + " has been explicitly excluded"); } if(feature == null) { feature = new FeatureConfig(featureId.getSpec()); } else if(feature.specId == null) { feature.specId = featureId.getSpec(); } for (Map.Entry<String, String> idEntry : featureId.getParams().entrySet()) { final String prevValue = feature.putParam(idEntry.getKey(), idEntry.getValue()); if (prevValue != null && !prevValue.equals(idEntry.getValue())) { throw new ProvisioningDescriptionException("Parameter " + idEntry.getKey() + " has value '" + idEntry.getValue() + "' in feature ID and value '" + prevValue + "' in the feature body"); } } includedFeatures = CollectionUtils.putLinked(includedFeatures, featureId, feature); return (B) this; }
final FeaturePackRuntimeBuilder depFp = depSpec.getOrigin() == null ? rt.layout.getFeaturePack(id.producer) : rt.getOrigin(depSpec.getOrigin()); final ResolvedFeatureSpec depResolvedSpec = rt.getFeatureSpec(depFp, depSpec.getFeatureId().getSpec().getName()); return Collections.singletonMap(depResolvedSpec.resolveFeatureId(depSpec.getFeatureId().getParams()), depSpec); final FeaturePackRuntimeBuilder depFp = userDep.getOrigin() == null ? ownFp : rt.getOrigin(userDep.getOrigin()); final ResolvedFeatureSpec depResolvedSpec = rt.getFeatureSpec(depFp, userDep.getFeatureId().getSpec().getName()); final ResolvedFeatureId depId = depResolvedSpec.resolveFeatureId(userDep.getFeatureId().getParams()); final FeatureDependencySpec specDep = result.put(depId, userDep); if(specDep != null) {
session.println("NONE"); } else { for (Entry<String, String> entry : f.getFeatureId().getParams().entrySet()) { session.println(entry.getKey() + "=" + entry.getValue());