Skip to content

Commit

Permalink
different required fileds when download hamledt (#729)
Browse files Browse the repository at this point in the history
* send email when SEND_TOKEN is required to EXTRA_EMAIL address

* removed unwanted line
  • Loading branch information
Paurikova2 authored Aug 20, 2024
1 parent 3a8443b commit b4adbad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class ClarinLicense implements ReloadableEntity<Integer> {
* Required info key word.
*/
public static final String SEND_TOKEN = "SEND_TOKEN";
public static final String EXTRA_EMAIL = "EXTRA_EMAIL";

@Id
@Column(name = "license_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.dspace.app.rest.utils.ContextUtil.obtainContext;
import static org.dspace.content.clarin.ClarinLicense.EXTRA_EMAIL;
import static org.dspace.content.clarin.ClarinLicense.SEND_TOKEN;
import static org.dspace.content.clarin.ClarinUserRegistration.ANONYMOUS_USER_REGISTRATION;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
Expand Down Expand Up @@ -395,7 +396,7 @@ private void sendAdminNotificationEmail(Context context,
}

private String getEmailFromUserMetadata(List<ClarinUserMetadataRest> clarinUserMetadataRestList) {
return getFieldFromUserMetadata(SEND_TOKEN, clarinUserMetadataRestList);
return getFieldFromUserMetadata(EXTRA_EMAIL, clarinUserMetadataRestList);
}

private String getFieldFromUserMetadata(String field, List<ClarinUserMetadataRest> clarinUserMetadataRestList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ public void notAuthorizedUser_shouldSendEmail() throws Exception {

ClarinUserMetadataRest clarinUserMetadata3 = new ClarinUserMetadataRest();
clarinUserMetadata3.setMetadataKey("SEND_TOKEN");
clarinUserMetadata3.setMetadataValue("[email protected]");

ClarinUserMetadataRest clarinUserMetadata4 = new ClarinUserMetadataRest();
clarinUserMetadata4.setMetadataKey("EXTRA_EMAIL");
clarinUserMetadata4.setMetadataValue("[email protected]");

List<ClarinUserMetadataRest> clarinUserMetadataRestList = new ArrayList<>();
clarinUserMetadataRestList.add(clarinUserMetadata1);
clarinUserMetadataRestList.add(clarinUserMetadata2);
clarinUserMetadataRestList.add(clarinUserMetadata3);
clarinUserMetadataRestList.add(clarinUserMetadata4);

String adminToken = getAuthToken(admin.getEmail(), password);
// Load bitstream from the item.
Expand Down Expand Up @@ -256,12 +260,16 @@ public void authorizedUserWithoutMetadata_shouldSendEmail() throws Exception {

ClarinUserMetadataRest clarinUserMetadata3 = new ClarinUserMetadataRest();
clarinUserMetadata3.setMetadataKey("SEND_TOKEN");
clarinUserMetadata3.setMetadataValue("[email protected]");

ClarinUserMetadataRest clarinUserMetadata4 = new ClarinUserMetadataRest();
clarinUserMetadata4.setMetadataKey("EXTRA_EMAIL");
clarinUserMetadata4.setMetadataValue("[email protected]");

List<ClarinUserMetadataRest> clarinUserMetadataRestList = new ArrayList<>();
clarinUserMetadataRestList.add(clarinUserMetadata1);
clarinUserMetadataRestList.add(clarinUserMetadata2);
clarinUserMetadataRestList.add(clarinUserMetadata3);
clarinUserMetadataRestList.add(clarinUserMetadata4);

String adminToken = getAuthToken(admin.getEmail(), password);

Expand Down Expand Up @@ -359,12 +367,16 @@ public void authorizedUserWithMetadata_shouldSendEmail() throws Exception {

ClarinUserMetadataRest clarinUserMetadata3 = new ClarinUserMetadataRest();
clarinUserMetadata3.setMetadataKey("SEND_TOKEN");
clarinUserMetadata3.setMetadataValue("[email protected]");

ClarinUserMetadataRest clarinUserMetadata4 = new ClarinUserMetadataRest();
clarinUserMetadata4.setMetadataKey("EXTRA_EMAIL");
clarinUserMetadata4.setMetadataValue("[email protected]");

List<ClarinUserMetadataRest> clarinUserMetadataRestList = new ArrayList<>();
clarinUserMetadataRestList.add(clarinUserMetadata1);
clarinUserMetadataRestList.add(clarinUserMetadata2);
clarinUserMetadataRestList.add(clarinUserMetadata3);
clarinUserMetadataRestList.add(clarinUserMetadata4);

String adminToken = getAuthToken(admin.getEmail(), password);

Expand Down

0 comments on commit b4adbad

Please sign in to comment.