Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 9ba7ee9

Browse files
committed
make forum creation optional
1 parent 9788f06 commit 9ba7ee9

File tree

2 files changed

+91
-14
lines changed

2 files changed

+91
-14
lines changed

services/project_service_facade/src/java/main/com/topcoder/service/facade/project/ProjectServiceFacade.java

+27-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@
124124
* <li>Added {@link #deleteTopCoderDirectProjectForum(long, long)} to delete direct project forums.</li>
125125
* </ul>
126126
* </p>
127-
* @author isv, GreatKevin, TCSDEVELOPER, duxiaoyang
128-
* @version 2.5
127+
* <p>
128+
* Version 2.6 (TOPCODER DIRECT - MAKE FORUM CREATION OPTIONAL) changes:
129+
* <ul>
130+
* <li>Added {@link #createProject(TCSubject, ProjectData, boolean)} to enable or disable forum creation</li>
131+
* </ul>
132+
* </p>
133+
* @author isv, GreatKevin, TCSDEVELOPER, duxiaoyang, TCSCODER
134+
* @version 2.6
129135
*/
130136
public interface ProjectServiceFacade {
131137

@@ -148,6 +154,25 @@ public interface ProjectServiceFacade {
148154
* @see ProjectService#createProject(ProjectData)
149155
*/
150156
ProjectData createProject(TCSubject tcSubject, ProjectData projectData) throws PersistenceFault, IllegalArgumentFault;
157+
158+
159+
/**
160+
* <p>Creates a project with the given project data.</p>
161+
*
162+
* @param tcSubject TCSubject instance contains the login security info for the current user
163+
* @param projectData
164+
* The project data to be created. Must not be null.
165+
* The <code>ProjectData.name</code> must not be null/empty.
166+
* The <code>ProjectData.projectId</code>, if any, is ignored.
167+
* @param withForum indicates the forum should be created or not
168+
* @return The project as it was created, with the <code>ProjectData.projectId</code> and <code>ProjectData.userId
169+
* </code> set. Will never be null.
170+
* @throws IllegalArgumentFault if the given <code>ProjectData</code> is illegal.
171+
* @throws PersistenceFault if a generic persistence error occurs.
172+
* @see ProjectService#createProject(ProjectData)
173+
* @since 2.6
174+
*/
175+
ProjectData createProject(TCSubject tcSubject, ProjectData projectData, boolean withForum) throws PersistenceFault, IllegalArgumentFault;
151176

152177
/**
153178
* <p>Creates a project with the given project data and forum templates.</p>

services/project_service_facade/src/java/main/com/topcoder/service/facade/project/ejb/ProjectServiceFacadeBean.java

+64-12
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,17 @@
207207
* Version 2.8 (Release Assembly - TC Cockpit Start Project Flow Billing Account Integration)
208208
* - Set project billing account when creating new project is the billing account is set.
209209
* </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>
210218
*
211-
* @author isv, waits, GreatKevin, duxiaoyang, GreatKevin
212-
* @version 2.8
219+
* @author isv, waits, GreatKevin, duxiaoyang, GreatKevin, TCSCODER
220+
* @version 2.9
213221
*/
214222
@Stateless
215223
@TransactionManagement(TransactionManagementType.CONTAINER)
@@ -500,9 +508,32 @@ public void init() {
500508
public ProjectData createProject(TCSubject tcSubject, ProjectData projectData)
501509
throws PersistenceFault, IllegalArgumentFault
502510
{
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);
504534
}
505535

536+
506537
/**
507538
* <p>Creates a project with the given project data and forum templates.</p>
508539
*
@@ -526,7 +557,30 @@ public ProjectData createProject(TCSubject tcSubject, ProjectData projectData)
526557
public ProjectData createProject(TCSubject tcSubject, ProjectData projectData, Map<String, String> forums)
527558
throws PersistenceFault, IllegalArgumentFault
528559
{
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) {
530584
for (String key : forums.keySet()) {
531585
if (key == null || forums.get(key) == null) {
532586
throw new IllegalArgumentFault("Forums map contains NULL key/value");
@@ -552,10 +606,12 @@ public ProjectData createProject(TCSubject tcSubject, ProjectData projectData, M
552606
permissions[0] = perm;
553607
permissionService.updatePermissions(tcSubject, permissions);
554608

555-
long forumID = createTopCoderDirectProjectForum(tcSubject, result.getProjectId(), null, forums);
609+
if (withForum) {
610+
long forumID = createTopCoderDirectProjectForum(tcSubject, result.getProjectId(), null, forums);
556611

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+
}
559615

560616
// send project creation notification email
561617
com.topcoder.project.phases.Phase phase = new com.topcoder.project.phases.Phase();
@@ -575,10 +631,6 @@ public ProjectData createProject(TCSubject tcSubject, ProjectData projectData, M
575631
final String[] toAddrs = projectCreationEmailToAddressesConfig.split(";");
576632
final String[] ccAddrs = projectCreationEmailCCAddressesConfig.split(";");
577633

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-
582634
return result;
583635
} catch (PermissionServiceException e) {
584636
sessionContext.setRollbackOnly();
@@ -969,7 +1021,7 @@ public List<Project> getClientProjectsByUser(TCSubject tcSubject) throws DAOFaul
9691021
public long createTopCoderDirectProjectForum(TCSubject currentUser, long projectId, Long tcDirectProjectTypeId,
9701022
Map<String, String> forumConfig) throws ProjectServiceFault {
9711023
long userId = currentUser.getUserId();
972-
logger.debug("createTopCoderDirectProjectForum (projectId = " + projectId + ", userId = " + userId
1024+
logger.info("createTopCoderDirectProjectForum (projectId = " + projectId + ", userId = " + userId
9731025
+ ", createProjectForum = )" + createForum);
9741026

9751027
if (!createForum) {

0 commit comments

Comments
 (0)