commit | author | age
|
ffbf03
|
1 |
/*
|
JM |
2 |
* Copyright 2013 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package com.gitblit.models;
|
|
17 |
|
|
18 |
import java.io.Serializable;
|
|
19 |
|
366bec
|
20 |
import com.gitblit.Constants.AccessPermission;
|
ffbf03
|
21 |
import com.gitblit.utils.ArrayUtils;
|
JM |
22 |
import com.gitblit.utils.StringUtils;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* Model class to represent a git client application.
|
699e71
|
26 |
*
|
ffbf03
|
27 |
* @author James Moger
|
JM |
28 |
*
|
|
29 |
*/
|
|
30 |
public class GitClientApplication implements Serializable {
|
|
31 |
|
|
32 |
private static final long serialVersionUID = 1L;
|
|
33 |
|
|
34 |
public String name;
|
828add
|
35 |
public String title;
|
JM |
36 |
public String description;
|
|
37 |
public String legal;
|
|
38 |
public String icon;
|
ffbf03
|
39 |
public String cloneUrl;
|
JM |
40 |
public String command;
|
|
41 |
public String productUrl;
|
416614
|
42 |
public String [] transports;
|
ffbf03
|
43 |
public String[] platforms;
|
366bec
|
44 |
public AccessPermission minimumPermission;
|
828add
|
45 |
public boolean isActive;
|
ffbf03
|
46 |
|
JM |
47 |
public boolean allowsPlatform(String p) {
|
|
48 |
if (ArrayUtils.isEmpty(platforms)) {
|
|
49 |
// all platforms
|
|
50 |
return true;
|
|
51 |
}
|
|
52 |
if (StringUtils.isEmpty(p)) {
|
|
53 |
return false;
|
|
54 |
}
|
|
55 |
String plc = p.toLowerCase();
|
|
56 |
for (String platform : platforms) {
|
|
57 |
if (plc.contains(platform)) {
|
|
58 |
return true;
|
|
59 |
}
|
|
60 |
}
|
|
61 |
return false;
|
|
62 |
}
|
699e71
|
63 |
|
416614
|
64 |
public boolean supportsTransport(String transportOrUrl) {
|
JM |
65 |
if (ArrayUtils.isEmpty(transports)) {
|
|
66 |
return true;
|
|
67 |
}
|
699e71
|
68 |
|
416614
|
69 |
String scheme = transportOrUrl;
|
JM |
70 |
if (transportOrUrl.indexOf(':') > -1) {
|
|
71 |
// strip scheme
|
|
72 |
scheme = transportOrUrl.substring(0, transportOrUrl.indexOf(':'));
|
|
73 |
}
|
699e71
|
74 |
|
416614
|
75 |
for (String transport : transports) {
|
JM |
76 |
if (transport.equalsIgnoreCase(scheme)) {
|
|
77 |
return true;
|
|
78 |
}
|
|
79 |
}
|
|
80 |
return false;
|
|
81 |
}
|
699e71
|
82 |
|
828add
|
83 |
@Override
|
JM |
84 |
public String toString() {
|
|
85 |
return StringUtils.isEmpty(title) ? name : title;
|
|
86 |
}
|
ffbf03
|
87 |
} |