| | |
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.FederationProposal;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | |
|
| | |
| | | */
|
| | | public class FederationUtils {
|
| | |
|
| | | public static final Type REPOSITORIES_TYPE = new TypeToken<Map<String, RepositoryModel>>() {
|
| | | private static final Type REPOSITORIES_TYPE = new TypeToken<Map<String, RepositoryModel>>() {
|
| | | }.getType();
|
| | |
|
| | | public static final Type SETTINGS_TYPE = new TypeToken<Map<String, String>>() {
|
| | | private static final Type SETTINGS_TYPE = new TypeToken<Map<String, String>>() {
|
| | | }.getType();
|
| | |
|
| | | public static final Type USERS_TYPE = new TypeToken<Collection<UserModel>>() {
|
| | | private static final Type USERS_TYPE = new TypeToken<Collection<UserModel>>() {
|
| | | }.getType();
|
| | |
|
| | | public static final Type RESULTS_TYPE = new TypeToken<List<FederationModel>>() {
|
| | | private static final Type TEAMS_TYPE = new TypeToken<Collection<TeamModel>>() {
|
| | | }.getType();
|
| | |
|
| | | private static final Logger LOGGER = LoggerFactory.getLogger(FederationUtils.class);
|
| | |
| | | * @return a collection of UserModel objects
|
| | | * @throws Exception
|
| | | */
|
| | | public static Collection<UserModel> getUsers(FederationModel registration) throws Exception {
|
| | | public static List<UserModel> getUsers(FederationModel registration) throws Exception {
|
| | | String url = asLink(registration.url, registration.token, FederationRequest.PULL_USERS);
|
| | | Collection<UserModel> models = JsonUtils.retrieveJson(url, USERS_TYPE);
|
| | | return models;
|
| | | List<UserModel> list = new ArrayList<UserModel>(models);
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Tries to pull the gitblit team definitions from the remote gitblit
|
| | | * instance.
|
| | | * |
| | | * @param registration
|
| | | * @return a collection of TeamModel objects
|
| | | * @throws Exception
|
| | | */
|
| | | public static List<TeamModel> getTeams(FederationModel registration) throws Exception {
|
| | | String url = asLink(registration.url, registration.token, FederationRequest.PULL_TEAMS);
|
| | | Collection<TeamModel> models = JsonUtils.retrieveJson(url, TEAMS_TYPE);
|
| | | List<TeamModel> list = new ArrayList<TeamModel>(models);
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * Tries to pull the referenced scripts from the remote gitblit instance.
|
| | | * |
| | | * @param registration
|
| | | * @return a map of the remote gitblit scripts by script name
|
| | | * @throws Exception
|
| | | */
|
| | | public static Map<String, String> getScripts(FederationModel registration) throws Exception {
|
| | | String url = asLink(registration.url, registration.token, FederationRequest.PULL_SCRIPTS);
|
| | | Map<String, String> scripts = JsonUtils.retrieveJson(url, SETTINGS_TYPE);
|
| | | return scripts;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Send an status acknowledgment to the remote Gitblit server.
|
| | | *
|
| | | * @param identification
|