Search in sources :

Example 26 with Element

use of net.sf.ehcache.Element in project ORCID-Source by ORCID.

the class OrcidGenerationManagerImpl method isInRecentOrcidCache.

private boolean isInRecentOrcidCache(String formattedOrcid) {
    LOGGER.debug("Recent ORCID cache size: {}", recentOrcidCache.getSize());
    Element alreadyUsed = recentOrcidCache.get(formattedOrcid);
    if (alreadyUsed != null) {
        LOGGER.debug("Same ORCID randomly generated a few moments ago: {}", formattedOrcid);
        return true;
    }
    return false;
}
Also used : Element(net.sf.ehcache.Element)

Example 27 with Element

use of net.sf.ehcache.Element in project ORCID-Source by ORCID.

the class OrcidGenerationManagerImpl method createNewOrcid.

@Override
public String createNewOrcid() {
    String orcid = getNextOrcid();
    while (isInRecentOrcidCache(orcid) || profileEntityManager.orcidExists(orcid)) {
        orcid = getNextOrcid();
    }
    recentOrcidCache.put(new Element(orcid, orcid));
    return orcid;
}
Also used : Element(net.sf.ehcache.Element)

Example 28 with Element

use of net.sf.ehcache.Element in project OpenClinica by OpenClinica.

the class EhCacheWrapper method get.

public V get(final K key) {
    String db_type = CoreResources.getField("dbType");
    if (db_type.equalsIgnoreCase("postgres")) {
        Element element = null;
        Ehcache ehCache = getCache();
        if (ehCache != null) {
            element = getCache().get(key);
            logMe("element  null" + element);
        }
        if (element != null) {
            logMe("element not null" + element);
            return (V) element.getObjectValue();
        }
    }
    return null;
}
Also used : Element(net.sf.ehcache.Element) Ehcache(net.sf.ehcache.Ehcache)

Example 29 with Element

use of net.sf.ehcache.Element in project OpenClinica by OpenClinica.

the class RandomizationRegistrar method getCachedRandomizationDTOObject.

public SeRandomizationDTO getCachedRandomizationDTOObject(String studyOid, Boolean resetCache) throws Exception {
    // check if exist in cache ;
    SeRandomizationDTO seRandomizationDTO = null;
    String ocUrl = CoreResources.getField("sysURL.base");
    String mapKey = ocUrl + studyOid;
    Element element = cache.get(mapKey);
    if (element != null && element.getObjectValue() != null && !resetCache) {
        seRandomizationDTO = (SeRandomizationDTO) element.getObjectValue();
    }
    if (seRandomizationDTO == null) {
        seRandomizationDTO = getRandomizationDTOObject(studyOid);
    }
    if (seRandomizationDTO != null) {
        cache.put(new Element(mapKey, seRandomizationDTO));
    }
    return seRandomizationDTO;
}
Also used : Element(net.sf.ehcache.Element)

Example 30 with Element

use of net.sf.ehcache.Element in project ORCID-Source by ORCID.

the class ClientDetailsEntityCacheManagerImpl method retrieve.

@Override
public ClientDetailsEntity retrieve(String clientId) throws IllegalArgumentException {
    Object key = new ClientIdCacheKey(clientId, releaseName);
    Date dbDate = retrieveLastModifiedDate(clientId);
    ClientDetailsEntity clientDetails = toClientDetailsEntity(clientDetailsCache.get(key));
    if (needsFresh(dbDate, clientDetails)) {
        try {
            synchronized (lockers.obtainLock(clientId)) {
                clientDetails = toClientDetailsEntity(clientDetailsCache.get(key));
                if (needsFresh(dbDate, clientDetails)) {
                    clientDetails = clientDetailsManager.findByClientId(clientId);
                    if (clientDetails == null)
                        throw new IllegalArgumentException("Invalid client id " + clientId);
                    clientDetailsCache.put(new Element(key, clientDetails));
                }
            }
        } finally {
            lockers.releaseLock(clientId);
        }
    }
    return clientDetails;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Element(net.sf.ehcache.Element) Date(java.util.Date)

Aggregations

Element (net.sf.ehcache.Element)114 Test (org.junit.Test)21 CacheKey (org.apereo.portal.utils.cache.CacheKey)8 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 Cache (net.sf.ehcache.Cache)7 HashSet (java.util.HashSet)6 CacheException (net.sf.ehcache.CacheException)6 MalformedURLException (java.net.MalformedURLException)5 ConfigurationException (javax.naming.ConfigurationException)5 Ehcache (net.sf.ehcache.Ehcache)5 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)5 EntityIdentifier (org.apereo.portal.EntityIdentifier)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 URISyntaxException (java.net.URISyntaxException)4 SQLException (java.sql.SQLException)4 EntityExistsException (javax.persistence.EntityExistsException)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 BaseCacheTest (org.apache.camel.component.BaseCacheTest)4