public void update(Settings settings, File settingsFile) throws ManipulationException {
    try {
      Settings defaultSettings = new Settings();

      if (settingsFile.exists()) {
        DefaultSettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
        settingsRequest.setGlobalSettingsFile(settingsFile);
        defaultSettings = settingsBuilder.build(settingsRequest).getEffectiveSettings();
      }

      for (Profile profile : settings.getProfiles()) {
        Iterator<Profile> i = defaultSettings.getProfiles().iterator();
        while (i.hasNext()) {
          if (i.next().getId().equals(profile.getId())) {
            i.remove();
          }
        }
        defaultSettings.addProfile(profile);
      }
      for (String activeProfile : settings.getActiveProfiles()) {
        Iterator<String> i = defaultSettings.getActiveProfiles().iterator();
        while (i.hasNext()) {
          if (i.next().equals(activeProfile)) {
            i.remove();
          }
        }
        defaultSettings.addActiveProfile(activeProfile);
      }
      for (Mirror mirror : settings.getMirrors()) {
        defaultSettings.addMirror(mirror);
      }
      for (Proxy proxy : settings.getProxies()) {
        defaultSettings.addProxy(proxy);
      }
      for (Server server : settings.getServers()) {
        defaultSettings.addServer(server);
      }
      for (String pluginGroup : settings.getPluginGroups()) {
        defaultSettings.addPluginGroup(pluginGroup);
      }
      if (settings.getLocalRepository() != null) {
        defaultSettings.setLocalRepository(settings.getLocalRepository());
      }

      write(defaultSettings, settingsFile);
    } catch (SettingsBuildingException e) {
      throw new ManipulationException(
          "Failed to build existing settings.xml for repo removal backup.",
          e,
          settingsFile,
          e.getMessage());
    }
  }
  @Override
  public <T> List<T> getData(String key, Class<T> type, Object... params) {
    List<T> retval = null;

    if ("profileIds".equals(key)) {
      final List<T> profileIds = new ArrayList<T>();

      try {
        final List<Profile> profiles = MavenPlugin.getMaven().getSettings().getProfiles();

        for (final Profile profile : profiles) {
          if (profile.getActivation() != null) {
            if (profile.getActivation().isActiveByDefault()) {
              continue;
            }
          }

          profileIds.add(type.cast(profile.getId()));
        }

        if (params[0] != null && params[0] instanceof File) {
          final File locationDir = (File) params[0];

          File pomFile = new File(locationDir, IMavenConstants.POM_FILE_NAME);

          if (!pomFile.exists() && locationDir.getParentFile().exists()) {
            // try one level up for when user is adding new module
            pomFile = new File(locationDir.getParentFile(), IMavenConstants.POM_FILE_NAME);
          }

          if (pomFile.exists()) {
            final IMaven maven = MavenPlugin.getMaven();

            Model model = maven.readModel(pomFile);

            File parentDir = pomFile.getParentFile();

            while (model != null) {
              for (org.apache.maven.model.Profile p : model.getProfiles()) {
                profileIds.add(type.cast(p.getId()));
              }

              parentDir = parentDir.getParentFile();

              if (parentDir != null && parentDir.exists()) {
                try {
                  model = maven.readModel(new File(parentDir, IMavenConstants.POM_FILE_NAME));
                } catch (Exception e) {
                  model = null;
                }
              }
            }
          }
        }
      } catch (CoreException e) {
        LiferayMavenCore.logError(e);
      }

      retval = profileIds;
    } else if ("liferayVersions".equals(key)) {
      final List<T> possibleVersions = new ArrayList<T>();

      final RepositorySystem system = AetherUtil.newRepositorySystem();

      final RepositorySystemSession session = AetherUtil.newRepositorySystemSession(system);

      final String groupId = params[0].toString();
      final String artifactId = params[1].toString();

      final String coords = groupId + ":" + artifactId + ":[6,)";

      final Artifact artifact = new DefaultArtifact(coords);

      final VersionRangeRequest rangeRequest = new VersionRangeRequest();
      rangeRequest.setArtifact(artifact);
      rangeRequest.addRepository(AetherUtil.newCentralRepository());
      rangeRequest.addRepository(AetherUtil.newLiferayRepository());

      try {
        final VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);

        final List<Version> versions = rangeResult.getVersions();

        for (Version version : versions) {
          final String val = version.toString();

          if (!"6.2.0".equals(val)) {
            possibleVersions.add(type.cast(val));
          }
        }

        retval = possibleVersions;
      } catch (VersionRangeResolutionException e) {
      }
    } else if ("parentVersion".equals(key)) {
      final List<T> version = new ArrayList<T>();

      final File locationDir = (File) params[0];

      final File parentPom = new File(locationDir, IMavenConstants.POM_FILE_NAME);

      if (parentPom.exists()) {
        try {
          final IMaven maven = MavenPlugin.getMaven();

          final Model model = maven.readModel(parentPom);

          version.add(type.cast(model.getVersion()));

          retval = version;
        } catch (CoreException e) {
          LiferayMavenCore.logError("unable to get parent version", e);
        }
      }
    } else if ("parentGroupId".equals(key)) {
      final List<T> groupId = new ArrayList<T>();

      final File locationDir = (File) params[0];

      final File parentPom = new File(locationDir, IMavenConstants.POM_FILE_NAME);

      if (parentPom.exists()) {
        try {
          final IMaven maven = MavenPlugin.getMaven();

          final Model model = maven.readModel(parentPom);

          groupId.add(type.cast(model.getGroupId()));

          retval = groupId;
        } catch (CoreException e) {
          LiferayMavenCore.logError("unable to get parent groupId", e);
        }
      }
    }

    return retval;
  }
  protected String getNewLiferayProfilesPluginVersion(
      String[] activeProfiles,
      List<NewLiferayProfile> newLiferayProfiles,
      String archetypeVersion) {
    org.osgi.framework.Version minVersion =
        new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

    try {
      final List<Profile> profiles = MavenPlugin.getMaven().getSettings().getProfiles();

      org.osgi.framework.Version minNewVersion =
          new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

      org.osgi.framework.Version minExistedVersion =
          new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

      for (final String activeProfile : activeProfiles) {
        for (final NewLiferayProfile newProfile : newLiferayProfiles) {
          if (activeProfile.equals(newProfile.getId().content())) {
            final String liferayVersion = newProfile.getLiferayVersion().content();

            final org.osgi.framework.Version shortLiferayVersion =
                new org.osgi.framework.Version(liferayVersion.substring(0, 3));

            final org.osgi.framework.Version shortPluginVersion =
                new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

            minNewVersion =
                shortLiferayVersion.compareTo(shortPluginVersion) < 0
                    ? shortLiferayVersion
                    : shortPluginVersion;
          }
        }

        minVersion = minVersion.compareTo(minNewVersion) < 0 ? minVersion : minNewVersion;

        for (final Profile existProfile : profiles) {
          if (activeProfile.equals(existProfile.getId())) {
            final Properties properties = existProfile.getProperties();
            final String liferayVersion = properties.getProperty("liferay.version");
            final String pluginVersion = properties.getProperty("liferay.maven.plugin.version");

            if (pluginVersion != null && liferayVersion != null) {
              final org.osgi.framework.Version shortLiferayVersion =
                  new org.osgi.framework.Version(liferayVersion.substring(0, 3));

              final org.osgi.framework.Version shortPluginVersion =
                  new org.osgi.framework.Version(pluginVersion.substring(0, 3));

              minExistedVersion =
                  shortLiferayVersion.compareTo(shortPluginVersion) < 0
                      ? shortLiferayVersion
                      : shortPluginVersion;
            }
          }
        }

        minVersion = minVersion.compareTo(minExistedVersion) < 0 ? minVersion : minExistedVersion;
      }
    } catch (Exception e) {
    }

    return minVersion.toString();
  }