Package io.fabric8.api

Examples of io.fabric8.api.Profile


        if (profiles != null && versionId != null) {
            ProfileService profileService = fabricService.get().adapt(ProfileService.class);
            Version version = profileService.getVersion(versionId);
            if (version != null) {
                for (String profileId : profiles) {
                    Profile profile = version.getRequiredProfile(profileId);
                    if (profile != null) {
                        Profile overlay = profileService.getOverlayProfile(profile);
                        Map<String, String> openshiftConfig = overlay.getConfiguration(OpenShiftConstants.OPENSHIFT_PID);
                        if (openshiftConfig != null)  {
                            openshiftConfigOverlay.putAll(openshiftConfig);
                        }
                    }
                }
View Full Code Here


                        profileService.deleteProfile(fabricService.get(), versionId, profileId, true);
                    }
                    return;
                }
               
                Profile managedProfile;
                if (version.hasProfile(profileId)) {
                    Profile profile = profileService.getRequiredProfile(versionId, profileId);
                    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
                    builder.setFileConfigurations(profileData.getFiles());
                    managedProfile = profileService.updateProfile(builder.getProfile());
                } else {
                    ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
View Full Code Here

        }

        Container current = fabricService.get().getCurrentContainer();
        Version version = current.getVersion();
        String templateProfileName = String.valueOf(context.getConfiguration().get(TEMPLATE_PROFILE_PROPERTY_NAME));
        Profile templateProfile = version.getRequiredProfile(templateProfileName);
        Set<String> allFiles = templateProfile.getFileConfigurations().keySet();
        Iterable<String> mvelFiles = Iterables.filter(allFiles, MvelPredicate.INSTANCE);
        Iterable<String> plainFiles = Iterables.filter(allFiles, Predicates.not(MvelPredicate.INSTANCE));


        for (String mvelFile : mvelFiles) {
            Key key = new Key(templateProfile.getId(), mvelFile);
            synchronized (templates) {
                CompiledTemplate template = templates.get(key);
                if (template == null) {
                    template = TemplateCompiler.compileTemplate(new String(templateProfile.getFileConfigurations().get(mvelFile)), parserContext);
                    templates.put(key, template);
                }
            }
        }

        for (WorkItem workItem : workItems) {
            Map<String, WorkItem> data = new HashMap<String, WorkItem>();
            data.put(WorkItem.ITEM, workItem);

            //Render templates
            for (String fileTemplate : mvelFiles) {
                String file = renderTemplateName(fileTemplate, workItem);
                Key key = new Key(templateProfile.getId(), fileTemplate);
                try {
                    String renderedTemplate = TemplateRuntime.execute(templates.get(key), parserContext, data).toString();
                    updateProfileData(file, renderedTemplate, profileData);
                } catch (Exception ex) {
                    LOGGER.warn("Failed to render {}. Ignoring.", fileTemplate);
                }
            }

            //Copy plain files.
            for (String file : plainFiles) {
                    String content = new String(templateProfile.getFileConfigurations().get(file));
                    updateProfileData(file, content, profileData);
            }
        }
        return profileData;
    }
View Full Code Here

            List<Profile> profiles = version.getProfiles();

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

            if (!version.hasProfile(parent)) {
                throw new IllegalArgumentException("Parent profile " + parent + " does not exists in version " + version.getId());
            }
        }

        Profile profile = getOrCreateProfile(version, requirements);
        boolean isAbstract = requirements.isAbstractProfile();
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
        builder.addAttribute(Profile.ABSTRACT, "" + isAbstract);

        ProjectRequirements oldRequirements = writeRequirementsJson(requirements, profile, builder);
