Search in sources :

Example 36 with ProfileService

use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.

the class ProfileDTO method populateBuilder.

/**
 * Uses the profile DTO as input to the builder
 */
public void populateBuilder(FabricService fabricService, ProfileService profileService, ProfileBuilder builder) {
    System.out.println("Parents are: " + parents);
    if (parents != null && parents.size() > 0 && version != null) {
        List<Profile> parentProfiles = Profiles.getProfiles(fabricService, parents, version);
        System.out.println("Found parents: " + parentProfiles);
        for (Profile parent : parentProfiles) {
            builder.addParent(parent.getId());
        }
    }
    builder.setOverlay(overlay);
    // TODO builder doesn't expose it
    // builder.setAbstractProfile(abstractProfile);
    builder.setLocked(locked);
    if (attributes != null) {
        builder.setAttributes(attributes);
    }
    if (bundles != null) {
        builder.setBundles(bundles);
    }
    if (fabs != null) {
        builder.setBundles(fabs);
    }
    if (features != null) {
        builder.setBundles(features);
    }
    if (repositories != null) {
        builder.setBundles(repositories);
    }
    if (overrides != null) {
        builder.setBundles(overrides);
    }
}
Also used : Profile(io.fabric8.api.Profile)

Example 37 with ProfileService

use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.

the class JavaContainers method getJavaContainerArtifactsFiles.

public static Map<String, File> getJavaContainerArtifactsFiles(FabricService fabricService, List<Profile> profileList, DownloadManager downloadManager) throws Exception {
    Map<String, File> answer = new HashMap<String, File>();
    ProfileService profileService = fabricService.adapt(ProfileService.class);
    for (Profile profile : profileList) {
        Profile overlay = profileService.getOverlayProfile(profile);
        Map<String, Parser> profileArtifacts = AgentUtils.getProfileArtifacts(fabricService, downloadManager, overlay);
        appendMavenDependencies(profileArtifacts, profile);
        Set<String> rawUrls = profileArtifacts.keySet();
        downloadArtifactUrls(downloadManager, rawUrls, answer);
    }
    return answer;
}
Also used : ProfileService(io.fabric8.api.ProfileService) HashMap(java.util.HashMap) File(java.io.File) Profile(io.fabric8.api.Profile) Parser(io.fabric8.maven.util.Parser)

Example 38 with ProfileService

use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.

the class BeanUtils method fetchChildIds.

public static List<String> fetchChildIds(FabricService fabricService, Profile self) {
    List<String> ids = new ArrayList<String>();
    ProfileService profileService = fabricService.adapt(ProfileService.class);
    for (Profile p : profileService.getRequiredVersion(self.getVersion()).getProfiles()) {
        for (String parentId : p.getParentIds()) {
            if (parentId.equals(self.getId())) {
                ids.add(p.getId());
                break;
            }
        }
    }
    return ids;
}
Also used : ProfileService(io.fabric8.api.ProfileService) ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 39 with ProfileService

use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.

the class VersionEditAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    ProfileService profileService = fabricService.adapt(ProfileService.class);
    ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
    Version version = profileService.getVersion(versionId);
    if (version == null) {
        System.err.println("Version " + versionId + " does not exist.");
        return null;
    }
    profileRegistry.modifyVersionDescription(version, description);
    return null;
}
Also used : ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) ProfileRegistry(io.fabric8.api.ProfileRegistry)

Example 40 with ProfileService

use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.

the class PatchApplyTest method testApplyPatch.

@Test
public void testApplyPatch() throws Exception {
    System.err.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
    BundleContext moduleContext = ServiceLocator.getSystemContext();
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
    try {
        // copy the original version of the bundle into the system folder
        final File jar = new File("system/" + getMavenRepoFile(ORIGINAL_VERSION));
        jar.getParentFile().mkdirs();
        IOHelpers.writeTo(jar, getClass().getClassLoader().getResourceAsStream("/bundles/patchable-1.0.0.jar"));
        // copy the patch zip file into a local working directory
        File patch = new File("data/patches/patch-01.zip");
        patch.getParentFile().mkdirs();
        IOHelpers.writeTo(patch, getClass().getClassLoader().getResourceAsStream("/patches/patch-01.zip"));
        FabricService fabricService = fabricProxy.getService();
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        // set up the 'patchable' profile and make sure it contains the original bundle version
        CommandSupport.executeCommand("fabric:profile-create --parents default patchable");
        CommandSupport.executeCommand("fabric:profile-edit --bundle mvn:io.fabric8.itests/patchable/1.0.0 patchable");
        Profile profile = fabricService.getRequiredDefaultVersion().getRequiredProfile("patchable");
        Profile overlay = profileService.getOverlayProfile(profile);
        assertTrue(overlay.getBundles().contains(getMavenUrl(ORIGINAL_VERSION)));
        assertFalse(overlay.getOverrides().contains(getMavenUrl(PATCHED_VERSION)));
        // create a new version and apply the patch
        CommandSupport.executeCommand("fabric:version-create 1.1");
        Thread.sleep(2000);
        CommandSupport.executeCommand(String.format("fabric:patch-apply -u admin -p admin --version 1.1 %s", patch.toURI().toURL()));
        // ensure there's an override with the patched bundle version in the 'patchable' profile
        profile = profileService.getRequiredVersion("1.1").getProfile("patchable");
        overlay = profileService.getOverlayProfile(profile);
        assertTrue(overlay.getBundles().contains(getMavenUrl(ORIGINAL_VERSION)));
        assertTrue(overlay.getOverrides().contains(getMavenUrl(PATCHED_VERSION)));
    } finally {
        fabricProxy.close();
    }
}
Also used : ProfileService(io.fabric8.api.ProfileService) FabricService(io.fabric8.api.FabricService) File(java.io.File) Profile(io.fabric8.api.Profile) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

ProfileService (io.fabric8.api.ProfileService)36 Profile (io.fabric8.api.Profile)22 Version (io.fabric8.api.Version)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)8 FabricService (io.fabric8.api.FabricService)7 Map (java.util.Map)6 Parser (io.fabric8.maven.util.Parser)5 File (java.io.File)5 HashSet (java.util.HashSet)5 ProfileBuilder (io.fabric8.api.ProfileBuilder)4 DownloadManager (io.fabric8.agent.download.DownloadManager)3 Feature (io.fabric8.agent.model.Feature)3 MalformedURLException (java.net.MalformedURLException)3 Container (io.fabric8.api.Container)2 ProfileRequirements (io.fabric8.api.ProfileRequirements)2 IOException (java.io.IOException)2 URL (java.net.URL)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2