}
// 4.
log.debug("refreshing resource {}",resource);
try {
ClientResponse response = clientService.retrieveResource(resource);
if(response != null) {
log.info("refreshed resource {}",resource);
URI context = cacheProvider.getTripleRepository().getValueFactory().createURI(CTX_CACHE);
RepositoryConnection lmfConnection = cacheProvider.getTripleRepository().getConnection();
RepositoryConnection respConnection = response.getTriples().getConnection();
lmfConnection.remove(resource,null,null,context);
RepositoryResult<Statement> triples = respConnection.getStatements(null,null,null,true);
while(triples.hasNext()) {
Statement triple = triples.next();
try {
lmfConnection.add(triple,context);
} catch (RuntimeException ex) {
log.warn("not adding triple {}: an exception occurred ({})",triple,ex.getMessage());
}
}
lmfConnection.commit();
lmfConnection.close();
respConnection.close();
CacheEntry newEntry = new CacheEntry();
newEntry.setResource(resource);
newEntry.setExpiryDate(response.getExpires());
newEntry.setLastRetrieved(new Date());
if(entry != null) {
newEntry.setUpdateCount(entry.getUpdateCount()+1);
} else {
newEntry.setUpdateCount((long)1);