Package io.fabric8.api

Examples of io.fabric8.api.Version


        this.profileService = fabricService.adapt(ProfileService.class);
    }

    @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;
        }

        fabricService.adapt(ProfileRegistry.class).exportProfiles(ver.getId(), outputZipFileName.getAbsolutePath(), wildcard);
        System.out.println("Exported profiles to " + outputZipFileName.getCanonicalPath());
        return null;
    }
View Full Code Here


    }

    @Override
    protected Object doExecute() throws Exception {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        Version version = versionId != null ? profileService.getRequiredVersion(versionId) : fabricService.getRequiredDefaultVersion();
        List<Profile> profiles = version.getProfiles();
        profiles = sortProfiles(profiles);
        printProfiles(profileService, profiles, System.out);
        return null;
    }
View Full Code Here

    protected Object doExecute() throws Exception {
        if (!profileService.hasVersion(versionId)) {
            System.out.println("Version " + versionId + " does not exists!");
            return null;
        }
        Version version = profileService.getRequiredVersion(versionId);
        String description = version.getAttributes().get(Version.DESCRIPTION);
        String derivedFrom = null;
        boolean defaultVersion = version.getId().equals(fabricService.getDefaultVersionId());
        List<Profile> profiles = CommandUtils.sortProfiles(version.getProfiles());

        List<Container> containerList = new ArrayList<Container>();
        for (String c : dataStore.getContainers()) {
            Container container = fabricService.getContainer(c);
            if (version.getId().equals(container.getVersion().getId())) {
                containerList.add(container);
            }
        }
        Container[] containers = CommandUtils.sortContainers(containerList.toArray(new io.fabric8.api.Container[containerList.size()]));

        System.out.println(String.format(FORMAT, "Name:", version.getId()));
        System.out.println(String.format(FORMAT, "Description:", (description != null ? description : "")));
        System.out.println(String.format(FORMAT, "Derived From:", (derivedFrom) != null ? derivedFrom : ""));
        System.out.println(String.format(FORMAT, "Default Version:", defaultVersion));
        if (containers.length == 0) {
            System.out.println(String.format(FORMAT, "Containers:", ""));
View Full Code Here

    @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;
View Full Code Here

    @Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        StringsCompleter delegate = new StringsCompleter();
        try {
            Version version = fabricService.getRequiredDefaultVersion();
            List<Profile> profiles = version.getProfiles();
            for (Profile profile : profiles) {
                delegate.getStrings().add(profile.getId());
            }
        } catch (Exception ex) {
            //Ignore Exceptions
View Full Code Here

            if (FabricCommand.doesContainerExist(fabricService, name)) {
                throw new IllegalArgumentException("A container with name " + name + " already exists.");
            }

            // get the profiles for the given version
            Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
            List<Profile> profiles = ver.getProfiles();

            // validate profiles exists before creating a new container
            Set<String> names = getProfileNames();
            for (String profile : names) {
                Profile prof = getProfile(profiles, profile, ver);
                if (prof == null) {
                    throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
                }
                if (prof.isAbstract()) {
                    throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
                }
            }
        }

        if (!isEnsembleServer && fabricService.getZookeeperUrl() == null) {
View Full Code Here

     */
    String getGatewayVersion() {
        assertValid();
        Container currentContainer = fabricService.get().getCurrentContainer();
        if (currentContainer != null) {
            Version version = currentContainer.getVersion();
            if (version != null) {
                return version.getId();
            }
        }
        return null;
    }
View Full Code Here

    public String getGatewayVersion() {
        FabricService fabricService = getFabricService();
        if (fabricService != null) {
            Container currentContainer = fabricService.getCurrentContainer();
            if (currentContainer != null) {
                Version version = currentContainer.getVersion();
                if (version != null) {
                    return version.getId();
                }
            }
        }
        return null;
    }
View Full Code Here

    @Path("version/{versionId}")
    public VersionResource version(@PathParam("versionId") String versionId) {
        FabricService fabricService = getFabricService();
        if (fabricService != null && Strings.isNotBlank(versionId)) {
            ProfileService profileService = fabricService.adapt(ProfileService.class);
            Version version = profileService.getRequiredVersion(versionId);
            if (version != null) {
                return new VersionResource(this, version);
            } else {
                LOG.warn("No version found for: {}", version);
            }
View Full Code Here

    }
   
    @Test
    public void createVersionFrom() {
       
        Version defaultVersion = profileRegistry.getRequiredVersion("1.0");
        Assert.assertNotNull(defaultVersion);
       
        Assert.assertFalse(profileRegistry.hasVersion("1.1"));
        Assert.assertNull(profileRegistry.getVersion("1.1"));
       
        String versionId = profileRegistry.createVersion("1.0", "1.1", Collections.singletonMap("foo", "bar"));
        Assert.assertTrue(profileRegistry.hasVersion(versionId));
        Assert.assertEquals("1.1", versionId);
       
        // Version cannot get created twice
        try {
            profileRegistry.createVersion("1.0", "1.1", null);
            Assert.fail("IllegalStateException expected");
        } catch (IllegalStateException ex) {
            Assert.assertTrue(ex.getMessage().contains("Version already exists: 1.1"));
        }
       
        Version version = profileRegistry.getRequiredVersion(versionId);
        Assert.assertEquals("bar", version.getAttributes().get("foo"));
        Assert.assertEquals(defaultVersion.getProfileIds(), version.getProfileIds());
       
        // Delete the version again
        profileRegistry.deleteVersion(versionId);

        Assert.assertFalse(profileRegistry.hasVersion("1.1"));
View Full Code Here

TOP

Related Classes of io.fabric8.api.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.