Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/web/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
<property name="loggerName" value="com.topcoder.accounting.fees.view.actions.ContestFeesHomeAction"/>
<property name="contestFeeService" ref="contestFeeService"/>
<property name="contestFeePercentageService" ref="contestFeePercentageService"/>
<property name="userGroupsApiEndpoint" value="@userGroupsApiEndpoint@"/>
</bean>

<bean id="projectAction" class="com.topcoder.direct.services.view.action.contest.launch.ProjectAction"
Expand Down Expand Up @@ -424,6 +425,7 @@
<bean id="saveDraftContestAction"
class="com.topcoder.direct.services.view.action.contest.launch.SaveDraftContestAction"
parent="contestAction" scope="prototype">
<property name="userGroupsApiEndpoint" value="@userGroupsApiEndpoint@"/>
</bean>

<bean id="documentUploadAction" class="com.topcoder.direct.services.view.action.contest.launch.DocumentUploadAction"
Expand Down
5 changes: 5 additions & 0 deletions conf/web/WEB-INF/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,11 @@
<result name="error" type="json"/>
</action>

<action name="getGroups" method="getGroups" class="commonAction">
<result name="success" type="json"/>
<result name="error" type="json"/>
</action>

<action name="documentUpload" class="documentUploadAction">
<result name="success" type="json"/>
<result name="error" type="json"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.topcoder.project.service.ScorecardReviewData;
import com.topcoder.search.builder.SearchBuilderException;
import com.topcoder.security.TCSubject;
import com.topcoder.service.contest.eligibility.ContestEligibility;
import com.topcoder.service.contest.eligibility.dao.ContestEligibilityPersistenceException;
import com.topcoder.service.facade.contest.notification.ProjectNotification;
import com.topcoder.service.payment.CreditCardPaymentData;
import com.topcoder.service.payment.TCPurhcaseOrderPaymentData;
Expand Down Expand Up @@ -1666,4 +1668,14 @@ Set<Long> updatePreRegister(TCSubject tcSubject, SoftwareCompetition contest,
* @since 1.8.6
*/
public ProjectGroup[] getAllProjectGroups(TCSubject tcSubject) throws ContestServiceException;

/**
* Get group for a contest
*
* @param contestId contestId
* @param isStudio false
* @return
* @throws ContestServiceException
*/
public List<ProjectGroup> getGroupForContest(long contestId, boolean isStudio) throws ContestServiceException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9592,4 +9592,26 @@ private ProjectPayment addManualCopilotPayment(com.topcoder.management.resource.
newPayment.setResourceId(copilotResource.getId());
return projectPaymentManager.create(newPayment, String.valueOf(tcSubject.getUserId()));
}

/**
* Get group for a contest
*
* @param contestId contestId
* @param isStudio false
* @return
* @throws ContestServiceException
*/
public List<ProjectGroup> getGroupForContest(long contestId, boolean isStudio) throws ContestServiceException {
try {
List<ContestEligibility> ces = contestEligibilityManager.getContestEligibility(contestId, isStudio);
List<ProjectGroup> groupList = new ArrayList<ProjectGroup>();
for (ContestEligibility ce : ces) {
groupList.add(new ProjectGroup(((GroupContestEligibility) ce).getGroupId(), ""));
}
return groupList;
} catch (ContestEligibilityPersistenceException ce) {
logger.error("Failed to get security group for challenge id:" + contestId);
throw new ContestServiceException("Failed to get security group for challenge id:" + contestId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
*/
package com.topcoder.direct.services.view.action.contest.launch;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.topcoder.clients.model.Project;
import com.topcoder.clients.model.ProjectContestFee;
import com.topcoder.clients.model.ProjectContestFeePercentage;
import com.topcoder.direct.services.configs.AlgorithmSubtypeContestFee;
import com.topcoder.direct.services.configs.ConfigUtils;
import com.topcoder.direct.services.configs.ContestFee;
import com.topcoder.direct.services.configs.StudioSubtypeContestFee;
import com.topcoder.direct.services.project.metadata.entities.dao.DirectProjectAccess;
import com.topcoder.direct.services.project.milestone.model.Milestone;
import com.topcoder.direct.services.project.milestone.model.MilestoneStatus;
Expand All @@ -24,18 +15,20 @@
import com.topcoder.direct.services.view.dto.IdNamePair;
import com.topcoder.direct.services.view.dto.contest.ContestCopilotDTO;
import com.topcoder.direct.services.view.dto.contest.ProblemDTO;
import com.topcoder.direct.services.view.dto.contest.TypedContestBriefDTO;
import com.topcoder.direct.services.view.dto.contest.ReviewScorecardDTO;
import com.topcoder.direct.services.view.dto.contest.TypedContestBriefDTO;
import com.topcoder.direct.services.view.util.AuthorizationProvider;
import com.topcoder.direct.services.view.util.DataProvider;
import com.topcoder.direct.services.view.util.DirectUtils;
import com.topcoder.direct.services.view.util.challenge.CostCalculationService;
import com.topcoder.management.project.ProjectGroup;
import com.topcoder.security.TCSubject;
import com.topcoder.service.facade.contest.ContestServiceException;
import com.topcoder.service.facade.project.DAOFault;
import org.apache.commons.lang3.StringEscapeUtils;
import org.codehaus.jackson.map.ObjectMapper;
import com.topcoder.management.project.ProjectGroup;

import java.util.*;

/**
* <p>
Expand Down Expand Up @@ -130,6 +123,11 @@ public class CommonAction extends BaseContestFeeAction {

private long categoryId;

/**
* Endpoint to group of a user
*/
private String userGroupsApiEndpoint;

/**
* <p>
* Executes the action.
Expand Down Expand Up @@ -325,7 +323,6 @@ public String getContestConfigs() throws Exception {

configs.put("copilotFees", ConfigUtils.getCopilotFees());
configs.put("billingInfos", getBillingProjectInfos());
configs.put("groups", getAllProjectGroups());
configs.put("platforms", getReferenceDataBean().getPlatforms());
configs.put("technologies", getReferenceDataBean().getTechnologies());
setResult(configs);
Expand Down Expand Up @@ -552,4 +549,30 @@ public long getCategoryId() {
public void setCategoryId(long categoryId) {
this.categoryId = categoryId;
}

/**
* Get Accessible security groups from group Api
*
* @return
*/
public String getGroups() {
try {
TCSubject tcSubject = DirectUtils.getTCSubjectFromSession();
Set<ProjectGroup> projectGroups = DirectUtils.getGroups(tcSubject, userGroupsApiEndpoint);
setResult(projectGroups);
} catch (Throwable e) {
if (getModel() != null) {
setResult(e);
}
}
return SUCCESS;
}

public String getUserGroupsApiEndpoint() {
return userGroupsApiEndpoint;
}

public void setUserGroupsApiEndpoint(String userGroupsApiEndpoint) {
this.userGroupsApiEndpoint = userGroupsApiEndpoint;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.topcoder.direct.services.view.util.SessionData;
import com.topcoder.management.deliverable.Submission;
import com.topcoder.management.project.Prize;
import com.topcoder.management.project.ProjectGroup;
import com.topcoder.management.resource.Resource;
import com.topcoder.management.resource.ResourceRole;
import com.topcoder.security.TCSubject;
Expand Down Expand Up @@ -342,11 +343,11 @@ public class GetContestAction extends ContestAction {
private boolean admin;

/**
* The registration end date.
*/
private String regEndDate;
/**
* The registration end date.
*/
private String regEndDate;

/**
* The submission end date.
* @since 1.5
*/
Expand Down Expand Up @@ -452,11 +453,16 @@ protected void executeAction() throws Exception {
if (DirectUtils.isStudio(softwareCompetition)) {
softwareCompetition.setType(CompetionType.STUDIO);
}
softwareCompetition.getProjectHeader().setGroups(DirectUtils.getGroupIdAndName(
softwareCompetition.getProjectHeader().getGroups()));

setResult(softwareCompetition);
regEndDate = DirectUtils.getDateString(DirectUtils.getRegistrationEndDate(softwareCompetition));
regEndDate = DirectUtils.getDateString(DirectUtils.getRegistrationEndDate(softwareCompetition));
subEndDate = DirectUtils.getDateString(DirectUtils.getSubmissionEndDate(softwareCompetition));
contestEndDate = DirectUtils.getDateString(DirectUtils.getEndDate(softwareCompetition));



// depends on the type :
// 1. if contest, store softwareCompetition in session
// 2. if json data for contest, stops here since we are getting it
Expand Down Expand Up @@ -955,13 +961,13 @@ public void setType(TYPE type) {
this.type = type;
}

/**
* Gets the registration end date.
*/
public String getRegEndDate() {
return regEndDate;
}
/**
* Gets the registration end date.
*/
public String getRegEndDate() {
return regEndDate;
}

/**
* Gets the submission end date.
* @since 1.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,17 @@ public class SaveDraftContestAction extends ContestAction {
*/
private static final long APPIRIO_MANAGER_METADATA_KEY_ID = 15L;

/**
* Private constant specifying administrator role.
*/
private static final String ADMIN_ROLE = "Cockpit Administrator";

/**
* Private constant specifying administrator role.
*/
private static final String TC_STAFF_ROLE = "TC Staff";


/**
* </p>
*
Expand Down Expand Up @@ -731,6 +742,11 @@ public class SaveDraftContestAction extends ContestAction {
*/
private Double customCopilotFee;

/**
* Endpoint to group of a user
*/
private String userGroupsApiEndpoint;

/**
* <p>
* Creates a <code>SaveDraftContestAction</code> instance.
Expand Down Expand Up @@ -1055,24 +1071,16 @@ public boolean evaluate(Object object) {
populateSoftwareCompetition(softwareCompetition);
}

//set groups
//do backend validation for groups here
List<ProjectGroup> projectGroups = new ArrayList<ProjectGroup>();
if (groups != null && groups.size() > 0) {
List<ProjectGroup> groupsList = new ArrayList<ProjectGroup>();
// get the TCSubject from session
ProjectGroup[] allProjectGroups = getContestServiceFacade().getAllProjectGroups(DirectStrutsActionsHelper.getTCSubjectFromSession());
for (String groupId : groups) {
for (ProjectGroup projectGroup : allProjectGroups) {
if (Long.valueOf(groupId).equals(projectGroup.getId())) {
groupsList.add(projectGroup);
}
}

projectGroups.add(new ProjectGroup(Long.valueOf(groupId), ""));
}
softwareCompetition.getProjectHeader().setGroups(groupsList);
} else {
softwareCompetition.getProjectHeader().setGroups(new ArrayList<ProjectGroup>());
}

softwareCompetition.getProjectHeader().setGroups(projectGroups);

// remove the thurgood information if needed
if(softwareCompetition.getProjectHeader().getProperties().containsKey(THURGOOD_PLATFORM_KEY)) {
if(softwareCompetition.getProjectHeader().getProperties().get(THURGOOD_PLATFORM_KEY) == null
Expand Down Expand Up @@ -2552,6 +2560,14 @@ public void setPreRegisterUsers(String preRegisterUsers) {
this.preRegisterUsers = preRegisterUsers;
}

public String getUserGroupsApiEndpoint() {
return userGroupsApiEndpoint;
}

public void setUserGroupsApiEndpoint(String userGroupsApiEndpoint) {
this.userGroupsApiEndpoint = userGroupsApiEndpoint;
}

/**
* Pre-Register users to a given project
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ public Object transform(Object object) {
}
}));

result.put("groupNames", CollectionUtils.collect(bean.getProjectHeader().getGroups(), new Transformer() {
public Object transform(Object object) {
return ((ProjectGroup) object).getName();
}
}));

// documentation
result.put("documentation", CollectionUtils.collect(assetDTO.getDocumentation(), new Transformer() {
public Object transform(Object object) {
Expand Down
Loading