private ProvisionedFeatureBuilder(ResolvedFeatureId id, ResolvedSpecId specId) { this.id = id; this.specId = specId; if(id != null) { Map<String, Object> idParams = id.getParams(); if(idParams.size() > 1) { configParams = new HashMap<>(idParams.size()); for(Map.Entry<String, Object> entry : idParams.entrySet()) { configParams.put(entry.getKey(), (String) entry.getValue()); } } else { final Map.Entry<String, Object> entry = idParams.entrySet().iterator().next(); configParams = Collections.singletonMap(entry.getKey(), (String) entry.getValue()); } idBuilder = null; } else { idBuilder = ResolvedFeatureId.builder(specId); } }
public static ResolvedFeatureId fromString(String str) throws ProvisioningDescriptionException { final int length = str.length(); if(length == 0) { formatException(str); formatException(str); formatException(str); formatException(str); final int equals = str.indexOf('=', colon + 1); if(equals < 0 || equals == str.length() - 1) { formatException(str); return new ResolvedFeatureId(specId, Collections.singletonMap(str.substring(colon + 1, equals), str.substring(equals + 1))); int equals = str.indexOf('=', lastComma + 1); if(equals < 0 || equals == str.length() - 1) { formatException(str); formatException(str); return new ResolvedFeatureId(specId, params);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProvisionedFeatureBuilder other = (ProvisionedFeatureBuilder) obj; if (configParams == null) { if (other.configParams != null) return false; } else if (!configParams.equals(other.configParams)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (specId == null) { if (other.specId != null) return false; } else if (!specId.equals(other.specId)) return false; return true; }
Group buildFeatureGroups(String name, ResolvedFeatureId id, List<String> pathItems) { String[] groups = name.split("\\."); Group current = allgroups.get(ROOT); currentPath = "/"; for (int it = 0; it < groups.length; it++) { String g = groups[it]; String value = id == null ? null : (String) id.getParams().get(g); if (value != null) { current = addGroup(value, current, pathItems, g); if (it < groups.length - 1) { String next = groups[it + 1]; if (next.equals(value)) { it += 1; } } } else { current = addGroup(current, pathItems, g); } } return current; }
public static ResolvedFeatureId create(ResolvedSpecId specId, String param, String value) { return new ResolvedFeatureId(specId, Collections.singletonMap(param, value)); }
for (int i = 0; i < specLoops.size(); ++i) { final CircularRefInfo specLoop = specLoops.get(i); if (specLoop.nextOnPath.id.equals(refId)) { if (featureLoops == null) { featureLoops = Collections.singletonList(specLoop); feature.addBranchDep(dep.branch, refId.isChildRef()); } else { dep.addBranchDependee(feature);
public static ProvisionedFeatureBuilder builder(ResolvedFeatureId id) { return new ProvisionedFeatureBuilder(id, id.getSpecId()); }
case ID: try { id = ResolvedFeatureId.fromString(reader.getAttributeValue(i)); } catch (ProvisioningDescriptionException e) { throw new XMLStreamException(Errors.parseXml(), e);
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((configParams == null) ? 0 : configParams.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((specId == null) ? 0 : specId.hashCode()); return result; }
case ID: try { id = ResolvedFeatureId.fromGalleon1String(reader.getAttributeValue(i)); } catch (ProvisioningDescriptionException e) { throw new XMLStreamException(Errors.parseXml(), e);
public FeatureInfo(ConfigInfo configInfo, ProvisionedFeature feature, List<String> path, FPID currentFP) throws ProvisioningDescriptionException { this.feature = feature; this.path = path; this.currentFP = currentFP; this.configInfo = configInfo; FeatureId.Builder builder = FeatureId.builder(feature.getSpecId().getName()); if (feature.getId() != null) { for (Entry<String, Object> param : feature.getId().getParams().entrySet()) { builder.setParam(param.getKey(), param.getValue().toString()); } featureId = builder.build(); featureConfig = FeatureConfig.newConfig(featureId); } else { featureId = null; featureConfig = null; } StringBuilder b = new StringBuilder(); b.append(FeatureContainerPathConsumer.FINAL_CONFIGS_PATH).append(configInfo.getModel()). append(PathParser.PATH_SEPARATOR).append(configInfo.getName()).append(PathParser.PATH_SEPARATOR); for (int i = 0; i < path.size(); i++) { b.append(path.get(i)); if (i < path.size() - 1) { b.append(PathParser.PATH_SEPARATOR); } } fullPath = b.toString(); }
public ResolvedFeatureId build() throws ProvisioningDescriptionException { if(params.isEmpty()) { throw new ProvisioningDescriptionException("Failed to create an instance of ResolvedFeatureId for " + specId + ": params have not been initialized"); } return new ResolvedFeatureId(specId, params); } }
private Map<ResolvedFeatureId, FeatureDependencySpec> resolveFeatureDeps(ConfigModelStack configStack, Collection<FeatureDependencySpec> featureDeps, final ResolvedFeatureSpec spec) throws ProvisioningException { Map<ResolvedFeatureId, FeatureDependencySpec> resolvedDeps = spec.resolveFeatureDeps(this, featureDeps); if(!resolvedDeps.isEmpty()) { for(Map.Entry<ResolvedFeatureId, FeatureDependencySpec> dep : resolvedDeps.entrySet()) { if(!dep.getValue().isInclude()) { continue; } final ResolvedFeatureId depId = dep.getKey(); if(configStack.includes(depId) || configStack.isFilteredOut(depId.specId, depId)) { continue; } final FeatureDependencySpec depSpec = dep.getValue(); final FeaturePackRuntimeBuilder originalFp = setOrigin(depSpec.getOrigin()); try { resolveFeatureDepsAndRefs(configStack, getFeatureSpec(depId.getSpecId().getName()), depId, Collections.emptyMap(), Collections.emptyList()); } finally { setOrigin(originalFp); } } } return resolvedDeps; }
case ID: try { id = ResolvedFeatureId.fromString(reader.getAttributeValue(i)); } catch (ProvisioningDescriptionException e) { throw new XMLStreamException(Errors.parseXml(), e);
private static FeatureId getFeatureId(final ProvisionedFeature feature) throws ProvisioningDescriptionException, ProvisioningException { final FeatureId.Builder id = FeatureId.builder(feature.getSpecId().getName()); final ResolvedFeatureId resolvedId = feature.getId(); for(String name : resolvedId.getParams().keySet()) { id.setParam(name, feature.getConfigParam(name)); } return id.build(); } }
public static ResolvedFeatureId fromGalleon1String(String str) throws ProvisioningDescriptionException { final int length = str.length(); if(length == 0) { formatException(str); if(c == '#') { if(artifactId == null || version != null || buf.length() == 0) { formatException(str); } else if(c == ':') { if(buf.length() == 0) { formatException(str); artifactId = buf.toString(); } else if(version == null) { formatException(str); } else { specId = new ResolvedSpecId(LegacyGalleon1Universe.toFpl(groupId, artifactId, version).getProducer(), buf.toString()); formatException(str); final int equals = str.indexOf('=', nextIndex + 1); if(equals < 0 || equals == str.length() - 1) { formatException(str); return new ResolvedFeatureId(specId, Collections.singletonMap(str.substring(nextIndex, equals), str.substring(equals + 1))); int equals = str.indexOf('=', lastComma + 2); if(equals < 0 || equals == str.length() - 1) { formatException(str);
public static ResolvedFeatureId create(ProducerSpec producer, String spec, String param, String value) { return new ResolvedFeatureId(new ResolvedSpecId(producer, spec), Collections.singletonMap(param, value)); }
for (int i = 0; i < specLoops.size(); ++i) { final CircularRefInfo specLoop = specLoops.get(i); if (specLoop.nextOnPath.id.equals(refId)) { if (featureLoops == null) { featureLoops = Collections.singletonList(specLoop);
ResolvedFeatureId resolveFeatureId(Map<String, String> params) throws ProvisioningException { if(!xmlSpec.hasId()) { return null; } final List<FeatureParameterSpec> idSpecs = xmlSpec.getIdParams(); if(idSpecs.size() == 1) { final FeatureParameterSpec idSpec = idSpecs.get(0); return new ResolvedFeatureId(id, Collections.singletonMap(idSpec.getName(), resolveIdParamValue(params, idSpec))); } final Map<String, Object> resolvedParams = new HashMap<>(idSpecs.size()); for(FeatureParameterSpec param : idSpecs) { resolvedParams.put(param.getName(), resolveIdParamValue(params, param)); } return new ResolvedFeatureId(id, resolvedParams); }