Skip to content

Commit

Permalink
Merge branch 'main' into 8875-update-the-email-verification-schedule-…
Browse files Browse the repository at this point in the history
…to-send-emails-2-7-and-28-days-after-email-creation
  • Loading branch information
amontenegro authored Oct 30, 2023
2 parents 64a0901 + 2a977ec commit 4bcff45
Show file tree
Hide file tree
Showing 101 changed files with 1,198 additions and 8,448 deletions.
75 changes: 75 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
## v2.43.3 - 2023-10-30

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

- [#6918](https://github.com/ORCID/ORCID-Source/pull/6918): 8889 prod looks like the ror loader is broken

## v2.43.2 - 2023-10-25

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

- [#6916](https://github.com/ORCID/ORCID-Source/pull/6916): fix: Invert selfAsserted and validated in sort by source

### Fix

- Invert selfAsserted and validated in sort by source

## v2.43.1 - 2023-10-25

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

- [#6914](https://github.com/ORCID/ORCID-Source/pull/6914): Shorter id

## v2.43.0 - 2023-10-25

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

- [#6913](https://github.com/ORCID/ORCID-Source/pull/6913): feature: Add functionality to capture user events in the database and…

### Fix

- Add missing label and fix test

### Feature

- Add functionality to capture user events in the database and create views to display info in panoply

## v2.42.6 - 2023-10-24

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

- [#6912](https://github.com/ORCID/ORCID-Source/pull/6912): add an option to configure timeout

## v2.42.5 - 2023-10-23

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

- [#6909](https://github.com/ORCID/ORCID-Source/pull/6909): fix: Update sort by source functionality to sort also alphabetically

### Fix

- Update external identifier is validates method
- Update sort by source functionality to sort also alphabetically

## v2.42.4 - 2023-10-20

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

- [#6907](https://github.com/ORCID/ORCID-Source/pull/6907): fix/remove-fundingSubType-core-details-from-codebase

### Fix

- remove fundingSubType core config manually removed from prod

## v2.42.3 - 2023-10-20

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

- [#6911](https://github.com/ORCID/ORCID-Source/pull/6911): Initial commit

## v2.42.2 - 2023-10-20

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

- [#6910](https://github.com/ORCID/ORCID-Source/pull/6910): 8855 duplicate isni external identifiers for same disambiguated organisation

## v2.42.1 - 2023-10-13

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.42.0...v2.42.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@
<constructor-arg index="1" value="${org.orcid.core.utils.cache.redis.port}" />
<constructor-arg index="2" value="${org.orcid.core.utils.cache.redis.password}" />
<constructor-arg index="3" value="${org.orcid.core.utils.cache.redis.expiration_in_secs:600}" />
<constructor-arg index="4" value="${org.orcid.core.utils.cache.redis.connection_timeout_millis:10000}" />
</bean>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import java.util.List;

import org.orcid.core.common.manager.impl.EmailDomainManagerImpl.STATUS;
import org.orcid.persistence.jpa.entities.EmailDomainEntity;

public interface EmailDomainManager {
EmailDomainEntity createEmailDomain(String emailDomain, EmailDomainEntity.DomainCategory category);

boolean updateCategory(long id, EmailDomainEntity.DomainCategory category);

EmailDomainEntity findByEmailDoman(String emailDomain);

List<EmailDomainEntity> findByCategory(EmailDomainEntity.DomainCategory category);

STATUS createOrUpdateEmailDomain(String emailDomain, String rorId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.orcid.core.common.manager;

import org.orcid.core.utils.EventType;
import org.orcid.pojo.ajaxForm.RequestInfoForm;

import javax.servlet.http.HttpServletRequest;

/**
*
* @author Daniel Palafox
*
*/
public interface EventManager {

boolean removeEvents(String orcid);

void createEvent(String orcid, EventType eventType, HttpServletRequest request, RequestInfoForm requestInfoForm);

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@

public class EmailDomainManagerImpl implements EmailDomainManager {

public enum STATUS {CREATED, UPDATED};

@Resource(name = "emailDomainDao")
private EmailDomainDao emailDomainDao;

@Resource(name = "emailDomainDaoReadOnly")
private EmailDomainDao emailDomainDaoReadOnly;

@Override
public EmailDomainEntity createEmailDomain(String emailDomain, DomainCategory category) {
private void validateEmailDomain(String emailDomain) {
if (emailDomain == null || emailDomain.isBlank()) {
throw new IllegalArgumentException("Email Domain must not be empty");
}
if(!InternetDomainName.isValid(emailDomain)) {
throw new IllegalArgumentException("Email Domain '" + emailDomain + "' is invalid");
}
}

@Override
public EmailDomainEntity createEmailDomain(String emailDomain, DomainCategory category) {
validateEmailDomain(emailDomain);
if (category == null) {
throw new IllegalArgumentException("Category must not be empty");
}
Expand Down Expand Up @@ -57,4 +63,22 @@ public List<EmailDomainEntity> findByCategory(DomainCategory category) {
return emailDomainDaoReadOnly.findByCategory(category);
}

@Override
public STATUS createOrUpdateEmailDomain(String emailDomain, String rorId) {
EmailDomainEntity existingEntity = emailDomainDaoReadOnly.findByEmailDoman(emailDomain);
if(existingEntity != null) {
if(!rorId.equals(existingEntity.getRorId())) {
boolean updated = emailDomainDao.updateRorId(existingEntity.getId(), rorId);
if(updated)
return STATUS.UPDATED;
}
} else {
EmailDomainEntity newEntity = emailDomainDao.createEmailDomain(emailDomain, DomainCategory.PROFESSIONAL, rorId);
if (newEntity != null) {
return STATUS.CREATED;
}
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package org.orcid.core.common.manager.impl;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.orcid.core.common.manager.EventManager;
import org.orcid.core.constants.OrcidOauth2Constants;
import org.orcid.core.manager.ClientDetailsEntityCacheManager;
import org.orcid.core.utils.EventType;
import org.orcid.persistence.dao.EventDao;
import org.orcid.persistence.jpa.entities.ClientDetailsEntity;
import org.orcid.persistence.jpa.entities.EventEntity;
import org.orcid.pojo.ajaxForm.RequestInfoForm;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

/**
*
* @author Daniel Palafox
*
*/
public class EventManagerImpl implements EventManager {

@Resource
private EventDao eventDao;

@Resource
private ClientDetailsEntityCacheManager clientDetailsEntityCacheManager;

@Override
public boolean removeEvents(String orcid) {
return eventDao.removeEvents(orcid);
}

@Override
public void createEvent(String orcid, EventType eventType, HttpServletRequest request, RequestInfoForm requestInfoForm) {
String label = "Website";
String clientId = null;
String redirectUrl = null;
String publicPage = null;

switch (eventType) {
case PUBLIC_PAGE:
publicPage = orcid;
orcid = null;
break;
case REAUTHORIZE:
clientId = requestInfoForm.getClientId();
redirectUrl = requestInfoForm.getRedirectUrl();
label = "OAuth " + requestInfoForm.getClientName();
break;
default:
if (request != null) {
Boolean isOauth2ScreensRequest = (Boolean) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_2SCREENS);
if (isOauth2ScreensRequest != null && isOauth2ScreensRequest) {
String queryString = (String) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_QUERY_STRING);
clientId = getParameterValue(queryString, "client_id");
redirectUrl = getParameterValue(queryString, "redirect_uri");
ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(clientId);
label = "OAuth " + clientDetailsEntity.getClientName();
}
}
}

EventEntity eventEntity = new EventEntity();

eventEntity.setOrcid(orcid);
eventEntity.setEventType(eventType.getValue());
eventEntity.setClientId(clientId);
eventEntity.setRedirectUrl(redirectUrl);
eventEntity.setLabel(label);
eventEntity.setPublicPage(publicPage);

eventDao.createEvent(eventEntity);
}

private String getParameterValue(String queryString, String parameter) {
if (StringUtils.isNotEmpty(queryString)) {
try {
queryString = URLDecoder.decode(queryString, StandardCharsets.UTF_8.toString());
} catch (UnsupportedEncodingException u) {
// l
}
String[] parameters = queryString.split("&");
for (String p : parameters) {
String[] keyValuePair = p.split("=");
if (parameter.equals(keyValuePair[0])) {
return keyValuePair[1];
}
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ public interface OrgDisambiguatedManager {
void createOrgDisambiguatedExternalIdentifier(OrgDisambiguatedExternalIdentifierEntity identifier);

public List<OrgDisambiguated> findOrgDisambiguatedIdsForSameExternalIdentifier(String identifier, String type);

public void cleanDuplicatedExternalIdentifiersForOrgDisambiguated(OrgDisambiguatedEntity orgDisambiguatedEntity);

}
Loading

0 comments on commit 4bcff45

Please sign in to comment.