com.atlassian.sal.api.pluginsettings.PluginSettings Java Examples

The following examples show how to use com.atlassian.sal.api.pluginsettings.PluginSettings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigDao.java    From pr-harmony with GNU General Public License v3.0 6 votes vote down vote up
Config readConfig(PluginSettings settings) {
  return Config.builder()
      .requiredReviews(parseInt(get(settings, REQUIRED_REVIEWS, null)))
      .blockMergeIfPrNeedsWork(parseBoolean(get(settings, BLOCK_MERGE_IF_PR_NEEDS_WORK, null)))
      .requiredReviewers(split(get(settings, REQUIRED_REVIWERS, "")))
      .requiredReviewerGroups(split(get(settings, REQUIRED_REVIWER_GROUPS, "")))
      .defaultReviewers(split(get(settings, DEFAULT_REVIEWERS, "")))
      .defaultReviewerGroups(split(get(settings, DEFAULT_REVIEWER_GROUPS, "")))
      .excludedUsers(split(get(settings, EXCLUDED_USERS, "")))
      .excludedGroups(split(get(settings, EXCLUDED_GROUPS, "")))
      .blockedCommits(split(get(settings, BLOCKED_COMMITS, "")))
      .blockedPRs(split(get(settings, BLOCKED_PRS, "")))
      .automergePRs(split(get(settings, AUTOMERGE_PRS, "")))
      .automergePRsFrom(split(get(settings, AUTOMERGE_PRS_FROM, "")))
      .build();
}
 
Example #2
Source File: ConfigDao.java    From pr-harmony with GNU General Public License v3.0 5 votes vote down vote up
@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)));
}
 
Example #3
Source File: UserConfigDao.java    From stash-token-auth with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the list of users with config data in the system
 *
 * @return
 */
@SuppressWarnings("unchecked")
private List<String> getUserList() {
  PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
  List<String> list = (List<String>) settings.get(USER_LIST);
  return list == null ? Lists.<String>newArrayList() : list;
}
 
Example #4
Source File: UserConfigDao.java    From stash-token-auth with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates the list of users to add a new one, if it does not already exist.
 *
 * @param username
 */
@SuppressWarnings("unchecked")
private void updateUserList(final String username) {
  transactionTemplate.execute(new TransactionCallback<Object>() {
    public Object doInTransaction() {
      PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
      List<String> list = getUserList();
      list.add(username);
      list = newArrayList(newHashSet(list));
      settings.put(USER_LIST, list);
      return null;
    }
  });
}
 
Example #5
Source File: UserConfigDao.java    From stash-token-auth with GNU General Public License v3.0 5 votes vote down vote up
public List<UserConfig> getAllUserConfigs() {
  PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
  List<UserConfig> configs = newArrayList();
  for (String username : getUserList()) {
    configs.add(readUserConfig(username, settings));
  }
  return configs;
}
 
Example #6
Source File: UserConfigDao.java    From stash-token-auth with GNU General Public License v3.0 5 votes vote down vote up
public void setUserConfig(final String username, final UserConfig config) {
  transactionTemplate.execute(new TransactionCallback<UserConfig>() {
    public UserConfig doInTransaction() {
      PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
      settings.put(BASE + "." + username + ".token", config.getToken());
      updateUserList(username);
      return config;
    }
  });
}
 
Example #7
Source File: OnlyOfficeConfServlet.java    From onlyoffice-confluence with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String username = userManager.getRemoteUsername(request);
    if (username == null || !userManager.isSystemAdmin(username)) {
        SettingsManager settingsManager = (SettingsManager) ContainerManager.getComponent("settingsManager");
        String baseUrl = settingsManager.getGlobalSettings().getBaseUrl();
        response.sendRedirect(baseUrl);
        return;
    }

    PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();
    String apiUrl = (String) pluginSettings.get("onlyoffice.apiUrl");
    String jwtSecret = (String) pluginSettings.get("onlyoffice.jwtSecret");
    if (apiUrl == null || apiUrl.isEmpty()) {
        apiUrl = "";
    }
    if (jwtSecret == null || jwtSecret.isEmpty()) {
        jwtSecret = "";
    }

    response.setContentType("text/html;charset=UTF-8");
    PrintWriter writer = response.getWriter();

    Map<String, Object> contextMap = MacroUtils.defaultVelocityContext();

    contextMap.put("docserviceApiUrl", apiUrl);
    contextMap.put("docserviceJwtSecret", jwtSecret);

    writer.write(getTemplate(contextMap));
}
 
Example #8
Source File: FieldDataManagerImpl.java    From jira-groovioli with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}
 
Example #9
Source File: ScrapingSettingsManagerImpl.java    From prom-confluence-exporter with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}
 
