| | |
| | | import com.gitblit.models.FederationProposal;
|
| | | import com.gitblit.models.FederationSet;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.ServerSettings;
|
| | | import com.gitblit.models.ServerStatus;
|
| | | import com.gitblit.models.SettingModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | |
|
| | |
| | | public class RpcUtils {
|
| | |
|
| | | public static final Type NAMES_TYPE = new TypeToken<Collection<String>>() {
|
| | | }.getType();
|
| | |
|
| | | public static final Type SETTINGS_TYPE = new TypeToken<Collection<SettingModel>>() {
|
| | | }.getType();
|
| | |
|
| | | private static final Type REPOSITORIES_TYPE = new TypeToken<Map<String, RepositoryModel>>() {
|
| | |
| | | List<FederationModel> list = new ArrayList<FederationModel>(registrations);
|
| | | return list;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Retrieves the list of federation proposals.
|
| | | *
|
| | |
| | | * @return a collection of FederationProposal objects
|
| | | * @throws IOException
|
| | | */
|
| | | public static List<FederationProposal> getFederationProposals(String serverUrl,
|
| | | String account, char[] password) throws IOException {
|
| | | public static List<FederationProposal> getFederationProposals(String serverUrl, String account,
|
| | | char[] password) throws IOException {
|
| | | String url = asLink(serverUrl, RpcRequest.LIST_FEDERATION_PROPOSALS);
|
| | | Collection<FederationProposal> proposals = JsonUtils.retrieveJson(url, PROPOSALS_TYPE,
|
| | | account, password);
|
| | | List<FederationProposal> list = new ArrayList<FederationProposal>(proposals);
|
| | | return list;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Retrieves the list of federation repository sets.
|
| | | *
|
| | |
| | | * @return a collection of FederationSet objects
|
| | | * @throws IOException
|
| | | */
|
| | | public static List<FederationSet> getFederationSets(String serverUrl,
|
| | | String account, char[] password) throws IOException {
|
| | | public static List<FederationSet> getFederationSets(String serverUrl, String account,
|
| | | char[] password) throws IOException {
|
| | | String url = asLink(serverUrl, RpcRequest.LIST_FEDERATION_SETS);
|
| | | Collection<FederationSet> sets = JsonUtils.retrieveJson(url, SETS_TYPE,
|
| | | account, password);
|
| | | Collection<FederationSet> sets = JsonUtils.retrieveJson(url, SETS_TYPE, account, password);
|
| | | List<FederationSet> list = new ArrayList<FederationSet>(sets);
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Retrieves the settings of the Gitblit server.
|
| | | * |
| | | * @param serverUrl
|
| | | * @param account
|
| | | * @param password
|
| | | * @return an Settings object
|
| | | * @throws IOException
|
| | | */
|
| | | public static ServerSettings getSettings(String serverUrl, String account, char[] password)
|
| | | throws IOException {
|
| | | String url = asLink(serverUrl, RpcRequest.LIST_SETTINGS);
|
| | | ServerSettings settings = JsonUtils.retrieveJson(url, ServerSettings.class, account,
|
| | | password);
|
| | | return settings;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Update the settings on the Gitblit server.
|
| | | * |
| | | * @param settings
|
| | | * the settings to update
|
| | | * @param serverUrl
|
| | | * @param account
|
| | | * @param password
|
| | | * @return true if the action succeeded
|
| | | * @throws IOException
|
| | | */
|
| | | public static boolean updateSettings(Map<String, String> settings, String serverUrl,
|
| | | String account, char[] password) throws IOException {
|
| | | return doAction(RpcRequest.EDIT_SETTINGS, null, settings, serverUrl, account, password);
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * Retrieves the server status object.
|
| | | * |
| | | * @param serverUrl
|
| | | * @param account
|
| | | * @param password
|
| | | * @return an ServerStatus object
|
| | | * @throws IOException
|
| | | */
|
| | | public static ServerStatus getStatus(String serverUrl, String account, char[] password)
|
| | | throws IOException {
|
| | | String url = asLink(serverUrl, RpcRequest.LIST_STATUS);
|
| | | ServerStatus status = JsonUtils.retrieveJson(url, ServerStatus.class, account, password);
|
| | | return status;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Do the specified administrative action on the Gitblit server.
|
| | | *
|
| | | * @param request
|