io.fabric8.api.Version.hasProfile()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中io.fabric8.api.Version.hasProfile()方法的一些代码示例,展示了Version.hasProfile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.hasProfile()方法的具体详情如下:
包路径:io.fabric8.api.Version
类名称:Version
方法名:hasProfile

Version.hasProfile介绍

[英]True if the version contains a profile for the given identity.
[中]如果版本包含给定标识的配置文件,则为True。

代码示例

代码示例来源:origin: io.fabric8/fabric-project-deployer

/**
 * Sets the list of parent profile IDs
 */
private void setParentProfileIds(ProfileBuilder builder, Version version, Profile profile, List<String> parentProfileIds) {
  List<String> list = new ArrayList<>();
  for (String parentProfileId : parentProfileIds) {
    if (version.hasProfile(parentProfileId)) {
      list.add(parentProfileId);
    } else {
      LOG.warn("Could not find parent profile: " + parentProfileId + " in version " + version.getId());
    }
  }
  builder.setParents(list);
}

代码示例来源:origin: io.fabric8/fabric-rest

@Path("profile/{profileId}")
public ProfileResource version(@PathParam("profileId") String profileId) {
  if (Strings.isNotBlank(profileId) && version != null && version.hasProfile(profileId)) {
    Profile profile = version.getRequiredProfile(profileId);
    if (profile != null) {
      return new ProfileResource(this, profile);
    }
  }
  return null;
}

代码示例来源:origin: jboss-fuse/fabric8

@Path("profile/{profileId}")
public ProfileResource version(@PathParam("profileId") String profileId) {
  if (Strings.isNotBlank(profileId) && version != null && version.hasProfile(profileId)) {
    Profile profile = version.getRequiredProfile(profileId);
    if (profile != null) {
      return new ProfileResource(this, profile);
    }
  }
  return null;
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
  public ProfileBuilder addOptions(ProfileBuilder builder) {
    List<String> missingProfiles = new ArrayList<>();
    List<String> profileIds = dataStore.getContainerProfiles(cntId);
    LOGGER.debug("Building container overlay for {} with profile: {}", cntId, profileIds);
    for (String profileId : profileIds) {
      if (version.hasProfile(profileId)) {
        builder.addParent(profileId);
      } else {
        missingProfiles.add(profileId);
      }
    }
    if (!missingProfiles.isEmpty()) {
      LOGGER.warn("Container overlay has missing profiles: {}", missingProfiles);
      builder.addAttribute("missing.profiles", missingProfiles.toString());
      // builder.addConfiguration(Constants.AGENT_PID, "disabled", "true");
    }
    return builder;
  }
}

代码示例来源:origin: io.fabric8/fabric-commands

@Override
protected Object doExecute() throws Exception {
  // do not validate the old name in case a profile was created somehow with invalid name
  // 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 null;
  }
  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 null;
  } 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;
}

代码示例来源:origin: io.fabric8/fabric-commands

@Override
protected Object doExecute() throws Exception {
  // do not validate the old name in case a profile was created somehow with invalid name
  // but validate the new name
  try {
    FabricValidations.validateProfileName(newName);
  } 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 null;
  }
  Version version;
  if (versionId != null) {
    version = profileService.getRequiredVersion(versionId);
  } else {
    version = fabricService.getDefaultVersion();
  }
  if (!version.hasProfile(profileName)) {
    System.out.println("Profile " + profileName + " not found.");
    return null;
  } else if (version.hasProfile(newName)) {
    if (!force) {
      System.out.println("New name " + newName + " already exists. Use --force if you want to overwrite.");
      return null;
    }
  }
  Profiles.renameProfile(fabricService, versionId, profileName, newName, force);
  return null;
}

代码示例来源:origin: io.fabric8/fabric-git

public String call(Git git, GitContext context) throws Exception {
    String versionId = profile.getVersion();
    String profileId = profile.getId();
    Version version = getRequiredVersion(versionId);
    IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
    checkoutRequiredProfileBranch(git, context, versionId, profileId);
    return createOrUpdateProfile(context, null, profile, new HashSet<String>());
  }
};

代码示例来源:origin: jboss-fuse/fabric8

