Search in sources :

Example 1 with InitialCacheUpdate

use of org.n52.sos.ds.cache.InitialCacheUpdate in project SOS by 52North.

the class SosCacheFeederHandler method updateCache.

@Override
public void updateCache(SosWritableContentCache cache) throws OwsExceptionReport {
    checkCacheNotNull(cache);
    List<OwsExceptionReport> errors = CollectionHelper.synchronizedList();
    Session session = null;
    try {
        InitialCacheUpdate update = new InitialCacheUpdate(this.cacheThreadCount, this.defaultLocale, this.i18NDAORepository, this.sessionStore, this.serviceMetadataRepository, geometryHandler);
        session = this.sessionStore.getSession();
        update.setCache(cache);
        update.setErrors(errors);
        update.setSession(session);
        LOGGER.info("Starting cache update");
        long cacheUpdateStartTime = System.currentTimeMillis();
        update.execute();
        logCacheLoadTime(cacheUpdateStartTime);
    } catch (Exception e) {
        LOGGER.error(ERROR_UPDATE_CACHE, e);
        errors.add(new NoApplicableCodeException().causedBy(e).withMessage(ERROR_UPDATE_CACHE));
    } finally {
        try {
            this.sessionStore.returnSession(session);
        } catch (Exception e2) {
            // TODO check why this is necessary
            LOGGER.error(ERROR_RETURNING_CONNECTION, e2);
        }
    }
    if (!errors.isEmpty()) {
        throw new CompositeOwsException(errors);
    }
}
Also used : NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) InitialCacheUpdate(org.n52.sos.ds.cache.InitialCacheUpdate) CompositeOwsException(org.n52.shetland.ogc.ows.exception.CompositeOwsException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) CompositeOwsException(org.n52.shetland.ogc.ows.exception.CompositeOwsException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) Session(org.hibernate.Session)

Aggregations

Session (org.hibernate.Session)1 CompositeOwsException (org.n52.shetland.ogc.ows.exception.CompositeOwsException)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 InitialCacheUpdate (org.n52.sos.ds.cache.InitialCacheUpdate)1