View Javadoc

1   package org.apache.continuum.distributed.transport.master;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Map;
23  
24  import org.apache.continuum.builder.distributed.DistributedBuildService;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  /**
29   * MasterBuildAgentTransportServer
30   */
31  public class MasterBuildAgentTransportServer
32      implements MasterBuildAgentTransportService
33  {
34      private static final Logger log = LoggerFactory.getLogger( MasterBuildAgentTransportServer.class );
35  
36      private final DistributedBuildService distributedBuildService;
37  
38      public MasterBuildAgentTransportServer( DistributedBuildService distributedBuildService )
39      {
40          this.distributedBuildService = distributedBuildService;
41      }
42  
43      public Boolean returnBuildResult( Map<String, Object> buildResult )
44          throws Exception
45      {
46          log.info( "Build result returned." );
47          distributedBuildService.updateBuildResult( buildResult );
48          return Boolean.TRUE;
49      }
50  
51      public Boolean ping()
52          throws Exception
53      {
54          log.info( "Ping ok" );
55  
56          return Boolean.TRUE;
57      }
58  
59      public Boolean prepareBuildFinished( Map<String, Object> prepareBuildResult )
60          throws Exception
61      {
62          log.info( "Prepare build finished." );
63          distributedBuildService.prepareBuildFinished( prepareBuildResult );
64          return Boolean.TRUE;
65      }
66  
67      public Boolean startProjectBuild( Integer projectId )
68          throws Exception
69      {
70          log.info( "Start project build." );
71          distributedBuildService.startProjectBuild( projectId );
72          return Boolean.TRUE;
73      }
74  
75      public Boolean startPrepareBuild( Map<String, Object> prepareBuildResult )
76          throws Exception
77      {
78          log.info( "Start prepare build." );
79          distributedBuildService.startPrepareBuild( prepareBuildResult );
80          return Boolean.TRUE;
81      }
82  
83      public Map<String, String> getEnvironments( Integer buildDefinitionId, String installationType )
84          throws Exception
85      {
86          log.info( "Retrieving environments" );
87          return distributedBuildService.getEnvironments( buildDefinitionId, installationType );
88      }
89  
90      public Boolean updateProject( Map<String, Object> project )
91          throws Exception
92      {
93          log.info( "Start updating project" );
94          distributedBuildService.updateProject( project );
95          return Boolean.TRUE;
96      }
97  
98      public Boolean shouldBuild( Map<String, Object> context )
99          throws Exception
100     {
101         log.info( "Checking if project should build" );
102         return distributedBuildService.shouldBuild( context );
103     }
104 }