1 package org.apache.maven.continuum.xmlrpc.server;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.lang.reflect.Field;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.Iterator;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.Set;
31
32 import org.apache.commons.lang.StringEscapeUtils;
33 import org.apache.commons.lang.StringUtils;
34 import org.apache.continuum.buildmanager.BuildManagerException;
35 import org.apache.continuum.buildmanager.BuildsManager;
36 import org.apache.continuum.dao.SystemConfigurationDao;
37 import org.apache.continuum.purge.ContinuumPurgeManagerException;
38 import org.apache.continuum.purge.PurgeConfigurationServiceException;
39 import org.apache.continuum.repository.RepositoryServiceException;
40 import org.apache.continuum.xmlrpc.release.ContinuumReleaseResult;
41 import org.apache.continuum.xmlrpc.repository.DirectoryPurgeConfiguration;
42 import org.apache.continuum.xmlrpc.repository.LocalRepository;
43 import org.apache.continuum.xmlrpc.repository.RepositoryPurgeConfiguration;
44 import org.apache.maven.continuum.Continuum;
45 import org.apache.maven.continuum.ContinuumException;
46 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
47 import org.apache.maven.continuum.installation.InstallationException;
48 import org.apache.maven.continuum.profile.ProfileException;
49 import org.apache.maven.continuum.project.ContinuumProjectState;
50 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
51 import org.apache.maven.continuum.security.ContinuumRoleConstants;
52 import org.apache.maven.continuum.store.ContinuumStoreException;
53 import org.apache.maven.continuum.xmlrpc.project.AddingResult;
54 import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
55 import org.apache.maven.continuum.xmlrpc.project.BuildDefinitionTemplate;
56 import org.apache.maven.continuum.xmlrpc.project.BuildProjectTask;
57 import org.apache.maven.continuum.xmlrpc.project.BuildResult;
58 import org.apache.maven.continuum.xmlrpc.project.BuildResultSummary;
59 import org.apache.maven.continuum.xmlrpc.project.Project;
60 import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
61 import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
62 import org.apache.maven.continuum.xmlrpc.project.ProjectNotifier;
63 import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
64 import org.apache.maven.continuum.xmlrpc.project.Schedule;
65 import org.apache.maven.continuum.xmlrpc.system.Installation;
66 import org.apache.maven.continuum.xmlrpc.system.Profile;
67 import org.apache.maven.continuum.xmlrpc.system.SystemConfiguration;
68 import org.codehaus.plexus.redback.authorization.AuthorizationException;
69 import org.codehaus.plexus.redback.role.RoleManager;
70 import org.codehaus.plexus.redback.role.RoleManagerException;
71
72 import net.sf.dozer.util.mapping.DozerBeanMapperSingletonWrapper;
73 import net.sf.dozer.util.mapping.MapperIF;
74
75
76
77
78
79
80 public class ContinuumServiceImpl
81 extends AbstractContinuumSecureService
82 {
83 private static final String NAME_VALID_EXPRESSION = "[a-zA-Z0-9_.\\s\\-]*";
84
85 private static final String DIRECTORY_VALID_EXPRESSION = "[A-Za-z0-9_/\\s:.\\\\-]*";
86
87 private static final String URL_VALID_EXPRESSION = "[A-Za-z0-9_.@:/-]*";
88
89 private static final String PROJECT_VERSION_VALID_EXPRESSION = "[a-zA-Z0-9.-]*";
90
91 private static final String PROJECT_SCM_URL_VALID_EXPRESSION = "[a-zA-Z0-9_.:${}#~=@\\/|\\[\\]-]*";
92
93 private static final String PROJECT_SCM_TAG_VALID_EXPRESSION = "[a-zA-Z0-9_.:@\\/|#~=\\[\\]-]*";
94
95 private static final String PROJECT_GROUP_ID_VALID_EXPRESSION = "[A-Za-z0-9.]*";
96
97 private static final String PROJECT_ARTIFACT_ID_VALID_EXPRESSION = "[A-Za-z0-9\\-]*";
98
99 private static final String PROJECT_EXECUTOR_OR_BUILDDEF_TYPE_VALID_EXPRESSION = "maven2|maven-1|ant|shell";
100
101 private static final String SCHEDULE_CRON_VALID_EXPRESSION = "[A-Z0-9\\s*/,-?#]*";
102
103 private static final String PROJECTGROUP_ID_VALID_EXPRESSION = "[a-zA-Z0-9.\\s]*";
104
105 private static final String REPOSITORY_LAYOUT_VALID_EXPRESSION = "default|legacy";
106
107 private static final String BUILD_DEFINITION_ARGUMENTS_VALID_EXPRESSION = "[A-Za-z0-9_./=,${}\":\\s\\\\-]*";
108
109 private static final String BUILD_DEFINITION_GOALS_VALID_EXPRESSION = "[A-Za-z0-9_:\\s\\-]*";
110
111 private static final String BUILD_DEFINITION_BUILD_FILE_VALID_EXPRESSION = "[A-Za-z0-9_.\\-]*";
112
113 private static final String INSTALLATION_VARNAME_VALID_EXPRESSION = "[A-Za-z][A-Za-z0-9_]*";
114
115 private static final String INSTALLATION_VARVALUE_VALID_EXPRESSION = "[A-Za-z0-9_.:=${}/\\s\\\\-]*";
116
117 private static final String INSTALLATION_TYPE_VALID_EXPRESSION = "jdk|maven2|maven1|ant|envvar";
118
119 private static final String DIRECTORY_TYPE_VALID_EXPRESSION = "releases|buildOutput";
120
121 private static final String NOTIFIER_TYPE_VALID_EXPRESSION = "irc|jabber|msn|mail|wagon";
122
123 private static final MapperIF mapper = DozerBeanMapperSingletonWrapper.getInstance();
124
125
126
127
128 private Continuum continuum;
129
130
131
132
133 private SystemConfigurationDao systemConfigurationDao;
134
135
136
137
138 private RoleManager roleManager;
139
140
141
142
143 private BuildsManager parallelBuildsManager;
144
145 public boolean ping()
146 throws ContinuumException
147 {
148 return true;
149 }
150
151
152
153
154
155 public List<ProjectSummary> getProjects( int projectGroupId )
156 throws ContinuumException
157 {
158 checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
159
160 List<ProjectSummary> projectsList = new ArrayList<ProjectSummary>();
161
162 Collection<org.apache.maven.continuum.model.project.Project> projects =
163 continuum.getProjectsInGroup( projectGroupId );
164 if ( projects != null )
165 {
166 for ( org.apache.maven.continuum.model.project.Project project : projects )
167 {
168 ProjectSummary ps = populateProjectSummary( project );
169 projectsList.add( ps );
170 }
171 }
172 return projectsList;
173 }
174
175 public ProjectSummary getProjectSummary( int projectId )
176 throws ContinuumException
177 {
178 org.apache.maven.continuum.model.project.Project project = continuum.getProject( projectId );
179
180 checkViewProjectGroupAuthorization( project.getProjectGroup().getName() );
181
182 return populateProjectSummary( project );
183 }
184
185 public Project getProjectWithAllDetails( int projectId )
186 throws ContinuumException
187 {
188 org.apache.maven.continuum.model.project.Project project = continuum.getProjectWithAllDetails( projectId );
189
190 checkViewProjectGroupAuthorization( project.getProjectGroup().getName() );
191
192 return populateProject( project );
193 }
194
195
196 public int removeProject( int projectId )
197 throws ContinuumException
198 {
199 ProjectSummary ps = getProjectSummary( projectId );
200
201 checkRemoveProjectFromGroupAuthorization( ps.getProjectGroup().getName() );
202
203 continuum.removeProject( projectId );
204
205 return 0;
206 }
207
208 public ProjectSummary updateProject( ProjectSummary project )
209 throws ContinuumException
210 {
211 if ( StringUtils.isNotBlank( project.getName() ) &&
212 !project.getName().matches( NAME_VALID_EXPRESSION ) )
213
214 {
215 throw new ContinuumException( "Project Name contains invalid characters" );
216 }
217
218 if ( StringUtils.isNotBlank( project.getScmTag() ) &&
219 !project.getScmTag().matches( PROJECT_SCM_TAG_VALID_EXPRESSION ) )
220 {
221 throw new ContinuumException( "Project Scm Tag contains invalid characters" );
222 }
223
224 if ( StringUtils.isNotBlank( project.getScmUrl() ) &&
225 !project.getScmUrl().matches( PROJECT_SCM_URL_VALID_EXPRESSION ) )
226 {
227 throw new ContinuumException( "Project Scm Url contains invalid characters" );
228 }
229
230 if ( StringUtils.isNotBlank( project.getVersion() ) &&
231 !project.getVersion().matches( PROJECT_VERSION_VALID_EXPRESSION ) )
232 {
233 throw new ContinuumException( "Project Version contains invalid characters" );
234 }
235
236 ProjectSummary ps = getProjectSummary( project.getId() );
237
238 checkRemoveProjectFromGroupAuthorization( ps.getProjectGroup().getName() );
239
240 org.apache.maven.continuum.model.project.Project p = continuum.getProject( project.getId() );
241
242 p.setName( project.getName() );
243 p.setVersion( project.getVersion() );
244 p.setScmUrl( project.getScmUrl() );
245 p.setScmUseCache( project.isScmUseCache() );
246 p.setScmUsername( project.getScmUsername() );
247 p.setScmPassword( project.getScmPassword() );
248 p.setScmTag( project.getScmTag() );
249
250 continuum.updateProject( p );
251
252 return getProjectSummary( project.getId() );
253 }
254
255
256
257
258
259 public List<ProjectGroupSummary> getAllProjectGroups()
260 throws ContinuumException
261 {
262 Collection<org.apache.maven.continuum.model.project.ProjectGroup> pgList = continuum.getAllProjectGroups();
263 List<ProjectGroupSummary> result = new ArrayList<ProjectGroupSummary>();
264 for ( org.apache.maven.continuum.model.project.ProjectGroup projectGroup : pgList )
265 {
266 try
267 {
268 if ( isAuthorized( ContinuumRoleConstants.CONTINUUM_VIEW_GROUP_OPERATION, projectGroup.getName() ) )
269 {
270 result.add( populateProjectGroupSummary( projectGroup ) );
271 }
272 }
273 catch ( AuthorizationException e )
274 {
275 throw new ContinuumException( "error authorizing request." );
276 }
277 }
278 return result;
279 }
280
281 public ProjectGroup getProjectGroup( int projectGroupId )
282 throws ContinuumException
283 {
284 ProjectGroup result = null;
285 org.apache.maven.continuum.model.project.ProjectGroup projectGroup = continuum.getProjectGroup( projectGroupId )
286 ;
287 try
288 {
289 if ( isAuthorized( ContinuumRoleConstants.CONTINUUM_VIEW_GROUP_OPERATION, projectGroup.getName() ) )
290 {
291 result = populateProjectGroupWithAllDetails( projectGroup );
292 }
293 }
294 catch ( AuthorizationException e )
295 {
296 throw new ContinuumException( "error authorizing request." );
297 }
298 return result;
299 }
300
301 public List<ProjectGroup> getAllProjectGroupsWithAllDetails()
302 throws ContinuumException
303 {
304 Collection<org.apache.maven.continuum.model.project.ProjectGroup> pgList =
305 continuum.getAllProjectGroupsWithBuildDetails();
306 List<ProjectGroup> result = new ArrayList<ProjectGroup>();
307 for ( org.apache.maven.continuum.model.project.ProjectGroup projectGroup : pgList )
308 {
309 try
310 {
311 if ( isAuthorized( ContinuumRoleConstants.CONTINUUM_VIEW_GROUP_OPERATION, projectGroup.getName() ) )
312 {
313 result.add( populateProjectGroupWithAllDetails( projectGroup ) );
314 }
315 }
316 catch ( AuthorizationException e )
317 {
318 throw new ContinuumException( "error authorizing request." );
319 }
320 }
321 return result;
322 }
323
324 public List<ProjectGroup> getAllProjectGroupsWithProjects()
325 throws ContinuumException
326 {
327 return getAllProjectGroupsWithAllDetails();
328 }
329
330 protected String getProjectGroupName( int projectGroupId )
331 throws ContinuumException
332 {
333 ProjectGroupSummary pgs = getPGSummary( projectGroupId );
334 return pgs.getName();
335 }
336
337 private ProjectGroupSummary getPGSummary( int projectGroupId )
338 throws ContinuumException
339 {
340 org.apache.maven.continuum.model.project.ProjectGroup projectGroup = continuum.getProjectGroup( projectGroupId )
341 ;
342
343 checkViewProjectGroupAuthorization( projectGroup.getName() );
344 return populateProjectGroupSummary( projectGroup );
345 }
346
347 public ProjectGroupSummary getProjectGroupSummary( int projectGroupId )
348 throws ContinuumException
349 {
350 checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
351
352 org.apache.maven.continuum.model.project.ProjectGroup projectGroup = continuum.getProjectGroup( projectGroupId )
353 ;
354 return populateProjectGroupSummary( projectGroup );
355 }
356
357 public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
358 throws ContinuumException
359 {
360 checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
361
362 org.apache.maven.continuum.model.project.ProjectGroup projectGroup =
363 continuum.getProjectGroupWithProjects( projectGroupId );
364 return populateProjectGroupWithAllDetails( projectGroup );
365 }
366
367 public int removeProjectGroup( int projectGroupId )
368 throws ContinuumException
369 {
370 checkRemoveProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
371
372 continuum.removeProjectGroup( projectGroupId );
373 return 0;
374 }
375
376 public ProjectGroupSummary updateProjectGroup( ProjectGroupSummary projectGroup )
377 throws ContinuumException
378 {
379 if ( projectGroup == null )
380 {
381 return null;
382 }
383
384 checkModifyProjectGroupAuthorization( getProjectGroupName( projectGroup.getId() ) );
385
386 if ( StringUtils.isEmpty( projectGroup.getName() ) )
387 {
388 throw new ContinuumException( "project group name is required" );
389 }
390 else if ( StringUtils.isEmpty( projectGroup.getName().trim() ) )
391 {
392 throw new ContinuumException( "project group name can't be spaces" );
393 }
394
395 if ( !projectGroup.getName().matches( NAME_VALID_EXPRESSION ) )
396 {
397 throw new ContinuumException( "ProjectGroup Name contains invalid characters" );
398 }
399
400 org.apache.maven.continuum.model.project.ProjectGroup pg =
401 continuum.getProjectGroupWithProjects( projectGroup.getId() );
402
403
404
405 if ( !projectGroup.getName().equals( pg.getName() ) )
406 {
407 try
408 {
409 roleManager.updateRole( "project-administrator", pg.getName(), projectGroup.getName() );
410 roleManager.updateRole( "project-developer", pg.getName(), projectGroup.getName() );
411 roleManager.updateRole( "project-user", pg.getName(), projectGroup.getName() );
412
413 pg.setName( projectGroup.getName() );
414 }
415 catch ( RoleManagerException e )
416 {
417 throw new ContinuumException( "unable to rename the project group", e );
418 }
419 }
420
421 pg.setDescription( StringEscapeUtils.escapeXml( projectGroup.getDescription() ) );
422
423 org.apache.continuum.model.repository.LocalRepository repo =
424 new org.apache.continuum.model.repository.LocalRepository();
425 pg.setLocalRepository( populateLocalRepository( projectGroup.getLocalRepository(), repo ) );
426
427 continuum.updateProjectGroup( pg );
428 return getProjectGroupSummary( projectGroup.getId() );
429 }
430
431 public ProjectGroupSummary addProjectGroup( String groupName, String groupId, String description )
432 throws Exception
433 {
434 if ( StringUtils.isNotBlank( groupId ) &&
435 !groupId.matches( PROJECTGROUP_ID_VALID_EXPRESSION ) )
436 {
437 throw new ContinuumException( "ProjectGroup Id contains invalid characters" );
438 }
439
440 if ( StringUtils.isNotBlank( groupName ) &&
441 !groupName.matches( NAME_VALID_EXPRESSION ) )
442 {
443 throw new ContinuumException( "ProjectGroup Name contains invalid characters" );
444 }
445
446 org.apache.maven.continuum.model.project.ProjectGroup pg =
447 new org.apache.maven.continuum.model.project.ProjectGroup();
448 pg.setName( groupName );
449 pg.setGroupId( groupId );
450 pg.setDescription( StringEscapeUtils.escapeXml( description ) );
451 continuum.addProjectGroup( pg );
452 return populateProjectGroupSummary( continuum.getProjectGroupByGroupId( groupId ) );
453 }
454
455 public ProjectNotifier getNotifier( int projectid, int notifierId )
456 throws ContinuumException
457 {
458 return populateProjectNotifier( continuum.getNotifier( projectid, notifierId ) );
459 }
460
461 public ProjectNotifier updateNotifier( int projectid, ProjectNotifier newNotifier )
462 throws ContinuumException
463 {
464 if ( StringUtils.isNotBlank( newNotifier.getType() ) &&
465 !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) )
466 {
467 throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail or wagon" );
468 }
469
470 org.apache.maven.continuum.model.project.ProjectNotifier notifier =
471 continuum.getNotifier( projectid, newNotifier.getId() );
472 notifier.setConfiguration( newNotifier.getConfiguration() );
473 notifier.setFrom( newNotifier.getFrom() );
474 notifier.setRecipientType( newNotifier.getRecipientType() );
475 notifier.setType( newNotifier.getType() );
476 notifier.setEnabled( newNotifier.isEnabled() );
477 notifier.setSendOnError( newNotifier.isSendOnError() );
478 notifier.setSendOnFailure( newNotifier.isSendOnFailure() );
479 notifier.setSendOnSuccess( newNotifier.isSendOnSuccess() );
480 notifier.setSendOnWarning( newNotifier.isSendOnWarning() );
481 return populateProjectNotifier( continuum.updateNotifier( projectid, notifier ) );
482 }
483
484 public ProjectNotifier addNotifier( int projectid, ProjectNotifier newNotifier )
485 throws ContinuumException
486 {
487 if ( StringUtils.isNotBlank( newNotifier.getType() ) &&
488 !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) )
489 {
490 throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail or wagon'" );
491 }
492
493 org.apache.maven.continuum.model.project.ProjectNotifier notifier =
494 new org.apache.maven.continuum.model.project.ProjectNotifier();
495 notifier.setConfiguration( newNotifier.getConfiguration() );
496 notifier.setFrom( newNotifier.getFrom() );
497 notifier.setRecipientType( newNotifier.getRecipientType() );
498 notifier.setType( newNotifier.getType() );
499 notifier.setEnabled( newNotifier.isEnabled() );
500 notifier.setSendOnError( newNotifier.isSendOnError() );
501 notifier.setSendOnFailure( newNotifier.isSendOnFailure() );
502 notifier.setSendOnSuccess( newNotifier.isSendOnSuccess() );
503 notifier.setSendOnWarning( newNotifier.isSendOnWarning() );
504 return populateProjectNotifier( continuum.addNotifier( projectid, notifier ) );
505 }
506
507 public int removeNotifier( int projectid, int notifierId )
508 throws ContinuumException
509 {
510 continuum.removeNotifier( projectid, notifierId );
511 return 0;
512 }
513
514 public ProjectNotifier getGroupNotifier( int projectgroupid, int notifierId )
515 throws ContinuumException
516 {
517 return populateProjectNotifier( continuum.getGroupNotifier( projectgroupid, notifierId ) );
518 }
519
520 public ProjectNotifier updateGroupNotifier( int projectgroupid, ProjectNotifier newNotifier )
521 throws ContinuumException
522 {
523 if ( StringUtils.isNotBlank( newNotifier.getType() ) &&
524 !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) )
525 {
526 throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail, or wagon" );
527 }
528
529 org.apache.maven.continuum.model.project.ProjectNotifier notifier =
530 continuum.getGroupNotifier( projectgroupid, newNotifier.getId() );
531 notifier.setConfiguration( newNotifier.getConfiguration() );
532 notifier.setFrom( newNotifier.getFrom() );
533 notifier.setRecipientType( newNotifier.getRecipientType() );
534 notifier.setType( newNotifier.getType() );
535 notifier.setEnabled( newNotifier.isEnabled() );
536 notifier.setSendOnError( newNotifier.isSendOnError() );
537 notifier.setSendOnFailure( newNotifier.isSendOnFailure() );
538 notifier.setSendOnSuccess( newNotifier.isSendOnSuccess() );
539 notifier.setSendOnWarning( newNotifier.isSendOnWarning() );
540 return populateProjectNotifier( continuum.updateGroupNotifier( projectgroupid, notifier ) );
541 }
542
543 public ProjectNotifier addGroupNotifier( int projectgroupid, ProjectNotifier newNotifier )
544 throws ContinuumException
545 {
546 org.apache.maven.continuum.model.project.ProjectNotifier notifier =
547 new org.apache.maven.continuum.model.project.ProjectNotifier();
548
549 if ( StringUtils.isNotBlank( newNotifier.getType() ) &&
550 !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) )
551 {
552 throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail or wagon" );
553 }
554
555 notifier.setConfiguration( newNotifier.getConfiguration() );
556 notifier.setFrom( newNotifier.getFrom() );
557 notifier.setRecipientType( newNotifier.getRecipientType() );
558 notifier.setType( newNotifier.getType() );
559 notifier.setEnabled( newNotifier.isEnabled() );
560 notifier.setSendOnError( newNotifier.isSendOnError() );
561 notifier.setSendOnFailure( newNotifier.isSendOnFailure() );
562 notifier.setSendOnSuccess( newNotifier.isSendOnSuccess() );
563 notifier.setSendOnWarning( newNotifier.isSendOnWarning() );
564 return populateProjectNotifier( continuum.addGroupNotifier( projectgroupid, notifier ) );
565 }
566
567 public int removeGroupNotifier( int projectgroupid, int notifierId )
568 throws ContinuumException
569 {
570 continuum.removeGroupNotifier( projectgroupid, notifierId );
571 return 0;
572 }
573
574
575
576
577
578 public List<BuildDefinition> getBuildDefinitionsForProject( int projectId )
579 throws ContinuumException
580 {
581 ProjectSummary ps = getProjectSummary( projectId );
582
583 checkViewProjectGroupAuthorization( ps.getProjectGroup().getName() );
584
585 List<org.apache.maven.continuum.model.project.BuildDefinition> bds =
586 continuum.getBuildDefinitionsForProject( projectId );
587
588 List<BuildDefinition> result = new ArrayList<BuildDefinition>();
589 for ( org.apache.maven.continuum.model.project.BuildDefinition bd : bds )
590 {
591 result.add( populateBuildDefinition( bd ) );
592 }
593 return result;
594 }
595
596 public List<BuildDefinition> getBuildDefinitionsForProjectGroup( int projectGroupId )
597 throws ContinuumException
598 {
599 checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
600
601 List<org.apache.maven.continuum.model.project.BuildDefinition> bds =
602 continuum.getBuildDefinitionsForProjectGroup( projectGroupId );
603
604 List<BuildDefinition> result = new ArrayList<BuildDefinition>();
605 for ( org.apache.maven.continuum.model.project.BuildDefinition bd : bds )
606 {
607 result.add( populateBuildDefinition( bd ) );
608 }
609 return result;
610 }
611
612 public int removeBuildDefinitionFromProjectGroup( int projectGroupId, int buildDefinitionId )
613 throws ContinuumException
614 {
615 checkRemoveGroupBuildDefinitionAuthorization( getProjectGroupName( projectGroupId ) );
616
617 continuum.removeBuildDefinitionFromProjectGroup( projectGroupId, buildDefinitionId );
618 return 0;
619 }
620
621 public BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition buildDef )
622 throws ContinuumException
623 {
624 ProjectSummary ps = getProjectSummary( projectId );
625
626 checkModifyProjectBuildDefinitionAuthorization( ps.getProjectGroup().getName() );
627 org.apache.maven.continuum.model.project.BuildDefinition newbd =
628 continuum.getBuildDefinition( buildDef.getId() );
629 org.apache.maven.continuum.model.project.BuildDefinition bd = populateBuildDefinition( buildDef, newbd );
630 bd = continuum.updateBuildDefinitionForProject( projectId, bd );
631 return populateBuildDefinition( bd );
632 }
633
634 public BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition buildDef )
635 throws ContinuumException
636 {
637 checkModifyGroupBuildDefinitionAuthorization( getProjectGroupName( projectGroupId ) );
638 org.apache.maven.continuum.model.project.BuildDefinition newbd =
639 continuum.getBuildDefinition( buildDef.getId() );
640 org.apache.maven.continuum.model.project.BuildDefinition bd = populateBuildDefinition( buildDef, newbd );
641 bd = continuum.updateBuildDefinitionForProjectGroup( projectGroupId, bd );
642 return populateBuildDefinition( bd );
643 }
644
645 public BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDef )
646 throws ContinuumException
647 {
648 checkAddProjectBuildDefinitionAuthorization( getProjectSummary( projectId ).getProjectGroup().getName() );
649
650 if ( buildDef.getSchedule() == null )
651 {
652 throw new ContinuumException( "The schedule can't be null." );
653 }
654 org.apache.maven.continuum.model.project.BuildDefinition newbd =
655 new org.apache.maven.continuum.model.project.BuildDefinition();
656 org.apache.maven.continuum.model.project.BuildDefinition bd = populateBuildDefinition( buildDef, newbd );
657 bd = continuum.addBuildDefinitionToProject( projectId, bd );
658 return populateBuildDefinition( bd );
659 }
660
661 public BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDef )
662 throws ContinuumException
663 {
664 checkAddGroupBuildDefinitionAuthorization( getPGSummary( projectGroupId ).getName() );
665
666 if ( buildDef.getSchedule() == null )
667 {
668 throw new ContinuumException( "The schedule can't be null." );
669 }
670 org.apache.maven.continuum.model.project.BuildDefinition newbd =
671 new org.apache.maven.continuum.model.project.BuildDefinition();
672 org.apache.maven.continuum.model.project.BuildDefinition bd = populateBuildDefinition( buildDef, newbd );
673 bd = continuum.addBuildDefinitionToProjectGroup( projectGroupId, bd );
674 return populateBuildDefinition( bd );
675 }
676
677 public List<BuildDefinitionTemplate> getBuildDefinitionTemplates()
678 throws Exception
679 {
680 checkManageBuildDefinitionTemplatesAuthorization();
681 List<org.apache.maven.continuum.model.project.BuildDefinitionTemplate> bdts =
682 continuum.getBuildDefinitionService().getAllBuildDefinitionTemplate();
683
684 List<BuildDefinitionTemplate> result = new ArrayList<BuildDefinitionTemplate>();
685 for ( org.apache.maven.continuum.model.project.BuildDefinitionTemplate bdt : bdts )
686 {
687 result.add( populateBuildDefinitionTemplate( bdt ) );
688 }
689 return result;
690 }
691
692
693
694
695
696 public int addProjectToBuildQueue( int projectId )
697 throws ContinuumException
698 {
699 ProjectSummary ps = getProjectSummary( projectId );
700 checkBuildProjectInGroupAuthorization( ps.getProjectGroup().getName() );
701
702 continuum.buildProject( projectId, ContinuumProjectState.TRIGGER_SCHEDULED );
703 return 0;
704 }
705
706 public int addProjectToBuildQueue( int projectId, int buildDefinitionId )
707 throws ContinuumException
708 {
709 ProjectSummary ps = getProjectSummary( projectId );
710 checkBuildProjectInGroupAuthorization( ps.getProjectGroup().getName() );
711
712 continuum.buildProject( projectId, buildDefinitionId, ContinuumProjectState.TRIGGER_SCHEDULED );
713 return 0;
714 }
715
716 public int buildProject( int projectId )
717 throws ContinuumException
718 {
719 ProjectSummary ps = getProjectSummary( projectId );
720 checkBuildProjectInGroupAuthorization( ps.getProjectGroup().getName() );
721
722 continuum.buildProject( projectId );
723 return 0;
724 }
725
726 public int buildProject( int projectId, int buildDefintionId )
727 throws ContinuumException
728 {
729 ProjectSummary ps = getProjectSummary( projectId );
730 checkBuildProjectInGroupAuthorization( ps.getProjectGroup().getName() );
731
732 continuum.buildProjectWithBuildDefinition( projectId, buildDefintionId );
733 return 0;
734 }
735
736 public int buildGroup( int projectGroupId )
737 throws ContinuumException
738 {
739 ProjectGroupSummary pg = getProjectGroupSummary( projectGroupId );
740 checkBuildProjectInGroupAuthorization( pg.getName() );
741
742 continuum.buildProjectGroup( projectGroupId );
743
744 return 0;
745 }
746
747 public int buildGroup( int projectGroupId, int buildDefintionId )
748 throws ContinuumException
749 {
750 ProjectGroupSummary pg = getProjectGroupSummary( projectGroupId );
751 checkBuildProjectInGroupAuthorization( pg.getName() );
752
753 continuum.buildProjectGroupWithBuildDefinition( projectGroupId, buildDefintionId );
754
755 return 0;
756 }
757
758
759
760
761
762 public BuildResult getLatestBuildResult( int projectId )
763 throws ContinuumException
764 {
765 ProjectSummary ps = getProjectSummary( projectId );
766 checkViewProjectGroupAuthorization( ps.getProjectGroup().getName() );
767
768 org.apache.maven.continuum.model.project.BuildResult buildResult =
769 continuum.getLatestBuildResultForProject( projectId );
770
771 return getBuildResult( projectId, buildResult.getId() );
772 }
773
774 public BuildResult getBuildResult( int projectId, int buildId )
775 throws ContinuumException
776 {
777 ProjectSummary ps = getProjectSummary( projectId );
778 checkViewProjectGroupAuthorization( ps.getProjectGroup().getName() );
779
780 return populateBuildResult( continuum.getBuildResult( buildId ) );
781 }
782
783 public List<BuildResultSummary> getBuildResultsForProject( int projectId )
784 throws ContinuumException
785 {
786 ProjectSummary ps = getProjectSummary( projectId );
787 checkViewProjectGroupAuthorization( ps.getProjectGroup().getName() );
788
789 List<BuildResultSummary> result = new ArrayList<BuildResultSummary>();
790 Collection buildResults = continuum.getBuildResultsForProject( projectId );
791 if ( buildResults != null )
792 {
793 for ( org.apache.maven.continuum.model.project.BuildResult buildResult : (List<org.apache.maven.continuum.model.project.BuildResult>) buildResults )
794 {
795 BuildResultSummary br = populateBuildResultSummary( buildResult );
796 result.add( br );
797 }
798 }
799
800 return result;
801 }
802
803 public int removeBuildResult( BuildResult br )
804 throws ContinuumException
805 {
806 checkModifyProjectGroupAuthorization(
807 getProjectSummary( br.getProject().getId() ).getProjectGroup().getName() );
808 continuum.removeBuildResult( br.getId() );
809 return 0;
810 }
811
812 public String getBuildOutput( int projectId, int buildId )
813 throws ContinuumException
814 {
815 ProjectSummary ps = getProjectSummary( projectId );
816 checkViewProjectGroupAuthorization( ps.getProjectGroup().getName() );
817
818 return continuum.getBuildOutput( projectId, buildId );
819 }
820
821
822
823
824
825 public AddingResult addMavenTwoProject( String url )
826 throws ContinuumException
827 {
828 checkAddProjectGroupAuthorization();
829
830 ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url );
831 return populateAddingResult( result );
832 }
833
834 public AddingResult addMavenTwoProject( String url, int projectGroupId )
835 throws ContinuumException
836 {
837 checkAddProjectToGroupAuthorization( getProjectGroupName( projectGroupId ) );
838
839 ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url, projectGroupId );
840 return populateAddingResult( result );
841 }
842
843
844
845
846
847 public AddingResult addMavenOneProject( String url, int projectGroupId )
848 throws ContinuumException
849 {
850 checkAddProjectToGroupAuthorization( getProjectGroupName( projectGroupId ) );
851
852 ContinuumProjectBuildingResult result = continuum.addMavenOneProject( url, projectGroupId );
853 return populateAddingResult( result );
854 }
855
856
857
858
859
860 public ProjectSummary addAntProject( ProjectSummary project, int projectGroupId )
861 throws ContinuumException
862 {
863 checkAddProjectGroupAuthorization();
864 org.apache.maven.continuum.model.project.Project newProject =
865 new org.apache.maven.continuum.model.project.Project();
866 int projectId = continuum.addProject( populateProject( project, newProject ),
867 ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR, projectGroupId );
868 return getProjectSummary( projectId );
869 }
870
871
872
873
874
875 public ProjectSummary addShellProject( ProjectSummary project, int projectGroupId )
876 throws ContinuumException
877 {
878 checkAddProjectGroupAuthorization();
879 org.apache.maven.continuum.model.project.Project newProject =
880 new org.apache.maven.continuum.model.project.Project();
881 int projectId = continuum.addProject( populateProject( project, newProject ),
882 ContinuumBuildExecutorConstants.SHELL_BUILD_EXECUTOR, projectGroupId );
883 return getProjectSummary( projectId );
884 }
885
886
887
888
889
890 public List<Schedule> getSchedules()
891 throws ContinuumException
892 {
893 checkManageSchedulesAuthorization();
894 Collection schedules = continuum.getSchedules();
895
896 List<Schedule> s = new ArrayList<Schedule>();
897 for ( Object schedule : schedules )
898 {
899 s.add( populateSchedule( (org.apache.maven.continuum.model.project.Schedule) schedule ) );
900 }
901
902 return s;
903 }
904
905 public Schedule getSchedule( int scheduleId )
906 throws ContinuumException
907 {
908 checkManageSchedulesAuthorization();
909 return populateSchedule( continuum.getSchedule( scheduleId ) );
910 }
911
912 public Schedule updateSchedule( Schedule schedule )
913 throws ContinuumException
914 {
915 checkManageSchedulesAuthorization();
916 org.apache.maven.continuum.model.project.Schedule s = continuum.getSchedule( schedule.getId() );
917 org.apache.maven.continuum.model.project.Schedule newSchedule = populateSchedule( schedule, s );
918 org.apache.maven.continuum.model.project.Schedule storedSchedule = continuum.getSchedule( schedule.getId() );
919 storedSchedule.setActive( newSchedule.isActive() );
920 storedSchedule.setName( newSchedule.getName() );
921 storedSchedule.setDescription( StringEscapeUtils.escapeXml( newSchedule.getDescription() ) );
922 storedSchedule.setDelay( newSchedule.getDelay() );
923 storedSchedule.setCronExpression( newSchedule.getCronExpression() );
924 storedSchedule.setMaxJobExecutionTime( newSchedule.getMaxJobExecutionTime() );
925 continuum.updateSchedule( storedSchedule );
926
927 return populateSchedule( continuum.getScheduleByName( schedule.getName() ) );
928 }
929
930 public Schedule addSchedule( Schedule schedule )
931 throws ContinuumException
932 {
933 checkManageSchedulesAuthorization();
934 org.apache.maven.continuum.model.project.Schedule s = new org.apache.maven.continuum.model.project.Schedule();
935 continuum.addSchedule( populateSchedule( schedule, s ) );
936
937 return populateSchedule( continuum.getScheduleByName( schedule.getName() ) );
938 }
939
940 public int removeSchedule( int scheduleId )
941 throws ContinuumException
942 {
943 checkManageSchedulesAuthorization();
944
945 continuum.removeSchedule( scheduleId );
946
947 return 0;
948 }
949
950
951
952
953
954 public List<Profile> getProfiles()
955 throws ContinuumException
956 {
957 checkManageProfilesAuthorization();
958 Collection profiles = continuum.getProfileService().getAllProfiles();
959
960 List<Profile> p = new ArrayList<Profile>();
961 for ( Object profile : profiles )
962 {
963 p.add( populateProfile( (org.apache.maven.continuum.model.system.Profile) profile ) );
964 }
965
966 return p;
967 }
968
969 public Profile getProfile( int profileId )
970 throws ContinuumException
971 {
972 checkManageProfilesAuthorization();
973 return populateProfile( continuum.getProfileService().getProfile( profileId ) );
974 }
975
976 public Profile addProfile( Profile profile )
977 throws ContinuumException
978 {
979 org.apache.maven.continuum.model.system.Profile newProfile =
980 new org.apache.maven.continuum.model.system.Profile();
981
982 return populateProfile( continuum.getProfileService().addProfile( populateProfile( profile, newProfile ) ) );
983 }
984
985 public int updateProfile( Profile profile )
986 throws ContinuumException
987 {
988 org.apache.maven.continuum.model.system.Profile newProfile =
989 continuum.getProfileService().getProfile( profile.getId() );
990
991 continuum.getProfileService().updateProfile( populateProfile( profile, newProfile ) );
992 return 0;
993 }
994
995 public int deleteProfile( int profileId )
996 throws ContinuumException
997 {
998
999 continuum.getProfileService().deleteProfile( profileId );
1000 return 0;
1001 }
1002
1003
1004
1005
1006
1007 public List<Installation> getInstallations()
1008 throws ContinuumException
1009 {
1010 checkManageInstallationsAuthorization();
1011 try
1012 {
1013 List<org.apache.maven.continuum.model.system.Installation> installs =
1014 continuum.getInstallationService().getAllInstallations();
1015
1016 List<Installation> i = new ArrayList<Installation>();
1017 for ( Object install : installs )
1018 {
1019 i.add( populateInstallation( (org.apache.maven.continuum.model.system.Installation) install ) );
1020 }
1021 return i;
1022 }
1023 catch ( InstallationException e )
1024 {
1025 throw new ContinuumException( "Can't load installations", e );
1026 }
1027 }
1028
1029 public Installation getInstallation( int installationId )
1030 throws ContinuumException
1031 {
1032 checkManageInstallationsAuthorization();
1033 try
1034 {
1035 org.apache.maven.continuum.model.system.Installation install =
1036 continuum.getInstallationService().getInstallation( installationId );
1037 return populateInstallation( install );
1038 }
1039 catch ( InstallationException e )
1040 {
1041 throw new ContinuumException( "Can't load installations", e );
1042 }
1043 }
1044
1045 public Installation addInstallation( Installation installation )
1046 throws ContinuumException
1047 {
1048 try
1049 {
1050 org.apache.maven.continuum.model.system.Installation newInstallation =
1051 new org.apache.maven.continuum.model.system.Installation();
1052 return populateInstallation(
1053 continuum.getInstallationService().add( populateInstallation( installation, newInstallation ) ) );
1054 }
1055 catch ( InstallationException e )
1056 {
1057 throw new ContinuumException( "Can't delete installations", e );
1058 }
1059 }
1060
1061 public int updateInstallation( Installation installation )
1062 throws ContinuumException
1063 {
1064 try
1065 {
1066 final org.apache.maven.continuum.model.system.Installation newInst =
1067 continuum.getInstallationService().getInstallation( installation.getInstallationId() );
1068 continuum.getInstallationService().update( populateInstallation( installation, newInst ) );
1069 return 0;
1070 }
1071 catch ( InstallationException e )
1072 {
1073 throw new ContinuumException( "Can't delete installations", e );
1074 }
1075 }
1076
1077 public int deleteInstallation( int installationId )
1078 throws ContinuumException
1079 {
1080 try
1081 {
1082 org.apache.maven.continuum.model.system.Installation installationTODelete =
1083 continuum.getInstallationService().getInstallation( installationId );
1084 continuum.getInstallationService().delete( installationTODelete );
1085 return 0;
1086 }
1087 catch ( InstallationException e )
1088 {
1089 throw new ContinuumException( "Can't delete installations", e );
1090 }
1091 }
1092
1093
1094
1095
1096
1097 public SystemConfiguration getSystemConfiguration()
1098 throws ContinuumException
1099 {
1100 checkManageConfigurationAuthorization();
1101 try
1102 {
1103 org.apache.maven.continuum.model.system.SystemConfiguration sysConf =
1104 systemConfigurationDao.getSystemConfiguration();
1105 return populateSystemConfiguration( sysConf );
1106 }
1107 catch ( ContinuumStoreException e )
1108 {
1109 throw new ContinuumException( "Can't get SystemConfigurationDao.", e );
1110 }
1111 }
1112
1113
1114
1115
1116
1117
1118 public boolean isProjectInBuildingQueue( int projectId )
1119 throws ContinuumException
1120 {
1121 try
1122 {
1123 return parallelBuildsManager.isInAnyBuildQueue( projectId );
1124 }
1125 catch ( BuildManagerException e )
1126 {
1127 throw new ContinuumException( e.getMessage(), e );
1128 }
1129 }
1130
1131 public List<BuildProjectTask> getProjectsInBuildQueue()
1132 throws ContinuumException
1133 {
1134 try
1135 {
1136 Map<String, List<org.apache.continuum.taskqueue.BuildProjectTask>> buildTasks =
1137 parallelBuildsManager.getProjectsInBuildQueues();
1138 Set<String> keys = buildTasks.keySet();
1139 List<org.apache.continuum.taskqueue.BuildProjectTask> convertedTasks =
1140 new ArrayList<org.apache.continuum.taskqueue.BuildProjectTask>();
1141
1142 for ( String key : keys )
1143 {
1144 List<org.apache.continuum.taskqueue.BuildProjectTask> tasks = buildTasks.get( key );
1145 for ( org.apache.continuum.taskqueue.BuildProjectTask task : tasks )
1146 {
1147 convertedTasks.add( task );
1148 }
1149 }
1150
1151 return populateBuildProjectTaskList( convertedTasks );
1152 }
1153 catch ( BuildManagerException e )
1154 {
1155 throw new ContinuumException( e.getMessage(), e );
1156 }
1157 }
1158
1159 public int removeProjectsFromBuildingQueue( int[] projectsId )
1160 throws ContinuumException
1161 {
1162 checkManageQueuesAuthorization();
1163
1164 parallelBuildsManager.removeProjectsFromBuildQueue( projectsId );
1165
1166 return 0;
1167 }
1168
1169 public boolean cancelCurrentBuild()
1170 throws ContinuumException
1171 {
1172 checkManageQueuesAuthorization();
1173 try
1174 {
1175 return parallelBuildsManager.cancelAllBuilds();
1176 }
1177 catch ( BuildManagerException e )
1178 {
1179 throw new ContinuumException( e.getMessage(), e );
1180 }
1181 }
1182
1183
1184
1185
1186
1187 public ContinuumReleaseResult getReleaseResult( int releaseId )
1188 throws ContinuumException
1189 {
1190 org.apache.continuum.model.release.ContinuumReleaseResult releaseResult =
1191 continuum.getContinuumReleaseResult( releaseId );
1192 checkViewProjectGroupAuthorization( getProjectGroupName( releaseResult.getProjectGroup().getId() ) );
1193 return populateReleaseResult( releaseResult );
1194 }
1195
1196 public List<ContinuumReleaseResult> getReleaseResultsForProjectGroup( int projectGroupId )
1197 throws ContinuumException
1198 {
1199 checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
1200 Collection releaseResults = continuum.getContinuumReleaseResultsByProjectGroup( projectGroupId );
1201
1202 List<ContinuumReleaseResult> r = new ArrayList<ContinuumReleaseResult>();
1203 for ( Object releaseResult : releaseResults )
1204 {
1205 r.add( populateReleaseResult( (org.apache.continuum.model.release.ContinuumReleaseResult) releaseResult ) );
1206 }
1207 return r;
1208 }
1209
1210 public int removeReleaseResult( ContinuumReleaseResult releaseResult )
1211 throws ContinuumException
1212 {
1213 checkModifyProjectGroupAuthorization( getProjectGroupName( releaseResult.getProjectGroup().getId() ) );
1214 continuum.removeContinuumReleaseResult( releaseResult.getId() );
1215 return 0;
1216 }
1217
1218 public String getReleaseOutput( int releaseId )
1219 throws ContinuumException
1220 {
1221 org.apache.continuum.model.release.ContinuumReleaseResult releaseResult =
1222 continuum.getContinuumReleaseResult( releaseId );
1223 checkViewProjectGroupAuthorization( getProjectGroupName( releaseResult.getProjectGroup().getId() ) );
1224
1225 return continuum.getReleaseOutput( releaseId );
1226 }
1227
1228
1229
1230
1231
1232 public RepositoryPurgeConfiguration addRepositoryPurgeConfiguration( RepositoryPurgeConfiguration repoPurge )
1233 throws ContinuumException
1234 {
1235 checkManagePurgingAuthorization();
1236
1237 try
1238 {
1239 org.apache.continuum.model.repository.RepositoryPurgeConfiguration newPurge =
1240 new org.apache.continuum.model.repository.RepositoryPurgeConfiguration();
1241 return populateRepositoryPurgeConfiguration( continuum.getPurgeConfigurationService().
1242 addRepositoryPurgeConfiguration( populateRepositoryPurgeConfiguration( repoPurge, newPurge ) ) );
1243 }
1244 catch ( RepositoryServiceException e )
1245 {
1246 throw new ContinuumException( "Error while converting repository purge configuration", e );
1247 }
1248 catch ( PurgeConfigurationServiceException e )
1249 {
1250 throw new ContinuumException( "Can't add repositoryPurgeConfiguration", e );
1251 }
1252 }
1253
1254 public int updateRepositoryPurgeConfiguration( RepositoryPurgeConfiguration repoPurge )
1255 throws ContinuumException
1256 {
1257 checkManagePurgingAuthorization();
1258
1259 try
1260 {
1261 org.apache.continuum.model.repository.RepositoryPurgeConfiguration purge =
1262 new org.apache.continuum.model.repository.RepositoryPurgeConfiguration();
1263 continuum.getPurgeConfigurationService().updateRepositoryPurgeConfiguration(
1264 populateRepositoryPurgeConfiguration( repoPurge, purge ) );
1265 return 0;
1266 }
1267 catch ( RepositoryServiceException e )
1268 {
1269 throw new ContinuumException( "Error while converting repository purge configuration", e );
1270 }
1271 catch ( PurgeConfigurationServiceException e )
1272 {
1273 throw new ContinuumException( "Cant' update repository PurgeException", e );
1274 }
1275 }
1276
1277 public int removeRepositoryPurgeConfiguration( int repoPurgeId )
1278 throws ContinuumException
1279 {
1280 checkManagePurgingAuthorization();
1281
1282 try
1283 {
1284 org.apache.continuum.model.repository.RepositoryPurgeConfiguration repoPurge =
1285 continuum.getPurgeConfigurationService().getRepositoryPurgeConfiguration( repoPurgeId );
1286 continuum.getPurgeConfigurationService().removeRepositoryPurgeConfiguration( repoPurge );
1287 return 0;
1288 }
1289 catch ( PurgeConfigurationServiceException e )
1290 {
1291 throw new ContinuumException( "Can't delete repository purge configuration", e );
1292 }
1293 }
1294
1295 public RepositoryPurgeConfiguration getRepositoryPurgeConfiguration( int repoPurgeId )
1296 throws ContinuumException
1297 {
1298 checkManagePurgingAuthorization();
1299
1300 try
1301 {
1302 org.apache.continuum.model.repository.RepositoryPurgeConfiguration repoPurgeConfig =
1303 continuum.getPurgeConfigurationService().getRepositoryPurgeConfiguration( repoPurgeId );
1304 return populateRepositoryPurgeConfiguration( repoPurgeConfig );
1305 }
1306 catch ( PurgeConfigurationServiceException e )
1307 {
1308 throw new ContinuumException( "Error while retrieving repository purge configuration", e );
1309 }
1310 }
1311
1312 public List<RepositoryPurgeConfiguration> getAllRepositoryPurgeConfigurations()
1313 throws ContinuumException
1314 {
1315 checkManagePurgingAuthorization();
1316 Collection repoPurgeConfigs = continuum.getPurgeConfigurationService().getAllRepositoryPurgeConfigurations();
1317
1318 List<RepositoryPurgeConfiguration> r = new ArrayList<RepositoryPurgeConfiguration>();
1319 for ( Object repoPurgeConfig : repoPurgeConfigs )
1320 {
1321 r.add( populateRepositoryPurgeConfiguration(
1322 (org.apache.continuum.model.repository.RepositoryPurgeConfiguration) repoPurgeConfig ) );
1323 }
1324 return r;
1325 }
1326
1327 public DirectoryPurgeConfiguration addDirectoryPurgeConfiguration( DirectoryPurgeConfiguration dirPurge )
1328 throws ContinuumException
1329 {
1330 checkManagePurgingAuthorization();
1331
1332 try
1333 {
1334 org.apache.continuum.model.repository.DirectoryPurgeConfiguration newPurge =
1335 new org.apache.continuum.model.repository.DirectoryPurgeConfiguration();
1336 return populateDirectoryPurgeConfiguration( continuum.getPurgeConfigurationService().
1337 addDirectoryPurgeConfiguration( populateDirectoryPurgeConfiguration( dirPurge, newPurge ) ) );
1338 }
1339 catch ( RepositoryServiceException e )
1340 {
1341 throw new ContinuumException( "Error while converting directory purge configuration", e );
1342 }
1343 catch ( PurgeConfigurationServiceException e )
1344 {
1345 throw new ContinuumException( "Can't add directory purge configuration", e );
1346 }
1347 }
1348
1349 public int updateDirectoryPurgeConfiguration( DirectoryPurgeConfiguration dirPurge )
1350 throws ContinuumException
1351 {
1352 checkManagePurgingAuthorization();
1353
1354 try
1355 {
1356 org.apache.continuum.model.repository.DirectoryPurgeConfiguration purge =
1357 new org.apache.continuum.model.repository.DirectoryPurgeConfiguration();
1358 continuum.getPurgeConfigurationService().updateDirectoryPurgeConfiguration(
1359 populateDirectoryPurgeConfiguration( dirPurge, purge ) );
1360 return 0;
1361 }
1362 catch ( RepositoryServiceException e )
1363 {
1364 throw new ContinuumException( "Error while converting directory purge configuration", e );
1365 }
1366 catch ( PurgeConfigurationServiceException e )
1367 {
1368 throw new ContinuumException( "Can't add directory purge configuration", e );
1369 }
1370 }
1371
1372 public int removeDirectoryPurgeConfiguration( int dirPurgeId )
1373 throws ContinuumException
1374 {
1375 checkManagePurgingAuthorization();
1376
1377 try
1378 {
1379 org.apache.continuum.model.repository.DirectoryPurgeConfiguration dirPurge =
1380 continuum.getPurgeConfigurationService().getDirectoryPurgeConfiguration( dirPurgeId );
1381 continuum.getPurgeConfigurationService().removeDirectoryPurgeConfiguration( dirPurge );
1382 return 0;
1383 }
1384 catch ( PurgeConfigurationServiceException e )
1385 {
1386 throw new ContinuumException( "Can't delete directory purge configuration", e );
1387 }
1388 }
1389
1390 public DirectoryPurgeConfiguration getDirectoryPurgeConfiguration( int dirPurgeId )
1391 throws ContinuumException
1392 {
1393 checkManagePurgingAuthorization();
1394
1395 try
1396 {
1397 org.apache.continuum.model.repository.DirectoryPurgeConfiguration dirPurgeConfig =
1398 continuum.getPurgeConfigurationService().getDirectoryPurgeConfiguration( dirPurgeId );
1399 return populateDirectoryPurgeConfiguration( dirPurgeConfig );
1400 }
1401 catch ( PurgeConfigurationServiceException e )
1402 {
1403 throw new ContinuumException( "Error while retrieving directory purge configuration", e );
1404 }
1405 }
1406
1407 public List<DirectoryPurgeConfiguration> getAllDirectoryPurgeConfigurations()
1408 throws ContinuumException
1409 {
1410 checkManagePurgingAuthorization();
1411 Collection dirPurgeConfigs = continuum.getPurgeConfigurationService().getAllDirectoryPurgeConfigurations();
1412
1413 List<DirectoryPurgeConfiguration> d = new ArrayList<DirectoryPurgeConfiguration>();
1414 for ( Object dirPurgeConfig : dirPurgeConfigs )
1415 {
1416 d.add( populateDirectoryPurgeConfiguration(
1417 (org.apache.continuum.model.repository.DirectoryPurgeConfiguration) dirPurgeConfig ) );
1418 }
1419 return d;
1420 }
1421
1422 public void purgeLocalRepository( int repoPurgeId )
1423 throws ContinuumException
1424 {
1425 checkManagePurgingAuthorization();
1426
1427 try
1428 {
1429 org.apache.continuum.model.repository.RepositoryPurgeConfiguration repoPurgeConfig =
1430 continuum.getPurgeConfigurationService().getRepositoryPurgeConfiguration( repoPurgeId );
1431 continuum.getPurgeManager().purgeRepository( repoPurgeConfig );
1432 }
1433 catch ( PurgeConfigurationServiceException e )
1434 {
1435 throw new ContinuumException( "Error while retrieving repository purge configuration", e );
1436 }
1437 catch ( ContinuumPurgeManagerException e )
1438 {
1439 throw new ContinuumException( "Error while purging local repository", e );
1440 }
1441 }
1442
1443 public void purgeDirectory( int dirPurgeId )
1444 throws ContinuumException
1445 {
1446 checkManagePurgingAuthorization();
1447
1448 try
1449 {
1450 org.apache.continuum.model.repository.DirectoryPurgeConfiguration dirPurgeConfig =
1451 continuum.getPurgeConfigurationService().getDirectoryPurgeConfiguration( dirPurgeId );
1452 continuum.getPurgeManager().purgeDirectory( dirPurgeConfig );
1453 }
1454 catch ( PurgeConfigurationServiceException e )
1455 {
1456 throw new ContinuumException( "Error while retrieving directory purge configuration", e );
1457 }
1458 catch ( ContinuumPurgeManagerException e )
1459 {
1460 throw new ContinuumException( "Error while purging directory", e );
1461 }
1462 }
1463
1464
1465
1466
1467
1468 public LocalRepository addLocalRepository( LocalRepository repository )
1469 throws ContinuumException
1470 {
1471 checkManageRepositoriesAuthorization();
1472
1473 try
1474 {
1475 org.apache.continuum.model.repository.LocalRepository newRepository =
1476 new org.apache.continuum.model.repository.LocalRepository();
1477 return populateLocalRepository( continuum.getRepositoryService().addLocalRepository(
1478 populateLocalRepository( repository, newRepository ) ) );
1479 }
1480 catch ( RepositoryServiceException e )
1481 {
1482 throw new ContinuumException( "Unable to add repository", e );
1483 }
1484 }
1485
1486 public int updateLocalRepository( LocalRepository repository )
1487 throws ContinuumException
1488 {
1489 checkManageRepositoriesAuthorization();
1490
1491 try
1492 {
1493 final org.apache.continuum.model.repository.LocalRepository newRepo =
1494 continuum.getRepositoryService().getLocalRepository( repository.getId() );
1495 continuum.getRepositoryService().updateLocalRepository( populateLocalRepository( repository, newRepo ) );
1496 return 0;
1497 }
1498 catch ( RepositoryServiceException e )
1499 {
1500 throw new ContinuumException( "Can't update repository", e );
1501 }
1502 }
1503
1504 public int removeLocalRepository( int repositoryId )
1505 throws ContinuumException
1506 {
1507 checkManageRepositoriesAuthorization();
1508
1509 try
1510 {
1511 continuum.getRepositoryService().removeLocalRepository( repositoryId );
1512 return 0;
1513 }
1514 catch ( RepositoryServiceException e )
1515 {
1516 throw new ContinuumException( "Can't delete repository", e );
1517 }
1518 }
1519
1520 public LocalRepository getLocalRepository( int repositoryId )
1521 throws ContinuumException
1522 {
1523 checkManageRepositoriesAuthorization();
1524
1525 try
1526 {
1527 return populateLocalRepository( continuum.getRepositoryService().getLocalRepository( repositoryId ) );
1528 }
1529 catch ( RepositoryServiceException e )
1530 {
1531 throw new ContinuumException( "Error while retrieving repository.", e );
1532 }
1533 }
1534
1535 public List<LocalRepository> getAllLocalRepositories()
1536 throws ContinuumException
1537 {
1538 checkManageRepositoriesAuthorization();
1539 Collection repos = continuum.getRepositoryService().getAllLocalRepositories();
1540
1541 List<LocalRepository> r = new ArrayList<LocalRepository>();
1542 for ( Object repo : repos )
1543 {
1544 r.add( populateLocalRepository( (org.apache.continuum.model.repository.LocalRepository) repo ) );
1545 }
1546 return r;
1547 }
1548
1549
1550
1551
1552
1553 private List<BuildProjectTask> populateBuildProjectTaskList(
1554 List<org.apache.continuum.taskqueue.BuildProjectTask> buildProjectTasks )
1555 {
1556 List<BuildProjectTask> responses = new ArrayList<BuildProjectTask>();
1557 for ( org.apache.continuum.taskqueue.BuildProjectTask buildProjectTask : buildProjectTasks )
1558 {
1559
1560 responses.add( (BuildProjectTask) mapper.map( buildProjectTask, BuildProjectTask.class ) );
1561 }
1562 return responses;
1563 }
1564
1565 private ProjectSummary populateProjectSummary( org.apache.maven.continuum.model.project.Project project )
1566 {
1567 return (ProjectSummary) mapper.map( project, ProjectSummary.class );
1568 }
1569
1570 private Project populateProject( org.apache.maven.continuum.model.project.Project project )
1571 {
1572 return (Project) mapper.map( project, Project.class );
1573 }
1574
1575 private org.apache.maven.continuum.model.project.Project populateProject( ProjectSummary projectSummary,
1576 org.apache.maven.continuum.model.project.Project project )
1577 throws ContinuumException
1578 {
1579 if ( projectSummary == null )
1580 {
1581 return null;
1582 }
1583
1584
1585 if ( StringUtils.isNotBlank( projectSummary.getArtifactId() ) &&
1586 !projectSummary.getArtifactId().matches( PROJECT_ARTIFACT_ID_VALID_EXPRESSION ) )
1587 {
1588 throw new ContinuumException( "Project Artifact Id contains invalid characters" );
1589 }
1590
1591 if ( StringUtils.isNotBlank( projectSummary.getExecutorId() ) &&
1592 !projectSummary.getExecutorId().matches( PROJECT_EXECUTOR_OR_BUILDDEF_TYPE_VALID_EXPRESSION ) )
1593 {
1594 throw new ContinuumException( "Project Executor Id can only be 'maven2, maven-1, ant or shell'" );
1595 }
1596
1597 if ( StringUtils.isNotBlank( projectSummary.getGroupId() ) &&
1598 !projectSummary.getGroupId().matches( PROJECT_GROUP_ID_VALID_EXPRESSION ) )
1599 {
1600 throw new ContinuumException( "Project Group Id contains invalid characters" );
1601 }
1602
1603 if ( StringUtils.isNotBlank( projectSummary.getName() ) &&
1604 !projectSummary.getName().matches( NAME_VALID_EXPRESSION ) )
1605 {
1606 throw new ContinuumException( "Project Name contains invalid characters" );
1607 }
1608
1609 if ( StringUtils.isNotBlank( projectSummary.getScmTag() ) &&
1610 !projectSummary.getScmTag().matches( PROJECT_SCM_TAG_VALID_EXPRESSION ) )
1611 {
1612 throw new ContinuumException( "Project Scm Tag contains invalid characters" );
1613 }
1614
1615 if ( StringUtils.isNotBlank( projectSummary.getScmUrl() ) &&
1616 !projectSummary.getScmUrl().matches( PROJECT_SCM_URL_VALID_EXPRESSION ) )
1617 {
1618 throw new ContinuumException( "Project Scm Url contains invalid characters" );
1619 }
1620
1621 if ( StringUtils.isNotBlank( projectSummary.getUrl() ) &&
1622 !projectSummary.getUrl().matches( URL_VALID_EXPRESSION ) )
1623 {
1624 throw new ContinuumException( "Project Url contains invalid characters" );
1625 }
1626
1627 if ( StringUtils.isNotBlank( projectSummary.getVersion() ) &&
1628 !projectSummary.getVersion().matches( PROJECT_VERSION_VALID_EXPRESSION ) )
1629 {
1630 throw new ContinuumException( "Project Version contains invalid characters" );
1631 }
1632
1633 if ( StringUtils.isNotBlank( projectSummary.getWorkingDirectory() ) &&
1634 !projectSummary.getWorkingDirectory().matches( DIRECTORY_VALID_EXPRESSION ) )
1635 {
1636 throw new ContinuumException( "Project Working Directory contains invalid characters" );
1637 }
1638
1639 project.setArtifactId( projectSummary.getArtifactId() );
1640 project.setBuildNumber( projectSummary.getBuildNumber() );
1641 project.setDescription( StringEscapeUtils.escapeXml( projectSummary.getDescription() ) );
1642 project.setExecutorId( projectSummary.getExecutorId() );
1643 project.setGroupId( projectSummary.getGroupId() );
1644 project.setId( projectSummary.getId() );
1645 project.setLatestBuildId( projectSummary.getLatestBuildId() );
1646 project.setName( projectSummary.getName() );
1647 if ( projectSummary.getProjectGroup() != null )
1648 {
1649 org.apache.maven.continuum.model.project.ProjectGroup g =
1650 continuum.getProjectGroup( projectSummary.getProjectGroup().getId() );
1651 project.setProjectGroup( populateProjectGroupSummary( projectSummary.getProjectGroup(), g ) );
1652 }
1653 else
1654 {
1655 project.setProjectGroup( null );
1656 }
1657 project.setScmTag( projectSummary.getScmTag() );
1658 project.setScmUrl( projectSummary.getScmUrl() );
1659 project.setScmUseCache( projectSummary.isScmUseCache() );
1660 project.setScmUsername( projectSummary.getScmUsername() );
1661 project.setState( projectSummary.getState() );
1662 project.setUrl( projectSummary.getUrl() );
1663 project.setVersion( projectSummary.getVersion() );
1664 project.setWorkingDirectory( projectSummary.getWorkingDirectory() );
1665 return project;
1666 }
1667
1668 private ProjectNotifier populateProjectNotifier( org.apache.maven.continuum.model.project.ProjectNotifier notifier )
1669 {
1670 return (ProjectNotifier) mapper.map( notifier, ProjectNotifier.class );
1671 }
1672
1673 private ProjectGroupSummary populateProjectGroupSummary(
1674 org.apache.maven.continuum.model.project.ProjectGroup group )
1675 {
1676 return (ProjectGroupSummary) mapper.map( group, ProjectGroupSummary.class );
1677 }
1678
1679 private org.apache.maven.continuum.model.project.ProjectGroup populateProjectGroupSummary(
1680 ProjectGroupSummary group, org.apache.maven.continuum.model.project.ProjectGroup g )
1681 throws ContinuumException
1682 {
1683 if ( group == null )
1684 {
1685 return null;
1686 }
1687
1688 if ( StringUtils.isNotBlank( group.getGroupId() ) &&
1689 !group.getGroupId().matches( PROJECTGROUP_ID_VALID_EXPRESSION ) )
1690 {
1691 throw new ContinuumException( "ProjectGroup Id contains invalid characters" );
1692 }
1693
1694 if ( StringUtils.isNotBlank( group.getName() ) &&
1695 !group.getName().matches( NAME_VALID_EXPRESSION ) )
1696 {
1697 throw new ContinuumException( "ProjectGroup Name contains invalid characters" );
1698 }
1699
1700 g.setDescription( StringEscapeUtils.escapeXml( group.getDescription() ) );
1701 g.setGroupId( group.getGroupId() );
1702 g.setId( group.getId() );
1703 g.setName( group.getName() );
1704 org.apache.continuum.model.repository.LocalRepository repo =
1705 new org.apache.continuum.model.repository.LocalRepository();
1706 g.setLocalRepository( populateLocalRepository( group.getLocalRepository(), repo ) );
1707 return g;
1708 }
1709
1710 private ProjectGroup populateProjectGroupWithAllDetails(
1711 org.apache.maven.continuum.model.project.ProjectGroup group )
1712 {
1713 return (ProjectGroup) mapper.map( group, ProjectGroup.class );
1714 }
1715
1716 private BuildResultSummary populateBuildResultSummary(
1717 org.apache.maven.continuum.model.project.BuildResult buildResult )
1718 {
1719 return (BuildResultSummary) mapper.map( buildResult, BuildResultSummary.class );
1720 }
1721
1722 private BuildResult populateBuildResult( org.apache.maven.continuum.model.project.BuildResult buildResult )
1723 throws ContinuumException
1724 {
1725 return (BuildResult) mapper.map( buildResult, BuildResult.class );
1726 }
1727
1728 private AddingResult populateAddingResult( ContinuumProjectBuildingResult result )
1729 {
1730 if ( result == null )
1731 {
1732 return null;
1733 }
1734 AddingResult res = new AddingResult();
1735
1736 if ( result.hasErrors() )
1737 {
1738 for ( String error : result.getErrors() )
1739 {
1740 res.addError( error );
1741 }
1742 }
1743
1744 if ( result.getProjects() != null )
1745 {
1746 for ( org.apache.maven.continuum.model.project.Project project : result.getProjects() )
1747 {
1748 res.addProject( populateProjectSummary( project ) );
1749 }
1750 }
1751
1752 if ( result.getProjectGroups() != null )
1753 {
1754 for ( org.apache.maven.continuum.model.project.ProjectGroup projectGroup : result.getProjectGroups() )
1755 {
1756 res.addProjectGroup( populateProjectGroupSummary( projectGroup ) );
1757 }
1758 }
1759
1760 return res;
1761 }
1762
1763 private BuildDefinition populateBuildDefinition( org.apache.maven.continuum.model.project.BuildDefinition buildDef )
1764 {
1765 return (BuildDefinition) mapper.map( buildDef, BuildDefinition.class );
1766 }
1767
1768 private org.apache.maven.continuum.model.project.BuildDefinition populateBuildDefinition( BuildDefinition buildDef,
1769 org.apache.maven.continuum.model.project.BuildDefinition bd )
1770 throws ProfileException, ContinuumException
1771 {
1772 if ( buildDef == null )
1773 {
1774 return null;
1775 }
1776
1777 if ( StringUtils.isNotBlank( buildDef.getArguments() ) &&
1778 !buildDef.getArguments().matches( BUILD_DEFINITION_ARGUMENTS_VALID_EXPRESSION ) )
1779 {
1780 throw new ContinuumException( "Build Definition Arguments contain invalid characters" );
1781 }
1782
1783 if ( StringUtils.isNotBlank( buildDef.getBuildFile() ) &&
1784 !buildDef.getBuildFile().matches( BUILD_DEFINITION_BUILD_FILE_VALID_EXPRESSION ) )
1785 {
1786 throw new ContinuumException( "Build Definition Build File contains invalid characters" );
1787 }
1788
1789 if ( StringUtils.isNotBlank( buildDef.getGoals() ) &&
1790 !buildDef.getGoals().matches( BUILD_DEFINITION_GOALS_VALID_EXPRESSION ) )
1791 {
1792 throw new ContinuumException( "Build Definition Goals contain invalid characters" );
1793 }
1794
1795 if ( StringUtils.isNotBlank( buildDef.getType() ) &&
1796 !buildDef.getType().matches( PROJECT_EXECUTOR_OR_BUILDDEF_TYPE_VALID_EXPRESSION ) )
1797 {
1798 throw new ContinuumException( "Build Definition Type can only be 'maven2, maven-1, ant, or shell'" );
1799 }
1800
1801 bd.setArguments( buildDef.getArguments() );
1802 bd.setBuildFile( buildDef.getBuildFile() );
1803 bd.setType( buildDef.getType() );
1804 bd.setBuildFresh( buildDef.isBuildFresh() );
1805 bd.setAlwaysBuild( buildDef.isAlwaysBuild() );
1806 bd.setDefaultForProject( buildDef.isDefaultForProject() );
1807 bd.setGoals( buildDef.getGoals() );
1808 bd.setId( buildDef.getId() );
1809 if ( buildDef.getProfile() != null )
1810 {
1811 bd.setProfile( populateProfile( buildDef.getProfile(), continuum.getProfileService().getProfile(
1812 buildDef.getProfile().getId() ) ) );
1813 }
1814 else
1815 {
1816 bd.setProfile( null );
1817 }
1818 if ( buildDef.getSchedule() != null )
1819 {
1820 bd.setSchedule(
1821 populateSchedule( buildDef.getSchedule(), continuum.getSchedule( buildDef.getSchedule().getId() ) ) );
1822 }
1823 else
1824 {
1825 bd.setSchedule( null );
1826 }
1827
1828 return bd;
1829 }
1830
1831 private BuildDefinitionTemplate populateBuildDefinitionTemplate(
1832 org.apache.maven.continuum.model.project.BuildDefinitionTemplate bdt )
1833 {
1834 return (BuildDefinitionTemplate) mapper.map( bdt, BuildDefinitionTemplate.class );
1835 }
1836
1837 private org.apache.maven.continuum.model.project.Schedule populateSchedule( Schedule schedule,
1838 org.apache.maven.continuum.model.project.Schedule s )
1839 throws ContinuumException
1840 {
1841 if ( schedule == null )
1842 {
1843 return null;
1844 }
1845
1846 if ( StringUtils.isNotBlank( schedule.getCronExpression() ) &&
1847 !schedule.getCronExpression().matches( SCHEDULE_CRON_VALID_EXPRESSION ) )
1848 {
1849 throw new ContinuumException( "Schedule Cron Expression contains invalid characters" );
1850 }
1851
1852 if ( StringUtils.isNotBlank( schedule.getName() ) &&
1853 !schedule.getName().matches( NAME_VALID_EXPRESSION ) )
1854 {
1855 throw new ContinuumException( "Schedule Name contains invalid characters" );
1856 }
1857
1858 s.setActive( schedule.isActive() );
1859 s.setCronExpression( schedule.getCronExpression() );
1860 s.setDelay( schedule.getDelay() );
1861 s.setDescription( StringEscapeUtils.escapeXml( schedule.getDescription() ) );
1862 s.setId( schedule.getId() );
1863 s.setMaxJobExecutionTime( schedule.getMaxJobExecutionTime() );
1864 s.setName( schedule.getName() );
1865 return s;
1866 }
1867
1868 private Schedule populateSchedule( org.apache.maven.continuum.model.project.Schedule schedule )
1869 {
1870 return (Schedule) mapper.map( schedule, Schedule.class );
1871 }
1872
1873 private org.apache.maven.continuum.model.system.Profile populateProfile( Profile profile,
1874 org.apache.maven.continuum.model.system.Profile newProfile )
1875 throws ContinuumException
1876 {
1877 if ( profile == null )
1878 {
1879 return null;
1880 }
1881
1882 if ( StringUtils.isNotBlank( profile.getName() )
1883 && !profile.getName().matches( NAME_VALID_EXPRESSION ) )
1884 {
1885 throw new ContinuumException( "Build Environment Name contains invalid characters" );
1886 }
1887
1888 try
1889 {
1890 newProfile.setActive( profile.isActive() );
1891 newProfile.setBuildWithoutChanges( profile.isBuildWithoutChanges() );
1892 newProfile.setDescription( StringEscapeUtils.escapeXml( profile.getDescription() ) );
1893 newProfile.setName( profile.getName() );
1894 newProfile.setScmMode( profile.getScmMode() );
1895 if ( profile.getBuilder() != null )
1896 {
1897 final org.apache.maven.continuum.model.system.Installation newBuilder =
1898 continuum.getInstallationService().getInstallation( profile.getBuilder().getInstallationId() );
1899 newProfile.setBuilder( populateInstallation( profile.getBuilder(), newBuilder ) );
1900
1901 }
1902 else
1903 {
1904 newProfile.setBuilder( null );
1905 }
1906 if ( profile.getJdk() != null )
1907 {
1908 final org.apache.maven.continuum.model.system.Installation newJdk =
1909 continuum.getInstallationService().getInstallation( profile.getJdk().getInstallationId() );
1910 newProfile.setJdk( populateInstallation( profile.getJdk(), newJdk ) );
1911
1912 }
1913 else
1914 {
1915 newProfile.setJdk( null );
1916 }
1917 newProfile.getEnvironmentVariables().clear();
1918 if ( profile.getEnvironmentVariables() != null )
1919 {
1920 for ( Iterator it = profile.getEnvironmentVariables().iterator(); it.hasNext(); )
1921 {
1922 final Installation varEnv = (Installation) it.next();
1923
1924 final org.apache.maven.continuum.model.system.Installation newInst =
1925 continuum.getInstallationService().getInstallation( varEnv.getInstallationId() );
1926 newProfile.getEnvironmentVariables().add( populateInstallation( varEnv, newInst ) );
1927
1928 }
1929 }
1930 return newProfile;
1931 }
1932 catch ( InstallationException e )
1933 {
1934 throw new ContinuumException( "Can't load installations", e );
1935 }
1936 }
1937
1938 private Profile populateProfile( org.apache.maven.continuum.model.system.Profile profile )
1939 {
1940 return (Profile) mapper.map( profile, Profile.class );
1941 }
1942
1943 private org.apache.maven.continuum.model.system.Installation populateInstallation( Installation install,
1944 org.apache.maven.continuum.model.system.Installation inst )
1945 throws ContinuumException
1946 {
1947 if ( install == null )
1948 {
1949 return null;
1950 }
1951
1952 if ( StringUtils.isNotBlank( install.getName() ) &&
1953 !install.getName().matches( NAME_VALID_EXPRESSION ) )
1954 {
1955 throw new ContinuumException( "Installation Name contains invalid characters" );
1956 }
1957
1958 if ( StringUtils.isNotBlank( install.getType() ) &&
1959 !install.getType().matches( INSTALLATION_TYPE_VALID_EXPRESSION ))
1960 {
1961 throw new ContinuumException( "Installation Type contains invalid characters" );
1962 }
1963
1964 if ( StringUtils.isNotBlank( install.getVarName() ) &&
1965 !install.getVarName().matches( INSTALLATION_VARNAME_VALID_EXPRESSION ) )
1966 {
1967 throw new ContinuumException( "Installation VarName contains invalid characters" );
1968 }
1969
1970 if ( StringUtils.isNotBlank( install.getVarValue() ) &&
1971 !install.getVarValue().matches( INSTALLATION_VARVALUE_VALID_EXPRESSION ) )
1972 {
1973 throw new ContinuumException( "Installation VarValue contains invalid characters" );
1974 }
1975
1976 inst.setName( install.getName() );
1977 inst.setType( install.getType() );
1978 inst.setVarName( install.getVarName() );
1979 inst.setVarValue( install.getVarValue() );
1980 return inst;
1981 }
1982
1983 private Installation populateInstallation( org.apache.maven.continuum.model.system.Installation install )
1984 {
1985 return (Installation) mapper.map( install, Installation.class );
1986 }
1987
1988 private SystemConfiguration populateSystemConfiguration(
1989 org.apache.maven.continuum.model.system.SystemConfiguration sysConf )
1990 {
1991 return (SystemConfiguration) mapper.map( sysConf, SystemConfiguration.class );
1992 }
1993
1994 private ContinuumReleaseResult populateReleaseResult(
1995 org.apache.continuum.model.release.ContinuumReleaseResult releaseResult )
1996 {
1997 return (ContinuumReleaseResult) mapper.map( releaseResult, ContinuumReleaseResult.class );
1998 }
1999
2000 private RepositoryPurgeConfiguration populateRepositoryPurgeConfiguration(
2001 org.apache.continuum.model.repository.RepositoryPurgeConfiguration repoPurgeConfig )
2002 {
2003 return (RepositoryPurgeConfiguration) mapper.map( repoPurgeConfig, RepositoryPurgeConfiguration.class );
2004 }
2005
2006 private org.apache.continuum.model.repository.RepositoryPurgeConfiguration populateRepositoryPurgeConfiguration(
2007 RepositoryPurgeConfiguration repoPurgeConfig,
2008 org.apache.continuum.model.repository.RepositoryPurgeConfiguration repoPurge )
2009 throws RepositoryServiceException, ContinuumException
2010 {
2011 if ( repoPurgeConfig == null )
2012 {
2013 return null;
2014 }
2015
2016 repoPurge.setDaysOlder( repoPurgeConfig.getDaysOlder() );
2017 repoPurge.setDefaultPurge( repoPurgeConfig.isDefaultPurge() );
2018 repoPurge.setDeleteAll( repoPurgeConfig.isDeleteAll() );
2019 repoPurge.setDeleteReleasedSnapshots( repoPurgeConfig.isDeleteReleasedSnapshots() );
2020 repoPurge.setDescription( StringEscapeUtils.escapeXml( repoPurgeConfig.getDescription() ) );
2021 repoPurge.setEnabled( repoPurgeConfig.isEnabled() );
2022 repoPurge.setRetentionCount( repoPurgeConfig.getRetentionCount() );
2023 if ( repoPurgeConfig.getRepository() != null )
2024 {
2025 repoPurge.setRepository(
2026 populateLocalRepository( repoPurgeConfig.getRepository(), continuum.getRepositoryService().
2027 getLocalRepository( repoPurgeConfig.getRepository().getId() ) ) );
2028 }
2029 else
2030 {
2031 repoPurge.setRepository( null );
2032 }
2033 if ( repoPurgeConfig.getSchedule() != null )
2034 {
2035 repoPurge.setSchedule( populateSchedule( repoPurgeConfig.getSchedule(),
2036 continuum.getSchedule( repoPurgeConfig.getSchedule().getId() ) ) );
2037 }
2038 else
2039 {
2040 repoPurge.setSchedule( null );
2041 }
2042
2043 return repoPurge;
2044 }
2045
2046 private DirectoryPurgeConfiguration populateDirectoryPurgeConfiguration(
2047 org.apache.continuum.model.repository.DirectoryPurgeConfiguration dirPurgeConfig )
2048 {
2049 return (DirectoryPurgeConfiguration) mapper.map( dirPurgeConfig, DirectoryPurgeConfiguration.class );
2050 }
2051
2052 private org.apache.continuum.model.repository.DirectoryPurgeConfiguration populateDirectoryPurgeConfiguration(
2053 DirectoryPurgeConfiguration dirPurgeConfig,
2054 org.apache.continuum.model.repository.DirectoryPurgeConfiguration dirPurge )
2055 throws RepositoryServiceException, ContinuumException
2056 {
2057 if ( dirPurgeConfig == null )
2058 {
2059 return null;
2060 }
2061
2062 if ( StringUtils.isNotBlank( dirPurgeConfig.getDirectoryType() ) &&
2063 !dirPurgeConfig.getDirectoryType().matches( DIRECTORY_TYPE_VALID_EXPRESSION ) )
2064 {
2065 throw new ContinuumException( "Directory Purge Configuration Type can only be 'releases or buildOutput'" );
2066 }
2067
2068 if ( StringUtils.isNotBlank( dirPurgeConfig.getLocation() ) &&
2069 !dirPurgeConfig.getLocation().matches( DIRECTORY_VALID_EXPRESSION ) )
2070 {
2071 throw new ContinuumException( "Directory Purge Configuration Location contains invalid characters" );
2072 }
2073
2074 dirPurge.setDaysOlder( dirPurgeConfig.getDaysOlder() );
2075 dirPurge.setDefaultPurge( dirPurgeConfig.isDefaultPurge() );
2076 dirPurge.setDeleteAll( dirPurgeConfig.isDeleteAll() );
2077 dirPurge.setDescription( StringEscapeUtils.escapeXml( dirPurgeConfig.getDescription() ) );
2078 dirPurge.setDirectoryType( dirPurgeConfig.getDirectoryType() );
2079 dirPurge.setEnabled( dirPurgeConfig.isEnabled() );
2080
2081 String path = "";
2082
2083 if ( dirPurge.getDirectoryType().equals( "releases" ) )
2084 {
2085 path = continuum.getConfiguration().getWorkingDirectory().getAbsolutePath();
2086 }
2087 else if ( dirPurge.getDirectoryType().equals( "buildOutput" ) )
2088 {
2089 path = continuum.getConfiguration().getBuildOutputDirectory().getAbsolutePath();
2090 }
2091
2092 dirPurge.setLocation( path );
2093 dirPurge.setRetentionCount( dirPurgeConfig.getRetentionCount() );
2094 if ( dirPurgeConfig.getSchedule() != null )
2095 {
2096 dirPurge.setSchedule( populateSchedule( dirPurgeConfig.getSchedule(),
2097 continuum.getSchedule( dirPurgeConfig.getSchedule().getId() ) ) );
2098 }
2099 else
2100 {
2101 dirPurge.setSchedule( null );
2102 }
2103
2104 return dirPurge;
2105 }
2106
2107 private LocalRepository populateLocalRepository(
2108 org.apache.continuum.model.repository.LocalRepository localRepository )
2109 {
2110 return (LocalRepository) mapper.map( localRepository, LocalRepository.class );
2111 }
2112
2113 private org.apache.continuum.model.repository.LocalRepository populateLocalRepository( LocalRepository repository,
2114 org.apache.continuum.model.repository.LocalRepository repo )
2115 throws ContinuumException
2116 {
2117 if ( repository == null )
2118 {
2119 return null;
2120 }
2121
2122 if ( StringUtils.isNotBlank( repository.getLayout() ) &&
2123 !repository.getLayout().matches( REPOSITORY_LAYOUT_VALID_EXPRESSION ) )
2124 {
2125 throw new ContinuumException( "Repository Layout can only be 'default or legacy'" );
2126 }
2127
2128 if ( StringUtils.isNotBlank( repository.getLocation() ) &&
2129 !repository.getLocation().matches( DIRECTORY_VALID_EXPRESSION ) )
2130 {
2131 throw new ContinuumException( "Repository Location contains invalid characters" );
2132 }
2133
2134 if ( StringUtils.isNotBlank( repository.getName() ) &&
2135 !repository.getName().matches( NAME_VALID_EXPRESSION ) )
2136 {
2137 throw new ContinuumException( "Repository Name contains invalid characters" );
2138 }
2139
2140 repo.setLayout( repository.getLayout() );
2141 repo.setLocation( repository.getLocation() );
2142 repo.setName( repository.getName() );
2143 return repo;
2144 }
2145
2146 private Map<String, Object> serializeObject( Object o, final String... ignore )
2147 {
2148 if ( o != null )
2149 {
2150 return serializeObject( o, o.getClass(), ignore );
2151 }
2152 else
2153 {
2154 return null;
2155 }
2156 }
2157
2158 private Map<String, Object> serializeObject( Object o, Class clasz, final String... ignore )
2159 {
2160
2161 final List<String> ignoreList = ignore == null ? new ArrayList<String>() : Arrays.asList( ignore );
2162 if ( o != null )
2163 {
2164 final Map<String, Object> retValue = new HashMap<String, Object>();
2165 if ( !Object.class.equals( clasz.getSuperclass() ) )
2166 {
2167 retValue.putAll( serializeObject( o, clasz.getSuperclass(), ignore ) );
2168 }
2169
2170 final Field[] fields = clasz.getDeclaredFields();
2171
2172 retValue.put( "__class", clasz.getName() );
2173 for ( final Field field : fields )
2174 {
2175
2176 if ( !ignoreList.contains( field.getName() ) )
2177 {
2178 field.setAccessible( true );
2179 try
2180 {
2181 final Object tmpFO = field.get( o );
2182 final Object tmpNO = mapObject( tmpFO );
2183
2184 retValue.put( field.getName(), tmpNO );
2185 }
2186 catch ( IllegalAccessException e )
2187 {
2188 e.printStackTrace();
2189 }
2190 }
2191 }
2192 return retValue;
2193 }
2194 else
2195 {
2196 return null;
2197 }
2198 }
2199
2200 private Object mapObject( Object tmpFO )
2201 {
2202 final Object retValue;
2203 if ( tmpFO instanceof String )
2204 {
2205 Object tmpNO = serializeObject( (String) tmpFO );
2206 if ( tmpNO == null )
2207 {
2208 tmpNO = "";
2209 }
2210 retValue = tmpNO;
2211 }
2212 else if ( tmpFO instanceof Float )
2213 {
2214 Object tmpNO = serializeObject( (Float) tmpFO );
2215 if ( tmpNO == null )
2216 {
2217 tmpNO = "";
2218 }
2219 retValue = tmpNO;
2220 }
2221 else if ( tmpFO instanceof Boolean )
2222 {
2223 Object tmpNO = serializeObject( (Boolean) tmpFO );
2224 if ( tmpNO == null )
2225 {
2226 tmpNO = "";
2227 }
2228 retValue = tmpNO;
2229 }
2230 else if ( tmpFO instanceof Integer )
2231 {
2232 Object tmpNO = serializeObject( (Integer) tmpFO );
2233 if ( tmpNO == null )
2234 {
2235 tmpNO = "";
2236 }
2237 retValue = tmpNO;
2238 }
2239 else if ( tmpFO instanceof Long )
2240 {
2241 Object tmpNO = serializeObject( (Long) tmpFO );
2242 if ( tmpNO == null )
2243 {
2244 tmpNO = "";
2245 }
2246 retValue = tmpNO;
2247 }
2248 else if ( tmpFO instanceof Character )
2249 {
2250 Object tmpNO = serializeObject( (Character) tmpFO );
2251 if ( tmpNO == null )
2252 {
2253 tmpNO = "";
2254 }
2255 retValue = tmpNO;
2256 }
2257 else if ( tmpFO instanceof Byte )
2258 {
2259 Object tmpNO = serializeObject( (Byte) tmpFO );
2260 if ( tmpNO == null )
2261 {
2262 tmpNO = "";
2263 }
2264 retValue = tmpNO;
2265 }
2266 else if ( tmpFO instanceof Double )
2267 {
2268 Object tmpNO = serializeObject( (Double) tmpFO );
2269 if ( tmpNO == null )
2270 {
2271 tmpNO = "";
2272 }
2273 retValue = tmpNO;
2274 }
2275 else if ( tmpFO instanceof List )
2276 {
2277 Object tmpNO = serializeObject( (List) tmpFO );
2278 if ( tmpNO == null )
2279 {
2280 tmpNO = "";
2281 }
2282 retValue = tmpNO;
2283 }
2284 else if ( tmpFO instanceof Map )
2285 {
2286 Object tmpNO = serializeObject( (Map) tmpFO );
2287 if ( tmpNO == null )
2288 {
2289 tmpNO = "";
2290 }
2291 retValue = tmpNO;
2292 }
2293 else
2294 {
2295 Object tmpNO = serializeObject( tmpFO );
2296 if ( tmpNO == null )
2297 {
2298 tmpNO = "";
2299 }
2300 retValue = tmpNO;
2301 }
2302 return retValue;
2303 }
2304
2305 private Map<String, Object> serializeObject( Map<Object, Object> map )
2306 {
2307 final Map<String, Object> retValue = new HashMap<String, Object>();
2308
2309 for ( Object key : map.keySet() )
2310 {
2311 final Object tmpKey = mapObject( key );
2312
2313 if ( tmpKey != null )
2314 {
2315 retValue.put( tmpKey.toString(), mapObject( map.get( key ) ) );
2316 }
2317 }
2318 return retValue;
2319 }
2320
2321 private List<Object> serializeObject( List list )
2322 {
2323 final List<Object> retValue = new ArrayList<Object>();
2324
2325 for ( Object o : list )
2326 {
2327 final Object tmpO = mapObject( o );
2328 if ( tmpO == null )
2329 {
2330 retValue.add( "" );
2331 }
2332 else
2333 {
2334 retValue.add( tmpO );
2335 }
2336 }
2337 return retValue;
2338 }
2339
2340 private String serializeObject( String o )
2341 {
2342 return o;
2343 }
2344
2345 private String serializeObject( Byte o )
2346 {
2347 return ( o == null ? null : o.toString() );
2348 }
2349
2350 private String serializeObject( Character o )
2351 {
2352 return ( o == null ? null : o.toString() );
2353 }
2354
2355 private Double serializeObject( Long o )
2356 {
2357 return ( o == null ? null : o.doubleValue() );
2358 }
2359
2360 private Double serializeObject( Float o )
2361 {
2362 return ( o == null ? null : o.doubleValue() );
2363 }
2364
2365 private Double serializeObject( Double o )
2366 {
2367 return o;
2368 }
2369
2370 private Integer serializeObject( Integer o )
2371 {
2372 return o;
2373 }
2374
2375 private Boolean serializeObject( Boolean o )
2376 {
2377 return o;
2378 }
2379
2380 private Object unserializeObject( Map<String, Object> o )
2381 {
2382 Object retValue = null;
2383 if ( o != null )
2384 {
2385 final String className = (String) o.remove( "__class" );
2386
2387 if ( className != null )
2388 {
2389 try
2390 {
2391 final Class clasz = Class.forName( className );
2392 final Object tmpO = clasz.newInstance();
2393 for ( final String key : o.keySet() )
2394 {
2395 final Field field = clasz.getDeclaredField( key );
2396 field.setAccessible( true );
2397 final Object tmpFO = o.get( key );
2398
2399 field.set( tmpO, unMapObject( tmpFO ) );
2400 }
2401 retValue = tmpO;
2402 }
2403 catch ( Exception e )
2404 {
2405 e.printStackTrace();
2406 retValue = null;
2407 }
2408 }
2409 else
2410 {
2411
2412 Map<String, Object> tmpValue = new HashMap<String, Object>();
2413
2414 for ( String key : o.keySet() )
2415 {
2416 tmpValue.put( key, unMapObject( o.get( key ) ) );
2417 }
2418 retValue = tmpValue;
2419 }
2420 }
2421 return retValue;
2422 }
2423
2424 private Object unMapObject( Object tmpFO )
2425 {
2426 final Object retValue;
2427 if ( tmpFO instanceof String )
2428 {
2429 retValue = unserializeObject( (String) tmpFO );
2430 }
2431 else if ( tmpFO instanceof Float )
2432 {
2433 retValue = unserializeObject( (Float) tmpFO );
2434 }
2435 else if ( tmpFO instanceof Boolean )
2436 {
2437 retValue = unserializeObject( (Boolean) tmpFO );
2438 }
2439 else if ( tmpFO instanceof Integer )
2440 {
2441 retValue = unserializeObject( (Integer) tmpFO );
2442 }
2443 else if ( tmpFO instanceof Long )
2444 {
2445 retValue = unserializeObject( (Long) tmpFO );
2446 }
2447 else if ( tmpFO instanceof Character )
2448 {
2449 retValue = unserializeObject( (Character) tmpFO );
2450 }
2451 else if ( tmpFO instanceof Byte )
2452 {
2453 retValue = unserializeObject( (Byte) tmpFO );
2454 }
2455 else if ( tmpFO instanceof Double )
2456 {
2457 retValue = unserializeObject( (Double) tmpFO );
2458 }
2459 else if ( tmpFO instanceof List )
2460 {
2461 retValue = unserializeObject( (List) tmpFO );
2462 }
2463 else if ( tmpFO instanceof Map )
2464 {
2465 retValue = unserializeObject( (Map) tmpFO );
2466 }
2467 else if ( tmpFO instanceof Object[] )
2468 {
2469 retValue = unserializeObject( (Object[]) tmpFO );
2470 }
2471 else
2472 {
2473 retValue = unserializeObject( tmpFO );
2474 }
2475 return retValue;
2476 }
2477
2478 private List<Object> unserializeObject( List list )
2479 {
2480 final List<Object> retValue = new ArrayList<Object>();
2481
2482 for ( Object o : list )
2483 {
2484 retValue.add( unMapObject( o ) );
2485 }
2486 return retValue;
2487 }
2488
2489 private Object unserializeObject( Object o )
2490 {
2491 return o;
2492 }
2493
2494 private Object unserializeObject( Object[] list )
2495 {
2496 final List<Object> retValue = new ArrayList<Object>();
2497
2498 for ( Object o : list )
2499 {
2500 retValue.add( unMapObject( o ) );
2501 }
2502 return retValue;
2503 }
2504
2505 private String unserializeObject( String o )
2506 {
2507 return o;
2508 }
2509
2510 private Byte unserializeObject( Byte o )
2511 {
2512 return o;
2513 }
2514
2515 private Character unserializeObject( Character o )
2516 {
2517 return o;
2518 }
2519
2520 private Long unserializeObject( Long o )
2521 {
2522 return o;
2523 }
2524
2525 private Float unserializeObject( Float o )
2526 {
2527 return o;
2528 }
2529
2530 private Double unserializeObject( Double o )
2531 {
2532 return o;
2533 }
2534
2535 private Integer unserializeObject( Integer o )
2536 {
2537 return o;
2538 }
2539
2540 private Boolean unserializeObject( Boolean o )
2541 {
2542 return o;
2543 }
2544
2545 public Map<String, Object> addAntProjectRPC( Map<String, Object> project, int projectGroupId )
2546 throws Exception
2547 {
2548 return serializeObject( this.addAntProject( (ProjectSummary) unserializeObject( project ), projectGroupId ) );
2549 }
2550
2551 public Map<String, Object> addBuildDefinitionToProjectGroupRPC( int projectGroupId, Map<String, Object> buildDef )
2552 throws Exception
2553 {
2554 return serializeObject(
2555 this.addBuildDefinitionToProjectGroup( projectGroupId, (BuildDefinition) unserializeObject( buildDef ) ) );
2556 }
2557
2558 public Map<String, Object> addBuildDefinitionToProjectRPC( int projectId, Map<String, Object> buildDef )
2559 throws Exception
2560 {
2561 return serializeObject(
2562 this.addBuildDefinitionToProject( projectId, (BuildDefinition) unserializeObject( buildDef ) ) );
2563 }
2564
2565 public Map<String, Object> addMavenOneProjectRPC( String url, int projectGroupId )
2566 throws Exception
2567 {
2568 return serializeObject( this.addMavenOneProject( url, projectGroupId ) );
2569 }
2570
2571 public Map<String, Object> addMavenTwoProjectRPC( String url )
2572 throws Exception
2573 {
2574 return serializeObject( this.addMavenTwoProject( url ) );
2575 }
2576
2577 public Map<String, Object> addMavenTwoProjectRPC( String url, int projectGroupId )
2578 throws Exception
2579 {
2580 return serializeObject( this.addMavenTwoProject( url, projectGroupId ) );
2581 }
2582
2583 public Map<String, Object> addProjectGroupRPC( String groupName, String groupId, String description )
2584 throws Exception
2585 {
2586 return serializeObject( this.addProjectGroup( groupName, groupId, description ) );
2587 }
2588
2589 public Map<String, Object> addScheduleRPC( Map<String, Object> schedule )
2590 throws Exception
2591 {
2592 return serializeObject( this.addSchedule( (Schedule) unserializeObject( schedule ) ) );
2593 }
2594
2595 public Map<String, Object> addShellProjectRPC( Map<String, Object> project, int projectGroupId )
2596 throws Exception
2597 {
2598 return serializeObject( this.addShellProject( (ProjectSummary) unserializeObject( project ), projectGroupId ) );
2599 }
2600
2601 public List<Object> getAllProjectGroupsRPC()
2602 throws Exception
2603 {
2604 return serializeObject( this.getAllProjectGroups() );
2605 }
2606
2607 public List<Object> getAllProjectGroupsWithAllDetailsRPC()
2608 throws Exception
2609 {
2610 return serializeObject( this.getAllProjectGroupsWithAllDetails() );
2611 }
2612
2613 public List<Object> getBuildDefinitionTemplatesRPC()
2614 throws Exception
2615 {
2616 return serializeObject( this.getBuildDefinitionTemplates() );
2617 }
2618
2619 public List<Object> getBuildDefinitionsForProjectGroupRPC( int projectGroupId )
2620 throws Exception
2621 {
2622 return serializeObject( this.getBuildDefinitionsForProjectGroup( projectGroupId ) );
2623 }
2624
2625 public List<Object> getBuildDefinitionsForProjectRPC( int projectId )
2626 throws Exception
2627 {
2628 return serializeObject( this.getBuildDefinitionsForProject( projectId ) );
2629 }
2630
2631 public Map<String, Object> getBuildResultRPC( int projectId, int buildId )
2632 throws Exception
2633 {
2634 return serializeObject( this.getBuildResult( projectId, buildId ) );
2635 }
2636
2637 public List<Object> getBuildResultsForProjectRPC( int projectId )
2638 throws Exception
2639 {
2640 return serializeObject( this.getBuildResultsForProject( projectId ) );
2641 }
2642
2643 public Map<String, Object> getInstallationRPC( int installationId )
2644 throws Exception
2645 {
2646 return serializeObject( this.getInstallation( installationId ) );
2647 }
2648
2649 public List<Object> getInstallationsRPC()
2650 throws Exception
2651 {
2652 return serializeObject( this.getInstallations() );
2653 }
2654
2655 public Map<String, Object> getLatestBuildResultRPC( int projectId )
2656 throws Exception
2657 {
2658 return serializeObject( this.getLatestBuildResult( projectId ) );
2659 }
2660
2661 public Map<String, Object> getProfileRPC( int profileId )
2662 throws Exception
2663 {
2664 return serializeObject( this.getProfile( profileId ) );
2665 }
2666
2667 public List<Object> getProfilesRPC()
2668 throws Exception
2669 {
2670 return serializeObject( this.getProfiles() );
2671 }
2672
2673 public Map<String, Object> getProjectGroupSummaryRPC( int projectGroupId )
2674 throws Exception
2675 {
2676 return serializeObject( this.getProjectGroupSummary( projectGroupId ) );
2677 }
2678
2679 public Map<String, Object> getProjectGroupWithProjectsRPC( int projectGroupId )
2680 throws Exception
2681 {
2682 return serializeObject( this.getProjectGroupWithProjects( projectGroupId ) );
2683 }
2684
2685 public Map<String, Object> updateProjectGroupRPC( Map<String, Object> projectGroup )
2686 throws Exception
2687 {
2688 return serializeObject( this.updateProjectGroup( (ProjectGroupSummary) unserializeObject( projectGroup ) ) );
2689 }
2690
2691 public Map<String, Object> getProjectSummaryRPC( int projectId )
2692 throws Exception
2693 {
2694 return serializeObject( this.getProjectSummary( projectId ) );
2695 }
2696
2697 public Map<String, Object> getProjectWithAllDetailsRPC( int projectId )
2698 throws Exception
2699 {
2700 return serializeObject( this.getProjectWithAllDetails( projectId ) );
2701 }
2702
2703 public List<Object> getProjectsRPC( int projectGroupId )
2704 throws Exception
2705 {
2706 return serializeObject( this.getProjects( projectGroupId ) );
2707 }
2708
2709 public Map<String, Object> getScheduleRPC( int scheduleId )
2710 throws Exception
2711 {
2712 return serializeObject( this.getSchedule( scheduleId ) );
2713 }
2714
2715 public List<Object> getSchedulesRPC()
2716 throws Exception
2717 {
2718 return serializeObject( this.getSchedules() );
2719 }
2720
2721 public Map<String, Object> getSystemConfigurationRPC()
2722 throws Exception
2723 {
2724 return serializeObject( this.getSystemConfiguration() );
2725 }
2726
2727 public int removeBuildResultRPC( Map<String, Object> br )
2728 throws Exception
2729 {
2730 return serializeObject( this.removeBuildResult( (BuildResult) unserializeObject( br ) ) );
2731 }
2732
2733 public Map<String, Object> updateBuildDefinitionForProjectGroupRPC( int projectGroupId,
2734 Map<String, Object> buildDef )
2735 throws Exception
2736 {
2737 return serializeObject( this.updateBuildDefinitionForProjectGroup( projectGroupId,
2738 (BuildDefinition) unserializeObject(
2739 buildDef ) ) );
2740 }
2741
2742 public Map<String, Object> updateBuildDefinitionForProjectRPC( int projectId, Map<String, Object> buildDef )
2743 throws Exception
2744 {
2745 return serializeObject(
2746 this.updateBuildDefinitionForProject( projectId, (BuildDefinition) unserializeObject( buildDef ) ) );
2747 }
2748
2749 public Map<String, Object> updateProjectRPC( Map<String, Object> project )
2750 throws Exception
2751 {
2752 return serializeObject( this.updateProject( (ProjectSummary) unserializeObject( project ) ) );
2753 }
2754
2755 public Map<String, Object> updateScheduleRPC( Map<String, Object> schedule )
2756 throws Exception
2757 {
2758 return serializeObject( this.updateSchedule( (Schedule) unserializeObject( schedule ) ) );
2759 }
2760
2761 public Map<String, Object> getProjectGroupRPC( int projectGroupId )
2762 throws Exception
2763 {
2764 return serializeObject( this.getProjectGroup( projectGroupId ), "projects" );
2765 }
2766
2767 public Map<String, Object> getGroupNotifierRPC( int projectgroupid, int notifierId )
2768 throws Exception
2769 {
2770 return serializeObject( this.getGroupNotifier( projectgroupid, notifierId ) );
2771 }
2772
2773 public Map<String, Object> getNotifierRPC( int projectid, int notifierId )
2774 throws Exception
2775 {
2776 return serializeObject( this.getNotifier( projectid, notifierId ) );
2777 }
2778
2779 public Map<String, Object> updateGroupNotifierRPC( int projectgroupid, Map<String, Object> newNotifier )
2780 throws Exception
2781 {
2782 return serializeObject(
2783 this.updateGroupNotifier( projectgroupid, (ProjectNotifier) unserializeObject( newNotifier ) ) );
2784 }
2785
2786 public Map<String, Object> updateNotifierRPC( int projectid, Map<String, Object> newNotifier )
2787 throws Exception
2788 {
2789 return serializeObject( this.updateNotifier( projectid, (ProjectNotifier) unserializeObject( newNotifier ) ) );
2790 }
2791
2792 public Map<String, Object> addGroupNotifierRPC( int projectgroupid, Map<String, Object> newNotifier )
2793 throws Exception
2794 {
2795 return serializeObject(
2796 this.addGroupNotifier( projectgroupid, (ProjectNotifier) unserializeObject( newNotifier ) ) );
2797 }
2798
2799 public Map<String, Object> addNotifierRPC( int projectid, Map<String, Object> newNotifier )
2800 throws Exception
2801 {
2802 return serializeObject( this.addNotifier( projectid, (ProjectNotifier) unserializeObject( newNotifier ) ) );
2803 }
2804
2805 public Map<String, Object> addInstallationRPC( Map<String, Object> installation )
2806 throws Exception
2807 {
2808 return serializeObject( this.addInstallation( (Installation) unserializeObject( installation ) ) );
2809 }
2810
2811 public Map<String, Object> addProfileRPC( Map<String, Object> profile )
2812 throws Exception
2813 {
2814 return serializeObject( this.addProfile( (Profile) unserializeObject( profile ) ) );
2815 }
2816
2817 public int updateInstallationRPC( Map<String, Object> installation )
2818 throws Exception
2819 {
2820 return this.updateInstallation( (Installation) unserializeObject( installation ) );
2821 }
2822
2823 public int updateProfileRPC( Map<String, Object> profile )
2824 throws Exception
2825 {
2826 return this.updateProfile( (Profile) unserializeObject( profile ) );
2827 }
2828
2829 public Map<String, Object> getReleaseResultRPC( int releaseId )
2830 throws Exception
2831 {
2832 return serializeObject( this.getReleaseResult( releaseId ) );
2833 }
2834
2835 public List<Object> getReleaseResultsForProjectGroupRPC( int projectGroupId )
2836 throws Exception
2837 {
2838 return serializeObject( this.getReleaseResultsForProjectGroup( projectGroupId ) );
2839 }
2840
2841 public int removeReleaseResultRPC( Map<String, Object> rr )
2842 throws Exception
2843 {
2844 return serializeObject( this.removeReleaseResult( (ContinuumReleaseResult) unserializeObject( rr ) ) );
2845 }
2846
2847 public Map<String, Object> addRepositoryPurgeConfigurationRPC( Map<String, Object> repoPurge )
2848 throws Exception
2849 {
2850 return serializeObject(
2851 this.addRepositoryPurgeConfiguration( (RepositoryPurgeConfiguration) unserializeObject( repoPurge ) ) );
2852 }
2853
2854 public int updateRepositoryPurgeConfigurationRPC( Map<String, Object> repoPurge )
2855 throws Exception
2856 {
2857 return serializeObject(
2858 this.updateRepositoryPurgeConfiguration( (RepositoryPurgeConfiguration) unserializeObject( repoPurge ) ) );
2859 }
2860
2861 public Map<String, Object> getRepositoryPurgeConfigurationRPC( int repoPurgeId )
2862 throws Exception
2863 {
2864 return serializeObject( this.getRepositoryPurgeConfiguration( repoPurgeId ) );
2865 }
2866
2867 public List<Object> getAllRepositoryPurgeConfigurationsRPC()
2868 throws Exception
2869 {
2870 return serializeObject( this.getAllDirectoryPurgeConfigurations() );
2871 }
2872
2873 public Map<String, Object> addDirectoryPurgeConfigurationRPC( Map<String, Object> dirPurge )
2874 throws Exception
2875 {
2876 return serializeObject(
2877 this.addDirectoryPurgeConfiguration( (DirectoryPurgeConfiguration) unserializeObject( dirPurge ) ) );
2878 }
2879
2880 public int updateDirectoryPurgeConfigurationRPC( Map<String, Object> dirPurge )
2881 throws Exception
2882 {
2883 return serializeObject(
2884 this.updateDirectoryPurgeConfiguration( (DirectoryPurgeConfiguration) unserializeObject( dirPurge ) ) );
2885 }
2886
2887 public Map<String, Object> getDirectoryPurgeConfigurationRPC( int dirPurgeId )
2888 throws Exception
2889 {
2890 return serializeObject( this.getDirectoryPurgeConfiguration( dirPurgeId ) );
2891 }
2892
2893 public List<Object> getAllDirectoryPurgeConfigurationsRPC()
2894 throws Exception
2895 {
2896 return serializeObject( this.getAllRepositoryPurgeConfigurations() );
2897 }
2898
2899 public Map<String, Object> addLocalRepositoryRPC( Map<String, Object> repository )
2900 throws Exception
2901 {
2902 return serializeObject( this.addLocalRepository( (LocalRepository) unserializeObject( repository ) ) );
2903 }
2904
2905 public int updateLocalRepositoryRPC( Map<String, Object> repository )
2906 throws Exception
2907 {
2908 return serializeObject( this.updateLocalRepository( (LocalRepository) unserializeObject( repository ) ) );
2909 }
2910
2911 public Map<String, Object> getLocalRepositoryRPC( int repositoryId )
2912 throws Exception
2913 {
2914 return serializeObject( this.getLocalRepository( repositoryId ) );
2915 }
2916
2917 public List<Object> getAllLocalRepositoriesRPC()
2918 throws Exception
2919 {
2920 return serializeObject( this.getAllLocalRepositories() );
2921 }
2922 }