8
8
9
9
import com .google .common .base .Predicate ;
10
10
import com .google .common .base .Strings ;
11
+ import com .google .common .collect .ImmutableMap ;
11
12
12
13
import java .io .IOException ;
13
14
import java .io .InputStream ;
@@ -27,6 +28,7 @@ public class BuildWithDetails extends Build {
27
28
private List actions ; // TODO: Should be improved.
28
29
private boolean building ;
29
30
private String description ;
31
+ private String displayName ;
30
32
private long duration ;
31
33
private long estimatedDuration ;
32
34
private String fullDisplayName ;
@@ -43,9 +45,11 @@ public class BuildWithDetails extends Build {
43
45
public BuildWithDetails () {
44
46
// Default ctor is needed to jackson.
45
47
}
48
+
46
49
public BuildWithDetails (BuildWithDetails details ) {
47
50
this .actions = details .actions ;
48
51
this .description = details .description ;
52
+ this .displayName = details .displayName ;
49
53
this .building = details .building ;
50
54
this .duration = details .duration ;
51
55
this .estimatedDuration = details .estimatedDuration ;
@@ -98,6 +102,81 @@ public boolean apply(Map<String, Object> action) {
98
102
return result ;
99
103
}
100
104
105
+ /**
106
+ * Update <code>displayName</code> and the <code>description</code> of a build.
107
+ * @param displayName The new displayName which should be set.
108
+ * @param description The description which should be set.
109
+ * @param crumbFlag <code>true</code> or <code>false</code>.
110
+ * @throws IOException in case of errors.
111
+ */
112
+ public void updateDisplayNameAndDescription (String displayName , String description , boolean crumbFlag )
113
+ throws IOException {
114
+ Objects .requireNonNull (displayName , "displayName is not allowed to be null." );
115
+ Objects .requireNonNull (description , "description is not allowed to be null." );
116
+ //TODO: Check what the "core:apply" means?
117
+ ImmutableMap <String , String > params = ImmutableMap .of ("displayName" , displayName , "description" , description ,
118
+ "core:apply" , "" , "Submit" , "Save" );
119
+ client .post_form (this .getUrl () + "/configSubmit?" , params , crumbFlag );
120
+ }
121
+
122
+ /**
123
+ * Update <code>displayName</code> and the <code>description</code> of a build.
124
+ * @param displayName The new displayName which should be set.
125
+ * @param description The description which should be set.
126
+ * @throws IOException in case of errors.
127
+ */
128
+ public void updateDisplayNameAndDescription (String displayName , String description ) throws IOException {
129
+ updateDisplayNameAndDescription (displayName , description , false );
130
+ }
131
+
132
+ /**
133
+ * Update <code>displayName</code> of a build.
134
+ * @param displayName The new displayName which should be set.
135
+ * @param crumbFlag <code>true</code> or <code>false</code>.
136
+ * @throws IOException in case of errors.
137
+ */
138
+ public void updateDisplayName (String displayName , boolean crumbFlag ) throws IOException {
139
+ Objects .requireNonNull (displayName , "displayName is not allowed to be null." );
140
+ String description = getDescription () == null ? "" : getDescription ();
141
+ //TODO: Check what the "core:apply" means?
142
+ ImmutableMap <String , String > params = ImmutableMap .of ("displayName" , displayName , "description" ,
143
+ description , "core:apply" , "" , "Submit" , "Save" );
144
+ client .post_form (this .getUrl () + "/configSubmit?" , params , crumbFlag );
145
+ }
146
+
147
+ /**
148
+ * Update <code>displayName</code> of a build.
149
+ * @param displayName The new displayName which should be set.
150
+ * @throws IOException in case of errors.
151
+ */
152
+ public void updateDisplayName (String displayName ) throws IOException {
153
+ updateDisplayName (displayName , false );
154
+ }
155
+
156
+ /**
157
+ * Update the <code>description</code> of a build.
158
+ * @param description The description which should be set.
159
+ * @param crumbFlag <code>true</code> or <code>false</code>.
160
+ * @throws IOException in case of errors.
161
+ */
162
+ public void updateDescription (String description , boolean crumbFlag ) throws IOException {
163
+ Objects .requireNonNull (description , "description is not allowed to be null." );
164
+ String displayName = getDisplayName () == null ? "" : getDisplayName ();
165
+ //TODO: Check what the "core:apply" means?
166
+ ImmutableMap <String , String > params = ImmutableMap .of ("displayName" , displayName , "description" ,
167
+ description , "core:apply" , "" , "Submit" , "Save" );
168
+ client .post_form (this .getUrl () + "/configSubmit?" , params , crumbFlag );
169
+ }
170
+
171
+ /**
172
+ * Update the <code>description</code> of a build.
173
+ * @param description The description which should be set.
174
+ * @throws IOException in case of errors.
175
+ */
176
+ public void updateDescription (String description ) throws IOException {
177
+ updateDescription (description , false );
178
+ }
179
+
101
180
private BuildCause convertToBuildCause (Map <String , Object > cause ) {
102
181
BuildCause cause_object = new BuildCause ();
103
182
@@ -150,6 +229,10 @@ public String getFullDisplayName() {
150
229
return fullDisplayName ;
151
230
}
152
231
232
+ public String getDisplayName () {
233
+ return displayName ;
234
+ }
235
+
153
236
public String getId () {
154
237
return id ;
155
238
}
@@ -202,6 +285,11 @@ public String getConsoleOutputText() throws IOException {
202
285
return client .get (getUrl () + "/logText/progressiveText" );
203
286
}
204
287
288
+ /**
289
+ * The console output with HTML.
290
+ * @return The console output as HTML.
291
+ * @throws IOException
292
+ */
205
293
public String getConsoleOutputHtml () throws IOException {
206
294
return client .get (getUrl () + "/logText/progressiveHtml" );
207
295
}
@@ -287,6 +375,11 @@ public boolean equals(Object obj) {
287
375
return false ;
288
376
} else if (!description .equals (other .description ))
289
377
return false ;
378
+ if (displayName == null ) {
379
+ if (other .displayName != null )
380
+ return false ;
381
+ } else if (!displayName .equals (other .displayName ))
382
+ return false ;
290
383
if (duration != other .duration )
291
384
return false ;
292
385
if (estimatedDuration != other .estimatedDuration )
@@ -321,6 +414,7 @@ public int hashCode() {
321
414
result = prime * result + ((consoleOutputText == null ) ? 0 : consoleOutputText .hashCode ());
322
415
result = prime * result + ((culprits == null ) ? 0 : culprits .hashCode ());
323
416
result = prime * result + ((description == null ) ? 0 : description .hashCode ());
417
+ result = prime * result + ((displayName == null ) ? 0 : displayName .hashCode ());
324
418
result = prime * result + (int ) (duration ^ (duration >>> 32 ));
325
419
result = prime * result + (int ) (estimatedDuration ^ (estimatedDuration >>> 32 ));
326
420
result = prime * result + ((fullDisplayName == null ) ? 0 : fullDisplayName .hashCode ());
0 commit comments