Skip to content

Commit e3ef02f

Browse files
authored
Merge branch 'main' into 1973-proquest-export-diss_note
2 parents 4abdf18 + 54d2c82 commit e3ef02f

File tree

7 files changed

+39
-51
lines changed

7 files changed

+39
-51
lines changed

src/main/java/org/tdl/vireo/controller/SubmissionController.java

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.data.domain.Pageable;
4242
import org.springframework.data.domain.Sort.Direction;
4343
import org.springframework.data.web.PageableDefault;
44+
import org.springframework.http.HttpStatus;
4445
import org.springframework.messaging.simp.SimpMessagingTemplate;
4546
import org.springframework.security.access.prepost.PreAuthorize;
4647
import org.springframework.transaction.annotation.Transactional;
@@ -531,6 +532,16 @@ public void batchExport(HttpServletResponse response, @WeaverUser User user, @Pa
531532
processBatchExport(response, user, packagerName, activeFilter);
532533
}
533534

535+
private void handleBatchExportError(Exception e, HttpServletResponse response) throws IOException {
536+
LOG.info("Error With Export", e);
537+
String responseMessage = "Something went wrong with the export!";
538+
ApiResponse apiResponse = new ApiResponse(ERROR, responseMessage);
539+
response.reset();
540+
response.setContentType("application/json");
541+
response.getOutputStream().print(objectMapper.writeValueAsString(apiResponse));
542+
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
543+
}
544+
534545
@SuppressWarnings("unchecked")
535546
private void processBatchExport(HttpServletResponse response, User user, String packagerName, NamedSearchFilterGroup filter) throws IOException {
536547
AbstractPackager<?> packager = packagerUtility.getPackager(packagerName);
@@ -576,7 +587,7 @@ private void processBatchExport(HttpServletResponse response, User user, String
576587
break;
577588
case "MarcXML21":
578589
case "Marc21":
579-
ServletOutputStream sos = response.getOutputStream();
590+
ByteArrayOutputStream sos = new ByteArrayOutputStream();
580591

581592
try {
582593
ZipOutputStream zos = new ZipOutputStream(sos, StandardCharsets.UTF_8);
@@ -599,24 +610,19 @@ private void processBatchExport(HttpServletResponse response, User user, String
599610
}
600611
}
601612
zos.close();
602-
613+
response.getOutputStream().write(sos.toByteArray());
603614
response.setContentType(packager.getMimeType());
604615
response.setHeader("Content-Disposition", "inline; filename=" + packagerName + "." + packager.getFileExtension());
605616
} catch (Exception e) {
606-
LOG.info("Error With Export",e);
607-
response.setContentType("application/json");
608-
ApiResponse apiResponse = new ApiResponse(ERROR, "Something went wrong with the export!");
609-
sos.print(objectMapper.writeValueAsString(apiResponse));
610-
sos.close();
617+
handleBatchExportError(e, response);
611618
}
612619
break;
613620

614621
case "ProQuest":
615-
ServletOutputStream sos_pq = response.getOutputStream();
622+
ByteArrayOutputStream sos_pq = new ByteArrayOutputStream();
616623

617624
try {
618625
ZipOutputStream zos = new ZipOutputStream(sos_pq, StandardCharsets.UTF_8);
619-
620626
for (Submission submission : submissionRepo.batchDynamicSubmissionQuery(filter, columns)) {
621627
List<FieldValue> fieldValues = submission.getFieldValuesByPredicateValue("first_name");
622628
Optional<String> firstNameOpt = fieldValues.size() > 0 ? Optional.of(fieldValues.get(0).getValue()) : Optional.empty();
@@ -664,29 +670,22 @@ private void processBatchExport(HttpServletResponse response, User user, String
664670
b.putNextEntry(new ZipEntry(personName+fType));
665671
b.write(fileBytes);
666672
b.closeEntry();
667-
668-
}catch(IOException ioe){
669-
ioe.printStackTrace();
670673
}
671674
zos.putNextEntry(new ZipEntry("upload_"+personName+".zip"));
672675
baos.close();
673676
zos.write(baos.toByteArray());
674677
zos.closeEntry();
675678
}
676679
zos.close();
677-
678680
response.setContentType(packager.getMimeType());
681+
response.getOutputStream().write(sos_pq.toByteArray());
679682
response.setHeader("Content-Disposition", "inline; filename=" + packagerName + "." + packager.getFileExtension());
680683
} catch (Exception e) {
681-
LOG.info("Error With Export",e);
682-
response.setContentType("application/json");
683-
ApiResponse apiResponse = new ApiResponse(ERROR, "Something went wrong with the export!");
684-
sos_pq.print(objectMapper.writeValueAsString(apiResponse));
685-
sos_pq.close();
684+
handleBatchExportError(e, response);
686685
}
687686
break;
688687
case "DSpaceMETS":
689-
ServletOutputStream sos_mets = response.getOutputStream();
688+
ByteArrayOutputStream sos_mets = new ByteArrayOutputStream();
690689

691690
try {
692691
ZipOutputStream zos = new ZipOutputStream(sos_mets);
@@ -700,19 +699,15 @@ private void processBatchExport(HttpServletResponse response, User user, String
700699
zos.closeEntry();
701700
}
702701
zos.close();
703-
702+
response.getOutputStream().write(sos_mets.toByteArray());
704703
response.setContentType(packager.getMimeType());
705704
response.setHeader("Content-Disposition", "inline; filename=" + packagerName + "." + packager.getFileExtension());
706705
} catch (Exception e) {
707-
LOG.info("Error With Export",e);
708-
response.setContentType("application/json");
709-
ApiResponse apiResponse = new ApiResponse(ERROR, "Something went wrong with the export!");
710-
sos_mets.print(objectMapper.writeValueAsString(apiResponse));
711-
sos_mets.close();
706+
handleBatchExportError(e, response);
712707
}
713708
break;
714709
case "DSpaceSimple":
715-
ServletOutputStream sosDss = response.getOutputStream();
710+
ByteArrayOutputStream sosDss = new ByteArrayOutputStream();
716711
try {
717712
ZipOutputStream zos = new ZipOutputStream(sosDss);
718713
for (Submission submission : submissionRepo.batchDynamicSubmissionQuery(filter, columns)) {
@@ -772,25 +767,16 @@ private void processBatchExport(HttpServletResponse response, User user, String
772767

773768
}
774769
zos.close();
775-
770+
response.getOutputStream().write(sosDss.toByteArray());
776771
response.setContentType(packager.getMimeType());
777772
response.setHeader("Content-Disposition", "inline; filename=" + packagerName + "." + packager.getFileExtension());
778773
} catch (Exception e) {
779-
LOG.info("Error With Export",e);
780-
response.setContentType("application/json");
781-
ApiResponse apiResponse = new ApiResponse(ERROR, "Something went wrong with the export!");
782-
sosDss.print(objectMapper.writeValueAsString(apiResponse));
783-
sosDss.close();
774+
handleBatchExportError(e, response);
784775
}
785776
break;
786777

787778
default:
788-
response.setContentType("application/json");
789-
790-
ApiResponse apiResponse = new ApiResponse(ERROR, "No packager " + packagerName + " found!");
791-
PrintWriter out = response.getWriter();
792-
out.print(objectMapper.writeValueAsString(apiResponse));
793-
out.close();
779+
handleBatchExportError(new Exception("No packager " + packagerName + " found!"), response);
794780
}
795781

796782
response.getOutputStream().close();

src/main/java/org/tdl/vireo/controller/SubmissionListController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public ApiResponse addFilterCriterion(@WeaverUser User user, @RequestBody Map<St
234234
SubmissionListColumn column = submissionListColumnRepo.findByTitle(criterionName);
235235
for (NamedSearchFilter existingFilter : activeFilter.getNamedSearchFilters()) {
236236
if (existingFilter.getSubmissionListColumn() != null &&
237+
existingFilter.getSubmissionListColumn().getPredicate() != null &&
237238
existingFilter.getSubmissionListColumn().getPredicate().equals(column.getPredicate()) &&
238239
existingFilter.getSubmissionListColumn().getValuePath().equals(column.getValuePath())) {
239240
namedSearchFilter = existingFilter;

src/main/java/org/tdl/vireo/utility/SubmissionHelperUtility.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,15 +661,17 @@ public String getEmbargoLiftDate() {
661661
Optional<FieldValue> defaultEmbargo = getFirstFieldValueByPredicateValue("default_embargos");
662662

663663
Optional<FieldValue> embargo = Optional.empty();
664+
665+
Boolean proquestEmbargoCheck = proquestEmbargo.isPresent() && proquestEmbargo.get().getIdentifier() != null && Integer.valueOf(proquestEmbargo.get().getIdentifier()) > 0;
666+
Boolean defaultEmbargoCheck = defaultEmbargo.isPresent() && defaultEmbargo.get().getIdentifier() != null && Integer.valueOf(defaultEmbargo.get().getIdentifier()) > 0;
664667

665-
if (proquestEmbargo.isPresent() && Integer.valueOf(proquestEmbargo.get().getIdentifier()) > 0 &&
666-
defaultEmbargo.isPresent() && Integer.valueOf(defaultEmbargo.get().getIdentifier()) > 0) {
668+
if (proquestEmbargoCheck && defaultEmbargoCheck) {
667669
embargo = Integer.valueOf(proquestEmbargo.get().getIdentifier()) >= Integer.valueOf(defaultEmbargo.get().getIdentifier())
668670
? proquestEmbargo
669671
: defaultEmbargo;
670-
} else if (proquestEmbargo.isPresent() && Integer.valueOf(proquestEmbargo.get().getIdentifier()) > 0) {
672+
} else if (proquestEmbargoCheck) {
671673
embargo = proquestEmbargo;
672-
} else if (defaultEmbargo.isPresent() && Integer.valueOf(defaultEmbargo.get().getIdentifier()) > 0) {
674+
} else if (defaultEmbargoCheck) {
673675
embargo = defaultEmbargo;
674676
}
675677

src/main/resources/settings/SYSTEM_Defaults.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@
140140
"custom_css": "/* Insert Custom CSS here! */"
141141
},
142142
{
143-
"front_page_instructions_before": "<h1>Welcome to the Thesis<br/>&amp; Dissertation Submission System</h1>&#10;<p>Once you have passed the final defense and satisfied the requirements of the committee, you are ready to submit your manuscript to the Thesis Office for review. This submission process is fully electronic, and is made through an online application developed and maintained by the Texas Digital Library, in conjunction with Texas A&amp;M, Texas Tech, and Baylor Universities.</p>&#10;<p>To get started with your submission, click the link below. You will be asked to authenticate using your NetID:</p>"
144-
},
145-
{
146-
"front_page_instructions_after": "<h2>Your help can make things better</h2>&#10;<p>You feedback is very important to us; it allows us to continue to improve the system. Please feel free to notify us directly at dev@tdl.org if you have any suggestions to increase the usability or effectiveness of this application. You can talk to the your Thesis Office regarding any issues that may arise during the submission process.</p>"
143+
"front_page_instructions_before": "<h1>Welcome to the Thesis<br/>&amp; Dissertation Submission System</h1>&#10;<p>Once you have passed the final defense and satisfied the requirements of the committee, you are ready to submit your manuscript to the Thesis Office for review. This submission process is fully electronic, and is made through an online application developed and maintained by the Texas Digital Library along with open source community partners.</p>&#10;<p>To get started with your submission, click the link below. You will be asked to authenticate using your NetID:</p>"
147144
},
148145
{
149146
"post_submission_instructions": "<p>The Thesis Office has received your electronic submittal. You will also receive an email confirmation. We will check your records as soon as possible to determine whether or not we have the signed Approval Form on file. Please be aware that your file is not complete and cannot be reviewed until we have both the electronic manuscript and the signed Approval Form.</p>&#10;<p>As soon as both items have been received, your manuscript will be placed in the queue and will be processed along with all other submissions for the semester in the order in which your completed file (manuscript and Approval Form) was received.</p>&#10;<p>The following are approximate turn-around times after the manuscript and the signed approval form have been submitted to the Thesis Office.&#160;Manuscripts are reviewed in the order received.</p>&#10;<p>&#160;</p>&#10;<p>Early in semester &#8211; 5 working days</p>&#10;<p>Week before Deadline Day &#8211; 10 working days</p>&#10;<p>Deadline Day &#8211; 15 working days</p>&#10;<p>&#160;</p>&#10;<p>If you have any questions about your submittal, feel free to contact our office.</p>&#10;<p>&#160;</p>&#10;<p>Thank you, Thesis Office</p>"

src/main/webapp/app/controllers/submission/submissionListController.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,11 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle
440440
var batchDownloadExport = function (packager, filterId) {
441441
$scope.advancedfeaturesBox.exporting = true;
442442
SubmissionRepo.batchExport(packager, filterId).then(function (data) {
443-
saveAs(new Blob([data], {
444-
type: packager.mimeType
445-
}), packager.name + '.' + packager.fileExtension);
443+
if (!data.meta || !data.meta.status || data.meta.status !== "ERROR") {
444+
saveAs(new Blob([data], {
445+
type: packager.mimeType
446+
}), packager.name + '.' + packager.fileExtension);
447+
}
446448
resetBatchProcess();
447449
});
448450
};

src/main/webapp/app/views/sideboxes/submissionStatus.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
is-open="date"
2121
close-text="Close"
2222
stringtodate>
23-
<span ng-if="!box.savingDate" class="glyphicon glyphicon-pencil"></span> <span ng-if="box.savingDate" class="glyphicon glyphicon-refresh spinning"></span> {{box.submission.submissionDate || "not submitted" | date: 'M/d/yyyy'}}
23+
<span ng-if="!box.savingDate" class="glyphicon glyphicon-pencil"></span> <span ng-if="box.savingDate" class="glyphicon glyphicon-refresh spinning"></span> {{box.submission.submissionDate || "not submitted" | date: 'M/d/yyyy' : 'UTC'}}
2424
</li>
2525

2626
<li><button ng-click="openModal('#advisorEmail')" class="btn btn-default">Generate Advisor Email</button></li>

src/test/java/org/tdl/vireo/ApplicationInitializationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void assertInMemorySystemData(boolean isReload) throws ClassNotFoundExce
8080
assertSettingsType(2, "orcid", isReload);
8181
assertSettingsType(9, "proquest_umi_degree_code", isReload);
8282
assertSettingsType(1, "export", isReload);
83-
assertSettingsType(23, "lookAndFeel", isReload);
83+
assertSettingsType(22, "lookAndFeel", isReload);
8484
assertSettingsType(1, "submission", isReload);
8585
assertSettingsType(22, "shibboleth", isReload);
8686

0 commit comments

Comments
 (0)