Skip to content

Commit 98ca256

Browse files
committed
fix[Challenge Details]: fix download issue
1 parent 19ee9e5 commit 98ca256

File tree

3 files changed

+126
-33
lines changed

3 files changed

+126
-33
lines changed

src/main/java/com/cronos/onlinereview/actions/projectdetails/BaseProjectDetailsAction.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,38 @@ protected CorrectnessCheckResult checkForCorrectUploadId(HttpServletRequest requ
125125
// Prepare bean that will be returned as the result
126126
CorrectnessCheckResult result = new CorrectnessCheckResult();
127127

128+
UploadManager upMgr = ActionsHelper.createUploadManager();
129+
Upload upload = null;
128130
// Verify that Upload ID was specified and denotes correct upload
129131
String uidParam = request.getParameter("uid");
130132
if (uidParam == null || uidParam.trim().length() == 0) {
131-
result.setResult(ActionsHelper.produceErrorReport(this, request, errorMessageKey,
132-
"Error.UploadIdNotSpecified", null));
133-
// Return the result of the check
134-
return result;
135-
}
136-
137-
long uid;
138-
139-
try {
140-
// Try to convert specified uid parameter to its integer representation
141-
uid = Long.parseLong(uidParam, 10);
142-
} catch (NumberFormatException nfe) {
143-
result.setResult(
144-
ActionsHelper.produceErrorReport(this, request, errorMessageKey, "Error.UploadNotFound", null));
145-
// Return the result of the check
146-
return result;
133+
String sidParam = request.getParameter("sid");
134+
if (sidParam == null || sidParam.trim().length() == 0) {
135+
result.setResult(ActionsHelper.produceErrorReport(this, request, errorMessageKey,
136+
"Error.UploadIdNotSpecified", null));
137+
// Return the result of the check
138+
return result;
139+
} else {
140+
try{
141+
Submission submission = upMgr.getSubmission(Long.parseLong(sidParam));
142+
upload = submission.getUpload();
143+
} catch (NumberFormatException nfe) {
144+
result.setResult(
145+
ActionsHelper.produceErrorReport(this, request, errorMessageKey, "Error.UploadNotFound", null));
146+
// Return the result of the check
147+
return result;
148+
}
149+
}
150+
} else {
151+
try{
152+
upload = upMgr.getUpload(Long.parseLong(uidParam, 10));
153+
} catch (NumberFormatException nfe) {
154+
result.setResult(
155+
ActionsHelper.produceErrorReport(this, request, errorMessageKey, "Error.UploadNotFound", null));
156+
// Return the result of the check
157+
return result;
158+
}
147159
}
148-
149-
// Obtain an instance of Upload Manager
150-
UploadManager upMgr = ActionsHelper.createUploadManager();
151-
// Get Upload by its ID
152-
Upload upload = upMgr.getUpload(uid);
153160
// Verify that upload with given ID exists
154161
if (upload == null) {
155162
result.setResult(

src/main/java/com/cronos/onlinereview/model/PhaseGroup.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public class PhaseGroup {
118118
*/
119119
private Submission[] submissions = null;
120120

121+
private boolean[] readyToDownload = null;
122+
121123
/**
122124
* This member variable holds an array of uploads of Submission type which were deleted due to a
123125
* newer version has been uploaded by Submitter, or <code>null</code> value if no such array
@@ -335,6 +337,8 @@ public class PhaseGroup {
335337
*/
336338
private Submission specificationSubmission;
337339

340+
private boolean specificationReadyToDownload;
341+
338342
/**
339343
* <p>A <code>Resource</code> providing the details for specification submitter.</p>
340344
*/
@@ -345,6 +349,8 @@ public class PhaseGroup {
345349
*/
346350
private Submission[] checkpointSubmissions;
347351

352+
private boolean[] checkpointReadyToDownload;
353+
348354
/**
349355
* <p>A <code>Resource</code> providing the details on checkpoint screener.</p>
350356
*/
@@ -396,6 +402,8 @@ public class PhaseGroup {
396402
*/
397403
private Submission iterativeReviewSubmission;
398404

405+
private boolean iterativeReadyToDownload;
406+
399407
/**
400408
* <p>A <code>Resource</code> providing the details for iterative review submitter.</p>
401409
*/
@@ -575,6 +583,11 @@ public Submission[] getSubmissions() {
575583
*/
576584
public void setSubmissions(Submission[] submissions) {
577585
this.submissions = submissions;
586+
this.readyToDownload = new boolean[submissions.length];
587+
for (int i = 0; i < submissions.length; i++) {
588+
Upload upload = submissions[i].getUpload();
589+
this.readyToDownload[i] = upload == null || upload.getUrl() == null || !ActionsHelper.isDmzBucket(upload.getUrl());
590+
}
578591
}
579592

580593
/**
@@ -1139,6 +1152,8 @@ public Submission getSpecificationSubmission() {
11391152
*/
11401153
public void setSpecificationSubmission(Submission specificationSubmission) {
11411154
this.specificationSubmission = specificationSubmission;
1155+
Upload upload = specificationSubmission.getUpload();
1156+
this.specificationReadyToDownload = upload == null || upload.getUrl() == null || !ActionsHelper.isDmzBucket(upload.getUrl());
11421157
}
11431158

11441159
/**
@@ -1194,7 +1209,7 @@ public Resource getSpecificationSubmitter() {
11941209
public void setSpecificationSubmitter(Resource specificationSubmitter) {
11951210
this.specificationSubmitter = specificationSubmitter;
11961211
}
1197-
1212+
11981213
/**
11991214
* <p>Gets the list of checkpoint reviews..</p>
12001215
*
@@ -1283,6 +1298,11 @@ public Submission[] getCheckpointSubmissions() {
12831298
*/
12841299
public void setCheckpointSubmissions(Submission[] checkpointSubmissions) {
12851300
this.checkpointSubmissions = checkpointSubmissions;
1301+
this.checkpointReadyToDownload = new boolean[checkpointSubmissions.length];
1302+
for (int i = 0; i < checkpointSubmissions.length; i++) {
1303+
Upload upload = checkpointSubmissions[i].getUpload();
1304+
this.checkpointReadyToDownload[i] = upload == null || upload.getUrl() == null || !ActionsHelper.isDmzBucket(upload.getUrl());
1305+
}
12861306
}
12871307

12881308
/**
@@ -1357,6 +1377,8 @@ public Submission getIterativeReviewSubmission() {
13571377
*/
13581378
public void setIterativeReviewSubmission(Submission iterativeReviewSubmission) {
13591379
this.iterativeReviewSubmission = iterativeReviewSubmission;
1380+
Upload upload = iterativeReviewSubmission.getUpload();
1381+
this.iterativeReadyToDownload = upload == null || upload.getUrl() == null || !ActionsHelper.isDmzBucket(upload.getUrl());
13601382
}
13611383

13621384
/**
@@ -1412,4 +1434,20 @@ public Resource getIterativeReviewSubmitter() {
14121434
public void setIterativeReviewSubmitter(Resource iterativeReviewSubmitter) {
14131435
this.iterativeReviewSubmitter = iterativeReviewSubmitter;
14141436
}
1415-
}
1437+
1438+
public boolean[] getReadyToDownload() {
1439+
return readyToDownload;
1440+
}
1441+
1442+
public boolean isSpecificationReadyToDownload() {
1443+
return specificationReadyToDownload;
1444+
}
1445+
1446+
public boolean[] getCheckpointReadyToDownload() {
1447+
return checkpointReadyToDownload;
1448+
}
1449+
1450+
public boolean isIterativeReadyToDownload() {
1451+
return iterativeReadyToDownload;
1452+
}
1453+
}

0 commit comments

Comments
 (0)