Skip to content

Commit

Permalink
DCM: send email notification on checksum failure IQSS#3145
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jun 21, 2016
1 parent 9c7816a commit ac70aa1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ notification.email.returned.dataset.subject=Dataverse: Your dataset has been ret
notification.email.create.account.subject=Dataverse: Your account has been created
notification.email.assign.role.subject=Dataverse: You have been assigned a role
notification.email.revoke.role.subject=Dataverse: Your role has been revoked
notification.email.checksumfail.subject=Dataverse: Your upload failed checksum validation.

notification.email.greeting=Hello, \n
notification.email.welcome=Welcome to Dataverse! Get started by adding or finding data. Have questions? Check out the User Guide at {0}/{1}/user/ or contact Dataverse Support for assistance. Want to test out Dataverse features? Use our Demo Site at https://demo.dataverse.org
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ private String getSubjectTextBasedOnNotification(UserNotification userNotificati
return ResourceBundle.getBundle("Bundle").getString("notification.email.returned.dataset.subject");
case CREATEACC:
return ResourceBundle.getBundle("Bundle").getString("notification.email.create.account.subject");
case CHECKSUMFAIL:
return ResourceBundle.getBundle("Bundle").getString("notification.email.checksumfail.subject");
}
return "";
}
Expand Down Expand Up @@ -427,6 +429,13 @@ private String getMessageTextBasedOnNotification(UserNotification userNotificati
systemConfig.getVersion()
));
return messageText += accountCreatedMessage;
case CHECKSUMFAIL:
dataset = (Dataset) targetObject;
String checksumFailMessage = BundleUtil.getStringFromBundle("notification.checksumfail", Arrays.asList(
dataset.getGlobalId()
));
return messageText += checksumFailMessage;

}

return "";
Expand Down Expand Up @@ -457,6 +466,8 @@ private Object getObjectOfNotification (UserNotification userNotification){
return versionService.find(userNotification.getObjectId());
case CREATEACC:
return userNotification.getUser();
case CHECKSUMFAIL:
return datasetService.find(userNotification.getObjectId());
}
return null;
}
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ public void testCreateDatasetWithDcmDependency() {

/**
* @todo How can we test what the checksum validation notification looks
* like? There is no API for retrieving notifications.
* like in the GUI? There is no API for retrieving notifications.
*
* @todo How can we test that the email notification looks ok?
*/
// System.out.println("try logging in with " + username);
// System.out.println("try logging in with " + username);
// Meanwhile, the user trys uploading again...
JsonObjectBuilder goodNews = Json.createObjectBuilder();
goodNews.add("userId", userId);
Expand Down

1 comment on commit ac70aa1

@pdurbin
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A screenshot of how the email notification on checksum failure currently looks:

email-notification-checksumfail

Please sign in to comment.