Example #10
Source File: SecureTokenManagerImpl.java    From jira-prometheus-exporter with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}
 
Example #11
Source File: ConfigDao.java    From pr-harmony with GNU General Public License v3.0 4 votes vote down vote up
PluginSettings repoSettings(String projectKey, String repoSlug) {
  return pluginSettingsFactory.createSettingsForKey(projectKey + "-" + repoSlug);
}
 
Example #12
Source File: ConfigDao.java    From pr-harmony with GNU General Public License v3.0 4 votes vote down vote up
PluginSettings projectSettings(String projectKey) {
  return pluginSettingsFactory.createSettingsForKey(projectKey);
}
 
Example #13
Source File: ConfigDao.java    From pr-harmony with GNU General Public License v3.0 4 votes vote down vote up
String get(PluginSettings settings, String key, String defaultValue) {
  String val = (String) settings.get(key);
  return val == null ? defaultValue : val;
}
 
Example #14
Source File: AdminConfigDao.java    From stash-token-auth with GNU General Public License v3.0 4 votes vote down vote up
public void setAdminConfig(final AdminConfig config) {
  transactionTemplate.execute(new TransactionCallback<AdminConfig>() {
    public AdminConfig doInTransaction() {
      PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
      settings.put(BASE + ".enabled", BooleanUtils.toStringTrueFalse(config.getEnabled()));
      settings.put(BASE + ".ttl", Integer.toString(config.getTtl()));
      settings.put(BASE + ".key", config.getKey());

      if(config.getAdminPaths() != null) {
        settings.put(adminPathPrefix, "true");
        settings.put(adminPermissions, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getPermissions()));
        settings.put(adminUsers, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getUsers()));
        settings.put(adminGroups, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getGroups()));
        settings.put(adminLogs, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getLogs()));
        settings.put(adminAllRestApi, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getAllRestApi()));
        settings.put(adminAllBranchUtilsApi, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getAllBranchUtilsApi()));
        settings.put(adminAllKeysApi, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getAllKeysApi()));
        settings.put(adminAllDefaultReviewersApi, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getAllDefaultReviewersApi()));
        settings.put(adminAllBranchPermissionsApi, BooleanUtils.toStringTrueFalse(config.getAdminPaths().getAllBranchPermissionsApi()));
      }

      if(config.getProjectPaths() != null) {
        settings.put(projectPathPrefix, "true");
        settings.put(projectList, BooleanUtils.toStringTrueFalse(config.getProjectPaths().getProjectList()));
        settings.put(projectPermissions, BooleanUtils.toStringTrueFalse(config.getProjectPaths().getPermissions()));
        settings.put(projectRepoList, BooleanUtils.toStringTrueFalse(config.getProjectPaths().getRepoList()));
      }

      if(config.getRepoPaths() != null) {
        settings.put(repoPathPrefix, "true");
        settings.put(repoPermissions, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getPermissions()));
        settings.put(repoCommitHistory, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getCommitHistory()));
        settings.put(repoFiles, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getFiles()));
        settings.put(repoPullRequests, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getPullRequests()));
        settings.put(repoParticipants, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getParticipants()));
        settings.put(repoBranchPermissions, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getBranchPermissions()));
        settings.put(repoBuildStatus, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getBuildStatus()));
        settings.put(repoBaseDetails, BooleanUtils.toStringTrueFalse(config.getRepoPaths().getBaseDetails()));
      }

      if(config.getSSHPaths() != null) {
        settings.put(sshPathPrefix, "true");
        settings.put(sshUserKeys, BooleanUtils.toStringTrueFalse(config.getSSHPaths().getUserKeys()));
        settings.put(sshRepoKeys, BooleanUtils.toStringTrueFalse(config.getSSHPaths().getRepoKeys()));
      }

      setCache(config);
      return config;
    }
  });
}
 
Example #15
Source File: SecureTokenManagerImpl.java    From prom-confluence-exporter with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}
 
Example #16
Source File: ScrapingSettingsManagerImpl.java    From prom-bitbucket-exporter with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}
 
Example #17
Source File: UserConfigDao.java    From stash-token-auth with GNU General Public License v3.0 4 votes vote down vote up
private UserConfig readUserConfig(String username, PluginSettings settings) {
  UserConfig config = new UserConfig();
  config.setUsername(username);
  config.setToken((String) settings.get(BASE + "." + username + ".token"));
  return config;
}
 
Example #18
Source File: SecureTokenManagerImpl.java    From prom-bitbucket-exporter with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}
 
Example #19
Source File: ScrapingSettingsManagerImpl.java    From jira-prometheus-exporter with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private synchronized PluginSettings getPluginSettings() {
    return pluginSettings;
}