From 6651a8e96bdc51b0c558b88e1c77fcfbed1837da Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 8 Jun 2014 10:30:39 -0400 Subject: Move repository ownership to the UserModel and prepare for project ownership --- src/main/java/com/gitblit/utils/ModelUtils.java | 12 ++++++++- src/main/java/com/gitblit/utils/RpcUtils.java | 35 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/gitblit/utils') diff --git a/src/main/java/com/gitblit/utils/ModelUtils.java b/src/main/java/com/gitblit/utils/ModelUtils.java index 6fb4c0ac..74e97abb 100644 --- a/src/main/java/com/gitblit/utils/ModelUtils.java +++ b/src/main/java/com/gitblit/utils/ModelUtils.java @@ -56,6 +56,16 @@ public class ModelUtils return userRepoPrefix; } + /** + * Get the user project name for a user. + * + * @param username name of user + * @return the active user repository project prefix concatenated with the user name + */ + public static String getPersonalProject(String username) + { + return userRepoPrefix + username.toLowerCase(); + } /** * Get the user project name for a user. @@ -65,7 +75,7 @@ public class ModelUtils */ public static String getPersonalPath(String username) { - return userRepoPrefix + username.toLowerCase(); + return userRepoPrefix + username.toLowerCase() + "/"; } diff --git a/src/main/java/com/gitblit/utils/RpcUtils.java b/src/main/java/com/gitblit/utils/RpcUtils.java index 82202154..21841acc 100644 --- a/src/main/java/com/gitblit/utils/RpcUtils.java +++ b/src/main/java/com/gitblit/utils/RpcUtils.java @@ -460,6 +460,41 @@ public class RpcUtils { account, password); } + /** + * Retrieves the list of owners for the specified repository. + * + * @param repository + * @param serverUrl + * @param account + * @param password + * @return list of owners + * @throws IOException + */ + public static List getRepositoryOwners(RepositoryModel repository, + String serverUrl, String account, char [] password) throws IOException { + String url = asLink(serverUrl, RpcRequest.LIST_REPOSITORY_OWNERS, repository.name); + Collection list = JsonUtils.retrieveJson(url, NAMES_TYPE, account, password); + return new ArrayList(list); + } + + /** + * Sets the repository owners + * + * @param repository + * @param owners + * @param serverUrl + * @param account + * @param password + * @return true if the action succeeded + * @throws IOException + */ + public static boolean setRepositoryOwners(RepositoryModel repository, + List owners, String serverUrl, String account, char[] password) + throws IOException { + return doAction(RpcRequest.SET_REPOSITORY_OWNERS, repository.name, owners, serverUrl, + account, password); + } + /** * Retrieves the list of teams that can access the specified repository. * -- cgit v1.2.3