コード例 #1
0
 protected Profile getProfile(Version ver, String name) {
   Profile p = ver.getProfile(name);
   if (p == null) {
     throw new IllegalArgumentException("Profile " + name + " does not exist.");
   }
   return p;
 }
コード例 #2
0
  /**
   * Gets the profiles for upgrade/rollback
   *
   * @param existingProfiles the existing profiles
   * @param targetVersion the target version
   * @return the new profiles to be used
   */
  protected Profile[] getProfilesForUpgradeOrRollback(
      Profile[] existingProfiles, Version targetVersion) {
    List<Profile> list = new ArrayList<Profile>(existingProfiles.length);
    for (Profile old : existingProfiles) {
      // get new profile
      Profile newProfile = targetVersion.getProfile(old.getId());
      if (newProfile != null) {
        list.add(newProfile);
      } else {
        // we expect a profile with the new version to exist
        throw new IllegalArgumentException(
            "Profile " + old.getId() + " with version " + targetVersion + " does not exists");
      }
    }

    return list.toArray(new Profile[0]);
  }