View Full Code Here

        if (rootDependency != null) {
            // as a hack lets just add this bundle in
            LOG.info("Got root: " + rootDependency);
            List<String> parentIds = profile.getParentIds();
            Profile overlay = profileService.getOverlayProfile(profile);

            String bundleUrl = rootDependency.toBundleUrlWithType();
            LOG.info("Using resolver to add extra features and bundles on " + bundleUrl);

            List<String> features = new ArrayList<String>();
            List<String> bundles = new ArrayList<String>();
            List<String> optionals = new ArrayList<String>();

            if (requirements.getFeatures() != null) {
                features.addAll(requirements.getFeatures());
            }
            if (requirements.getBundles() != null) {
                bundles.addAll(requirements.getBundles());
            }

            bundles.add(bundleUrl);
            LOG.info("Adding bundle: " + bundleUrl);

            // TODO we maybe should detect a karaf based container in a nicer way than this?
            boolean isKarafContainer = parentIds.contains("karaf") || parentIds.contains("containers-karaf");
            boolean addBundleDependencies = Objects.equal("bundle", rootDependency.getType()) || isKarafContainer;
            if (addBundleDependencies && requirements.isUseResolver()) {

                // lets build up a list of all current active features and bundles along with all discovered features
                List<Feature> availableFeatures = new ArrayList<Feature>();
                addAvailableFeaturesFromProfile(availableFeatures, fabric, overlay);

                Set<String> currentBundleLocations = new HashSet<>();
                currentBundleLocations.addAll(bundles);

                // lets add the current features
                DownloadManager downloadManager = DownloadManagers.createDownloadManager(fabric, executorService);
                Set<Feature> currentFeatures = AgentUtils.getFeatures(fabric, downloadManager, overlay);
                addBundlesFromProfile(currentBundleLocations, overlay);

                List<String> parentProfileIds = requirements.getParentProfiles();
                if (parentProfileIds != null) {
                    for (String parentProfileId : parentProfileIds) {
                        Profile parentProfile = profileService.getProfile(profile.getVersion(), parentProfileId);
                        Profile parentOverlay = profileService.getOverlayProfile(parentProfile);
                        Set<Feature> parentFeatures = AgentUtils.getFeatures(fabric, downloadManager, parentOverlay);
                        currentFeatures.addAll(parentFeatures);
                        addAvailableFeaturesFromProfile(availableFeatures, fabric, parentOverlay);
                        addBundlesFromProfile(currentBundleLocations, parentOverlay);
                    }
View Full Code Here

            throw new IllegalArgumentException("No profile ID could be deduced for requirements: " + requirements);
        }
        // make sure the profileId is valid
        FabricValidations.validateProfileName(profileId);

        Profile profile;
        if (!version.hasProfile(profileId)) {
            LOG.info("Creating new profile " + profileId + " version " + version + " for requirements: " + requirements);
            String versionId = version.getId();
            ProfileService profileService = fabricService.get().adapt(ProfileService.class);
            ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
View Full Code Here

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

                List<Container> dosgiProviderContainers = containerList.subList(0, containerList.size() / 2);
                List<Container> dosgiCamelContainers = containerList.subList(containerList.size() / 2, containerList.size());

                for (Container c : dosgiProviderContainers) {
                    setData(curator, ZkPath.CONTAINER_PROVISION_RESULT.getPath(c.getId()), "changing profile");
                    Profile p = c.getVersion().getRequiredProfile("example-dosgi-camel.provider");
                    c.setProfiles(new Profile[]{p});
                }

                for (Container c : dosgiCamelContainers) {
                    setData(curator, ZkPath.CONTAINER_PROVISION_RESULT.getPath(c.getId()), "changing profile");
                    Profile p = c.getVersion().getRequiredProfile("example-dosgi-camel.consumer");
                    c.setProfiles(new Profile[]{p});
                }

                Provision.provisioningSuccess(dosgiProviderContainers, PROVISION_TIMEOUT);
                Provision.provisioningSuccess(dosgiCamelContainers, PROVISION_TIMEOUT);
View Full Code Here

  protected Profile getProfile(Container container, String name) throws Exception {
    return getProfile(container, name, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
  }

  protected Profile getProfile(Container container, String name, long timeout, TimeUnit unit) throws Exception {
    Profile result = null;
        for (long t = 0;  result == null && t < unit.toMillis(timeout); t += 200) {
      Profile[] profiles = container.getProfiles();
      for (Profile aux : profiles) {
        if (name.equals(aux.getId())) {
          result = aux;
View Full Code Here

TOP

Related Classes of io.fabric8.api.Profile

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.