Commit 4160a796 authored by michael.simon's avatar michael.simon
Browse files

track update change time for external users

parent f95fd0c3
package edu.kit.scc.webreg.dto.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
......@@ -116,6 +117,7 @@ public class ExternalUserDtoServiceImpl extends BaseDtoServiceImpl<ExternalUserE
reverseMapper.copyProperties(dto, entity);
entity.setUidNumber(serialDao.next("uid-number-serial").intValue());
entity.setUserStatus(UserStatus.ACTIVE);
entity.setLastUpdate(new Date());
entity.setAdmin(role);
entity = dao.persist(entity);
}
......@@ -128,6 +130,7 @@ public class ExternalUserDtoServiceImpl extends BaseDtoServiceImpl<ExternalUserE
if (role.equals(entity.getAdmin())) {
reverseMapper.copyProperties(dto, entity);
entity.setLastUpdate(new Date());
fireUserChangeEvent(entity, "external");
}
else {
......@@ -142,8 +145,11 @@ public class ExternalUserDtoServiceImpl extends BaseDtoServiceImpl<ExternalUserE
throw new NoUserFoundException("no such user");
if (role.equals(entity.getAdmin())) {
entity.setUserStatus(UserStatus.ACTIVE);
fireUserChangeEvent(entity, "external");
if (! UserStatus.ACTIVE.equals(entity.getUserStatus())) {
entity.setUserStatus(UserStatus.ACTIVE);
entity.setLastStatusChange(new Date());
fireUserChangeEvent(entity, "external");
}
}
else {
throw new UnauthorizedException("You are not authorized to modify this external user");
......@@ -157,8 +163,11 @@ public class ExternalUserDtoServiceImpl extends BaseDtoServiceImpl<ExternalUserE
throw new NoUserFoundException("no such user");
if (role.equals(entity.getAdmin())) {
entity.setUserStatus(UserStatus.ON_HOLD);
fireUserChangeEvent(entity, "external");
if (! UserStatus.ON_HOLD.equals(entity.getUserStatus())) {
entity.setUserStatus(UserStatus.ON_HOLD);
entity.setLastStatusChange(new Date());
fireUserChangeEvent(entity, "external");
}
}
else {
throw new UnauthorizedException("You are not authorized to modify this external user");
......
......@@ -169,7 +169,8 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
}
try {
if ((System.currentTimeMillis() - user.getLastUpdate().getTime()) < expireTime) {
if ((user.getLastUpdate() != null) &&
((System.currentTimeMillis() - user.getLastUpdate().getTime()) < expireTime)) {
logger.info("Skipping user update for {} with id {}", new Object[] {user.getEppn(), user.getId()});
}
else {
......
Supports Markdown
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