use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class ClientDetailsEntityCacheManagerImpl method retrieveByIdP.
@Override
public ClientDetailsEntity retrieveByIdP(String idp) throws IllegalArgumentException {
Object key = new ClientIdCacheKey("IdP+" + idp, releaseName);
Date dbDate = retrieveLastModifiedDateByIdP(idp);
ClientDetailsEntity clientDetails = toClientDetailsEntity(clientDetailsCache.get(key));
if (needsFresh(dbDate, clientDetails)) {
try {
synchronized (lockers.obtainLock(idp)) {
clientDetails = toClientDetailsEntity(clientDetailsCache.get(key));
if (needsFresh(dbDate, clientDetails)) {
clientDetails = clientDetailsManager.findByIdP(idp);
if (clientDetails == null)
throw new IllegalArgumentException("Invalid idp " + idp);
clientDetailsCache.put(new Element(key, clientDetails));
}
}
} finally {
lockers.releaseLock(idp);
}
}
return clientDetails;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class OrcidProfileCacheManagerImpl method retrieveProfileBioAndInternal.
@Override
public OrcidProfile retrieveProfileBioAndInternal(String orcid) {
Object key = new OrcidCacheKey(orcid, releaseName);
Date dbDate = retrieveLastModifiedDate(orcid);
OrcidProfile op = toOrcidProfile(profileBioAndInternalCache.get(key));
if (needsFresh(dbDate, op))
try {
synchronized (profileBioAndInternalLockers.obtainLock(orcid)) {
op = toOrcidProfile(profileBioAndInternalCache.get(orcid));
if (needsFresh(dbDate, op)) {
op = orcidProfileManager.retrieveFreshOrcidProfile(orcid, LoadOptions.BIO_AND_INTERNAL_ONLY);
profileBioAndInternalCache.put(new Element(key, op));
}
}
} finally {
profileBioAndInternalLockers.releaseLock(orcid);
}
return op;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class WorkEntityCacheManagerImpl method retrieveMinimizedWork.
@Override
public MinimizedWorkEntity retrieveMinimizedWork(long workId, long workLastModified) {
Object key = new WorkCacheKey(workId, releaseName);
MinimizedWorkEntity minimizedWorkEntity = toMinimizedWork(getFromMinimizedWorkEntityCache(key));
if (minimizedWorkEntity == null || minimizedWorkEntity.getLastModified().getTime() < workLastModified) {
try {
synchronized (lockerMinimizedWork.obtainLock(Long.toString(workId))) {
minimizedWorkEntity = toMinimizedWork(getFromMinimizedWorkEntityCache(key));
if (minimizedWorkEntity == null || minimizedWorkEntity.getLastModified().getTime() < workLastModified) {
minimizedWorkEntity = workDao.getMinimizedWorkEntity(workId);
workDao.detach(minimizedWorkEntity);
minimizedWorkEntityCache.put(new Element(key, minimizedWorkEntity));
}
}
} finally {
lockerMinimizedWork.releaseLock(Long.toString(workId));
}
}
return minimizedWorkEntity;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class WorkEntityCacheManagerImpl method retrieveFullWork.
/**
* Retrieves a full WorkEntity
* @param workId
* @param workLastModified
* @return a WorkEntity
*/
@Override
public WorkEntity retrieveFullWork(String orcid, long workId, long workLastModified) {
Object key = new WorkCacheKey(workId, releaseName);
WorkEntity workEntity = (WorkEntity) toWorkBaseEntity(getFromFullWorkEntityCache(key));
if (workEntity == null || workEntity.getLastModified().getTime() < workLastModified) {
try {
synchronized (lockerFullWork.obtainLock(Long.toString(workId))) {
workEntity = (WorkEntity) toWorkBaseEntity(getFromFullWorkEntityCache(key));
if (workEntity == null || workEntity.getLastModified().getTime() < workLastModified) {
workEntity = workDao.getWork(orcid, workId);
workDao.detach(workEntity);
fullWorkEntityCache.put(new Element(key, workEntity));
}
}
} finally {
lockerMinimizedWork.releaseLock(Long.toString(workId));
}
}
return workEntity;
}
use of net.sf.ehcache.Element in project ORCID-Source by ORCID.
the class StatisticsCacheManagerImpl method setLatestStatisticsSummary.
@Override
public void setLatestStatisticsSummary() {
LOG.info("Getting the latest statistics summary");
StatisticsSummary summary = statisticsManagerReadOnly.getLatestStatisticsModel();
if (statisticsCache.get(CACHE_STATISTICS_KEY) == null) {
statisticsCache.put(new Element(CACHE_STATISTICS_KEY, summary));
} else {
statisticsCache.replace(new Element(CACHE_STATISTICS_KEY, summary));
}
}
Aggregations