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

Commit b716cd4

Browse files
author
Dushyant Bhalgami
authored
Merge pull request #486 from appirio-tech/dev
defaulting every MM as rated match
2 parents 67736e2 + bbb6b84 commit b716cd4

File tree

16 files changed

+588
-43
lines changed

16 files changed

+588
-43
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ In this configuration, we'll run the direct app in a docker container locally bu
3434

3535
## Test Users
3636

37-
direct_user/topcoder2001 (Use this user to login to Direct and create challenges in the Topcoder DEV environment. You can alsoo use this user to manipulate challenges in Online Review)
37+
direct_user/topcoder2001 (Use this user to login to Direct and create challenges in the Topcoder DEV environment. You can alsoo use this user to manipulate challenges in Online Review).
3838

3939
## **old** instructions
4040

components/project_management/src/java/main/com/topcoder/management/project/persistence/AbstractInformixProjectPersistence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,7 @@ public abstract class AbstractInformixProjectPersistence implements ProjectPersi
25492549
*/
25502550
private static final String INSERT_MM_ROUND_SQL = "INSERT INTO informixoltp:round(round_id, contest_id, name, status, "
25512551
+ "registration_limit, invitational, round_type_id, short_name, rated_ind) "
2552-
+ "VALUES (?, ?, ?, 'F', 1024, 0, 13, ?, 0)";
2552+
+ "VALUES (?, ?, ?, 'F', 1024, 0, 13, ?, 1)";
25532553

