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:
@@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user