1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.releaser.service;
35
36 import java.io.IOException;
37 import java.sql.Timestamp;
38 import java.util.ArrayList;
39 import java.util.HashMap;
40 import java.util.HashSet;
41 import java.util.List;
42 import java.util.Locale;
43 import java.util.concurrent.ExecutorService;
44 import java.util.concurrent.Executors;
45
46 import javax.servlet.http.HttpServletRequest;
47 import javax.xml.bind.JAXBException;
48
49 import org.apache.commons.collections.CollectionUtils;
50 import org.apache.commons.lang3.StringUtils;
51 import org.eclipse.jgit.api.Git;
52 import org.eclipse.jgit.api.MergeResult;
53 import org.eclipse.jgit.api.errors.GitAPIException;
54 import org.eclipse.jgit.api.errors.InvalidRemoteException;
55 import org.eclipse.jgit.api.errors.TransportException;
56 import org.eclipse.jgit.internal.storage.file.FileRepository;
57 import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
58
59 import fr.paris.lutece.plugins.releaser.business.Component;
60 import fr.paris.lutece.plugins.releaser.business.RepositoryType;
61 import fr.paris.lutece.plugins.releaser.business.WorkflowContextHistory;
62 import fr.paris.lutece.plugins.releaser.business.WorkflowContextHistoryHome;
63 import fr.paris.lutece.plugins.releaser.business.WorkflowReleaseContext;
64 import fr.paris.lutece.plugins.releaser.util.CVSFactoryService;
65 import fr.paris.lutece.plugins.releaser.util.CommandResult;
66 import fr.paris.lutece.plugins.releaser.util.ConstanteUtils;
67 import fr.paris.lutece.plugins.releaser.util.IVCSResourceService;
68 import fr.paris.lutece.plugins.releaser.util.MapperJsonUtil;
69 import fr.paris.lutece.plugins.releaser.util.PluginUtils;
70 import fr.paris.lutece.plugins.releaser.util.ReleaserUtils;
71 import fr.paris.lutece.plugins.releaser.util.github.GitUtils;
72 import fr.paris.lutece.plugins.releaser.util.pom.PomUpdater;
73 import fr.paris.lutece.portal.business.user.AdminUser;
74 import fr.paris.lutece.portal.service.spring.SpringContextService;
75 import fr.paris.lutece.portal.service.util.AppException;
76 import fr.paris.lutece.portal.service.util.AppLogService;
77 import fr.paris.lutece.portal.service.util.AppPropertiesService;
78
79
80
81
82
83 public class WorkflowReleaseContextService implements IWorkflowReleaseContextService
84 {
85
86
87 private static IWorkflowReleaseContextService _singleton;
88
89
90 private HashMap<Integer, WorkflowReleaseContext> _mapWorkflowReleaseContext = new HashMap<Integer, WorkflowReleaseContext>( );
91
92
93 private ExecutorService _executor;
94
95
96 private HashSet<String> _releaseInProgress = new HashSet<String>( );
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 @Override
112 public synchronized int addWorkflowReleaseContext( WorkflowReleaseContext context )
113 {
114
115 try
116 {
117 String strJsonContext = MapperJsonUtil.getJson( context );
118
119 String strJsonContextClean = ReleaserUtils.cleanPWDInLog( strJsonContext );
120
121 WorkflowContextHistory/WorkflowContextHistory.html#WorkflowContextHistory">WorkflowContextHistory wfHistory = new WorkflowContextHistory( );
122 wfHistory.setArtifactId( context.getComponent( ) != null ? context.getComponent( ).getArtifactId( ) : context.getSite( ).getArtifactId( ) );
123 wfHistory.setData( strJsonContextClean );
124 WorkflowContextHistoryHome.create( wfHistory );
125 context.setId( wfHistory.getId( ) );
126 _mapWorkflowReleaseContext.put( context.getId( ), context );
127 }
128 catch( IOException e )
129 {
130 AppLogService.error( "error during add workkflow context context json", e );
131 }
132
133 return context.getId( );
134 }
135
136
137
138
139
140
141
142
143
144
145
146
147
148 @Override
149 public WorkflowReleaseContext getWorkflowReleaseContext( int nIdContext )
150 {
151 return _mapWorkflowReleaseContext.get( nIdContext );
152 }
153
154
155
156
157
158
159
160 public synchronized void saveWorkflowReleaseContext( WorkflowReleaseContext context )
161 {
162 try
163 {
164 String strJsonContext = MapperJsonUtil.getJson( context );
165
166 String strJsonContextClean = ReleaserUtils.cleanPWDInLog( strJsonContext );
167
168 WorkflowContextHistory wfHistory = WorkflowContextHistoryHome.findByPrimaryKey( context.getId( ) );
169
170 if ( wfHistory != null )
171 {
172 if ( context.getCommandResult( ) != null && context.getCommandResult( ).getDateBegin( ) != null )
173 {
174 wfHistory.setDateBegin( new Timestamp( context.getCommandResult( ).getDateBegin( ).getTime( ) ) );
175 }
176 if ( context.getCommandResult( ) != null && context.getCommandResult( ).getDateEnd( ) != null )
177 {
178 wfHistory.setDateEnd( new Timestamp( context.getCommandResult( ).getDateEnd( ).getTime( ) ) );
179 }
180 wfHistory.setData( strJsonContextClean );
181 WorkflowContextHistoryHome.update( wfHistory );
182 }
183 else
184 {
185 wfHistory = new WorkflowContextHistory( );
186
187 wfHistory.setArtifactId( context.getComponent( ) != null ? context.getComponent( ).getArtifactId( ) : context.getSite( ).getArtifactId( ) );
188 wfHistory.setData( strJsonContextClean );
189 WorkflowContextHistoryHome.create( wfHistory );
190 context.setId( wfHistory.getId( ) );
191 }
192
193 }
194 catch( IOException e )
195 {
196 AppLogService.error( "error during save context json", e );
197 }
198 }
199
200
201
202
203
204
205
206
207 public WorkflowReleaseContext getWorkflowReleaseContextHistory( int nIdContext )
208 {
209 WorkflowReleaseContext context = null;
210 try
211 {
212
213 WorkflowContextHistory wfHistory = WorkflowContextHistoryHome.findByPrimaryKey( nIdContext );
214 context = MapperJsonUtil.parse( wfHistory.getData( ), WorkflowReleaseContext.class );
215
216 }
217 catch( IOException e )
218 {
219 AppLogService.error( "error during get context in the datastore", e );
220 }
221 return context;
222
223 }
224
225
226
227
228
229
230
231
232 public List<WorkflowReleaseContext> getListWorkflowReleaseContextHistory( String strArtifactId )
233 {
234 WorkflowReleaseContext context = null;
235 List<WorkflowReleaseContext> listContext = new ArrayList<WorkflowReleaseContext>( );
236
237 try
238 {
239
240 List<WorkflowContextHistory> listWfContextHistory = WorkflowContextHistoryHome.getWorkflowDeployContextsListByArtifactId( strArtifactId );
241 if ( !CollectionUtils.isEmpty( listWfContextHistory ) )
242 {
243
244 for ( WorkflowContextHistory wfHistory : listWfContextHistory )
245 {
246 context = MapperJsonUtil.parse( wfHistory.getData( ), WorkflowReleaseContext.class );
247 if ( context != null )
248 {
249 listContext.add( context );
250 }
251 }
252
253 }
254 }
255 catch( IOException e )
256 {
257 AppLogService.error( "error for parsing json workflow context", e );
258 }
259 return listContext;
260
261 }
262
263
264
265
266
267
268
269
270 public int getIdWorkflow( WorkflowReleaseContext context )
271 {
272 int nIdWorkflow = ConstanteUtils.CONSTANTE_ID_NULL;
273
274 if ( context.isLuteceSite( ) )
275 {
276 nIdWorkflow = AppPropertiesService.getPropertyInt( ConstanteUtils.PROPERTY_ID_WORKFLOW_LUTECE_SITE, ConstanteUtils.CONSTANTE_ID_NULL );
277
278 }
279 else
280 {
281
282 nIdWorkflow = AppPropertiesService.getPropertyInt( ConstanteUtils.PROPERTY_ID_WORKFLOW_COMPONENT, ConstanteUtils.CONSTANTE_ID_NULL );
283 }
284
285 return nIdWorkflow;
286 }
287
288
289
290
291
292
293 public static IWorkflowReleaseContextService getService( )
294 {
295 if ( _singleton == null )
296 {
297
298 _singleton = SpringContextService.getBean( ConstanteUtils.BEAN_WORKFLOW_RELEASE_CONTEXT_SERVICE );
299 _singleton.init( );
300 }
301
302 return _singleton;
303 }
304
305
306
307
308
309
310
311
312
313 public void mergeDevelopMaster( WorkflowReleaseContext context, Locale locale )
314 {
315
316 if ( !context.getReleaserResource( ).getRepoType( ).equals( RepositoryType.SVN )
317 && ReleaserUtils.getBranchReleaseFrom( context ).equals( GitUtils.DEFAULT_RELEASE_BRANCH ) )
318 {
319
320 FileRepository fLocalRepo = null;
321 CommandResult commandResult = context.getCommandResult( );
322 String strLogin = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getLogin( );
323 String strPassword = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getPassword( );
324
325 ReleaserUtils.logStartAction( context, " Merge DEVELOP/MASTER" );
326
327 String strLocalComponentPath = ReleaserUtils.getLocalPath( context );
328 Git git = null;
329 try
330 {
331
332 fLocalRepo = new FileRepository( strLocalComponentPath + "/.git" );
333 git = new Git( fLocalRepo );
334 commandResult.getLog( ).append( "Checking if local repository " + strLocalComponentPath + " exist\n" );
335 if ( !fLocalRepo.getDirectory( ).exists( ) )
336 {
337
338 ReleaserUtils.addTechnicalError( commandResult, "the local repository does not exist" );
339
340 }
341 else
342 {
343 commandResult.getLog( ).append( "Checkout branch \"" + GitUtils.MASTER_BRANCH + "\" ...\n" );
344 GitUtils.checkoutRepoBranch( git, GitUtils.MASTER_BRANCH, commandResult );
345 commandResult.getLog( ).append( "Checkout successfull\n" );
346
347 commandResult.setProgressValue( commandResult.getProgressValue( ) + 5 );
348
349 commandResult.getLog( ).append( "Going to merge '" + GitUtils.DEFAULT_RELEASE_BRANCH + "' branch on 'master' branch...\n" );
350 MergeResult mergeResult = GitUtils.mergeRepoBranch( git, GitUtils.DEFAULT_RELEASE_BRANCH );
351 if ( mergeResult.getMergeStatus( ).equals( MergeResult.MergeStatus.CHECKOUT_CONFLICT )
352 || mergeResult.getMergeStatus( ).equals( MergeResult.MergeStatus.CONFLICTING )
353 || mergeResult.getMergeStatus( ).equals( MergeResult.MergeStatus.FAILED )
354 || mergeResult.getMergeStatus( ).equals( MergeResult.MergeStatus.NOT_SUPPORTED ) )
355 {
356 ReleaserUtils.addTechnicalError( commandResult, "An error appear during merge operation, the status of merge result is: "
357 + mergeResult.getMergeStatus( ).toString( ) + "\nPlease merge manually before releasing." );
358
359 }
360 else
361 {
362 git.push( ).setCredentialsProvider( new UsernamePasswordCredentialsProvider( strLogin, strPassword ) ).call( );
363 commandResult.getLog( ).append( mergeResult.getMergeStatus( ) );
364 }
365 ReleaserUtils.logEndAction( context, " Merge DEVELOP/MASTER" );
366
367 GitUtils.checkoutRepoBranch( git, GitUtils.DEFAULT_RELEASE_BRANCH, commandResult );
368
369 commandResult.setProgressValue( commandResult.getProgressValue( ) + 10 );
370
371 }
372
373 }
374 catch( InvalidRemoteException e )
375 {
376
377 ReleaserUtils.addTechnicalError( commandResult, e.getMessage( ), e );
378
379 }
380 catch( TransportException e )
381 {
382 ReleaserUtils.addTechnicalError( commandResult, e.getMessage( ), e );
383
384 }
385 catch( IOException e )
386 {
387 ReleaserUtils.addTechnicalError( commandResult, e.getMessage( ), e );
388 }
389 catch( GitAPIException e )
390 {
391 ReleaserUtils.addTechnicalError( commandResult, e.getMessage( ), e );
392 }
393 finally
394 {
395
396 if ( fLocalRepo != null )
397 {
398
399 fLocalRepo.close( );
400
401 }
402 if ( git != null )
403 {
404
405 git.close( );
406
407 }
408
409 }
410 }
411 }
412
413
414
415
416
417
418
419
420
421 public void releasePrepareComponent( WorkflowReleaseContext context, Locale locale )
422 {
423 String strComponentName = context.getComponent( ).getName( );
424 String strLogin = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getLogin( );
425 String strPassword = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getPassword( );
426 IVCSResourceService cvsService = CVSFactoryService.getService( context.getComponent( ).getRepoType( ) );
427
428 try
429 {
430 CommandResult commandResult = context.getCommandResult( );
431 Component component = context.getComponent( );
432
433
434 cvsService.checkoutBranch( context, component.getBranchReleaseFrom( ), locale );
435
436 String strLocalComponentPath = ReleaserUtils.getLocalPath( context );
437 String strLocalComponentPomPath = ReleaserUtils.getLocalPomPath( context );
438
439 String strComponentReleaseVersion = component.getTargetVersion( );
440
441 String strComponentReleaseTagName = null;
442 if ( component.getBranchReleaseFrom( ).equals( GitUtils.DEFAULT_RELEASE_BRANCH ) )
443 {
444 strComponentReleaseTagName = component.getArtifactId( ) + "-" + component.getTargetVersion( );
445 }
446 else
447 {
448 strComponentReleaseTagName = component.getArtifactId( ) + "-" + component.getTargetVersion( ) + "-" + component.getBranchReleaseFrom( );
449 }
450
451 String strComponentReleaseNewDeveloppmentVersion = component.getNextSnapshotVersion( );
452
453 ReleaserUtils.logStartAction( context, " Release Prepare" );
454
455 if ( PluginUtils.isCore( strComponentName ) )
456 {
457
458 String strCoreXMLPath = PluginUtils.getCoreXMLFile( strLocalComponentPath );
459
460 if ( StringUtils.isNotBlank( strCoreXMLPath ) )
461 {
462 commandResult.getLog( ).append( "Updating Core XML " + strComponentName + " to " + strComponentReleaseVersion + "\n" );
463
464 PluginUtils.updatePluginXMLVersion( strCoreXMLPath, strComponentReleaseVersion, commandResult );
465
466 cvsService.updateBranch( context, component.getBranchReleaseFrom( ), locale,
467 "[site-release] Update core version to " + strComponentReleaseVersion );
468 commandResult.getLog( ).append( "Core XML updated to " + strComponentReleaseVersion + "\n" );
469
470 commandResult.setProgressValue( commandResult.getProgressValue( ) + 5 );
471
472 }
473
474
475 String strAppInfoFilePath = PluginUtils.getAppInfoFile( strLocalComponentPath );
476
477 if ( StringUtils.isNotBlank( strAppInfoFilePath ) )
478 {
479 PluginUtils.updateAppInfoFile( strAppInfoFilePath, strComponentReleaseVersion, commandResult );
480 cvsService.updateBranch( context, component.getBranchReleaseFrom( ), locale, "[site-release] Update AppInfo.java version" );
481
482 }
483 else
484 {
485 commandResult.getLog( ).append( "No AppInfo file found..." );
486 }
487
488 }
489 else
490 {
491 String [ ] pluginNames = PluginUtils.getPluginXMLFile( strLocalComponentPath );
492 for ( String pluginXMLPath : pluginNames )
493 {
494 commandResult.getLog( ).append( "Updating plugin XML " + strComponentName + " to " + strComponentReleaseVersion + "\n" );
495 PluginUtils.updatePluginXMLVersion( pluginXMLPath, strComponentReleaseVersion, commandResult );
496 cvsService.updateBranch( context, component.getBranchReleaseFrom( ), locale,
497 "[site-release] Update plugin version to " + strComponentReleaseVersion + " for " + strComponentName );
498
499 commandResult.getLog( ).append( "Plugin XML updated to " + strComponentReleaseVersion + "\n" );
500
501 commandResult.setProgressValue( commandResult.getProgressValue( ) + 5 );
502
503 }
504 }
505
506 MavenService.getService( ).mvnReleasePrepare( strLocalComponentPomPath, strComponentReleaseVersion, strComponentReleaseTagName,
507 strComponentReleaseNewDeveloppmentVersion, strLogin, strPassword, commandResult );
508
509
510 if ( component.getBranchReleaseFrom( ).equals( GitUtils.DEFAULT_RELEASE_BRANCH ) )
511 {
512 cvsService.updateMasterBranch( context, locale );
513 }
514
515
516 cvsService.checkoutBranch( context, component.getBranchReleaseFrom( ), locale );
517
518
519 commandResult.setProgressValue( commandResult.getProgressValue( ) + 20 );
520
521
522 if ( PluginUtils.isCore( strComponentName ) )
523 {
524
525 String strCoreXMLPath = PluginUtils.getCoreXMLFile( strLocalComponentPath );
526
527 if ( StringUtils.isNotBlank( strCoreXMLPath ) )
528 {
529 commandResult.getLog( ).append( "Updating Core XML " + strComponentName + " to " + strComponentReleaseNewDeveloppmentVersion + "\n" );
530
531 PluginUtils.updatePluginXMLVersion( strCoreXMLPath, strComponentReleaseNewDeveloppmentVersion, commandResult );
532
533
534 cvsService.updateBranch( context, component.getBranchReleaseFrom( ), locale,
535 "[site-release] Update core version to " + strComponentReleaseNewDeveloppmentVersion );
536 }
537
538
539 String strAppInfoFilePath = PluginUtils.getAppInfoFile( strLocalComponentPath );
540
541 if ( StringUtils.isNotBlank( strAppInfoFilePath ) )
542 {
543 PluginUtils.updateAppInfoFile( strAppInfoFilePath, strComponentReleaseNewDeveloppmentVersion, commandResult );
544 cvsService.updateBranch( context, component.getBranchReleaseFrom( ), locale, "[site-release] Update AppInfo.java version" );
545 }
546 else
547 {
548 commandResult.getLog( ).append( "No AppInfo file found..." );
549 }
550
551 }
552 else
553 {
554 String [ ] pluginNames = PluginUtils.getPluginXMLFile( strLocalComponentPath );
555 for ( String pluginXMLPath : pluginNames )
556 {
557 commandResult.getLog( ).append( "Updating plugin XML " + strComponentName + " to " + strComponentReleaseNewDeveloppmentVersion + "\n" );
558 PluginUtils.updatePluginXMLVersion( pluginXMLPath, strComponentReleaseNewDeveloppmentVersion, commandResult );
559
560 cvsService.updateBranch( context, component.getBranchReleaseFrom( ), locale,
561 "[site-release] Update plugin version to " + strComponentReleaseNewDeveloppmentVersion + " for " + strComponentName );
562
563 commandResult.getLog( ).append( "Plugin XML updated to " + strComponentReleaseNewDeveloppmentVersion + "\n" );
564 }
565 }
566
567 commandResult.setProgressValue( commandResult.getProgressValue( ) + 15 );
568
569 ReleaserUtils.logEndAction( context, " Release Prepare" );
570
571 }
572 catch( AppException ex )
573 {
574
575 cvsService.rollbackRelease( context, locale );
576 throw ex;
577 }
578
579 }
580
581
582
583
584
585
586
587
588
589 public void releasePerformComponent( WorkflowReleaseContext context, Locale locale )
590 {
591
592 CommandResult commandResult = context.getCommandResult( );
593 String strLogin = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getLogin( );
594 String strPassword = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getPassword( );
595 IVCSResourceService cvsService = CVSFactoryService.getService( context.getComponent( ).getRepoType( ) );
596
597 ReleaserUtils.logStartAction( context, " Release Perform" );
598
599 String strLocalComponentPath = ReleaserUtils.getLocalPath( context );
600
601
602 commandResult.setProgressValue( commandResult.getProgressValue( ) + 10 );
603
604 try
605 {
606
607
608 MavenService.getService( ).mvnReleasePerform( strLocalComponentPath, strLogin, strPassword, commandResult,context.getComponent().getRepoType( ).equals(RepositoryType.GITLAB) );
609
610
611
612 }
613 catch( AppException ex )
614 {
615 cvsService.rollbackRelease( context, locale );
616 throw ex;
617 }
618 ReleaserUtils.logEndAction( context, " Release Perform" );
619 }
620
621
622
623
624
625
626
627
628
629 public void checkoutRepository( WorkflowReleaseContext context, Locale locale )
630 {
631 CommandResult commandResult = context.getCommandResult( );
632 String strLogin = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getLogin( );
633 String strPassword = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getPassword( );
634
635 ReleaserUtils.logStartAction( context, " checkout resource" );
636 CVSFactoryService.getService( context.getReleaserResource( ).getRepoType( ) ).doCheckoutRepository( context, strLogin, strPassword );
637
638 commandResult.setProgressValue( commandResult.getProgressValue( ) + 30 );
639
640 ReleaserUtils.logEndAction( context, " checkout resource" );
641
642 }
643
644
645
646
647
648
649
650
651
652 public void releasePrepareSite( WorkflowReleaseContext context, Locale locale )
653 {
654
655 IVCSResourceService cvsService = CVSFactoryService.getService( context.getSite( ).getRepoType( ) );
656 String strLogin = context.getReleaserUser( ).getCredential( context.getSite( ).getRepoType( ) ).getLogin( );
657 String strPassword = context.getReleaserUser( ).getCredential( context.getSite( ).getRepoType( ) ).getPassword( );
658 String strSitePomLocalBasePath = ReleaserUtils.getLocalPomPath( context );
659
660 CommandResult commandResult = context.getCommandResult( );
661 String componentTyeName = context.getSite( ).isTheme( ) ? "Theme " : "Site";
662
663 ReleaserUtils.logStartAction( context, " Release perpare " + componentTyeName );
664
665 commandResult.getLog( ).append( "Starting Action Release " + componentTyeName + "...\n" );
666
667 commandResult.getLog( ).append( "Preparing release " + componentTyeName + "\n" );
668 commandResult.getLog( ).append( "Updating pom version to " + context.getSite( ).getNextReleaseVersion( ) + "...\n" );
669 commandResult.getLog( ).append( "Updating dependency version ...\n" );
670 try
671 {
672 PomUpdater.updateSiteBeforeTag( context.getSite( ), ReleaserUtils.getLocalPomPath( context ) );
673 cvsService.updateDevelopBranch( context, locale, "[site-release] update pom before tag" );
674
675
676 commandResult.setProgressValue( commandResult.getProgressValue( ) + 30 );
677
678 commandResult.getLog( ).append( "Pom updated\n" );
679 commandResult.getLog( ).append( "Release prepare " + componentTyeName + " " + context.getSite( ).getNextReleaseVersion( ) + "...\n" );
680
681 MavenService.getService( ).mvnReleasePrepare( strSitePomLocalBasePath, context.getSite( ).getNextReleaseVersion( ),
682 context.getSite( ).getArtifactId( ) + "-" + context.getSite( ).getNextReleaseVersion( ), context.getSite( ).getNextSnapshotVersion( ),
683 strLogin, strPassword, commandResult );
684
685 commandResult.getLog( ).append( "End Release prepare " + componentTyeName + " " + context.getSite( ).getNextReleaseVersion( ) + "...\n" );
686
687
688 cvsService.updateMasterBranch( context, locale );
689
690 cvsService.checkoutDevelopBranch( context, locale );
691
692
693 commandResult.setProgressValue( commandResult.getProgressValue( ) + 20 );
694
695 commandResult.getLog( ).append( "Updating pom after release prepare \n" );
696
697 PomUpdater.updateSiteAfterTag( context.getSite( ), ReleaserUtils.getLocalPomPath( context ) );
698 cvsService.updateDevelopBranch( context, locale, "[site-release] update Updating pom to next development" );
699 commandResult.getLog( ).append( "Pom updated\n" );
700
701 }
702
703 catch( JAXBException e )
704 {
705 ReleaserUtils.addTechnicalError( commandResult, "error during update pom", e );
706 }
707 catch( AppException ex )
708 {
709
710 cvsService.rollbackRelease( context, locale );
711 throw ex;
712 }
713
714 ReleaserUtils.logEndAction( context, " Release prepare " + componentTyeName );
715
716 }
717
718
719
720
721
722
723
724
725
726 public void sendTweet( WorkflowReleaseContext context, Locale locale )
727 {
728
729 CommandResult commandResult = context.getCommandResult( );
730
731 ReleaserUtils.logStartAction( context, " send Tweet" );
732
733 TwitterService.getService( ).sendTweet( context.getComponent( ).getTweetMessage( ), commandResult );
734
735 ReleaserUtils.logEndAction( context, " send Tweet" );
736
737 }
738
739
740
741
742
743
744
745
746
747 public void updateJiraVersions( WorkflowReleaseContext context, Locale locale )
748 {
749
750 CommandResult commandResult = context.getCommandResult( );
751
752 ReleaserUtils.logStartAction( context, " Update Jira Versions" );
753
754 JiraComponentService.getService( ).updateComponentVersions( context.getComponent( ), commandResult );
755
756 ReleaserUtils.logEndAction( context, " Update Jira Versions" );
757
758 }
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774 public void startWorkflowReleaseContext( WorkflowReleaseContext context, int nIdWorkflow, Locale locale, HttpServletRequest request, AdminUser user )
775 {
776 _executor.execute( new ReleaseComponentTask( nIdWorkflow, context, request, user, locale ) );
777 }
778
779
780
781
782 public void init( )
783 {
784
785 _executor = Executors.newFixedThreadPool( AppPropertiesService.getPropertyInt( ConstanteUtils.PROPERTY_THREAD_RELEASE_POOL_MAX_SIZE, 5 ) );
786
787 }
788
789
790
791
792
793
794
795 public void startReleaseInProgress( String strArtifactId )
796 {
797
798 _releaseInProgress.add( strArtifactId );
799 }
800
801
802
803
804
805
806
807 public void stopReleaseInProgress( String strArtifactId )
808 {
809
810 _releaseInProgress.remove( strArtifactId );
811 }
812
813
814
815
816
817
818
819
820 public boolean isReleaseInProgress( String strArtifactId )
821 {
822
823 return _releaseInProgress.contains( strArtifactId );
824 }
825
826
827
828
829
830
831
832
833
834 @Override
835 public void releasePerformSite( WorkflowReleaseContext context, Locale locale )
836 {
837 CommandResult commandResult = context.getCommandResult( );
838 String strLogin = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getLogin( );
839 String strPassword = context.getReleaserUser( ).getCredential( context.getReleaserResource( ).getRepoType( ) ).getPassword( );
840 IVCSResourceService cvsService = CVSFactoryService.getService( context.getReleaserResource( ).getRepoType( ) );
841
842 if ( context.getSite( ).isTheme( ) )
843 {
844 ReleaserUtils.logStartAction( context, " Release Perform" );
845
846 String strLocalComponentPath = ReleaserUtils.getLocalPath( context );
847
848
849 commandResult.setProgressValue( commandResult.getProgressValue( ) + 10 );
850
851 try
852 {
853
854 MavenService.getService( ).mvnReleasePerform( strLocalComponentPath, strLogin, strPassword, commandResult,true );
855
856 }
857 catch( AppException ex )
858 {
859 cvsService.rollbackRelease( context, locale );
860 throw ex;
861 }
862 ReleaserUtils.logEndAction( context, " Release Perform" );
863 }
864 else
865 {
866 commandResult.getLog( ).append( "No release Perform for Site" );
867 }
868 }
869
870 }