1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.rest.params; |
22 |
|
|
23 |
|
import jalview.util.MessageManager; |
24 |
|
import jalview.ws.params.OptionI; |
25 |
|
import jalview.ws.rest.InputType; |
26 |
|
import jalview.ws.rest.NoValidInputDataException; |
27 |
|
import jalview.ws.rest.RestJob; |
28 |
|
|
29 |
|
import java.io.UnsupportedEncodingException; |
30 |
|
import java.net.URLEncoder; |
31 |
|
import java.util.ArrayList; |
32 |
|
import java.util.List; |
33 |
|
|
34 |
|
import org.apache.http.entity.mime.content.ContentBody; |
35 |
|
import org.apache.http.entity.mime.content.StringBody; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@author |
41 |
|
|
42 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 12 |
Complexity Density: 0.6 |
|
43 |
|
public class JobConstant extends InputType |
44 |
|
{ |
45 |
|
|
46 |
|
String value; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
|
52 |
|
@param |
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
55 |
0 |
public JobConstant(String param, String val)... |
56 |
|
{ |
57 |
|
|
58 |
0 |
super(null); |
59 |
0 |
this.token = param; |
60 |
0 |
value = val; |
61 |
|
} |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
0 |
@Override... |
64 |
|
public ContentBody formatForInput(RestJob rj) |
65 |
|
throws UnsupportedEncodingException, NoValidInputDataException |
66 |
|
{ |
67 |
|
|
68 |
0 |
return new StringBody(value); |
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
71 |
0 |
@Override... |
72 |
|
public List<String> getURLEncodedParameter() |
73 |
|
{ |
74 |
0 |
ArrayList<String> prm = new ArrayList<String>(); |
75 |
|
|
76 |
0 |
if (value != null && value.length() > 0) |
77 |
|
{ |
78 |
0 |
try |
79 |
|
{ |
80 |
0 |
prm.add(URLEncoder.encode(value, "UTF-8")); |
81 |
|
} catch (UnsupportedEncodingException ex) |
82 |
|
{ |
83 |
0 |
throw new Error(MessageManager |
84 |
|
.formatMessage("error.couldnt_encode_as_utf8", new String[] |
85 |
|
{ value }), ex); |
86 |
|
|
87 |
|
} |
88 |
|
} |
89 |
0 |
return prm; |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0 |
@Override... |
93 |
|
public String getURLtokenPrefix() |
94 |
|
{ |
95 |
0 |
return ""; |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
98 |
0 |
@Override... |
99 |
|
public boolean configureFromURLtokenString(List<String> tokenstring, |
100 |
|
StringBuffer warnings) |
101 |
|
{ |
102 |
0 |
if (tokenstring.size() > 1) |
103 |
|
{ |
104 |
0 |
warnings.append( |
105 |
|
"IMPLEMENTATION ERROR: Constant POST parameters cannot have more than one value."); |
106 |
0 |
return false; |
107 |
|
} |
108 |
0 |
if (tokenstring.size() == 1) |
109 |
|
{ |
110 |
0 |
value = tokenstring.get(0); |
111 |
|
} |
112 |
0 |
return true; |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
115 |
0 |
@Override... |
116 |
|
public boolean configureProperty(String tok, String val, |
117 |
|
StringBuffer warnings) |
118 |
|
{ |
119 |
0 |
warnings.append( |
120 |
|
"IMPLEMENTATION ERROR: No Properties to configure for a Constant parameter."); |
121 |
0 |
return false; |
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
124 |
0 |
@Override... |
125 |
|
public List<OptionI> getOptions() |
126 |
|
{ |
127 |
|
|
128 |
0 |
return new ArrayList<OptionI>(); |
129 |
|
} |
130 |
|
} |