32
32
*/
33
33
public class AjaxSpider {
34
34
35
- private ClientApi api = null ;
35
+ private final ClientApi api ;
36
36
37
37
public AjaxSpider (ClientApi api ) {
38
38
this .api = api ;
@@ -42,16 +42,14 @@ public AjaxSpider(ClientApi api) {
42
42
* This component is optional and therefore the API will only work if it is installed
43
43
*/
44
44
public ApiResponse status () throws ClientApiException {
45
- Map <String , String > map = null ;
46
- return api .callApi ("ajaxSpider" , "view" , "status" , map );
45
+ return api .callApi ("ajaxSpider" , "view" , "status" , null );
47
46
}
48
47
49
48
/**
50
49
* This component is optional and therefore the API will only work if it is installed
51
50
*/
52
51
public ApiResponse results (String start , String count ) throws ClientApiException {
53
- Map <String , String > map = null ;
54
- map = new HashMap <String , String >();
52
+ Map <String , String > map = new HashMap <>();
55
53
if (start != null ) {
56
54
map .put ("start" , start );
57
55
}
@@ -65,112 +63,137 @@ public ApiResponse results(String start, String count) throws ClientApiException
65
63
* This component is optional and therefore the API will only work if it is installed
66
64
*/
67
65
public ApiResponse numberOfResults () throws ClientApiException {
68
- Map <String , String > map = null ;
69
- return api .callApi ("ajaxSpider" , "view" , "numberOfResults" , map );
66
+ return api .callApi ("ajaxSpider" , "view" , "numberOfResults" , null );
70
67
}
71
68
72
69
/**
73
70
* This component is optional and therefore the API will only work if it is installed
74
71
*/
75
72
public ApiResponse optionBrowserId () throws ClientApiException {
76
- Map <String , String > map = null ;
77
- return api .callApi ("ajaxSpider" , "view" , "optionBrowserId" , map );
73
+ return api .callApi ("ajaxSpider" , "view" , "optionBrowserId" , null );
78
74
}
79
75
80
76
/**
81
77
* This component is optional and therefore the API will only work if it is installed
82
78
*/
83
79
public ApiResponse optionEventWait () throws ClientApiException {
84
- Map <String , String > map = null ;
85
- return api .callApi ("ajaxSpider" , "view" , "optionEventWait" , map );
80
+ return api .callApi ("ajaxSpider" , "view" , "optionEventWait" , null );
86
81
}
87
82
88
83
/**
89
84
* This component is optional and therefore the API will only work if it is installed
90
85
*/
91
86
public ApiResponse optionMaxCrawlDepth () throws ClientApiException {
92
- Map <String , String > map = null ;
93
- return api .callApi ("ajaxSpider" , "view" , "optionMaxCrawlDepth" , map );
87
+ return api .callApi ("ajaxSpider" , "view" , "optionMaxCrawlDepth" , null );
94
88
}
95
89
96
90
/**
97
91
* This component is optional and therefore the API will only work if it is installed
98
92
*/
99
93
public ApiResponse optionMaxCrawlStates () throws ClientApiException {
100
- Map <String , String > map = null ;
101
- return api .callApi ("ajaxSpider" , "view" , "optionMaxCrawlStates" , map );
94
+ return api .callApi ("ajaxSpider" , "view" , "optionMaxCrawlStates" , null );
102
95
}
103
96
104
97
/**
105
98
* This component is optional and therefore the API will only work if it is installed
106
99
*/
107
100
public ApiResponse optionMaxDuration () throws ClientApiException {
108
- Map <String , String > map = null ;
109
- return api .callApi ("ajaxSpider" , "view" , "optionMaxDuration" , map );
101
+ return api .callApi ("ajaxSpider" , "view" , "optionMaxDuration" , null );
110
102
}
111
103
112
104
/**
113
105
* This component is optional and therefore the API will only work if it is installed
114
106
*/
115
107
public ApiResponse optionNumberOfBrowsers () throws ClientApiException {
116
- Map <String , String > map = null ;
117
- return api .callApi ("ajaxSpider" , "view" , "optionNumberOfBrowsers" , map );
108
+ return api .callApi ("ajaxSpider" , "view" , "optionNumberOfBrowsers" , null );
118
109
}
119
110
120
111
/**
121
112
* This component is optional and therefore the API will only work if it is installed
122
113
*/
123
114
public ApiResponse optionReloadWait () throws ClientApiException {
124
- Map <String , String > map = null ;
125
- return api .callApi ("ajaxSpider" , "view" , "optionReloadWait" , map );
115
+ return api .callApi ("ajaxSpider" , "view" , "optionReloadWait" , null );
126
116
}
127
117
128
118
/**
129
119
* This component is optional and therefore the API will only work if it is installed
130
120
*/
131
121
public ApiResponse optionClickDefaultElems () throws ClientApiException {
132
- Map <String , String > map = null ;
133
- return api .callApi ("ajaxSpider" , "view" , "optionClickDefaultElems" , map );
122
+ return api .callApi ("ajaxSpider" , "view" , "optionClickDefaultElems" , null );
134
123
}
135
124
136
125
/**
137
126
* This component is optional and therefore the API will only work if it is installed
138
127
*/
139
128
public ApiResponse optionClickElemsOnce () throws ClientApiException {
140
- Map <String , String > map = null ;
141
- return api .callApi ("ajaxSpider" , "view" , "optionClickElemsOnce" , map );
129
+ return api .callApi ("ajaxSpider" , "view" , "optionClickElemsOnce" , null );
142
130
}
143
131
144
132
/**
145
133
* This component is optional and therefore the API will only work if it is installed
146
134
*/
147
135
public ApiResponse optionRandomInputs () throws ClientApiException {
148
- Map <String , String > map = null ;
149
- return api .callApi ("ajaxSpider" , "view" , "optionRandomInputs" , map );
136
+ return api .callApi ("ajaxSpider" , "view" , "optionRandomInputs" , null );
150
137
}
151
138
152
139
/**
153
- * This component is optional and therefore the API will only work if it is installed
140
+ * This component is optional and therefore the API will only work if it is installed.
154
141
*/
155
142
public ApiResponse scan (String apikey , String url , String inscope ) throws ClientApiException {
156
- Map <String , String > map = null ;
157
- map = new HashMap <String , String >();
143
+ return scan (apikey , url , inscope , null , null );
144
+ }
145
+
146
+ /**
147
+ * Runs the spider against the given URL and/or context, optionally, spidering everything in scope. The parameter 'contextName' can be used to constrain the scan to a Context, the option 'in scope' is ignored if a context was also specified. The parameter 'subtreeOnly' allows to restrict the spider under a site's subtree (using the specified 'url').
148
+ * <p>
149
+ * This component is optional and therefore the API will only work if it is installed
150
+ */
151
+ public ApiResponse scan (String apikey , String url , String inscope , String contextname , String subtreeonly ) throws ClientApiException {
152
+ Map <String , String > map = new HashMap <>();
158
153
if (apikey != null ) {
159
154
map .put ("apikey" , apikey );
160
155
}
161
- map .put ("url" , url );
156
+ if (url != null ) {
157
+ map .put ("url" , url );
158
+ }
162
159
if (inscope != null ) {
163
160
map .put ("inScope" , inscope );
164
161
}
162
+ if (contextname != null ) {
163
+ map .put ("contextName" , contextname );
164
+ }
165
+ if (subtreeonly != null ) {
166
+ map .put ("subtreeOnly" , subtreeonly );
167
+ }
165
168
return api .callApi ("ajaxSpider" , "action" , "scan" , map );
166
169
}
167
170
171
+ /**
172
+ * Runs the spider from the perspective of a User, obtained using the given context name and user name. The parameter 'url' allows to specify the starting point for the spider, otherwise it's used an existing URL from the context (if any). The parameter 'subtreeOnly' allows to restrict the spider under a site's subtree (using the specified 'url').
173
+ * <p>
174
+ * This component is optional and therefore the API will only work if it is installed
175
+ */
176
+ public ApiResponse scanAsUser (String apikey , String contextname , String username , String url , String subtreeonly ) throws ClientApiException {
177
+ Map <String , String > map = new HashMap <>();
178
+ if (apikey != null ) {
179
+ map .put ("apikey" , apikey );
180
+ }
181
+ map .put ("contextName" , contextname );
182
+ map .put ("userName" , username );
183
+ if (url != null ) {
184
+ map .put ("url" , url );
185
+ }
186
+ if (subtreeonly != null ) {
187
+ map .put ("subtreeOnly" , subtreeonly );
188
+ }
189
+ return api .callApi ("ajaxSpider" , "action" , "scanAsUser" , map );
190
+ }
191
+
168
192
/**
169
193
* This component is optional and therefore the API will only work if it is installed
170
194
*/
171
195
public ApiResponse stop (String apikey ) throws ClientApiException {
172
- Map <String , String > map = null ;
173
- map = new HashMap <String , String >();
196
+ Map <String , String > map = new HashMap <>();
174
197
if (apikey != null ) {
175
198
map .put ("apikey" , apikey );
176
199
}
@@ -181,8 +204,7 @@ public ApiResponse stop(String apikey) throws ClientApiException {
181
204
* This component is optional and therefore the API will only work if it is installed
182
205
*/
183
206
public ApiResponse setOptionBrowserId (String apikey , String string ) throws ClientApiException {
184
- Map <String , String > map = null ;
185
- map = new HashMap <String , String >();
207
+ Map <String , String > map = new HashMap <>();
186
208
if (apikey != null ) {
187
209
map .put ("apikey" , apikey );
188
210
}
@@ -194,8 +216,7 @@ public ApiResponse setOptionBrowserId(String apikey, String string) throws Clien
194
216
* This component is optional and therefore the API will only work if it is installed
195
217
*/
196
218
public ApiResponse setOptionClickDefaultElems (String apikey , boolean bool ) throws ClientApiException {
197
- Map <String , String > map = null ;
198
- map = new HashMap <String , String >();
219
+ Map <String , String > map = new HashMap <>();
199
220
if (apikey != null ) {
200
221
map .put ("apikey" , apikey );
201
222
}
@@ -207,8 +228,7 @@ public ApiResponse setOptionClickDefaultElems(String apikey, boolean bool) throw
207
228
* This component is optional and therefore the API will only work if it is installed
208
229
*/
209
230
public ApiResponse setOptionClickElemsOnce (String apikey , boolean bool ) throws ClientApiException {
210
- Map <String , String > map = null ;
211
- map = new HashMap <String , String >();
231
+ Map <String , String > map = new HashMap <>();
212
232
if (apikey != null ) {
213
233
map .put ("apikey" , apikey );
214
234
}
@@ -220,8 +240,7 @@ public ApiResponse setOptionClickElemsOnce(String apikey, boolean bool) throws C
220
240
* This component is optional and therefore the API will only work if it is installed
221
241
*/
222
242
public ApiResponse setOptionEventWait (String apikey , int i ) throws ClientApiException {
223
- Map <String , String > map = null ;
224
- map = new HashMap <String , String >();
243
+ Map <String , String > map = new HashMap <>();
225
244
if (apikey != null ) {
226
245
map .put ("apikey" , apikey );
227
246
}
@@ -233,8 +252,7 @@ public ApiResponse setOptionEventWait(String apikey, int i) throws ClientApiExce
233
252
* This component is optional and therefore the API will only work if it is installed
234
253
*/
235
254
public ApiResponse setOptionMaxCrawlDepth (String apikey , int i ) throws ClientApiException {
236
- Map <String , String > map = null ;
237
- map = new HashMap <String , String >();
255
+ Map <String , String > map = new HashMap <>();
238
256
if (apikey != null ) {
239
257
map .put ("apikey" , apikey );
240
258
}
@@ -246,8 +264,7 @@ public ApiResponse setOptionMaxCrawlDepth(String apikey, int i) throws ClientApi
246
264
* This component is optional and therefore the API will only work if it is installed
247
265
*/
248
266
public ApiResponse setOptionMaxCrawlStates (String apikey , int i ) throws ClientApiException {
249
- Map <String , String > map = null ;
250
- map = new HashMap <String , String >();
267
+ Map <String , String > map = new HashMap <>();
251
268
if (apikey != null ) {
252
269
map .put ("apikey" , apikey );
253
270
}
@@ -259,8 +276,7 @@ public ApiResponse setOptionMaxCrawlStates(String apikey, int i) throws ClientAp
259
276
* This component is optional and therefore the API will only work if it is installed
260
277
*/
261
278
public ApiResponse setOptionMaxDuration (String apikey , int i ) throws ClientApiException {
262
- Map <String , String > map = null ;
263
- map = new HashMap <String , String >();
279
+ Map <String , String > map = new HashMap <>();
264
280
if (apikey != null ) {
265
281
map .put ("apikey" , apikey );
266
282
}
@@ -272,8 +288,7 @@ public ApiResponse setOptionMaxDuration(String apikey, int i) throws ClientApiEx
272
288
* This component is optional and therefore the API will only work if it is installed
273
289
*/
274
290
public ApiResponse setOptionNumberOfBrowsers (String apikey , int i ) throws ClientApiException {
275
- Map <String , String > map = null ;
276
- map = new HashMap <String , String >();
291
+ Map <String , String > map = new HashMap <>();
277
292
if (apikey != null ) {
278
293
map .put ("apikey" , apikey );
279
294
}
@@ -285,8 +300,7 @@ public ApiResponse setOptionNumberOfBrowsers(String apikey, int i) throws Client
285
300
* This component is optional and therefore the API will only work if it is installed
286
301
*/
287
302
public ApiResponse setOptionRandomInputs (String apikey , boolean bool ) throws ClientApiException {
288
- Map <String , String > map = null ;
289
- map = new HashMap <String , String >();
303
+ Map <String , String > map = new HashMap <>();
290
304
if (apikey != null ) {
291
305
map .put ("apikey" , apikey );
292
306
}
@@ -298,8 +312,7 @@ public ApiResponse setOptionRandomInputs(String apikey, boolean bool) throws Cli
298
312
* This component is optional and therefore the API will only work if it is installed
299
313
*/
300
314
public ApiResponse setOptionReloadWait (String apikey , int i ) throws ClientApiException {
301
- Map <String , String > map = null ;
302
- map = new HashMap <String , String >();
315
+ Map <String , String > map = new HashMap <>();
303
316
if (apikey != null ) {
304
317
map .put ("apikey" , apikey );
305
318
}
0 commit comments