207
207
* Version 2.8 (Release Assembly - TC Cockpit Start Project Flow Billing Account Integration)
208
208
* - Set project billing account when creating new project is the billing account is set.
209
209
* </p>
210
+ * <p>
211
+ * Version 2.9 (TOPCODER DIRECT - MAKE FORUM CREATION OPTIONAL) changes:
212
+ * <ul>
213
+ * <li>Added {@link #createProject(TCSubject, ProjectData, boolean)} to enable or disable forum creation.</li>
214
+ * <li>Refactored the other createProject to use a common createProjectInternal method.</li>
215
+ * <li>Updated createTopCoderDirectProjectForum method to log the method entry at INFO level</li>
216
+ * </ul>
217
+ * </p>
210
218
*
211
- * @author isv, waits, GreatKevin, duxiaoyang, GreatKevin
212
- * @version 2.8
219
+ * @author isv, waits, GreatKevin, duxiaoyang, GreatKevin, TCSCODER
220
+ * @version 2.9
213
221
*/
214
222
@ Stateless
215
223
@ TransactionManagement (TransactionManagementType .CONTAINER )
@@ -500,9 +508,32 @@ public void init() {
500
508
public ProjectData createProject (TCSubject tcSubject , ProjectData projectData )
501
509
throws PersistenceFault , IllegalArgumentFault
502
510
{
503
- return createProject (tcSubject , projectData , null );
511
+ return createProjectInternal (tcSubject , projectData , true , null );
512
+ }
513
+
514
+ /**
515
+ * <p>Creates a project with the given project data.</p>
516
+ *
517
+ * @param tcSubject TCSubject instance contains the login security info for the current user
518
+ * @param projectData
519
+ * The project data to be created. Must not be null.
520
+ * The <code>ProjectData.name</code> must not be null/empty.
521
+ * The <code>ProjectData.projectId</code>, if any, is ignored.
522
+ * @param withForum indicates the forum should be created or not
523
+ * @return The project as it was created, with the <code>ProjectData.projectId</code> and <code>ProjectData.userId
524
+ * </code> set. Will never be null.
525
+ * @throws IllegalArgumentFault if the given <code>ProjectData</code> is illegal.
526
+ * @throws PersistenceFault if a generic persistence error occurs.
527
+ * @see ProjectService#createProject(ProjectData)
528
+ * @since 2.9
529
+ */
530
+ public ProjectData createProject (TCSubject tcSubject , ProjectData projectData , boolean withForum )
531
+ throws PersistenceFault , IllegalArgumentFault {
532
+
533
+ return createProjectInternal (tcSubject , projectData , withForum , null );
504
534
}
505
535
536
+
506
537
/**
507
538
* <p>Creates a project with the given project data and forum templates.</p>
508
539
*
@@ -526,7 +557,30 @@ public ProjectData createProject(TCSubject tcSubject, ProjectData projectData)
526
557
public ProjectData createProject (TCSubject tcSubject , ProjectData projectData , Map <String , String > forums )
527
558
throws PersistenceFault , IllegalArgumentFault
528
559
{
529
- if (forums != null ) {
560
+ return createProjectInternal (tcSubject , projectData , true , forums );
561
+ }
562
+
563
+
564
+ /**
565
+ * <p>Creates a project with the given project data and forum templates.</p>
566
+ *
567
+ *
568
+ * @param tcSubject TCSubject instance contains the login security info for the current user
569
+ * @param projectData The project data to be created. Must not be null. The <code>ProjectData.name</code> must not be
570
+ * null/empty. The <code>ProjectData.projectId</code>, if any, is ignored.
571
+ * @param withForum indicates the forum should be created or not
572
+ * @param forums a list of project forum templates configuration.
573
+ * @return The project as it was created, with the <code>ProjectData.projectId</code> and <code>ProjectData.userId
574
+ * </code> set. Will never be null.
575
+ * @throws IllegalArgumentFault if the given <code>ProjectData</code> is illegal, or <code>forums</code> list
576
+ * contains <code>null</code> key/value.
577
+ * @throws PersistenceFault if a generic persistence error occurs.
578
+ * @see ProjectService#createProject(TCSubject, ProjectData)
579
+ */
580
+ private ProjectData createProjectInternal (TCSubject tcSubject , ProjectData projectData , boolean withForum , Map <String , String > forums )
581
+ throws PersistenceFault , IllegalArgumentFault
582
+ {
583
+ if (forums != null ) {
530
584
for (String key : forums .keySet ()) {
531
585
if (key == null || forums .get (key ) == null ) {
532
586
throw new IllegalArgumentFault ("Forums map contains NULL key/value" );
@@ -552,10 +606,12 @@ public ProjectData createProject(TCSubject tcSubject, ProjectData projectData, M
552
606
permissions [0 ] = perm ;
553
607
permissionService .updatePermissions (tcSubject , permissions );
554
608
555
- long forumID = createTopCoderDirectProjectForum (tcSubject , result .getProjectId (), null , forums );
609
+ if (withForum ) {
610
+ long forumID = createTopCoderDirectProjectForum (tcSubject , result .getProjectId (), null , forums );
556
611
557
- projectData .setForumCategoryId (String .valueOf (forumID ));
558
- result .setForumCategoryId (String .valueOf (forumID ));
612
+ projectData .setForumCategoryId (String .valueOf (forumID ));
613
+ result .setForumCategoryId (String .valueOf (forumID ));
614
+ }
559
615
560
616
// send project creation notification email
561
617
com .topcoder .project .phases .Phase phase = new com .topcoder .project .phases .Phase ();
@@ -575,10 +631,6 @@ public ProjectData createProject(TCSubject tcSubject, ProjectData projectData, M
575
631
final String [] toAddrs = projectCreationEmailToAddressesConfig .split (";" );
576
632
final String [] ccAddrs = projectCreationEmailCCAddressesConfig .split (";" );
577
633
578
- // sendEmail(EMAIL_FILE_TEMPLATE_SOURCE_KEY, file,
579
- // projectCreationEmailSubject.replace("%PROJECT_NAME%", result.getName()), toAddrs, ccAddrs, null,
580
- // projectCreationEmailFromAddress, phase, "Cockpit Project Creation");
581
-
582
634
return result ;
583
635
} catch (PermissionServiceException e ) {
584
636
sessionContext .setRollbackOnly ();
@@ -969,7 +1021,7 @@ public List<Project> getClientProjectsByUser(TCSubject tcSubject) throws DAOFaul
969
1021
public long createTopCoderDirectProjectForum (TCSubject currentUser , long projectId , Long tcDirectProjectTypeId ,
970
1022
Map <String , String > forumConfig ) throws ProjectServiceFault {
971
1023
long userId = currentUser .getUserId ();
972
- logger .debug ("createTopCoderDirectProjectForum (projectId = " + projectId + ", userId = " + userId
1024
+ logger .info ("createTopCoderDirectProjectForum (projectId = " + projectId + ", userId = " + userId
973
1025
+ ", createProjectForum = )" + createForum );
974
1026
975
1027
if (!createForum ) {
0 commit comments