本文整理汇总了Java中com.atlassian.sal.api.pluginsettings.PluginSettings.put方法的典型用法代码示例。如果您正苦于以下问题:Java PluginSettings.put方法的具体用法?Java PluginSettings.put怎么用?Java PluginSettings.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.atlassian.sal.api.pluginsettings.PluginSettings
的用法示例。
在下文中一共展示了PluginSettings.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAdminConfigResourcesModel
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Transactional
public AdminConfigResourceModel updateAdminConfigResourcesModel(final AdminConfigResourceModel updatedConfig) {
Validate.isTrue(updatedConfig.getDaysToKeepBambooKeys() >= 0,"must keep keys at least 1 day (or 0 to disable)");
Validate.isTrue(updatedConfig.getDaysToKeepUserKeys() >= 0,"must keep keys at least 1 day (or 0 to disable)");
Validate.isTrue(updatedConfig.getMillisBetweenRuns() >= 300000 || updatedConfig.getMillisBetweenRuns() ==0,"Must space at least 5 minutes apart (or 0 to disable all jobs)");
PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
settings.put(SETTINGS_KEY_AUTHORIZED_GROUP, updatedConfig.getAuthorizedGroup());
settings.put(SETTINGS_KEY_BAMBOO_USER, updatedConfig.getBambooUser());
settings.put(SETTINGS_KEY_POLICY_LINK, updatedConfig.getInternalKeyPolicyLink());
settings.put(SETTINGS_KEY_DAYS_KEEP_USERS, String.valueOf(updatedConfig.getDaysToKeepUserKeys()));
settings.put(SETTINGS_KEY_DAYS_KEEP_BAMBOO, String.valueOf(updatedConfig.getDaysToKeepBambooKeys()));
settings.put(SETTINGS_KEY_MILLIS_INTERVAL, String.valueOf(updatedConfig.getMillisBetweenRuns()));
//refresh cache, including logic on default values in case some were not provided.
cachedModel = updatedConfig;
return cachedModel;
}
示例2: loadRepositoriesFromJiraProperties
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
/**
* Creates all GitManagers from stored configuration.
*/
@SuppressWarnings("unchecked")
private void loadRepositoriesFromJiraProperties() {
final PluginSettings globalSettings = pluginSettingsFactory.createGlobalSettings();
List<String> repositoryList = (List<String>)globalSettings.get(SETTINGS_REPOSITORY_LIST);
// New installation, settings don't exist yet
if (repositoryList == null) {
repositoryList = new ArrayList<String>();
globalSettings.put(SETTINGS_REPOSITORY_LIST, repositoryList);
}
for (final String repositoryId : repositoryList) {
final PluginSettings repositorySettings = pluginSettingsFactory.createSettingsForKey(repositoryId);
createRepositoryFromPropertySet(parseRepositoryId(repositoryId),
(Properties)repositorySettings.get(SETTINGS_REPOSITORY_VALUES));
}
}
示例3: saveRepository
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void saveRepository(final AbstractRepository repository) {
Validate.notNull(repository, "repository must not be null");
final Properties properties = new Properties();
properties.setProperty(PROPERTY_TYPE, RepositoryType.fromRepository(repository).name());
repository.saveToProperties(properties);
// Save identifier within global settings
final PluginSettings globalSettings = pluginSettingsFactory.createGlobalSettings();
@SuppressWarnings("unchecked")
final List<String> repositoryList = (List<String>)globalSettings.get(SETTINGS_REPOSITORY_LIST);
repositoryList.remove(String.valueOf(repository.getId()));
repositoryList.add(String.valueOf(repository.getId()));
globalSettings.put(SETTINGS_REPOSITORY_LIST, repositoryList);
// Save actual values within keyed settings
final PluginSettings repositorySettings = pluginSettingsFactory.createSettingsForKey(String.valueOf(repository.getId()));
repositorySettings.put(SETTINGS_REPOSITORY_VALUES, properties);
}
示例4: setValue
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
private void setValue(final PluginSettings settings, final String key, final Object value) {
if (value == null) {
settings.remove(key);
} else {
settings.put(key, String.valueOf(value));
}
}
示例5: setValue
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
private void setValue(final PluginSettings settings, final String key, final Object value) {
if (value == null) {
settings.remove(key);
} else {
settings.put(key, value);
}
}
示例6: writeConfig
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
void writeConfig(PluginSettings settings, Config config) {
settings.put(REQUIRED_REVIEWS, toString(config.getRequiredReviews()));
settings.put(BLOCK_MERGE_IF_PR_NEEDS_WORK, toString(config.getBlockMergeIfPrNeedsWork()));
settings.put(REQUIRED_REVIWERS, empty2null(join(config.getRequiredReviewers(), new FilterInvalidUsers())));
settings.put(REQUIRED_REVIWER_GROUPS, empty2null(join(config.getRequiredReviewerGroups(), new FilterInvalidGroups())));
settings.put(DEFAULT_REVIEWERS, empty2null(join(config.getDefaultReviewers(), new FilterInvalidUsers())));
settings.put(DEFAULT_REVIEWER_GROUPS, empty2null(join(config.getDefaultReviewerGroups(), new FilterInvalidGroups())));
settings.put(EXCLUDED_USERS, empty2null(join(config.getExcludedUsers(), new FilterInvalidUsers())));
settings.put(EXCLUDED_GROUPS, empty2null(join(config.getExcludedGroups(), new FilterInvalidGroups())));
settings.put(BLOCKED_COMMITS, empty2null(join(config.getBlockedCommits(), noOpFilter)));
settings.put(BLOCKED_PRS, empty2null(join(config.getBlockedPRs(), noOpFilter)));
settings.put(AUTOMERGE_PRS, empty2null(join(config.getAutomergePRs(), noOpFilter)));
settings.put(AUTOMERGE_PRS_FROM, empty2null(join(config.getAutomergePRsFrom(), noOpFilter)));
}
示例7: perform
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Override
public void perform(PluginSettings ps) {
String jenkinBaseUrl = (String) ps.get(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.JENKINS_BASE_URL,slug));
if (jenkinBaseUrl != null) {
log.info("Adding jenkins base url to the CI server list");;
ps.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.JENKINS_CI_SERVER_LIST,slug),jenkinBaseUrl);
}
}
示例8: doPost
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
String privateKey = request.getParameter("private_key");
PluginSettings settings = settingsFactory.createGlobalSettings();
settings.put("net.mediatemple.fisheye.gitrepoapi.privatekey", privateKey);
renderPage(request, response, privateKey);
}
示例9: testSaveConfigResetToBlank
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Test
public void testSaveConfigResetToBlank() throws Exception {
final String testUrl = "https://www.google.com";
final String username = "username";
final String passwordClear = "password";
final String passwordEnc = PasswordEncrypter.encrypt(passwordClear);
final String timeout = "120";
final UserManagerMock managerMock = new UserManagerMock();
managerMock.setRemoteUsername("User");
managerMock.setIsSystemAdmin(true);
final PluginSettingsFactoryMock settingsFactory = new PluginSettingsFactoryMock();
final PluginSettings settings = settingsFactory.createGlobalSettings();
settings.put(HubConfigKeys.CONFIG_HUB_URL, testUrl);
settings.put(HubConfigKeys.CONFIG_HUB_USER, username);
settings.put(HubConfigKeys.CONFIG_HUB_PASS, passwordEnc);
settings.put(HubConfigKeys.CONFIG_HUB_PASS_LENGTH, String.valueOf(passwordClear.length()));
settings.put(HubConfigKeys.CONFIG_HUB_TIMEOUT, timeout);
final TransactionTemplateMock transactionManager = new TransactionTemplateMock();
final HttpServletRequestMock requestMock = new HttpServletRequestMock();
final PluginAccessorMock pluginAccessorMock = new PluginAccessorMock();
final HubConfigController controller = new HubConfigController(managerMock, settingsFactory,
transactionManager, pluginAccessorMock);
HubServerConfigSerializable config = new HubServerConfigSerializable();
final Response response = controller.put(config, requestMock);
assertNotNull(response);
final Object configObject = response.getEntity();
assertNotNull(configObject);
config = (HubServerConfigSerializable) configObject;
assertNull(config.getHubUrl());
assertNull(config.getUsername());
assertNull(config.getPassword());
assertEquals(Integer.valueOf(0), Integer.valueOf(config.getPasswordLength()));
assertNull(config.getTimeout());
assertNull(config.getHubProxyHost());
assertNull(config.getHubProxyPort());
assertNull(config.getHubProxyUser());
assertNull(config.getHubProxyPassword());
assertEquals(Integer.valueOf(0), Integer.valueOf(config.getHubProxyPasswordLength()));
assertNotNull(config.getHubUrlError());
assertNotNull(config.getUsernameError());
assertNotNull(config.getPasswordError());
assertNotNull(config.getTimeoutError());
assertNull(config.getHubProxyHostError());
assertNull(config.getHubProxyUserError());
assertNull(config.getHubProxyPasswordError());
assertNull(config.getTestConnectionError());
assertTrue(config.hasErrors());
assertNull(settings.get(HubConfigKeys.CONFIG_HUB_URL));
assertNull(settings.get(HubConfigKeys.CONFIG_HUB_USER));
assertNull(settings.get(HubConfigKeys.CONFIG_HUB_PASS));
assertNull(settings.get(HubConfigKeys.CONFIG_HUB_PASS_LENGTH));
assertNull(settings.get(HubConfigKeys.CONFIG_HUB_TIMEOUT));
}
示例10: testSaveConfigChange
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Test
public void testSaveConfigChange() throws Exception {
final String testUrl1 = "https://www.google.com";
final String username1 = "username";
final String passwordClear1 = "password";
final String passwordEnc1 = PasswordEncrypter.encrypt(passwordClear1);
final String timeout1 = "120";
final String testUrl2 = "fakeUrl";
final String username2 = "user";
final String passwordClear2 = "pass";
final String passwordEnc2 = PasswordEncrypter.encrypt(passwordClear2);
final String timeout2 = "300";
final UserManagerMock managerMock = new UserManagerMock();
managerMock.setRemoteUsername("User");
managerMock.setIsSystemAdmin(true);
final PluginSettingsFactoryMock settingsFactory = new PluginSettingsFactoryMock();
final PluginSettings settings = settingsFactory.createGlobalSettings();
settings.put(HubConfigKeys.CONFIG_HUB_URL, testUrl1);
settings.put(HubConfigKeys.CONFIG_HUB_USER, username1);
settings.put(HubConfigKeys.CONFIG_HUB_PASS, passwordEnc1);
settings.put(HubConfigKeys.CONFIG_HUB_PASS_LENGTH, String.valueOf(passwordClear1.length()));
settings.put(HubConfigKeys.CONFIG_HUB_TIMEOUT, timeout1);
final TransactionTemplateMock transactionManager = new TransactionTemplateMock();
final HttpServletRequestMock requestMock = new HttpServletRequestMock();
final PluginAccessorMock pluginAccessorMock = new PluginAccessorMock();
final HubConfigController controller = new HubConfigController(managerMock, settingsFactory,
transactionManager, pluginAccessorMock);
HubServerConfigSerializable config = new HubServerConfigSerializable();
config.setHubUrl(testUrl2);
config.setUsername(username2);
config.setPassword(passwordClear2);
config.setTimeout(timeout2);
final Response response = controller.put(config, requestMock);
assertNotNull(response);
final Object configObject = response.getEntity();
assertNotNull(configObject);
config = (HubServerConfigSerializable) configObject;
assertEquals(testUrl2, config.getHubUrl());
assertEquals(username2, config.getUsername());
assertEquals(passwordClear2, config.getPassword());
assertEquals(Integer.valueOf(0), Integer.valueOf(config.getPasswordLength()));
assertEquals(timeout2, config.getTimeout());
assertNull(config.getHubProxyHost());
assertNull(config.getHubProxyPort());
assertNull(config.getHubProxyUser());
assertNull(config.getHubProxyPassword());
assertEquals(Integer.valueOf(0), Integer.valueOf(config.getHubProxyPasswordLength()));
assertNotNull(config.getHubUrlError());
assertNull(config.getUsernameError());
assertNull(config.getPasswordError());
assertNull(config.getTimeoutError());
assertNull(config.getHubProxyHostError());
assertNull(config.getHubProxyUserError());
assertNull(config.getHubProxyPasswordError());
assertNull(config.getTestConnectionError());
assertTrue(config.hasErrors());
assertEquals(testUrl2, settings.get(HubConfigKeys.CONFIG_HUB_URL));
assertEquals(username2, settings.get(HubConfigKeys.CONFIG_HUB_USER));
assertEquals(passwordEnc2, settings.get(HubConfigKeys.CONFIG_HUB_PASS));
assertEquals(String.valueOf(passwordClear2.length()), settings.get(HubConfigKeys.CONFIG_HUB_PASS_LENGTH));
assertEquals(timeout2, settings.get(HubConfigKeys.CONFIG_HUB_TIMEOUT));
}
示例11: testTestConnectionConfigBlank
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Test
public void testTestConnectionConfigBlank() throws Exception {
final String testUrl = "https://www.google.com";
final String username = "username";
final String passwordClear = "password";
final String passwordEnc = PasswordEncrypter.encrypt(passwordClear);
final String timeout = "120";
final UserManagerMock managerMock = new UserManagerMock();
managerMock.setRemoteUsername("User");
managerMock.setIsSystemAdmin(true);
final PluginSettingsFactoryMock settingsFactory = new PluginSettingsFactoryMock();
final PluginSettings settings = settingsFactory.createGlobalSettings();
settings.put(HubConfigKeys.CONFIG_HUB_URL, testUrl);
settings.put(HubConfigKeys.CONFIG_HUB_USER, username);
settings.put(HubConfigKeys.CONFIG_HUB_PASS, passwordEnc);
settings.put(HubConfigKeys.CONFIG_HUB_PASS_LENGTH, String.valueOf(passwordClear.length()));
settings.put(HubConfigKeys.CONFIG_HUB_TIMEOUT, timeout);
final TransactionTemplateMock transactionManager = new TransactionTemplateMock();
final HttpServletRequestMock requestMock = new HttpServletRequestMock();
final PluginAccessorMock pluginAccessorMock = new PluginAccessorMock();
final HubConfigController controller = new HubConfigController(managerMock, settingsFactory,
transactionManager, pluginAccessorMock);
HubServerConfigSerializable config = new HubServerConfigSerializable();
final Response response = controller.testConnection(config, requestMock);
assertNotNull(response);
final Object configObject = response.getEntity();
assertNotNull(configObject);
config = (HubServerConfigSerializable) configObject;
assertNull(config.getHubUrl());
assertNull(config.getUsername());
assertNull(config.getPassword());
assertEquals(Integer.valueOf(0), Integer.valueOf(config.getPasswordLength()));
assertNull(config.getTimeout());
assertNull(config.getHubProxyHost());
assertNull(config.getHubProxyPort());
assertNull(config.getHubProxyUser());
assertNull(config.getHubProxyPassword());
assertEquals(Integer.valueOf(0), Integer.valueOf(config.getHubProxyPasswordLength()));
assertNotNull(config.getHubUrlError());
assertNotNull(config.getUsernameError());
assertNotNull(config.getPasswordError());
assertNotNull(config.getTimeoutError());
assertNull(config.getHubProxyHostError());
assertNull(config.getHubProxyUserError());
assertNull(config.getHubProxyPasswordError());
assertNull(config.getTestConnectionError());
assertTrue(config.hasErrors());
}
示例12: doPost
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String username = userManager.getRemoteUsername(request);
if (username == null || !userManager.isSystemAdmin(username))
{
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
String body = getBody(request.getInputStream());
if (body.isEmpty())
{
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
String apiUrl;
try
{
JSONObject jsonObj = new JSONObject(body);
apiUrl = jsonObj.getString("apiUrl");
}
catch (Exception ex)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String error = ex.toString() + "\n" + sw.toString();
log.error(error);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();
pluginSettings.put("onlyoffice.apiUrl", apiUrl);
return;
}
示例13: expireOldErrors
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
public static List<TicketCreationError> expireOldErrors(final PluginSettings pluginSettings) {
logger.debug("Pulling error messages from settings");
final Object errorObject = pluginSettings.get(HubJiraConstants.HUB_JIRA_ERROR);
if (errorObject == null) {
logger.debug("No error messages found in settings");
return null;
}
if (!(errorObject instanceof String)) {
logger.warn("The error object in settings is invalid (probably stored by an older version of the plugin); discarding it");
pluginSettings.remove(HubJiraConstants.HUB_JIRA_ERROR);
return null;
}
List<TicketCreationError> ticketErrors = null;
final String ticketErrorsString = (String) errorObject;
try {
ticketErrors = TicketCreationError.fromJson(ticketErrorsString);
} catch (final Exception e) {
logger.warn("Error deserializing JSON string pulled from settings: " + e.getMessage() + "; resettting error message list");
pluginSettings.remove(HubJiraConstants.HUB_JIRA_ERROR);
return null;
}
if ((ticketErrors == null) || ticketErrors.isEmpty()) {
logger.debug("No error messages found in settings");
return null;
}
logger.debug("# error messages pulled from settings: " + ticketErrors.size());
Collections.sort(ticketErrors);
final DateTime currentTime = DateTime.now();
final Iterator<TicketCreationError> expirationIterator = ticketErrors.iterator();
while (expirationIterator.hasNext()) {
final TicketCreationError ticketError = expirationIterator.next();
final DateTime errorTime = ticketError.getTimeStampDateTime();
if (Days.daysBetween(errorTime, currentTime).isGreaterThan(Days.days(30))) {
logger.debug("Removing old error message with timestamp: " + ticketError.getTimeStamp());
expirationIterator.remove();
}
}
logger.debug("Saving " + ticketErrors.size() + " non-expired error messages in settings");
pluginSettings.put(HubJiraConstants.HUB_JIRA_ERROR, TicketCreationError.toJson(ticketErrors));
return ticketErrors;
}
示例14: perform
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
@Override
public void perform(PluginSettings pluginSettings) {
String slug = this.slug;
String jenkinsBaseUrl = (String) pluginSettings.get(JENKINS_BASE_URL);
String userName = (String) pluginSettings.get(JENKINS_USERNAME);
String password = (String) pluginSettings.get(JENKINS_PASSWORD);
String buildRefField = (String) pluginSettings.get(BUILD_REF_FIELD);
String buildTitleField = (String) pluginSettings.get(BUILD_TITLE_FIELD);
String triggerOnBuildCreate = (String) pluginSettings.get(TRIGGER_BUILD_ON_CREATE);
String triggerOnBuildReopen = (String) pluginSettings.get(TRIGGER_BUILD_ON_REOPEN);
String triggerOnBuildUpdate = (String) pluginSettings.get(TRIGGER_BUILD_ON_UPDATE);
if (jenkinsBaseUrl != null) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.JENKINS_BASE_URL,slug), jenkinsBaseUrl);
}
if (buildRefField != null) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.BUILD_REF_FIELD,slug), buildRefField);
}
if (triggerOnBuildCreate != null && !triggerOnBuildCreate.isEmpty()) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.TRIGGER_BUILD_ON_CREATE,slug), "checked");
}
if (triggerOnBuildUpdate != null && !triggerOnBuildUpdate.isEmpty()) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.TRIGGER_BUILD_ON_UPDATE,slug), "checked");
}
if (triggerOnBuildReopen != null && !triggerOnBuildReopen.isEmpty()) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.TRIGGER_BUILD_ON_REOPEN,slug), "checked");
}
if (userName != null) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.JENKINS_USERNAME,slug), userName);
}
if (password != null) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.JENKINS_PASSWORD,slug), password);
}
if (buildTitleField != null) {
pluginSettings.put(PluginSettingsHelper.getPluginKey(PluginSettingsHelper.BUILD_TITLE_FIELD,slug), buildTitleField);
}
removeOldSettings(pluginSettings);
}
示例15: removeRepository
import com.atlassian.sal.api.pluginsettings.PluginSettings; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void removeRepository(final Object id) {
Validate.notNull(id, "id must not be null");
final AbstractRepository repository = repositories.get(id);
if (repository == null) {
log.warn("Attempt to remove repository that does not exist: " + id);
return;
}
repositories.remove(id);
// Remove from global settings
final PluginSettings globalSettings = pluginSettingsFactory.createGlobalSettings();
final List<String> allManagerSettings = (List<String>)globalSettings.get(SETTINGS_REPOSITORY_LIST);
allManagerSettings.remove(String.valueOf(id));
globalSettings.put(SETTINGS_REPOSITORY_LIST, allManagerSettings);
// Wipe settings from keyed settings
final PluginSettings repositorySettings = pluginSettingsFactory.createSettingsForKey(String.valueOf(id));
final Properties properties = (Properties)repositorySettings.get(SETTINGS_REPOSITORY_VALUES);
if (properties != null) {
for (final Enumeration<?> e = properties.propertyNames(); e.hasMoreElements() ;) {
properties.remove(e.nextElement());
}
}
repositorySettings.put(SETTINGS_REPOSITORY_VALUES, properties);
try {
if (repository instanceof GitRepository) {
gitRevisionIndexer.removeEntries((GitRepository)repository);
}
} catch (final IndexException ie) {
log.error("Failed to remove entries from index for repository: " + id, ie);
}
try {
repositoryServiceHelper.getRepositoryService(repository).remove(repository);
} catch (final RepositoryException re) {
log.error("Failed to remove persistent repository information: " + id, re);
}
}