use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class ZkDataStoreImpl method deleteContainer.
@Override
public void deleteContainer(FabricService fabricService, String containerId) {
assertValid();
try {
if (curator.get() == null) {
throw new IllegalStateException("Zookeeper service not available");
}
// Wipe all config entries that are related to the container for all versions.
ProfileService profileService = fabricService.adapt(ProfileService.class);
for (String version : profileService.getVersions()) {
deleteSafe(curator.get(), ZkPath.CONFIG_VERSIONS_CONTAINER.getPath(version, containerId));
}
deleteSafe(curator.get(), ZkPath.CONFIG_CONTAINER.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_ALIVE.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_DOMAINS.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_PROVISION.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_STATUS.getPath(containerId));
deleteSafe(curator.get(), ZkPath.AUTHENTICATION_CONTAINER.getPath(containerId));
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class VersionCompleter method complete.
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
ProfileService profileService = fabricService.adapt(ProfileService.class);
List<String> versions = profileService.getVersions();
for (String version : versions) {
delegate.getStrings().add(version);
}
return delegate.complete(buffer, cursor, candidates);
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class FabricCommand method getProfiles.
/**
* Gets (or creates) all the profiles for the given names.
* <p/>
* <b>Important:</b> If a profile does not already exists with the given name, then a new {@link Profile} is
* created and returned in the list.
*
* @see #getExistingProfiles(io.fabric8.api.FabricService, io.fabric8.api.Version, java.util.List)
*/
public static Profile[] getProfiles(FabricService fabricService, Version version, List<String> names) {
List<Profile> allProfiles = version.getProfiles();
List<Profile> profiles = new ArrayList<>();
if (names == null) {
return new Profile[0];
}
for (String profileId : names) {
Profile profile = null;
for (Profile p : allProfiles) {
if (profileId.equals(p.getId())) {
profile = p;
break;
}
}
if (profile == null) {
ProfileBuilder builder = ProfileBuilder.Factory.create(version.getId(), profileId);
ProfileService profileService = fabricService.adapt(ProfileService.class);
profile = profileService.createProfile(builder.getProfile());
}
profiles.add(profile);
}
return profiles.toArray(new Profile[profiles.size()]);
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class VersionResource method createProfile.
/**
* Creates a new profile.
* <br>
* For example send this JSON to be able to create a new profile:
*
* <code>
* { "id": "myNewProfile", "parents": ["containers-tomcat"] }
* </code>
*/
@POST
public Response createProfile(ProfileDTO profileDTO) throws URISyntaxException {
Objects.notNull(profileDTO, "profileDTO");
FabricService fabricService = getFabricService();
Objects.notNull(fabricService, "fabricService");
ProfileService profileService = getProfileService();
Objects.notNull(profileService, "profileService");
String id = profileDTO.getId();
if (Strings.isNullOrBlank(id)) {
return Response.status(Response.Status.BAD_REQUEST).entity("No id specified for the profile to be created").build();
}
URI location = new URI(getBaseUri() + "profile/" + id);
// lets check it doesn't already exist
String versionId = version.getId();
if (profileService.hasProfile(versionId, id)) {
return Response.seeOther(location).entity("Profile already exists for id: " + id).build();
}
// lets override whatever the version is set to
profileDTO.setVersion(versionId);
// create the profile
ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, id);
profileDTO.populateBuilder(fabricService, profileService, builder);
Profile profile = builder.getProfile();
profileService.createProfile(profile);
return Response.created(location).build();
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class AgentUtils method getProfileArtifacts.
/**
* Returns the location and parser map (i.e. the location and the parsed maven coordinates and artifact locations) of each bundle and feature
*/
public static Map<String, Parser> getProfileArtifacts(FabricService fabricService, Profile profile, Iterable<String> bundles, Iterable<Feature> features, Callback<String> nonMavenLocationCallback) {
Set<String> locations = new HashSet<>();
for (Feature feature : features) {
List<BundleInfo> bundleList = feature.getBundles();
if (bundleList == null) {
LOGGER.warn("No bundles for feature " + feature);
} else {
for (BundleInfo bundle : bundleList) {
locations.add(bundle.getLocation());
}
}
}
for (String bundle : bundles) {
locations.add(bundle);
}
Map<String, Parser> artifacts = new HashMap<>();
for (String location : locations) {
try {
if (location.contains("$")) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
Profile overlay = profileService.getOverlayProfile(profile);
location = VersionPropertyPointerResolver.replaceVersions(fabricService, overlay.getConfigurations(), location);
}
if (location.startsWith("mvn:") || location.contains(":mvn:")) {
Parser parser = Parser.parsePathWithSchemePrefix(location);
artifacts.put(location, parser);
} else {
if (nonMavenLocationCallback != null) {
nonMavenLocationCallback.call(location);
}
}
} catch (MalformedURLException e) {
LOGGER.error("Failed to parse bundle URL: " + location + ". " + e, e);
}
}
return artifacts;
}
Aggregations