Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.orcid.persistence.jpa.entities.keys.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

public class ClientDetailsManagerImpl extends ClientDetailsManagerReadOnlyImpl implements ClientDetailsManager {
Expand Down Expand Up @@ -311,14 +310,13 @@ public ClientDetailsEntity getPublicClient(String ownerId) {
}

/**
* Get member name (cacheable by client id).
*
* Get member name
*
* @param clientId
* The client id
* @return the name of the member owner of the given client
*/
* @return the name of the member owner of the given client
* */
@Override
@Cacheable(value = "member-name", key = "#clientId")
public String getMemberName(String clientId) {
return clientDetailsDao.getMemberName(clientId);
}
Expand Down
7 changes: 1 addition & 6 deletions orcid-core/src/main/resources/ehcache_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@
<ehcache:value-type copier="org.ehcache.impl.copy.IdentityCopier"/>
<ehcache:heap unit="entries">2000</ehcache:heap>
</ehcache:cache>

<ehcache:cache alias="member-name" uses-template="defaultTemplate">
<ehcache:value-type copier="org.ehcache.impl.copy.IdentityCopier"/>
<ehcache:heap unit="entries">25000</ehcache:heap>
</ehcache:cache>


<ehcache:cache alias="custom-email" uses-template="defaultTemplate">
<ehcache:value-type copier="org.ehcache.impl.copy.IdentityCopier"/>
<ehcache:heap unit="entries">2000</ehcache:heap>
Expand Down
8 changes: 0 additions & 8 deletions orcid-core/src/main/resources/ehcache_orcid-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,6 @@
</ehcache:expiry>
<ehcache:heap unit="entries">2000</ehcache:heap>
</ehcache:cache>

<ehcache:cache alias="member-name" uses-template="defaultTemplate">
<ehcache:value-type copier="org.ehcache.impl.copy.IdentityCopier"/>
<ehcache:expiry>
<ehcache:tti unit="minutes">30</ehcache:tti>
</ehcache:expiry>
<ehcache:heap unit="entries">25000</ehcache:heap>
</ehcache:cache>


<ehcache:cache alias="count-tokens" uses-template="defaultTemplate">
Expand Down
8 changes: 0 additions & 8 deletions orcid-core/src/main/resources/orcid-core-cache-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@
<property name="timeToIdleSeconds" value="${org.orcid.core.cache.client_details.timeToIdleSeconds:36000}" />
<property name="maxMegaBytesInMemory" value="${org.orcid.core.cache.client_details.maxMegaBytesInMemory:16}" />
<property name="maxMegaBytesOnDisk" value="${org.orcid.core.cache.client_details.maxMegaBytesOnDisk:128}" />
</bean>

<bean id="memberNameCache" class="org.orcid.core.utils.OrcidEhCacheFactoryBean">
<property name="cacheName" value="member-name" />
<property name="cacheManager" ref="coreCacheManager" />
<property name="timeToIdleSeconds" value="${org.orcid.core.cache.member_name.timeToIdleSeconds:3600}" />
<property name="maxMegaBytesInMemory" value="${org.orcid.core.cache.member_name.maxMegaBytesInMemory:16}" />
<property name="maxMegaBytesOnDisk" value="${org.orcid.core.cache.member_name.maxMegaBytesOnDisk:128}" />
</bean>

<bean id="identityProviderNameCache" class="org.orcid.core.utils.OrcidEhCacheFactoryBean">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.orcid.frontend.web.controllers;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -18,7 +17,6 @@
import org.orcid.core.manager.PreferenceManager;
import org.orcid.core.manager.ProfileEntityCacheManager;
import org.orcid.core.manager.v3.NotificationManager;
import org.orcid.core.manager.v3.read_only.ClientDetailsManagerReadOnly;
import org.orcid.core.manager.v3.read_only.EmailManagerReadOnly;
import org.orcid.jaxb.model.v3.release.common.Source;
import org.orcid.jaxb.model.v3.release.common.SourceClientId;
Expand Down Expand Up @@ -66,9 +64,6 @@ public class NotificationController extends BaseController {
@Resource(name = "emailManagerReadOnlyV3")
private EmailManagerReadOnly emailManagerReadOnly;

@Resource(name = "clientDetailsManagerReadOnlyV3")
private ClientDetailsManagerReadOnly clientDetailsManagerReadOnly;

@Resource
private EmailFrequencyManager emailFrequencyManager;

Expand All @@ -94,7 +89,6 @@ public void shutdown() {
addSubjectToNotifications(notifications);
setOverwrittenSourceName(notifications);
addSourceDescription(notifications);
addMemberNameToPermissionNotifications(notifications);
return notifications;
}

Expand Down Expand Up @@ -266,44 +260,7 @@ private void addSourceDescription(List<Notification> notifications) {
}
}

}
}
}
/**
* Override {@code sourceDescription} for PERMISSION notifications with the owning member name
* (group record credit name; i.e. who owns the client id).
*/
private void addMemberNameToPermissionNotifications(List<Notification> notifications) {
Map<String, String> memberNameByClientId = new HashMap<>();
for (Notification notification : notifications) {
if (!(notification instanceof NotificationPermission)) {
continue;
}
Source source = notification.getSource();
if (source == null) {
continue;
}

String clientId = source.retrieveSourcePath();
if (StringUtils.isBlank(clientId)) {
continue;
}

String memberName = memberNameByClientId.get(clientId);
if (!memberNameByClientId.containsKey(clientId)) {
try {
memberName = clientDetailsManagerReadOnly.getMemberName(clientId);
} catch (Exception e) {
memberName = null;
}
memberNameByClientId.put(clientId, memberName);
}

if (StringUtils.isBlank(memberName)) {
continue;
}

notification.setSourceDescription(memberName);
}
}
}
}