public String call(Git git, GitContext context) throws Exception {
    String versionId = profile.getVersion();
    String profileId = profile.getId();
    Version version = getRequiredVersion(versionId);
    IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
    checkoutRequiredProfileBranch(git, context, versionId, profileId);
    return createOrUpdateProfile(context, null, profile, new HashSet<String>());
  }
};

代码示例来源:origin: jboss-fuse/fabric8

private void fillParentProfiles(Profile profile, List<Profile> profiles) {
  if (!profiles.contains(profile)) {
    List<Profile> circularRelationship = new ArrayList<>();
    for (String parentId : profile.getParentIds()) {
      if (version.hasProfile(parentId)){
        Profile parent = version.getRequiredProfile(parentId);
        if (parent != null){
          if ( !isCircularRelationship(profile, parent)){
            fillParentProfiles(parent, profiles);
          } else {
            circularRelationship.add(parent);
          }
        }
      } else {
        LOGGER.error("Tried to load a profile[{}] not present in this version[{}]", parentId, version);
      }
    }
    profiles.add(profile);
    for(Profile p: circularRelationship){
      fillParentProfiles(p, profiles);
    }
  }
}

代码示例来源:origin: io.fabric8/fabric-partition

@Override
public void stop(TaskContext context) {
  Container current = fabricService.get().getCurrentContainer();
  Version version = current.getVersion();
  String profileId = context.getConfiguration().get(TEMPLATE_PROFILE_PROPERTY_NAME) + "-" + name;
  if (version.hasProfile(profileId)) {
    //Just delete the profile
    version.getProfile(profileId).delete(true);
  }
}

代码示例来源:origin: io.fabric8/fabric-agent-commands

if (ver.hasProfile(profile)) {
  profileObject = ver.getRequiredProfile(profile);

代码示例来源:origin: jboss-fuse/fabric8

boolean create = !version.hasProfile(profileId);
if (create) {
  builder = ProfileBuilder.Factory.create(versionId, profileId);

代码示例来源:origin: io.fabric8/fabric-project-deployer

private Profile getOrCreateProfile(Version version, ProjectRequirements requirements) {
  String profileId = getProfileId(requirements);
  if (Strings.isEmpty(profileId)) {
    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);
    profile = profileService.createProfile(builder.getProfile());
  } else {
    profile = version.getRequiredProfile(profileId);
  }
  return profile;
}

代码示例来源:origin: io.fabric8/fabric-partition

private void manageProfile(TaskContext context) {
  Container current = fabricService.get().getCurrentContainer();
  ProfileData profileData = createProfileData(context);
  String profileId = context.getConfiguration().get(TEMPLATE_PROFILE_PROPERTY_NAME) + "-" + name;
  Version version = current.getVersion();
  try {
    if (lock.acquire(60, TimeUnit.SECONDS)) {
      if (profileData.isEmpty()) {
        if (version.hasProfile(profileId)) {
          //Just delete the profile
          version.getProfile(profileId).delete(true);
        }
        return;
      } else if (!version.hasProfile(profileId)) {
        //Create the profile
        fabricService.get().getDataStore().createProfile(version.getId(), profileId);
      }
      Profile managedProfile = version.getProfile(profileId);
      //managedProfile.setConfigurations(profileData.getConfigs());
      managedProfile.setFileConfigurations(profileData.getFiles());
      current.addProfiles(managedProfile);
    } else {
      throw new TimeoutException("Timed out waiting for lock");
    }
  } catch (Exception e) {
    LOGGER.error("Error managing work items.", e);
  } finally {
    releaseLock();
  }
}

代码示例来源:origin: io.fabric8/fabric-project-deployer

@Override
public DeployResults deployProject(ProjectRequirements requirements, boolean merge) throws Exception {
  Version version = getOrCreateVersion(requirements);
  // validate that all the parent profiles exists
  for (String parent : requirements.getParentProfiles()) {
    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);
  updateProfileConfiguration(version, profile, requirements, oldRequirements, builder, merge);
  return resolveProfileDeployments(requirements, fabricService.get(), profile, builder);
}

代码示例来源:origin: jboss-fuse/fabric8

boolean create = !version.hasProfile(profileId);
if (create) {
  builder = ProfileBuilder.Factory.create(versionId, profileId);

相关文章