25542554
/**
25552555
* Sql statement for updating MM round

services/contest_service_facade/src/java/main/com/topcoder/service/facade/contest/ejb/ContestServiceFacadeBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,11 +3862,11 @@ else if (isDevContest)
38623862
contest.getProjectHeader().setProperty(ProjectPropertyType.TRACK_LATE_DELIVERABLES_PROJECT_PROPERTY_KEY, "false");
38633863
}
38643864

3865-
if (isCodeContest(contest) || isF2FContest(contest) || isDesignF2FContest(contest)) {
3866-
// no rated for Code || F2F || Design F2F
3865+
if (isF2FContest(contest) || isDesignF2FContest(contest)) {
3866+
// no rated for F2F || Design F2F
38673867
contest.getProjectHeader().setProperty(ProjectPropertyType.RATED_PROJECT_PROPERTY_KEY, "No");
38683868

3869-
// no Reiliability for Code || F2F || Design F2F
3869+
// no Reliability for Code || F2F || Design F2F
38703870
contest.getProjectHeader().setProperty(ProjectPropertyType.RELIABILITY_BONUS_ELIGIBLE_PROJECT_PROPERTY_KEY, "false");
38713871
contest.getProjectHeader().setProperty(ProjectPropertyType.RELIABILITY_BONUS_COST_PROJECT_PROPERTY_KEY, "0");
38723872

services/project_services/src/java/main/com/topcoder/project/service/impl/ProjectServicesImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,7 @@ public FullProjectData createProject(Project projectHeader, com.topcoder.project
15941594
phase.setId(0);
15951595
}
15961596

1597+
setScorecards(projectHeader, projectPhases);
15971598
// call phaseManager.updatePhases(projectPhases,operator)
15981599
Util.log(logger, Level.DEBUG, "Starts calling ProjectManager#updatePhases method.");
15991600
phaseManager.updatePhases(projectPhases, operator);

src/java/main/com/topcoder/direct/services/view/action/contest/DownloadAllSoftwareSubmissionsAction.java

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@
88
import com.topcoder.direct.services.view.action.contest.launch.ContestAction;
99
import com.topcoder.direct.services.view.dto.contest.ContestRoundType;
1010
import com.topcoder.direct.services.view.dto.contest.ContestType;
11+
import com.topcoder.direct.services.view.util.AmazonS3URI;
1112
import com.topcoder.direct.services.view.util.DirectUtils;
1213
import com.topcoder.management.deliverable.Submission;
1314
import com.topcoder.management.deliverable.Upload;
1415
import com.topcoder.management.resource.Resource;
1516
import com.topcoder.service.project.SoftwareCompetition;
1617
import com.topcoder.servlet.request.FileUpload;
1718
import com.topcoder.servlet.request.UploadedFile;
19+
import com.topcoder.shared.util.logging.Logger;
1820
import org.apache.commons.io.FilenameUtils;
19-
20-
import java.io.BufferedInputStream;
21-
import java.io.ByteArrayInputStream;
22-
import java.io.ByteArrayOutputStream;
23-
import java.io.InputStream;
24-
import java.io.PipedInputStream;
25-
import java.io.PipedOutputStream;
21+
import org.apache.http.HttpEntity;
22+
import org.apache.http.HttpResponse;
23+
import org.apache.http.HttpStatus;
24+
import org.apache.http.client.HttpResponseException;
25+
import org.apache.http.client.methods.HttpGet;
26+
import org.apache.http.impl.client.DefaultHttpClient;
27+
28+
import java.io.*;
2629
import java.util.ArrayList;
2730
import java.util.List;
2831
import java.util.zip.ZipEntry;
29-
import java.util.zip.ZipInputStream;
3032
import java.util.zip.ZipOutputStream;
3133

3234
/**
@@ -65,6 +67,11 @@
6567
*/
6668
public class DownloadAllSoftwareSubmissionsAction extends ContestAction {
6769

70+
/**
71+
* Logging instance
72+
*/
73+
private static final Logger logger = Logger.getLogger(DownloadAllSoftwareSubmissionsAction.class);
74+
6875
/**
6976
* The id of the final submission type.
7077
*
@@ -287,15 +294,42 @@ public void run() {
287294
byte[] buffer = new byte[8192];
288295
int read;
289296
InputStream is = null;
297+
DefaultHttpClient httpClient = new DefaultHttpClient();
290298
try {
291299
for (Submission sub : submissionsToDownload) {
292300
String submissionFileZipName;
293-
// url != null is s3
301+
// url != null is s3/external url
294302
if (sub.getUpload().getUrl() != null) {
295-
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
296-
DirectUtils.getS3FileKey(sub.getUpload().getUrl())));
297-
is = s3Object.getObjectContent();
298-
submissionFileZipName = DirectUtils.getS3FileKey(sub.getUpload().getUrl());
303+
try {
304+
AmazonS3URI s3Uri = DirectUtils.getS3Uri(sub.getUpload().getUrl());
305+
if (s3Uri != null) {
306+
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
307+
DirectUtils.getS3FileKey(sub.getUpload().getUrl())));
308+
is = s3Object.getObjectContent();
309+
submissionFileZipName = "Submission-" + sub.getId() + "-" + DirectUtils.getS3FileKey(sub.getUpload().getUrl());
310+
} else {
311+
// external url other than s3
312+
HttpGet request = new HttpGet(sub.getUpload().getUrl());
313+
HttpResponse response = httpClient.execute(request);
314+
// skip status code >=400
315+
if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_BAD_REQUEST) {
316+
throw new HttpResponseException(response.getStatusLine().getStatusCode(), "Invalid file from external");
317+
}
318+
319+
HttpEntity entity = response.getEntity();
320+
if (entity != null) {
321+
is = entity.getContent();
322+
} else {
323+
throw new HttpResponseException(HttpStatus.SC_BAD_REQUEST, "Invalid response from external");
324+
}
325+
submissionFileZipName = "Submission-" + sub.getId() + "-" + DirectUtils.getFileNameFromUrl(sub.getUpload().getUrl());
326+
}
327+
} catch (Exception e) {
328+
logger.error("Fail to get submission " + sub.getId() + " url: " + sub.getUpload().getUrl() +
329+
" message: " + e.getMessage());
330+
logger.info("Skipping submission " + sub.getId() + " url: " + sub.getUpload().getUrl());
331+
continue;
332+
}
299333
} else {
300334
UploadedFile file;
301335
if (DirectUtils.isStudio(contest)) {
@@ -350,6 +384,10 @@ public void run() {
350384
// ignore
351385
}
352386
}
387+
} finally {
388+
if (httpClient != null) {
389+
httpClient.getConnectionManager().shutdown();
390+
}
353391
}
354392
try {
355393
zos.close();

src/java/main/com/topcoder/direct/services/view/action/contest/DownloadSoftwareSubmissionAction.java

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55

66
import com.amazonaws.services.s3.model.GetObjectRequest;
77
import com.amazonaws.services.s3.model.S3Object;
8+
import com.amazonaws.services.s3.model.S3Object;
89
import com.topcoder.direct.services.view.action.BaseDirectStrutsAction;
910
import com.topcoder.direct.services.view.dto.contest.ContestType;
11+
import com.topcoder.direct.services.view.util.AmazonS3URI;
1012
import com.topcoder.direct.services.view.util.DirectUtils;
1113
import com.topcoder.management.deliverable.Submission;
1214
import com.topcoder.management.resource.Resource;
1315
import com.topcoder.service.project.SoftwareCompetition;
1416
import com.topcoder.servlet.request.FileUpload;
1517
import com.topcoder.servlet.request.UploadedFile;
18+
import org.apache.http.HttpEntity;
19+
import org.apache.http.HttpResponse;
20+
import org.apache.http.HttpStatus;
21+
import org.apache.http.client.HttpResponseException;
22+
import org.apache.http.client.methods.HttpGet;
23+
import org.apache.http.impl.client.DefaultHttpClient;
1624

1725
import java.io.InputStream;
1826

@@ -91,9 +99,9 @@ public class DownloadSoftwareSubmissionAction extends BaseDirectStrutsAction {
9199
private SoftwareCompetition contest;
92100

93101
/**
94-
* S3 url of uploaded file. Null if it use local file
102+
* External url of uploaded file. Null if it use local file
95103
*/
96-
private String s3Url;
104+
private String externalUrl;
97105

98106
/**
99107
* S3 bucket
@@ -144,7 +152,7 @@ protected void executeAction() throws Exception {
144152
uploadedFile = fileUpload.getUploadedFile(submission.getUpload().getParameter());
145153
}
146154
} else {
147-
s3Url = submission.getUpload().getUrl();
155+
externalUrl = submission.getUpload().getUrl();
148156
}
149157

150158
}
@@ -157,10 +165,27 @@ protected void executeAction() throws Exception {
157165
* if any error occurs when getting the input stream of the uploaded file.
158166
*/
159167
public InputStream getInputStream() throws Exception {
160-
if (s3Url != null) {
161-
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
162-
DirectUtils.getS3FileKey(s3Url)));
163-
return s3Object.getObjectContent();
168+
if (externalUrl != null) {
169+
AmazonS3URI s3Uri = DirectUtils.getS3Uri(externalUrl);
170+
if (s3Uri != null) {
171+
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
172+
DirectUtils.getS3FileKey(externalUrl)));
173+
return s3Object.getObjectContent();
174+
} else {
175+
DefaultHttpClient httpClient = new DefaultHttpClient();
176+
HttpGet request = new HttpGet(externalUrl);
177+
HttpResponse response = httpClient.execute(request);
178+
// skip status code >=400
179+
if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_BAD_REQUEST) {
180+
throw new HttpResponseException(response.getStatusLine().getStatusCode(), "Invalid file from external");
181+
}
182+
183+
HttpEntity entity = response.getEntity();
184+
if (entity == null) {
185+
throw new HttpResponseException(HttpStatus.SC_BAD_REQUEST, "Invalid response from external");
186+
}
187+
return entity.getContent();
188+
}
164189
}
165190

