File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\scm\AbstractScmTagAction.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.scm;
25
26 import hudson.model.AbstractBuild;
27 import hudson.model.TaskAction;
28 import hudson.model.BuildBadgeAction;
29 import hudson.security.Permission;
30 import hudson.security.ACL;
31 import org.kohsuke.stapler.StaplerRequest;
32 import org.kohsuke.stapler.StaplerResponse;
33
34 import javax.servlet.ServletException;
35 import java.io.IOException;
36
37 /**
38 * Common part of {@link CVSSCM.TagAction} and {@link SubversionTagAction}.
39 *
40 * <p>
41 * This class implements the action that tags the modules. Derived classes
42 * need to provide <tt>tagForm.jelly</tt> view that displays a form for
43 * letting user start tagging.
44 *
45 * @author Kohsuke Kawaguchi
46 */
47 public abstract class AbstractScmTagAction extends TaskAction implements BuildBadgeAction {
48 protected final AbstractBuild build;
49
50 protected AbstractScmTagAction(AbstractBuild build) {
51 this.build = build;
52 }
53
54 public final String getUrlName() {
55 // to make this consistent with CVSSCM, even though the name is bit off
56 return "tagBuild";
57 }
58
59 /**
60 * Defaults to {@link SCM#TAG}.
61 */
62 protected Permission getPermission() {
63 return SCM.TAG;
64 }
65
66 public AbstractBuild getBuild() {
67 return build;
68 }
69
70 /**
71 * This message is shown as the tool tip of the build badge icon.
72 */
73 public String getTooltip() {
74 return null;
75 }
76
77 /**
78 * Returns true if the build is tagged already.
79 */
80 public abstract boolean isTagged();
81
82 protected ACL getACL() {
83 return build.getACL();
84 }
85
86 public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
87 req.getView(this,chooseAction()).forward(req,rsp);
88 }
89
90 protected synchronized String chooseAction() {
91 if(workerThread!=null)
92 return "inProgress.jelly";
93 return "tagForm.jelly";
94 }
95
96 }
97