2525 */
2626public class BuildWithDetails extends Build {
2727
28+ /**
29+ * This will be returned by the API in cases where the build has never run.
30+ * For example {@link Build#BUILD_HAS_NEVER_RUN}
31+ */
32+ public static final BuildWithDetails BUILD_HAS_NEVER_RUN = new BuildWithDetails () {
33+
34+ @ Override
35+ public List getActions () {
36+ return Collections .emptyList ();
37+ }
38+
39+ @ Override
40+ public List <Artifact > getArtifacts () {
41+ return Collections .<Artifact >emptyList ();
42+ }
43+
44+ @ Override
45+ public List <BuildCause > getCauses () {
46+ return Collections .<BuildCause >emptyList ();
47+ }
48+
49+ @ Override
50+ public List <BuildChangeSetAuthor > getCulprits () {
51+ return Collections .<BuildChangeSetAuthor >emptyList ();
52+ }
53+
54+ @ Override
55+ public BuildResult getResult () {
56+ return BuildResult .NOT_BUILT ;
57+ }
58+
59+ };
60+
61+ /**
62+ * This will be returned by the API in cases where the build has been
63+ * cancelled. For example {@link Build#BUILD_HAS_BEEN_CANCELLED}
64+ */
65+ public static final BuildWithDetails BUILD_HAS_BEEN_CANCELLED = new BuildWithDetails () {
66+
67+ @ Override
68+ public List getActions () {
69+ return Collections .emptyList ();
70+ }
71+
72+ @ Override
73+ public List <Artifact > getArtifacts () {
74+ return Collections .<Artifact >emptyList ();
75+ }
76+
77+ @ Override
78+ public List <BuildCause > getCauses () {
79+ return Collections .<BuildCause >emptyList ();
80+ }
81+
82+ @ Override
83+ public List <BuildChangeSetAuthor > getCulprits () {
84+ return Collections .<BuildChangeSetAuthor >emptyList ();
85+ }
86+
87+ @ Override
88+ public BuildResult getResult () {
89+ return BuildResult .CANCELLED ;
90+ }
91+
92+ };
93+
2894 private List actions ; // TODO: Should be improved.
2995 private boolean building ;
3096 private String description ;
@@ -103,7 +169,9 @@ public boolean apply(Map<String, Object> action) {
103169 }
104170
105171 /**
106- * Update <code>displayName</code> and the <code>description</code> of a build.
172+ * Update <code>displayName</code> and the <code>description</code> of a
173+ * build.
174+ *
107175 * @param displayName The new displayName which should be set.
108176 * @param description The description which should be set.
109177 * @param crumbFlag <code>true</code> or <code>false</code>.
@@ -113,14 +181,16 @@ public void updateDisplayNameAndDescription(String displayName, String descripti
113181 throws IOException {
114182 Objects .requireNonNull (displayName , "displayName is not allowed to be null." );
115183 Objects .requireNonNull (description , "description is not allowed to be null." );
116- //TODO: Check what the "core:apply" means?
184+ // TODO: Check what the "core:apply" means?
117185 ImmutableMap <String , String > params = ImmutableMap .of ("displayName" , displayName , "description" , description ,
118186 "core:apply" , "" , "Submit" , "Save" );
119187 client .post_form (this .getUrl () + "/configSubmit?" , params , crumbFlag );
120188 }
121189
122190 /**
123- * Update <code>displayName</code> and the <code>description</code> of a build.
191+ * Update <code>displayName</code> and the <code>description</code> of a
192+ * build.
193+ *
124194 * @param displayName The new displayName which should be set.
125195 * @param description The description which should be set.
126196 * @throws IOException in case of errors.
@@ -131,21 +201,23 @@ public void updateDisplayNameAndDescription(String displayName, String descripti
131201
132202 /**
133203 * Update <code>displayName</code> of a build.
204+ *
134205 * @param displayName The new displayName which should be set.
135206 * @param crumbFlag <code>true</code> or <code>false</code>.
136207 * @throws IOException in case of errors.
137208 */
138209 public void updateDisplayName (String displayName , boolean crumbFlag ) throws IOException {
139210 Objects .requireNonNull (displayName , "displayName is not allowed to be null." );
140211 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" );
212+ // TODO: Check what the "core:apply" means?
213+ ImmutableMap <String , String > params = ImmutableMap .of ("displayName" , displayName , "description" , description ,
214+ "core:apply" , "" , "Submit" , "Save" );
144215 client .post_form (this .getUrl () + "/configSubmit?" , params , crumbFlag );
145216 }
146217
147218 /**
148219 * Update <code>displayName</code> of a build.
220+ *
149221 * @param displayName The new displayName which should be set.
150222 * @throws IOException in case of errors.
151223 */
@@ -155,21 +227,23 @@ public void updateDisplayName(String displayName) throws IOException {
155227
156228 /**
157229 * Update the <code>description</code> of a build.
230+ *
158231 * @param description The description which should be set.
159232 * @param crumbFlag <code>true</code> or <code>false</code>.
160233 * @throws IOException in case of errors.
161234 */
162235 public void updateDescription (String description , boolean crumbFlag ) throws IOException {
163236 Objects .requireNonNull (description , "description is not allowed to be null." );
164237 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" );
238+ // TODO: Check what the "core:apply" means?
239+ ImmutableMap <String , String > params = ImmutableMap .of ("displayName" , displayName , "description" , description ,
240+ "core:apply" , "" , "Submit" , "Save" );
168241 client .post_form (this .getUrl () + "/configSubmit?" , params , crumbFlag );
169242 }
170243
171244 /**
172245 * Update the <code>description</code> of a build.
246+ *
173247 * @param description The description which should be set.
174248 * @throws IOException in case of errors.
175249 */
@@ -278,15 +352,15 @@ public boolean apply(Map<String, Object> action) {
278352 /**
279353 * @return The console output of the build. The line separation is done by
280354 * {@code CR+LF}.
281- * @throws IOException
282- * in case of a failure.
355+ * @throws IOException in case of a failure.
283356 */
284357 public String getConsoleOutputText () throws IOException {
285358 return client .get (getUrl () + "/logText/progressiveText" );
286359 }
287360
288361 /**
289362 * The console output with HTML.
363+ *
290364 * @return The console output as HTML.
291365 * @throws IOException
292366 */
0 commit comments