public void synchronizeUsers() {
Long since = null;
LOGGER.debug("Asking for users synchronisation");
try {
UserDao uDao = WOJServer.getInstance().getDataService().getUserDao();
// First we get the last time we have updated users
since = uDao.getLastUpdateTime();
LOGGER.debug("Synchronising with last upate time = " + TimeUtil.getDate(since.longValue()));
// We retrieve the users to add
User[] users = _portalSynchronizationService.getUpdatedUsers(since);
if (users != null) {
LOGGER.debug(users.length + " users to synchronize.");
for (int i = 0; i < users.length; i++) {
User u = users[i];
if (uDao.getUser(u.getLogin()) == null) {
uDao.insert(u);
LOGGER.debug(u + " has been inserted.");
} else {
uDao.update(u);
LOGGER.debug(u + " has been updated.");
}
}
LOGGER.debug(users.length + " users synchronized.");
}