use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ProfileDownloader method addMavenBundles.
protected void addMavenBundles(FabricService fabricService, Profile profile, Set<String> bundles, List<String> bundleList) {
for (String bundle : bundleList) {
if (bundle != null) {
if (bundle.contains("$")) {
// use similar logic as io.fabric8.agent.utils.AgentUtils.getProfileArtifacts method
// as we need to substitute version placeholders
ProfileService profileService = fabricService.adapt(ProfileService.class);
Profile overlay = profileService.getOverlayProfile(profile);
bundle = VersionPropertyPointerResolver.replaceVersions(fabricService, overlay.getConfigurations(), bundle);
}
bundles.add(bundle);
}
}
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ProfileDownloadArtifactsAction method doExecute.
@Override
protected Object doExecute() throws Exception {
Version ver = version != null ? profileService.getVersion(version) : fabricService.getDefaultVersion();
if (ver == null) {
if (version != null) {
System.out.println("version " + version + " does not exist!");
} else {
System.out.println("No default version available!");
}
return null;
}
if (target == null) {
String karafBase = System.getProperty("karaf.base", ".");
target = new File(karafBase, ProfileDownloadArtifactsAction.DEFAULT_TARGET);
}
target.mkdirs();
if (!target.exists()) {
System.out.println("Could not create the target directory " + target);
return null;
}
if (!target.isDirectory()) {
System.out.println("Target is not a directory " + target);
return null;
}
if (executorService == null) {
if (threadPoolSize > 1) {
executorService = Executors.newScheduledThreadPool(threadPoolSize);
} else {
executorService = Executors.newSingleThreadScheduledExecutor();
}
}
ProfileDownloader downloader = new ProfileDownloader(fabricService, target, force, executorService);
downloader.setStopOnFailure(stopOnFailure);
// we do not want to download the files from within the profile itself, only the dependencies
downloader.setDownloadFilesFromProfile(false);
if (verbose) {
downloader.setListener(new ProgressIndicator());
}
if (profile != null) {
Profile profileObject = null;
if (ver.hasProfile(profile)) {
profileObject = ver.getRequiredProfile(profile);
}
if (profileObject == null) {
System.out.println("Source profile " + profile + " not found.");
return null;
}
downloader.downloadProfile(profileObject);
} else {
downloader.downloadVersion(ver);
}
List<String> failedProfileIDs = downloader.getFailedProfileIDs();
System.out.println("Downloaded " + downloader.getProcessedFileCount() + " file(s) to " + target);
if (failedProfileIDs.size() > 0) {
System.out.println("Failed to download these profiles: " + failedProfileIDs + ". Check the logs for details");
}
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ProfileCopyAction method doExecute.
@Override
protected Object doExecute() throws Exception {
// but validate the target name
try {
FabricValidations.validateProfileName(target);
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
Version version = versionParam != null ? profileService.getRequiredVersion(versionParam) : fabricService.getRequiredDefaultVersion();
String versionId = version.getId();
if (!version.hasProfile(source)) {
System.out.println("Source profile " + source + " not found.");
return 1;
} else if (version.hasProfile(target)) {
if (!force) {
System.out.println("Target profile " + target + " already exists. Use --force if you want to overwrite.");
return null;
}
}
Profiles.copyProfile(fabricService, versionId, source, target, force);
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ProfileCreateAction method doExecute.
@Override
protected Object doExecute() throws Exception {
try {
FabricValidations.validateProfileName(profileId);
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
if (versionId != null) {
profileService.getRequiredVersion(versionId);
} else {
versionId = fabricService.getDefaultVersionId();
}
// we can only use existing parent profiles
Profile[] parents = FabricCommand.getExistingProfiles(fabricService, versionId, this.parents);
ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
for (Profile parent : parents) {
builder.addParent(parent.getId());
}
profileService.createProfile(builder.getProfile());
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ProfileDeleteAction method doExecute.
@Override
protected Object doExecute() throws Exception {
// do not validate the name in case a profile was created somehow with invalid name
ProfileService profileService = fabricService.adapt(ProfileService.class);
Version version = versionId != null ? profileService.getRequiredVersion(versionId) : fabricService.getRequiredDefaultVersion();
boolean deleted = false;
for (Profile profile : version.getProfiles()) {
String versionId = profile.getVersion();
String profileId = profile.getId();
if (name.equals(profileId)) {
profileService.deleteProfile(fabricService, versionId, profileId, force);
deleted = true;
}
}
if (!deleted) {
System.out.println("Profile " + name + " not found.");
}
return null;
}
Aggregations