Commit 3b55cde6 authored by michael.simon's avatar michael.simon
Browse files

introduce expire timeout for async user update

parent 20d3e7c1
......@@ -13,6 +13,7 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import edu.kit.scc.webreg.bootstrap.ApplicationConfig;
import edu.kit.scc.webreg.dao.RegistryDao;
import edu.kit.scc.webreg.dao.ServiceDao;
import edu.kit.scc.webreg.dao.UserDao;
......@@ -56,6 +57,9 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
@Inject
private ServiceDao serviceDao;
@Inject
private ApplicationConfig appConfig;
@Override
public Map<String, String> updateUser(String eppn,
String serviceShortName, String localHostName)
......@@ -110,11 +114,25 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
return;
}
try {
user = userUpdater.updateUserFromIdp(user);
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", e.getMessage(), user.getEppn());
}
Long expireTime = 24 * 60 * 60 * 1000L; // one stay standard expire time for async checks
if (appConfig.getConfigValue("async_userupdate_expire_time") != null) {
expireTime = Long.parseLong(appConfig.getConfigValue("async_userupdate_expire_time"));
}
if ((System.currentTimeMillis() - user.getLastUpdate().getTime()) < expireTime) {
logger.info("Skipping async attributequery for {} with {}@{}", new Object[] {user.getEppn(),
user.getPersistentId(), user.getIdp().getEntityId()});
}
else {
logger.info("Performing async attributequery for {} with {}@{}", new Object[] {user.getEppn(),
user.getPersistentId(), user.getIdp().getEntityId()});
try {
user = userUpdater.updateUserFromIdp(user);
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", e.getMessage(), user.getEppn());
}
}
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment