Allow modifying project config values on save

Upon saving the changes to a project config, allow modification of the
values that were entered before the result is committed.

This is useful for plugins which need to validate or change the entered
configuration values before they are saved. For example, a plugin may
require the value to be saved as encrypted text in the configuration
file. This feature would allow the user to input their value in plain
text, and the plugin may override this method to take care of the
encryption. Once the changes are saved, the updated value(s) are shown in
the project config field(s).

Change-Id: I54301b132f421665531ff41643b18933fdbb127c
This commit is contained in:
Janice Agustin
2015-06-10 10:25:28 -04:00
parent b3f83e2ec6
commit 9e8cac6739
2 changed files with 15 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.config;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
@@ -201,6 +202,18 @@ public class ProjectConfigEntry {
return null;
}
/**
* Called before the project config is updated. To modify the value before the
* project config is updated, override this method and return the modified
* value. Default implementation returns the same value.
*
* @param configValue the original configValue that was entered.
* @return the modified configValue.
*/
public ConfigValue preUpdate(ConfigValue configValue) {
return configValue;
}
/**
* Called after a project config is updated.
*