Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 016be65

Browse files
author
sowerstl
committed
Add File Approval Email; (DOECODE-803)
1 parent fbe2ea3 commit 016be65

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/main/java/gov/osti/services/Metadata.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,24 @@ public Response asYAML(String object) {
910910
* @throws IOException on IO transmission errors
911911
*/
912912
private static void sendToArchiver(Long codeId, String repositoryLink, File archiveFile, File archiveContainer) throws IOException {
913+
sendToArchiver(codeId, repositoryLink, archiveFile, archiveContainer, false);
914+
}
915+
916+
/**
917+
* Send this Metadata to the ARCHIVER external support process.
918+
*
919+
* Needs a CODE ID and one of either an ARCHIVE FILE or REPOSITORY LINK.
920+
*
921+
* If nothing supplied to archive, do nothing.
922+
*
923+
* @param codeId the CODE ID for this METADATA
924+
* @param repositoryLink (optional) the REPOSITORY LINK value, or null if none
925+
* @param archiveFile (optional) the File recently uploaded to ARCHIVE, or null if none
926+
* @param archiveContainer (optional) the Container recently uploaded to ARCHIVE, or null if none
927+
* @param sendFileNotic (optional) let archiver know to send a file notification email, if needed
928+
* @throws IOException on IO transmission errors
929+
*/
930+
private static void sendToArchiver(Long codeId, String repositoryLink, File archiveFile, File archiveContainer, Boolean sendFileNotice) throws IOException {
913931
if ( "".equals(ARCHIVER_URL) )
914932
return;
915933

@@ -954,6 +972,9 @@ private static void sendToArchiver(Long codeId, String repositoryLink, File arch
954972
if (archiveContainer != null)
955973
mpe.addPart("container", new FileBody(archiveContainer, ContentType.DEFAULT_BINARY));
956974

975+
if (archiveFile != null)
976+
mpe.addPart("sendFileNotification", new StringBody(sendFileNotice.toString(), ContentType.TEXT_PLAIN));
977+
957978
post.setEntity(mpe.build());
958979
}
959980
HttpResponse response = hc.execute(post);
@@ -1794,9 +1815,9 @@ private Response doAnnounce(String json, InputStream file, FormDataContentDispos
17941815
File archiveContainer = null; //(null==container) ? null : new File(fullContainerName);
17951816
if (DOECodeMetadata.Accessibility.CO.equals(md.getAccessibility()))
17961817
// if CO project type, no need to archive the repo because it is local GitLab
1797-
sendToArchiver(md.getCodeId(), null, archiveFile, archiveContainer);
1818+
sendToArchiver(md.getCodeId(), null, archiveFile, archiveContainer, true);
17981819
else
1799-
sendToArchiver(md.getCodeId(), md.getRepositoryLink(), archiveFile, archiveContainer);
1820+
sendToArchiver(md.getCodeId(), md.getRepositoryLink(), archiveFile, archiveContainer, true);
18001821
} catch ( IOException e ) {
18011822
log.error("Archiver call failure: " + e.getMessage());
18021823
return ErrorResponse

0 commit comments

Comments
 (0)