File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\model\PermalinkProjectAction.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.model;
25
26 import java.util.List;
27 import java.util.concurrent.CopyOnWriteArrayList;
28
29 /**
30 * Optional interface for {@link Action}s that are attached
31 * to {@link AbstractProject} (through {@link JobProperty#getJobActions(Job)}),
32 * which allows plugins to define additional permalinks in the project.
33 *
34 * <p>
35 * Permalinks are listed together in the UI for better ease of use,
36 * plus other plugins can use this information elsewhere (for example,
37 * a plugin to download an artifact from one of the permalinks.)
38 *
39 * @author Kohsuke Kawaguchi
40 * @since 1.253
41 * @see JobProperty
42 */
43 public interface PermalinkProjectAction extends Action {
44 /**
45 * Gets the permalinks defined for this project.
46 *
47 * <p>
48 * Because {@link Permalink} is a strategy-pattern object,
49 * this method should normally return a pre-initialzied
50 * read-only static list object.
51 *
52 * @return
53 * can be empty, but never null.
54 */
55 List<Permalink> getPermalinks();
56
57 /**
58 * Permalink as a strategy pattern.
59 */
60 abstract class Permalink {
61 /**
62 * String to be displayed in the UI, such as "Last successful build".
63 * The convention is to upper case the first letter.
64 */
65 public abstract String getDisplayName();
66
67 /**
68 * ID that uniquely identifies this permalink.
69 *
70 * <p>
71 * The is also used as an URL token to represent the permalink.
72 * This becomes the part of the permanent URL.
73 *
74 * <p>
75 * The expected format is the camel case,
76 * such as "lastSuccessfulBuild".
77 */
78 public abstract String getId();
79
80 /**
81 * Resolves the permalink to a build.
82 *
83 * @return null
84 * if the target of the permalink doesn't exist.
85 */
86 public abstract Run<?,?> resolve(Job<?,?> job);
87
88 /**
89 * List of {@link Permalink}s that are built into Hudson.
90 */
91 public static final List<Permalink> BUILTIN = new CopyOnWriteArrayList<Permalink>();
92
93 static {
94 BUILTIN.add(new Permalink() {
95 public String getDisplayName() {
96 return Messages.Permalink_LastBuild();
97 }
98
99 public String getId() {
100 return "lastBuild";
101 }
102
103 public Run<?,?> resolve(Job<?,?> job) {
104 return job.getLastBuild();
105 }
106 });
107
108 BUILTIN.add(new Permalink() {
109 public String getDisplayName() {
110 return Messages.Permalink_LastStableBuild();
111 }
112
113 public String getId() {
114 return "lastStableBuild";
115 }
116
117 public Run<?,?> resolve(Job<?,?> job) {
118 return job.getLastStableBuild();
119 }
120 });
121
122 BUILTIN.add(new Permalink() {
123 public String getDisplayName() {
124 return Messages.Permalink_LastSuccessfulBuild();
125 }
126
127 public String getId() {
128 return "lastSuccessfulBuild";
129 }
130
131 public Run<?,?> resolve(Job<?,?> job) {
132 return job.getLastSuccessfulBuild();
133 }
134 });
135
136 BUILTIN.add(new Permalink() {
137 public String getDisplayName() {
138 return Messages.Permalink_LastFailedBuild();
139 }
140
141 public String getId() {
142 return "lastFailedBuild";
143 }
144
145 public Run<?,?> resolve(Job<?,?> job) {
146 return job.getLastFailedBuild();
147 }
148 });
149
150 BUILTIN.add(new Permalink() {
151 public String getDisplayName() {
152 return Messages.Permalink_LastUnstableBuild();
153 }
154
155 public String getId() {
156 return "lastUnstableBuild";
157 }
158
159 public Run<?,?> resolve(Job<?,?> job) {
160 return job.getLastUnstableBuild();
161 }
162 });
163
164 BUILTIN.add(new Permalink() {
165 public String getDisplayName() {
166 return Messages.Permalink_LastUnsuccessfulBuild();
167 }
168
169 public String getId() {
170 return "lastUnsuccessfulBuild";
171 }
172
173 public Run<?,?> resolve(Job<?,?> job) {
174 return job.getLastUnsuccessfulBuild();
175 }
176 });
177 }
178 }
179 }
180