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

Commit d9b49cc

Browse files
committed
S-279280
1 parent 3c44910 commit d9b49cc

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

services/cloud_vm_service/src/java/main/com/topcoder/direct/cloudvm/service/bean/CloudVMServiceBean.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public class CloudVMServiceBean implements CloudVMServiceRemote, CloudVMServiceL
116116
*/
117117
private static final String EMAIL = "email";
118118

119+
/**
120+
* Represents the UserData key for storing challenge id
121+
*/
122+
private static final String CHALLENGE_ID = "challenge_id";
123+
124+
/**
125+
* Represents the UserData key for storing challenge id
126+
*/
127+
private static final String CHALLENGE_NAME = "challenge_name";
128+
129+
/**
130+
* Represents the UserData key for storing challenge id
131+
*/
132+
private static final String ROLE = "role";
133+
119134
/**
120135
* Represents the String containing the End of Line
121136
*/
@@ -319,6 +334,10 @@ public List<VMInstanceData> launchVMInstance(TCSubject tcSubject, VMInstance vmI
319334
userData.append(populateUserData(BRANCH,vmInstance.getSvnBranch()));
320335
userData.append(populateUserData(HANDLE,tcMemberHandle));
321336
userData.append(populateUserData(USER_EMAIL,userService.getEmailAddress(tcMemberHandle)));
337+
userData.append(populateUserData(CHALLENGE_ID,String.valueOf(vmInstanceMain.getContestId())));
338+
userData.append(populateUserData(CHALLENGE_NAME, vmInstanceMain.getContestName()));
339+
userData.append(populateUserData(ROLE, vmInstanceMain.getUsageName()));
340+
322341
if (vmInstanceMain.getUserData() != null ){
323342
userData.append(vmInstanceMain.getUserData());
324343
}

services/cloud_vm_service/src/java/main/com/topcoder/direct/services/view/dto/cloudvm/VMInstance.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public class VMInstance extends AbstractIdEntity {
6767
* Represents the usage id. It has getter & setter. It can be any value.
6868
*/
6969
private long usageId;
70+
71+
/**
72+
* Represents the usage id. It has getter & setter. It can be any value.
73+
*/
74+
private String usageName;
7075

7176
/**
7277
* Represents VM public IP address.
@@ -323,6 +328,27 @@ public void setPublicIP(String publicIP) {
323328
this.publicIP = publicIP;
324329
}
325330

331+
/**
332+
* Setter for the namesake instance variable. Simply set the value to the namesake instance variable.
333+
*
334+
* @param usageName
335+
*/
336+
public void setUsageName(String usageName) {
337+
this.usageName = usageName;
338+
}
339+
340+
/**
341+
* Getter for the namesake instance variable. Simply return the namesake instance variable.
342+
*
343+
* @return field value
344+
* @since BUGR-3932
345+
*/
346+
public String getUsageName() {
347+
return usageName;
348+
}
349+
350+
351+
326352
/**
327353
* Getter for the namesake instance variable. Simply return the namesake instance variable.
328354
*

services/cloud_vm_service/src/java/main/com/topcoder/direct/services/view/dto/cloudvm/VMUsage.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,26 @@ public String getName() {
4545
public void setName(String name) {
4646
this.name = name;
4747
}
48+
49+
50+
public static String getName(long id) {
51+
if (id == 1) {
52+
return "VM for competitors";
53+
}
54+
55+
if (id == 2) {
56+
return "VM for reviewers";
57+
}
58+
59+
if (id == 3) {
60+
return "VM for manager/copilots";
61+
}
62+
63+
if (id == 4) {
64+
return "VM for Bug race";
65+
}
66+
67+
return "VM for competitors";
68+
}
4869
}
4970

src/java/main/com/topcoder/direct/services/view/action/cloudvm/LaunchVMInstanceAction.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
import com.topcoder.direct.services.view.action.contest.launch.ValidationErrorRecord;
88
import com.topcoder.direct.services.view.action.contest.launch.ValidationErrors;
99
import com.topcoder.direct.services.view.dto.cloudvm.VMInstance;
10+
import com.topcoder.direct.services.view.dto.cloudvm.VMUsage;
1011
import com.topcoder.direct.services.view.util.DirectUtils;
12+
import com.topcoder.management.project.ProjectPropertyType;
1113
import com.topcoder.service.facade.contest.ContestServiceFacade;
14+
import com.topcoder.service.project.SoftwareCompetition;
1215
import com.topcoder.service.user.UserService;
1316
import com.topcoder.service.user.UserServiceException;
1417
import com.topcoder.security.TCSubject;
1518
import com.topcoder.shared.security.AuthorizationException;
1619

20+
1721
import javax.servlet.http.HttpServletRequest;
1822
import java.util.HashMap;
1923
import java.util.Map;
@@ -105,6 +109,18 @@ protected void executeAction() throws Exception {
105109
errors.put("contestId",
106110
"No contest with such id. Contest type may be wrong or you may have no permission to access contest data.");
107111
}
112+
113+
String challengeName = "Bug Race";
114+
if (instance.getContestTypeId() != bugRaceContestTypeId) {
115+
challengeName = ((SoftwareCompetition) result).getProjectHeader().getProperty(
116+
ProjectPropertyType.PROJECT_NAME_PROJECT_PROPERTY_KEY);
117+
118+
}
119+
120+
instance.setContestName(challengeName);
121+
122+
instance.setUsageName(VMUsage.getName(instance.getUsageId()));
123+
108124
}
109125

110126
// check member handle

0 commit comments

Comments
 (0)