use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method createProfile.
@Override
// Creates a profile with empty content. Is this meaningful?
@Deprecated
public Map<String, Object> createProfile(String versionId, String profileId) {
ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
Profile profile = profileService.createProfile(builder.getProfile());
return getProfile(versionId, profile.getId());
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method setProfileAttribute.
@Override
public void setProfileAttribute(String versionId, String profileId, String attributeId, String value) {
Profile profile = profileService.getRequiredProfile(versionId, profileId);
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
builder.addAttribute(attributeId, value);
profileService.updateProfile(builder.getProfile());
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method getProfileFeatures.
@Override
public Map<String, Object> getProfileFeatures(String versionId, String profileId) {
Profile profile = profileService.getVersion(versionId).getRequiredProfile(profileId);
Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, profileService.getOverlayProfile(profile));
Map<String, Boolean> isParentFeature = new HashMap<String, Boolean>();
for (String feature : profile.getFeatures()) {
isParentFeature.put(feature, Boolean.FALSE);
}
for (String feature : effectiveProfile.getFeatures()) {
if (isParentFeature.get(feature) == null) {
isParentFeature.put(feature, Boolean.TRUE);
}
}
Map<String, Object> rc = new HashMap<String, Object>();
List<Map<String, Object>> featureDefs = new ArrayList<Map<String, Object>>();
for (Map.Entry<String, Boolean> featureEntry : isParentFeature.entrySet()) {
Map<String, Object> featureDef = new HashMap<String, Object>();
featureDef.put("id", featureEntry.getKey());
featureDef.put("isParentFeature", featureEntry.getValue());
featureDefs.add(featureDef);
}
rc.put("featureDefinitions", featureDefs);
List<Map<String, Object>> repositoryDefs = new ArrayList<Map<String, Object>>();
for (String repo : effectiveProfile.getRepositories()) {
Map<String, Object> repoDef = new HashMap<String, Object>();
repoDef.put("id", repo);
Closeable closeable = null;
try {
URL url = new URL(repo);
InputStream os = url.openStream();
closeable = os;
InputStream is = new BufferedInputStream(url.openStream());
closeable = is;
char[] buffer = new char[8192];
StringBuilder data = new StringBuilder();
Reader in = new InputStreamReader(is, "UTF-8");
closeable = in;
for (; ; ) {
int stat = in.read(buffer, 0, buffer.length);
if (stat < 0) {
break;
}
data.append(buffer, 0, stat);
}
repoDef.put("data", data.toString());
} catch (Throwable t) {
repoDef.put("error", t.getMessage());
} finally {
try {
if (closeable != null) {
closeable.close();
}
} catch (Throwable t) {
// whatevs, I tried
}
}
repositoryDefs.add(repoDef);
}
rc.put("repositoryDefinitions", repositoryDefs);
return rc;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method getOverlayProfileProperties.
@Override
public Map<String, String> getOverlayProfileProperties(String versionId, String profileId, String pid) {
Map<String, String> answer = null;
Version version = profileService.getVersion(versionId);
if (version != null) {
Profile profile = version.getRequiredProfile(profileId);
if (profile != null) {
Profile overlayProfile = profileService.getOverlayProfile(profile);
answer = overlayProfile.getConfiguration(pid);
}
}
return answer;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method stringsToProfiles.
protected Profile[] stringsToProfiles(Version version, List<String> names) {
List<Profile> allProfiles = version.getProfiles();
List<Profile> profiles = new ArrayList<Profile>();
if (names == null) {
return new Profile[0];
}
for (String name : names) {
Profile profile = null;
for (Profile p : allProfiles) {
if (name.equals(p.getId())) {
profile = p;
break;
}
}
if (profile == null) {
throw new IllegalArgumentException("Profile " + name + " not found.");
}
profiles.add(profile);
}
return profiles.toArray(new Profile[profiles.size()]);
}
Aggregations