166191
if (contest.getProjectHeader().getProjectCategory().getId() == ContestType.COPILOT_POSTING.getId()) {
@@ -188,8 +213,12 @@ public InputStream getInputStream() throws Exception {
188213
* if any error occurs when getting the file name of the uploaded file.
189214
*/
190215
public String getContentDisposition() throws Exception {
191-
if (s3Url != null) {
192-
return "attachment; filename=\"submission-" + submission.getId() + "-" + DirectUtils.getS3FileKey(s3Url) + "\"";
216+
if (externalUrl != null) {
217+
AmazonS3URI s3Uri = DirectUtils.getS3Uri(externalUrl);
218+
if (s3Uri != null) {
219+
return "attachment; filename=\"submission-" + submission.getId() + "-" + DirectUtils.getS3FileKey(externalUrl) + "\"";
220+
}
221+
return "attachment; filename=\"submission-" + submission.getId() + "-" + DirectUtils.getFileNameFromUrl(externalUrl) + "\"";
193222
}
194223

195224
if (contest.getProjectHeader().getProjectCategory().getId() == ContestType.COPILOT_POSTING.getId()) {

src/java/main/com/topcoder/direct/services/view/ajax/SoftwareCompetitionBeanProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ private Object getMapResult(SoftwareCompetition bean) {
214214

215215
// retrieve review scorecard id.
216216
for(com.topcoder.project.phases.Phase phase : bean.getProjectPhases().getAllPhases()){
217-
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.REVIEW_PHASE.getName())){
217+
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.REVIEW_PHASE.getName()) && phase.getAttributes().get("Scorecard ID") != null){
218218
result.put("reviewScorecardId", phase.getAttributes().get("Scorecard ID").toString());
219219
}
220220

221-
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.ITERATIVE_REVIEW_PHASE.getName())){
221+
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.ITERATIVE_REVIEW_PHASE.getName()) && phase.getAttributes().get("Scorecard ID") != null){
222222
result.put("iterativeReviewScorecardId", phase.getAttributes().get("Scorecard ID").toString());
223223
}
224224
}

0 commit comments

Comments
 (0)