diff options
author | James Moger <james.moger@gitblit.com> | 2013-05-21 17:36:51 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-05-21 17:36:51 -0400 |
commit | 416614cdc35aff21281df7d1f359cd9f65d5af63 (patch) | |
tree | a58fbbf65fa13541e9e94f47776e367302b66323 | |
parent | 80d281ea19de08c6e10d2c502a109ecdc72736f4 (diff) | |
download | gitblit-416614cdc35aff21281df7d1f359cd9f65d5af63.tar.gz gitblit-416614cdc35aff21281df7d1f359cd9f65d5af63.zip |
Allow clients to define supported transports
-rw-r--r-- | src/main/java/com/gitblit/models/GitClientApplication.java | 20 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java | 20 |
2 files changed, 29 insertions, 11 deletions
diff --git a/src/main/java/com/gitblit/models/GitClientApplication.java b/src/main/java/com/gitblit/models/GitClientApplication.java index 8225da4a..eb47eb1f 100644 --- a/src/main/java/com/gitblit/models/GitClientApplication.java +++ b/src/main/java/com/gitblit/models/GitClientApplication.java @@ -39,6 +39,7 @@ public class GitClientApplication implements Serializable { public String cloneUrl;
public String command;
public String productUrl;
+ public String [] transports;
public String[] platforms;
public AccessPermission minimumPermission;
public boolean isActive;
@@ -60,6 +61,25 @@ public class GitClientApplication implements Serializable { return false;
}
+ public boolean supportsTransport(String transportOrUrl) {
+ if (ArrayUtils.isEmpty(transports)) {
+ return true;
+ }
+
+ String scheme = transportOrUrl;
+ if (transportOrUrl.indexOf(':') > -1) {
+ // strip scheme
+ scheme = transportOrUrl.substring(0, transportOrUrl.indexOf(':'));
+ }
+
+ for (String transport : transports) {
+ if (transport.equalsIgnoreCase(scheme)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public String toString() {
return StringUtils.isEmpty(title) ? name : title;
diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java index b28599f3..8a64b18e 100644 --- a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java @@ -228,18 +228,16 @@ public class RepositoryUrlPanel extends BasePanel { final GitClientApplication clientApp = item.getModelObject();
// filter the urls for the client app
- List<RepositoryUrl> urls;
- if (clientApp.minimumPermission == null) {
- // client app does not specify minimum access permission
- urls = repositoryUrls;
- } else {
- urls = new ArrayList<RepositoryUrl>();
- for (RepositoryUrl repoUrl : repositoryUrls) {
- if (repoUrl.permission == null) {
- // external permissions, assume it is satisfactory
+ List<RepositoryUrl> urls = new ArrayList<RepositoryUrl>();
+ for (RepositoryUrl repoUrl : repositoryUrls) {
+ if (clientApp.minimumPermission == null || repoUrl.permission == null) {
+ // no minimum permission or external permissions, assume it is satisfactory
+ if (clientApp.supportsTransport(repoUrl.url)) {
urls.add(repoUrl);
- } else if (repoUrl.permission.atLeast(clientApp.minimumPermission)) {
- // repo url meets minimum permission requirement
+ }
+ } else if (repoUrl.permission.atLeast(clientApp.minimumPermission)) {
+ // repo url meets minimum permission requirement
+ if (clientApp.supportsTransport(repoUrl.url)) {
urls.add(repoUrl);
}
}
|