1 package org.apache.continuum.distributed.transport.slave;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.continuum.buildagent.ContinuumBuildAgentException;
26 import org.apache.continuum.buildagent.ContinuumBuildAgentService;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33 public class SlaveBuildAgentTransportServer
34 implements SlaveBuildAgentTransportService
35 {
36 private Logger log = LoggerFactory.getLogger( this.getClass() );
37
38 private ContinuumBuildAgentService continuumBuildAgentService;
39
40 public SlaveBuildAgentTransportServer( ContinuumBuildAgentService continuumBuildAgentService )
41 {
42 this.continuumBuildAgentService = continuumBuildAgentService;
43 }
44
45 public Boolean buildProjects( List<Map<String, Object>> projectsBuildContext )
46 throws Exception
47 {
48 Boolean result;
49
50 try
51 {
52 continuumBuildAgentService.buildProjects( projectsBuildContext );
53 result = Boolean.TRUE;
54
55 log.info( "Building projects." );
56 }
57 catch ( ContinuumBuildAgentException e )
58 {
59 log.error( "Failed to build projects.", e );
60 throw e;
61 }
62
63 return result;
64 }
65
66 public List<Map<String, String>> getAvailableInstallations()
67 throws Exception
68 {
69 List<Map<String, String>> installations;
70
71 try
72 {
73 installations = continuumBuildAgentService.getAvailableInstallations();
74 log.info( "Available installations: " + installations.size() );
75 }
76 catch ( ContinuumBuildAgentException e )
77 {
78 log.error( "Failed to get available installations.", e );
79 throw e;
80 }
81
82 return installations;
83 }
84
85 public Map<String, Object> getBuildResult( int projectId )
86 throws Exception
87 {
88 Map<String, Object> buildResult;
89
90 try
91 {
92 buildResult = continuumBuildAgentService.getBuildResult( projectId );
93 log.info( "Build result for project " + projectId + " acquired." );
94 }
95 catch ( ContinuumBuildAgentException e )
96 {
97 log.error( "Failed to get build result for project " + projectId, e );
98 throw e;
99 }
100
101 return buildResult;
102 }
103
104 public Map<String, Object> getProjectCurrentlyBuilding()
105 throws Exception
106 {
107 Map<String, Object> project = continuumBuildAgentService.getProjectCurrentlyBuilding();
108
109 log.info( "Retrieving currently building project");
110
111 return project;
112 }
113
114 public Boolean ping()
115 throws Exception
116 {
117 log.info( "Ping ok" );
118
119 return Boolean.TRUE;
120 }
121
122 public Boolean cancelBuild()
123 throws Exception
124 {
125 Boolean result;
126
127 try
128 {
129 continuumBuildAgentService.cancelBuild();
130 result = Boolean.TRUE;
131 log.info( "Cancelled build" );
132 }
133 catch ( ContinuumBuildAgentException e )
134 {
135 log.error( "Failed to cancel build", e );
136 throw e;
137 }
138
139 return result;
140 }
141
142 public String generateWorkingCopyContent( int projectId, String directory, String baseUrl, String imagesBaseUrl )
143 throws Exception
144 {
145 try
146 {
147 return continuumBuildAgentService.generateWorkingCopyContent( projectId, directory, baseUrl,
148 imagesBaseUrl );
149 }
150 catch ( ContinuumBuildAgentException e )
151 {
152 log.error( "Failed to generate working copy content", e );
153 throw e;
154 }
155 }
156
157 public String getProjectFileContent( int projectId, String directory, String filename )
158 throws Exception
159 {
160 try
161 {
162 return continuumBuildAgentService.getProjectFileContent( projectId, directory, filename );
163 }
164 catch ( ContinuumBuildAgentException e )
165 {
166 log.error( "Failed to retrieve project file content", e );
167 throw e;
168 }
169 }
170
171 public Map getReleasePluginParameters( int projectId, String pomFilename )
172 throws Exception
173 {
174 try
175 {
176 return continuumBuildAgentService.getReleasePluginParameters( projectId, pomFilename );
177 }
178 catch ( ContinuumBuildAgentException e )
179 {
180 log.error( "Failed to retrieve release plugin parameters", e );
181 throw e;
182 }
183 }
184
185 public List<Map<String, String>> processProject( int projectId, String pomFilename, boolean autoVersionSubmodules )
186 throws Exception
187 {
188 try
189 {
190 return continuumBuildAgentService.processProject( projectId, pomFilename, autoVersionSubmodules );
191 }
192 catch ( ContinuumBuildAgentException e )
193 {
194 log.error( "Failed to process project", e );
195 throw e;
196 }
197 }
198
199 public String releasePrepare( Map project, Map properties, Map releaseVersion, Map developmentVersion,
200 Map environments )
201 throws Exception
202 {
203 try
204 {
205 return continuumBuildAgentService.releasePrepare( project, properties, releaseVersion, developmentVersion,
206 environments );
207 }
208 catch ( ContinuumBuildAgentException e )
209 {
210 log.error( "Failed to prepare release", e );
211 throw e;
212 }
213 }
214
215 public Map<String, Object> getListener( String releaseId )
216 throws Exception
217 {
218 try
219 {
220 return continuumBuildAgentService.getListener( releaseId );
221 }
222 catch ( ContinuumBuildAgentException e )
223 {
224 log.error( "Failed to retrieve listener state of " + releaseId, e );
225 throw e;
226 }
227 }
228
229 public Map<String, Object> getReleaseResult( String releaseId )
230 throws Exception
231 {
232 try
233 {
234 return continuumBuildAgentService.getReleaseResult( releaseId );
235 }
236 catch ( ContinuumBuildAgentException e )
237 {
238 log.error( "Failed to retrieve release result of " + releaseId, e );
239 throw e;
240 }
241 }
242
243 public Boolean removeListener( String releaseId )
244 throws Exception
245 {
246 Boolean result;
247
248 try
249 {
250 continuumBuildAgentService.removeListener( releaseId );
251 result = Boolean.TRUE;
252 }
253 catch ( ContinuumBuildAgentException e )
254 {
255 log.error( "Failed to remove listener of " + releaseId, e );
256 throw e;
257 }
258
259 return result;
260 }
261
262 public String getPreparedReleaseName( String releaseId )
263 throws Exception
264 {
265 try
266 {
267 return continuumBuildAgentService.getPreparedReleaseName( releaseId );
268 }
269 catch ( ContinuumBuildAgentException e )
270 {
271 log.error( "Failed to retrieve prepared release name of " + releaseId );
272 throw e;
273 }
274 }
275
276 public Boolean releasePerform( String releaseId, String goals, String arguments, boolean useReleaseProfile,
277 Map repository )
278 throws Exception
279 {
280 Boolean result;
281
282 try
283 {
284 continuumBuildAgentService.releasePerform( releaseId, goals, arguments, useReleaseProfile, repository );
285 result = Boolean.TRUE;
286 }
287 catch ( ContinuumBuildAgentException e )
288 {
289 log.error( "Unable to perform release", e );
290 throw e;
291 }
292
293 return result;
294 }
295
296 public String releasePerformFromScm( String goals, String arguments, boolean useReleaseProfile, Map repository,
297 String scmUrl, String scmUsername, String scmPassword, String scmTag,
298 String scmTagBase, Map environments )
299 throws Exception
300 {
301 try
302 {
303 return continuumBuildAgentService.releasePerformFromScm( goals, arguments, useReleaseProfile, repository,
304 scmUrl, scmUsername, scmPassword, scmTag,
305 scmTagBase, environments );
306 }
307 catch ( ContinuumBuildAgentException e )
308 {
309 log.error( "Unable to perform release", e );
310 throw e;
311 }
312 }
313
314 public String releaseCleanup( String releaseId )
315 throws Exception
316 {
317 try
318 {
319 return continuumBuildAgentService.releaseCleanup( releaseId );
320 }
321 catch ( ContinuumBuildAgentException e )
322 {
323 log.error( "Unable to cleanup release of " + releaseId, e );
324 throw e;
325 }
326 }
327
328 public Boolean releaseRollback( String releaseId, int projectId )
329 throws Exception
330 {
331 Boolean result;
332
333 try
334 {
335 continuumBuildAgentService.releaseRollback( releaseId, projectId );
336 result = Boolean.TRUE;
337 }
338 catch ( ContinuumBuildAgentException e )
339 {
340 log.error( "Failed to rollback release " + releaseId, e );
341 throw e;
342 }
343
344 return result;
345 }
346
347 public Integer getBuildSizeOfAgent()
348 throws Exception
349 {
350 try
351 {
352 return continuumBuildAgentService.getBuildSizeOfAgent();
353 }
354 catch ( ContinuumBuildAgentException e )
355 {
356 log.error( "Failed to retrieve build size of agent", e );
357 throw e;
358 }
359 }
360
361 public Map<String, Object> getProjectCurrentlyPreparingBuild()
362 throws Exception
363 {
364 try
365 {
366 return continuumBuildAgentService.getProjectCurrentlyPreparingBuild();
367 }
368 catch ( ContinuumBuildAgentException e )
369 {
370 log.error( "Failed to retrieve projects currently preparing build", e );
371 throw e;
372 }
373 }
374
375 public List<Map<String, Object>> getProjectsInBuildQueue()
376 throws Exception
377 {
378 try
379 {
380 return continuumBuildAgentService.getProjectsInBuildQueue();
381 }
382 catch ( ContinuumBuildAgentException e )
383 {
384 log.error( "Failed to retrieve projects in build queue", e );
385 throw e;
386 }
387 }
388
389 public List<Map<String, Object>> getProjectsInPrepareBuildQueue()
390 throws Exception
391 {
392 try
393 {
394 return continuumBuildAgentService.getProjectsInPrepareBuildQueue();
395 }
396 catch ( ContinuumBuildAgentException e )
397 {
398 log.error( "Failed to retrieve projects in prepare build queue", e );
399 throw e;
400 }
401 }
402
403 public Boolean isProjectGroupInQueue( int projectGroupId )
404 throws Exception
405 {
406 return continuumBuildAgentService.isProjectGroupInQueue( projectGroupId );
407 }
408
409 public Boolean isProjectCurrentlyBuilding( int projectId )
410 throws Exception
411 {
412 return continuumBuildAgentService.isProjectCurrentlyBuilding( projectId );
413 }
414
415 public Boolean isProjectInBuildQueue( int projectId )
416 throws Exception
417 {
418 return continuumBuildAgentService.isProjectInBuildQueue( projectId );
419 }
420
421 public Boolean removeFromPrepareBuildQueue( int projectGroupId, int scmRootId )
422 throws Exception
423 {
424 try
425 {
426 return continuumBuildAgentService.removeFromPrepareBuildQueue( projectGroupId, scmRootId );
427 }
428 catch ( ContinuumBuildAgentException e )
429 {
430 log.error( "Failed to remove projects from prepare build queue" );
431 throw e;
432 }
433 }
434
435 public Boolean removeFromPrepareBuildQueue( List<String> hashCodes )
436 throws Exception
437 {
438 Boolean result;
439
440 try
441 {
442 continuumBuildAgentService.removeFromPrepareBuildQueue( hashCodes );
443 result = Boolean.TRUE;
444 }
445 catch ( ContinuumBuildAgentException e )
446 {
447 log.error( "Failed to remove projects from prepare build queue" );
448 throw e;
449 }
450
451 return result;
452 }
453
454 public Boolean removeFromBuildQueue( int projectId, int buildDefinitionId )
455 throws Exception
456 {
457 try
458 {
459 return continuumBuildAgentService.removeFromBuildQueue( projectId, buildDefinitionId );
460 }
461 catch ( ContinuumBuildAgentException e )
462 {
463 log.error( "Failed to remove project from build queue" );
464 throw e;
465 }
466 }
467
468 public Boolean removeFromBuildQueue( List<String> hashCodes )
469 throws Exception
470 {
471 Boolean result;
472
473 try
474 {
475 continuumBuildAgentService.removeFromBuildQueue( hashCodes );
476 result = Boolean.TRUE;
477 }
478 catch ( ContinuumBuildAgentException e )
479 {
480 log.error( "Failed to remove projects from build queue" );
481 throw e;
482 }
483
484 return result;
485 }
486 }