summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/utils
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-06-08 10:30:39 -0400
committerJames Moger <james.moger@gitblit.com>2014-06-13 08:00:48 -0400
commit6651a8e96bdc51b0c558b88e1c77fcfbed1837da (patch)
treeb2d89a6dd77868783485af61636c65edf32b1861 /src/main/java/com/gitblit/utils
parent2bfea381bbcea934f7e20f8c00db86e990c2fc93 (diff)
downloadgitblit-ticket/75.tar.gz
gitblit-ticket/75.zip
Move repository ownership to the UserModel and prepare for project ownershipticket/75
Diffstat (limited to 'src/main/java/com/gitblit/utils')
-rw-r--r--src/main/java/com/gitblit/utils/ModelUtils.java12
-rw-r--r--src/main/java/com/gitblit/utils/RpcUtils.java35
2 files changed, 46 insertions, 1 deletions
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
@@ -461,6 +461,41 @@ public class RpcUtils {
}
/**
+ * 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<String> getRepositoryOwners(RepositoryModel repository,
+ String serverUrl, String account, char [] password) throws IOException {
+ String url = asLink(serverUrl, RpcRequest.LIST_REPOSITORY_OWNERS, repository.name);
+ Collection<String> list = JsonUtils.retrieveJson(url, NAMES_TYPE, account, password);
+ return new ArrayList<String>(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<String> 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.
*
* @param repository