View Javadoc

1   /*
2    * Copyright 2012 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.ci.comm.command;
17  
18  /**
19   * Abstract class that combines all every job command needs.
20   *
21   * @param <T> the concrete type of the command.
22   */
23  public abstract class AbstractJobCommand<T extends Command<T>> extends
24      AbstractCommand<T> implements Command<T>
25  {
26    // ********************************* Fields *********************************
27  
28    // --- constants ------------------------------------------------------------
29  
30    // --- members --------------------------------------------------------------
31  
32    /**
33     * The name of the job that shall be enabled.
34     */
35    protected String jobName;
36  
37    // ****************************** Initializer *******************************
38  
39    // ****************************** Constructors ******************************
40  
41    /**
42     * Default constructor.
43     *
44     * @param jobName the name of the job that shall be enabled.
45     */
46    public AbstractJobCommand(final String jobName)
47    {
48      this.jobName = jobName;
49    }
50  
51    // ****************************** Inner Classes *****************************
52  
53    // ********************************* Methods ********************************
54  
55    // --- init -----------------------------------------------------------------
56  
57    // --- get&set --------------------------------------------------------------
58  
59    /**
60     * Sets the name of the job that shall be enabled.
61     *
62     * @param jobName the name of the job that shall be enabled.
63     */
64    public final void setJobName(final String jobName)
65    {
66      this.jobName = jobName;
67    }
68  
69    // --- business -------------------------------------------------------------
70  
71    /**
72     * Build the job api url string.
73     *
74     * @param url the url to the system.
75     * @param jobName the name of the job.
76     * @param apiMethod the api method to call.
77     * @return the api string.
78     */
79    protected final String buildCiJobApiUrl(final String url, final String jobName,
80        final String apiMethod)
81    {
82      return url + "/job/" + jobName + "/" + apiMethod;
83    }
84  
85    // --- object basics --------------------------------------------------------
86  
87  }