FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/Hudson.java at main · Eggy115/Java · GitHub
Eggy115
/
Java
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
5
Star
3
Code
Issues
0
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
Hudson.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
322 lines (288 loc) · 11.4 KB
Breadcrumbs
Java
/
Hudson.java
Copy path
File metadata and controls
322 lines (288 loc) · 11.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
* The MIT License
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi,
* Erik Ramfelt, Koichi Fujikawa, Red Hat, Inc., Seiji Sogabe,
* Stephen Connolly, Tom Huybrechts, Yahoo! Inc., Alan Harder, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson
.
model
;
import
hudson
.
ExtensionListView
;
import
hudson
.
Functions
;
import
hudson
.
Platform
;
import
hudson
.
PluginManager
;
import
hudson
.
cli
.
declarative
.
CLIResolver
;
import
hudson
.
model
.
listeners
.
ItemListener
;
import
hudson
.
slaves
.
ComputerListener
;
import
hudson
.
util
.
CopyOnWriteList
;
import
hudson
.
util
.
FormValidation
;
import
jenkins
.
model
.
Jenkins
;
import
org
.
jvnet
.
hudson
.
reactor
.
ReactorException
;
import
org
.
kohsuke
.
stapler
.
QueryParameter
;
import
org
.
kohsuke
.
stapler
.
Stapler
;
import
org
.
kohsuke
.
stapler
.
StaplerRequest
;
import
org
.
kohsuke
.
stapler
.
StaplerResponse
;
import
javax
.
servlet
.
ServletContext
;
import
javax
.
servlet
.
ServletException
;
import
java
.
io
.
File
;
import
java
.
io
.
IOException
;
import
java
.
text
.
NumberFormat
;
import
java
.
text
.
ParseException
;
import
java
.
util
.
Collections
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
static
hudson
.
Util
.
fixEmpty
;
public
class
Hudson
extends
Jenkins
{
/**
* List of registered {@link hudson.model.listeners.ItemListener}s.
* @deprecated as of 1.286
*/
private
transient
final
CopyOnWriteList
<
ItemListener
>
itemListeners
=
ExtensionListView
.
createCopyOnWriteList
(
ItemListener
.
class
);
/**
* List of registered {@link hudson.slaves.ComputerListener}s.
* @deprecated as of 1.286
*/
private
transient
final
CopyOnWriteList
<
ComputerListener
>
computerListeners
=
ExtensionListView
.
createCopyOnWriteList
(
ComputerListener
.
class
);
@
CLIResolver
public
static
Hudson
getInstance
() {
return
(
Hudson
)
Jenkins
.
getInstance
();
}
public
Hudson
(
File
root
,
ServletContext
context
)
throws
IOException
,
InterruptedException
,
ReactorException
{
this
(
root
,
context
,
null
);
}
public
Hudson
(
File
root
,
ServletContext
context
,
PluginManager
pluginManager
)
throws
IOException
,
InterruptedException
,
ReactorException
{
super
(
root
,
context
,
pluginManager
);
}
/**
* Gets all the installed {@link ItemListener}s.
*
* @deprecated as of 1.286.
* Use {@link ItemListener#all()}.
*/
public
CopyOnWriteList
<
ItemListener
>
getJobListeners
() {
return
itemListeners
;
}
/**
* Gets all the installed {@link ComputerListener}s.
*
* @deprecated as of 1.286.
* Use {@link ComputerListener#all()}.
*/
public
CopyOnWriteList
<
ComputerListener
>
getComputerListeners
() {
return
computerListeners
;
}
/**
* Gets the slave node of the give name, hooked under this Hudson.
*
* @deprecated
* Use {@link #getNode(String)}. Since 1.252.
*/
public
Slave
getSlave
(
String
name
) {
Node
n
=
getNode
(
name
);
if
(
n
instanceof
Slave
)
return
(
Slave
)
n
;
return
null
;
}
/**
* @deprecated
* Use {@link #getNodes()}. Since 1.252.
*/
public
List
<
Slave
>
getSlaves
() {
return
(
List
)
slaves
;
}
/**
* Updates the slave list.
*
* @deprecated
* Use {@link #setNodes(List)}. Since 1.252.
*/
public
void
setSlaves
(
List
<
Slave
>
slaves
)
throws
IOException
{
setNodes
(
slaves
);
}
/**
* @deprecated
* Left only for the compatibility of URLs.
* Should not be invoked for any other purpose.
*/
public
TopLevelItem
getJob
(
String
name
) {
return
getItem
(
name
);
}
/**
* @deprecated
* Used only for mapping jobs to URL in a case-insensitive fashion.
*/
public
TopLevelItem
getJobCaseInsensitive
(
String
name
) {
String
match
=
Functions
.
toEmailSafeString
(
name
);
for
(
TopLevelItem
item
:
getItems
()) {
if
(
Functions
.
toEmailSafeString
(
item
.
getName
()).
equalsIgnoreCase
(
match
)) {
return
item
;
}
}
return
null
;
}
/**
* @deprecated as of 1.317
* Use {@link #doQuietDown()} instead.
*/
public
synchronized
void
doQuietDown
(
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
doQuietDown
().
generateResponse
(
null
,
rsp
,
this
);
}
/**
* RSS feed for log entries.
*
* @deprecated
* As on 1.267, moved to "/log/rss..."
*/
public
void
doLogRss
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
String
qs
=
req
.
getQueryString
();
rsp
.
sendRedirect2
(
"./log/rss"
+(
qs
==
null
?
""
:
'?'
+
qs
));
}
/**
* @deprecated as of 1.294
* Define your own check method, instead of relying on this generic one.
*/
public
void
doFieldCheck
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
doFieldCheck
(
fixEmpty
(
req
.
getParameter
(
"value"
)),
fixEmpty
(
req
.
getParameter
(
"type"
)),
fixEmpty
(
req
.
getParameter
(
"errorText"
)),
fixEmpty
(
req
.
getParameter
(
"warningText"
))).
generateResponse
(
req
,
rsp
,
this
);
}
/**
* Checks if the value for a field is set; if not an error or warning text is displayed.
* If the parameter "value" is not set then the parameter "errorText" is displayed
* as an error text. If the parameter "errorText" is not set, then the parameter "warningText"
* is displayed as a warning text.
* <p>
* If the text is set and the parameter "type" is set, it will validate that the value is of the
* correct type. Supported types are "number, "number-positive" and "number-negative".
*
* @deprecated as of 1.324
* Either use client-side validation (e.g. class="required number")
* or define your own check method, instead of relying on this generic one.
*/
public
FormValidation
doFieldCheck
(
@
QueryParameter
(
fixEmpty
=
true
)
String
value
,
@
QueryParameter
(
fixEmpty
=
true
)
String
type
,
@
QueryParameter
(
fixEmpty
=
true
)
String
errorText
,
@
QueryParameter
(
fixEmpty
=
true
)
String
warningText
) {
if
(
value
==
null
) {
if
(
errorText
!=
null
)
return
FormValidation
.
error
(
errorText
);
if
(
warningText
!=
null
)
return
FormValidation
.
warning
(
warningText
);
return
FormValidation
.
error
(
"No error or warning text was set for fieldCheck()."
);
}
if
(
type
!=
null
) {
try
{
if
(
type
.
equalsIgnoreCase
(
"number"
)) {
NumberFormat
.
getInstance
().
parse
(
value
);
}
else
if
(
type
.
equalsIgnoreCase
(
"number-positive"
)) {
if
(
NumberFormat
.
getInstance
().
parse
(
value
).
floatValue
() <=
0
)
return
FormValidation
.
error
(
Messages
.
Hudson_NotAPositiveNumber
());
}
else
if
(
type
.
equalsIgnoreCase
(
"number-negative"
)) {
if
(
NumberFormat
.
getInstance
().
parse
(
value
).
floatValue
() >=
0
)
return
FormValidation
.
error
(
Messages
.
Hudson_NotANegativeNumber
());
}
}
catch
(
ParseException
e
) {
return
FormValidation
.
error
(
Messages
.
Hudson_NotANumber
());
}
}
return
FormValidation
.
ok
();
}
/**
* @deprecated
* Use {@link Functions#isWindows()}.
*/
public
static
boolean
isWindows
() {
return
File
.
pathSeparatorChar
==
';'
;
}
/**
* @deprecated
* Use {@link hudson.Platform#isDarwin()}
*/
public
static
boolean
isDarwin
() {
return
Platform
.
isDarwin
();
}
/**
* @deprecated since 2007-12-18.
* Use {@link #checkPermission(hudson.security.Permission)}
*/
public
static
boolean
adminCheck
()
throws
IOException
{
return
adminCheck
(
Stapler
.
getCurrentRequest
(),
Stapler
.
getCurrentResponse
());
}
/**
* @deprecated since 2007-12-18.
* Use {@link #checkPermission(hudson.security.Permission)}
*/
public
static
boolean
adminCheck
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
{
if
(
isAdmin
(
req
))
return
true
;
rsp
.
sendError
(
StaplerResponse
.
SC_FORBIDDEN
);
return
false
;
}
/**
* Checks if the current user (for which we are processing the current request)
* has the admin access.
*
* @deprecated since 2007-12-18.
* This method is deprecated when Hudson moved from simple Unix root-like model
* of "admin gets to do everything, and others don't have any privilege" to more
* complex {@link hudson.security.ACL} and {@link hudson.security.Permission} based scheme.
*
* <p>
* For a quick migration, use {@code Hudson.getInstance().getACL().hasPermission(Hudson.ADMINISTER)}
* To check if the user has the 'administer' role in Hudson.
*
* <p>
* But ideally, your plugin should first identify a suitable {@link hudson.security.Permission} (or create one,
* if appropriate), then identify a suitable {@link hudson.security.AccessControlled} object to check its permission
* against.
*/
public
static
boolean
isAdmin
() {
return
Jenkins
.
getInstance
().
getACL
().
hasPermission
(
ADMINISTER
);
}
/**
* @deprecated since 2007-12-18.
* Define a custom {@link hudson.security.Permission} and check against ACL.
* See {@link #isAdmin()} for more instructions.
*/
public
static
boolean
isAdmin
(
StaplerRequest
req
) {
return
isAdmin
();
}
static
{
XSTREAM
.
alias
(
"hudson"
,
Hudson
.
class
);
}
/**
* @deprecated only here for backward comp
*/
public
static
final
class
MasterComputer
extends
Jenkins
.
MasterComputer
{
// no op
}
/**
* @deprecated only here for backward comp
*/
public
static
class
CloudList
extends
Jenkins
.
CloudList
{
public
CloudList
(
Jenkins
h
) {
super
(
h
);
}
public
CloudList
() {
// needed for XStream deserialization
super
();
}
}
}
Back
|
FazBrowse Home
|
New Git URL