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.hudson;
17  
18  import de.smartics.ci.comm.CiController;
19  import de.smartics.ci.comm.CiSystem;
20  import de.smartics.ci.comm.LogLevel;
21  import de.smartics.ci.comm.hudson.command.HudsonCreateJobCommand;
22  import de.smartics.ci.comm.hudson.command.HudsonDeleteJobCommand;
23  import de.smartics.ci.comm.hudson.command.HudsonDisableJobCommand;
24  import de.smartics.ci.comm.hudson.command.HudsonEnableJobCommand;
25  import de.smartics.ci.comm.hudson.command.HudsonGenericJobCommand;
26  import de.smartics.ci.comm.hudson.command.HudsonLoginCommand;
27  import de.smartics.ci.comm.hudson.command.HudsonCheckStatusJobCommand;
28  import de.smartics.ci.comm.hudson.command.HudsonUpdateJobCommand;
29  
30  /**
31   * Factory to create a CIController configured to connect to a hudson ci server.
32   */
33  public final class HudsonCiSystemFactory
34  {
35    // ********************************* Fields *********************************
36  
37    // --- constants ------------------------------------------------------------
38  
39    // --- members --------------------------------------------------------------
40  
41    // ****************************** Initializer *******************************
42  
43    // ****************************** Constructors ******************************
44  
45    /**
46     * Default constructor.
47     */
48    private HudsonCiSystemFactory()
49    {
50  
51    }
52  
53    // ****************************** Inner Classes *****************************
54  
55    // ********************************* Methods ********************************
56  
57    // --- init -----------------------------------------------------------------
58  
59    // --- get&set --------------------------------------------------------------
60  
61    // --- business -------------------------------------------------------------
62  
63    /**
64     * Factory method to create CIController.
65     *
66     * @param system the ci target system.
67     * @param loglevel set the log level to use.
68     * @return the controller to send commands to the given system.
69     */
70    public static CiController createCiController(final CiSystem system,
71        final LogLevel loglevel)
72    {
73      final CiController controller = new CiController(system);
74      controller.setLogLevel(loglevel);
75      final HudsonLoginCommand loginCommand = new HudsonLoginCommand();
76      controller.setLoginCommand(loginCommand);
77  
78      final HudsonDeleteJobCommand deleteCommand = new HudsonDeleteJobCommand();
79      controller.setDeleteJobCommand(deleteCommand);
80  
81      final HudsonCreateJobCommand createCommand = new HudsonCreateJobCommand();
82      controller.setCreateJobCommand(createCommand);
83  
84      final HudsonUpdateJobCommand updateCommand = new HudsonUpdateJobCommand();
85      controller.setUpdateJobCommand(updateCommand);
86  
87      final HudsonEnableJobCommand enableCommand = new HudsonEnableJobCommand();
88      controller.setEnableJobCommand(enableCommand);
89  
90      final HudsonDisableJobCommand disableCommand =
91          new HudsonDisableJobCommand();
92      controller.setDisableJobCommand(disableCommand);
93  
94      final HudsonCheckStatusJobCommand statusCommand =
95          new HudsonCheckStatusJobCommand();
96      controller.setStatusJobCommand(statusCommand);
97  
98      final HudsonGenericJobCommand genericJobCommand =
99          new HudsonGenericJobCommand();
100     controller.setGenericJobCommand(genericJobCommand);
101 
102     return controller;
103   }
104 
105   // --- object basics --------------------------------------------------------
106 
107 }