diff options
author | James Moger <james.moger@gitblit.com> | 2011-11-03 08:50:47 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-11-03 08:50:47 -0400 |
commit | ec5a889c907af30afeba527def2d9f836eecbec4 (patch) | |
tree | 61a0edc743c6b386b3a32c2b373a5e1b7c8e1c07 /src/com/gitblit/client/GitblitClient.java | |
parent | bab9c96e0f4730d52415469c45b92798e03f0733 (diff) | |
download | gitblit-ec5a889c907af30afeba527def2d9f836eecbec4.tar.gz gitblit-ec5a889c907af30afeba527def2d9f836eecbec4.zip |
Feeds and Manager must respect a server's web.mountParameters setting
Diffstat (limited to 'src/com/gitblit/client/GitblitClient.java')
-rw-r--r-- | src/com/gitblit/client/GitblitClient.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java index cc2b4584..dcc7dfc5 100644 --- a/src/com/gitblit/client/GitblitClient.java +++ b/src/com/gitblit/client/GitblitClient.java @@ -38,6 +38,7 @@ import com.gitblit.models.ServerStatus; import com.gitblit.models.SyndicatedEntryModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.RpcUtils;
+import com.gitblit.utils.StringUtils;
import com.gitblit.utils.SyndicationUtils;
/**
@@ -96,6 +97,7 @@ public class GitblitClient implements Serializable { }
public void login() throws IOException {
+ refreshSettings();
refreshAvailableFeeds();
refreshRepositories();
@@ -110,7 +112,6 @@ public class GitblitClient implements Serializable { // credentials may not have administrator access
// or server may have disabled rpc management
refreshUsers();
- refreshSettings();
allowManagement = true;
} catch (UnauthorizedException e) {
} catch (ForbiddenException e) {
@@ -132,7 +133,6 @@ public class GitblitClient implements Serializable { } catch (IOException e) {
e.printStackTrace();
}
-
}
public boolean allowManagement() {
@@ -147,6 +147,33 @@ public class GitblitClient implements Serializable { return account != null && account.equalsIgnoreCase(model.owner);
}
+ public String getURL(String action, String repository, String objectId) {
+ boolean mounted = settings.get(Keys.web.mountParameters).getBoolean(true);
+ StringBuilder sb = new StringBuilder();
+ sb.append(url);
+ sb.append('/');
+ sb.append(action);
+ sb.append('/');
+ if (mounted) {
+ // mounted url/action/repository/objectId
+ sb.append(StringUtils.encodeURL(repository));
+ if (!StringUtils.isEmpty(objectId)) {
+ sb.append('/');
+ sb.append(objectId);
+ }
+ return sb.toString();
+ } else {
+ // parameterized url/action/&r=repository&h=objectId
+ sb.append("?r=");
+ sb.append(repository);
+ if (!StringUtils.isEmpty(objectId)) {
+ sb.append("&h=");
+ sb.append(objectId);
+ }
+ return sb.toString();
+ }
+ }
+
public ServerSettings getSettings() {
return settings;
}
|