Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ORCID/ORCID-Source
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Aug 16, 2024
2 parents 3338fbb + 48a69e0 commit ebd6d1c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v2.63.8 - 2024-08-14

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.63.7...v2.63.8)

- [#7067](https://github.com/ORCID/ORCID-Source/pull/7067): 1. Fixed the correct query string for showing first 10 resutls.

## v2.63.7 - 2024-08-13

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.63.6...v2.63.7)

## v2.63.6 - 2024-08-12

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.63.5...v2.63.6)
Expand Down
2 changes: 1 addition & 1 deletion orcid-api-web/tutorial/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Description: Search for records modified between January 1, 2018 and today

Paging: First 10 results

URL: ```https://pub.sandbox.orcid.org/v3.0/search/?q=profile-last-modified-date:%5B2018-01-01T00:00:00Z%20TO%20NOW%5D&start=1&rows=10```
URL: ```https://pub.sandbox.orcid.org/v3.0/search/?q=profile-last-modified-date:%5B2018-01-01T00:00:00Z%20TO%20NOW%5D&start=0&rows=10```

### Example 14

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import org.orcid.persistence.dao.EmailDomainDao;
import org.orcid.persistence.dao.ProfileEmailDomainDao;
import org.orcid.persistence.jpa.entities.EmailDomainEntity;
import org.orcid.persistence.jpa.entities.EmailEntity;
import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
Expand All @@ -20,14 +23,16 @@
*
*/
public class ProfileEmailDomainManagerImpl extends ProfileEmailDomainManagerReadOnlyImpl implements ProfileEmailDomainManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ProfileEmailDomainManagerImpl.class);

@Resource
protected ProfileEmailDomainDao profileEmailDomainDao;

@Resource
protected EmailDomainDao emailDomainDao;

@Resource
protected EmailDao emailDao;
@Resource(name = "emailDaoReadOnly")
protected EmailDao emailDaoReadOnly;

private static final String DEFAULT_DOMAIN_VISIBILITY = Visibility.PRIVATE.toString().toUpperCase();

Expand Down Expand Up @@ -66,13 +71,47 @@ public void updateEmailDomains(String orcid, org.orcid.pojo.ajaxForm.Emails newE
public void processDomain(String orcid, String email) {
String domain = email.split("@")[1];
EmailDomainEntity domainInfo = emailDomainDao.findByEmailDomain(domain);
String domainVisibility = DEFAULT_DOMAIN_VISIBILITY;
// Check if email is professional
if (domainInfo != null && domainInfo.getCategory().equals(EmailDomainEntity.DomainCategory.PROFESSIONAL)) {
ProfileEmailDomainEntity existingDomain = profileEmailDomainDao.findByEmailDomain(orcid, domain);
// ADD NEW DOMAIN IF ONE DOESN'T EXIST
if (existingDomain == null) {
profileEmailDomainDao.addEmailDomain(orcid, domain, DEFAULT_DOMAIN_VISIBILITY);
// Verify the user doesn't have more emails with that domain
List<EmailEntity> existingEmails = emailDaoReadOnly.findByOrcid(orcid, System.currentTimeMillis());
if(existingEmails != null && existingEmails.size() > 1) {
for(EmailEntity emailEntity : existingEmails) {
//If it is not the same emails that is being verified and it is verified
if(!email.equals(emailEntity.getEmail()) && emailEntity.getVerified()) {
try {
String emailEntityDomain = (emailEntity.getEmail() == null) ? null : (email.split("@")[1]);
// If one of the existing emails have the same domain as the email being verified check the visibility and select the less restrictive
if(domain.equals(emailEntityDomain)){
String entityVisibility = emailEntity.getVisibility();
domainVisibility = getLessRestrictiveVisibility(domainVisibility, entityVisibility);
}
} catch (Exception e) {
LOGGER.warn("Could not get email domain from email entity " + emailEntity.getEmail(), e);
}
}
}
}
profileEmailDomainDao.addEmailDomain(orcid, domain, domainVisibility);
}
}
}

private String getLessRestrictiveVisibility(String a, String b) {
String visibility = DEFAULT_DOMAIN_VISIBILITY;
if(Visibility.PUBLIC.name().equals(a) || Visibility.PUBLIC.name().equals(b)) {
visibility = Visibility.PUBLIC.name();
} else if(a.equals(b)) {
visibility = a;
} else if(Visibility.PRIVATE.name().equals(a)) {
visibility = b;
} else if(Visibility.PRIVATE.name().equals(b)) {
visibility = a;
}
return visibility;
}
}

0 comments on commit ebd6d1c

Please sign in to comment.