Updated Sync Service
This commit is contained in:
parent
4b6cd01797
commit
2ab230a3ba
src
main
java/it/cnr/isti/epasmed
webapp/app
test/java/it/cnr/isti/epasmed/web/rest/sync
|
@ -34,270 +34,255 @@ import java.util.stream.Collectors;
|
||||||
@Transactional("epasMedTransactionManager")
|
@Transactional("epasMedTransactionManager")
|
||||||
public class UserService {
|
public class UserService {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(UserService.class);
|
private final Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||||
|
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
private final PersistentTokenRepository persistentTokenRepository;
|
private final PersistentTokenRepository persistentTokenRepository;
|
||||||
|
|
||||||
private final AuthorityRepository authorityRepository;
|
private final AuthorityRepository authorityRepository;
|
||||||
|
|
||||||
public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder, PersistentTokenRepository persistentTokenRepository, AuthorityRepository authorityRepository) {
|
public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder,
|
||||||
this.userRepository = userRepository;
|
PersistentTokenRepository persistentTokenRepository, AuthorityRepository authorityRepository) {
|
||||||
this.passwordEncoder = passwordEncoder;
|
this.userRepository = userRepository;
|
||||||
this.persistentTokenRepository = persistentTokenRepository;
|
this.passwordEncoder = passwordEncoder;
|
||||||
this.authorityRepository = authorityRepository;
|
this.persistentTokenRepository = persistentTokenRepository;
|
||||||
}
|
this.authorityRepository = authorityRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<User> activateRegistration(String key) {
|
public Optional<User> activateRegistration(String key) {
|
||||||
log.debug("Activating user for activation key {}", key);
|
logger.debug("Activating user for activation key {}", key);
|
||||||
return userRepository.findOneByActivationKey(key)
|
return userRepository.findOneByActivationKey(key).map(user -> {
|
||||||
.map(user -> {
|
// activate given user for the registration key.
|
||||||
// activate given user for the registration key.
|
user.setActivated(true);
|
||||||
user.setActivated(true);
|
user.setActivationKey(null);
|
||||||
user.setActivationKey(null);
|
logger.debug("Activated user: {}", user);
|
||||||
log.debug("Activated user: {}", user);
|
return user;
|
||||||
return user;
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<User> completePasswordReset(String newPassword, String key) {
|
public Optional<User> completePasswordReset(String newPassword, String key) {
|
||||||
log.debug("Reset user password for reset key {}", key);
|
logger.debug("Reset user password for reset key {}", key);
|
||||||
return userRepository.findOneByResetKey(key)
|
return userRepository.findOneByResetKey(key)
|
||||||
.filter(user -> user.getResetDate().isAfter(Instant.now().minusSeconds(86400)))
|
.filter(user -> user.getResetDate().isAfter(Instant.now().minusSeconds(86400))).map(user -> {
|
||||||
.map(user -> {
|
user.setPassword(passwordEncoder.encode(newPassword));
|
||||||
user.setPassword(passwordEncoder.encode(newPassword));
|
user.setResetKey(null);
|
||||||
user.setResetKey(null);
|
user.setResetDate(null);
|
||||||
user.setResetDate(null);
|
return user;
|
||||||
return user;
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<User> requestPasswordReset(String mail) {
|
public Optional<User> requestPasswordReset(String mail) {
|
||||||
return userRepository.findOneByEmailIgnoreCase(mail)
|
return userRepository.findOneByEmailIgnoreCase(mail).filter(User::getActivated).map(user -> {
|
||||||
.filter(User::getActivated)
|
user.setResetKey(RandomUtil.generateResetKey());
|
||||||
.map(user -> {
|
user.setResetDate(Instant.now());
|
||||||
user.setResetKey(RandomUtil.generateResetKey());
|
return user;
|
||||||
user.setResetDate(Instant.now());
|
});
|
||||||
return user;
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public User registerUser(UserDTO userDTO, String password) {
|
public User registerUser(UserDTO userDTO, String password) {
|
||||||
userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).ifPresent(existingUser -> {
|
userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).ifPresent(existingUser -> {
|
||||||
boolean removed = removeNonActivatedUser(existingUser);
|
boolean removed = removeNonActivatedUser(existingUser);
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
throw new UsernameAlreadyUsedException();
|
throw new UsernameAlreadyUsedException();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).ifPresent(existingUser -> {
|
userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).ifPresent(existingUser -> {
|
||||||
boolean removed = removeNonActivatedUser(existingUser);
|
boolean removed = removeNonActivatedUser(existingUser);
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
throw new EmailAlreadyUsedException();
|
throw new EmailAlreadyUsedException();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
User newUser = new User();
|
User newUser = new User();
|
||||||
String encryptedPassword = passwordEncoder.encode(password);
|
String encryptedPassword = passwordEncoder.encode(password);
|
||||||
newUser.setLogin(userDTO.getLogin().toLowerCase());
|
newUser.setLogin(userDTO.getLogin().toLowerCase());
|
||||||
// new user gets initially a generated password
|
// new user gets initially a generated password
|
||||||
newUser.setPassword(encryptedPassword);
|
newUser.setPassword(encryptedPassword);
|
||||||
newUser.setFirstName(userDTO.getFirstName());
|
newUser.setFirstName(userDTO.getFirstName());
|
||||||
newUser.setLastName(userDTO.getLastName());
|
newUser.setLastName(userDTO.getLastName());
|
||||||
if (userDTO.getEmail() != null) {
|
if (userDTO.getEmail() != null) {
|
||||||
newUser.setEmail(userDTO.getEmail().toLowerCase());
|
newUser.setEmail(userDTO.getEmail().toLowerCase());
|
||||||
}
|
}
|
||||||
newUser.setImageUrl(userDTO.getImageUrl());
|
newUser.setImageUrl(userDTO.getImageUrl());
|
||||||
newUser.setLangKey(userDTO.getLangKey());
|
newUser.setLangKey(userDTO.getLangKey());
|
||||||
// new user is not active
|
// new user is not active
|
||||||
newUser.setActivated(false);
|
newUser.setActivated(false);
|
||||||
// new user gets registration key
|
// new user gets registration key
|
||||||
newUser.setActivationKey(RandomUtil.generateActivationKey());
|
newUser.setActivationKey(RandomUtil.generateActivationKey());
|
||||||
Set<Authority> authorities = new HashSet<>();
|
Set<Authority> authorities = new HashSet<>();
|
||||||
authorityRepository.findById(AuthoritiesConstants.USER).ifPresent(authorities::add);
|
authorityRepository.findById(AuthoritiesConstants.USER).ifPresent(authorities::add);
|
||||||
newUser.setAuthorities(authorities);
|
newUser.setAuthorities(authorities);
|
||||||
userRepository.save(newUser);
|
userRepository.save(newUser);
|
||||||
log.debug("Created Information for User: {}", newUser);
|
logger.debug("Created Information for User: {}", newUser);
|
||||||
return newUser;
|
return newUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean removeNonActivatedUser(User existingUser) {
|
private boolean removeNonActivatedUser(User existingUser) {
|
||||||
if (existingUser.getActivated()) {
|
if (existingUser.getActivated()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
userRepository.delete(existingUser);
|
userRepository.delete(existingUser);
|
||||||
userRepository.flush();
|
userRepository.flush();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User createUser(UserDTO userDTO) {
|
public User createUser(UserDTO userDTO) {
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setLogin(userDTO.getLogin().toLowerCase());
|
user.setLogin(userDTO.getLogin().toLowerCase());
|
||||||
user.setFirstName(userDTO.getFirstName());
|
user.setFirstName(userDTO.getFirstName());
|
||||||
user.setLastName(userDTO.getLastName());
|
user.setLastName(userDTO.getLastName());
|
||||||
if (userDTO.getEmail() != null) {
|
if (userDTO.getEmail() != null) {
|
||||||
user.setEmail(userDTO.getEmail().toLowerCase());
|
user.setEmail(userDTO.getEmail().toLowerCase());
|
||||||
}
|
}
|
||||||
user.setImageUrl(userDTO.getImageUrl());
|
user.setImageUrl(userDTO.getImageUrl());
|
||||||
if (userDTO.getLangKey() == null) {
|
if (userDTO.getLangKey() == null) {
|
||||||
user.setLangKey(Constants.DEFAULT_LANGUAGE); // default language
|
user.setLangKey(Constants.DEFAULT_LANGUAGE); // default language
|
||||||
} else {
|
} else {
|
||||||
user.setLangKey(userDTO.getLangKey());
|
user.setLangKey(userDTO.getLangKey());
|
||||||
}
|
}
|
||||||
String encryptedPassword = passwordEncoder.encode(RandomUtil.generatePassword());
|
String encryptedPassword = passwordEncoder.encode(RandomUtil.generatePassword());
|
||||||
user.setPassword(encryptedPassword);
|
user.setPassword(encryptedPassword);
|
||||||
user.setResetKey(RandomUtil.generateResetKey());
|
user.setResetKey(RandomUtil.generateResetKey());
|
||||||
user.setResetDate(Instant.now());
|
user.setResetDate(Instant.now());
|
||||||
user.setActivated(true);
|
user.setActivated(true);
|
||||||
if (userDTO.getAuthorities() != null) {
|
if (userDTO.getAuthorities() != null) {
|
||||||
Set<Authority> authorities = userDTO.getAuthorities().stream()
|
Set<Authority> authorities = userDTO.getAuthorities().stream().map(authorityRepository::findById)
|
||||||
.map(authorityRepository::findById)
|
.filter(Optional::isPresent).map(Optional::get).collect(Collectors.toSet());
|
||||||
.filter(Optional::isPresent)
|
user.setAuthorities(authorities);
|
||||||
.map(Optional::get)
|
}
|
||||||
.collect(Collectors.toSet());
|
userRepository.save(user);
|
||||||
user.setAuthorities(authorities);
|
logger.debug("Created Information for User: {}", user);
|
||||||
}
|
return user;
|
||||||
userRepository.save(user);
|
}
|
||||||
log.debug("Created Information for User: {}", user);
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update all information for a specific user, and return the modified user.
|
* Update all information for a specific user, and return the modified user.
|
||||||
*
|
*
|
||||||
* @param userDTO user to update.
|
* @param userDTO user to update.
|
||||||
* @return updated user.
|
* @return updated user.
|
||||||
*/
|
*/
|
||||||
public Optional<UserDTO> updateUser(UserDTO userDTO) {
|
public Optional<UserDTO> updateUser(UserDTO userDTO) {
|
||||||
return Optional.of(userRepository
|
return Optional.of(userRepository.findById(userDTO.getId())).filter(Optional::isPresent).map(Optional::get)
|
||||||
.findById(userDTO.getId()))
|
.map(user -> {
|
||||||
.filter(Optional::isPresent)
|
user.setLogin(userDTO.getLogin().toLowerCase());
|
||||||
.map(Optional::get)
|
user.setFirstName(userDTO.getFirstName());
|
||||||
.map(user -> {
|
user.setLastName(userDTO.getLastName());
|
||||||
user.setLogin(userDTO.getLogin().toLowerCase());
|
if (userDTO.getEmail() != null) {
|
||||||
user.setFirstName(userDTO.getFirstName());
|
user.setEmail(userDTO.getEmail().toLowerCase());
|
||||||
user.setLastName(userDTO.getLastName());
|
}
|
||||||
if (userDTO.getEmail() != null) {
|
user.setImageUrl(userDTO.getImageUrl());
|
||||||
user.setEmail(userDTO.getEmail().toLowerCase());
|
user.setActivated(userDTO.isActivated());
|
||||||
}
|
user.setLangKey(userDTO.getLangKey());
|
||||||
user.setImageUrl(userDTO.getImageUrl());
|
Set<Authority> managedAuthorities = user.getAuthorities();
|
||||||
user.setActivated(userDTO.isActivated());
|
managedAuthorities.clear();
|
||||||
user.setLangKey(userDTO.getLangKey());
|
userDTO.getAuthorities().stream().map(authorityRepository::findById).filter(Optional::isPresent)
|
||||||
Set<Authority> managedAuthorities = user.getAuthorities();
|
.map(Optional::get).forEach(managedAuthorities::add);
|
||||||
managedAuthorities.clear();
|
logger.debug("Changed Information for User: {}", user);
|
||||||
userDTO.getAuthorities().stream()
|
return user;
|
||||||
.map(authorityRepository::findById)
|
}).map(UserDTO::new);
|
||||||
.filter(Optional::isPresent)
|
}
|
||||||
.map(Optional::get)
|
|
||||||
.forEach(managedAuthorities::add);
|
|
||||||
log.debug("Changed Information for User: {}", user);
|
|
||||||
return user;
|
|
||||||
})
|
|
||||||
.map(UserDTO::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteUser(String login) {
|
public void deleteUser(String login) {
|
||||||
userRepository.findOneByLogin(login).ifPresent(user -> {
|
userRepository.findOneByLogin(login).ifPresent(user -> {
|
||||||
userRepository.delete(user);
|
userRepository.delete(user);
|
||||||
log.debug("Deleted User: {}", user);
|
logger.debug("Deleted User: {}", user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update basic information (first name, last name, email, language) for the current user.
|
* Update basic information (first name, last name, email, language) for the
|
||||||
*
|
* current user.
|
||||||
* @param firstName first name of user.
|
*
|
||||||
* @param lastName last name of user.
|
* @param firstName first name of user.
|
||||||
* @param email email id of user.
|
* @param lastName last name of user.
|
||||||
* @param langKey language key.
|
* @param email email id of user.
|
||||||
* @param imageUrl image URL of user.
|
* @param langKey language key.
|
||||||
*/
|
* @param imageUrl image URL of user.
|
||||||
public void updateUser(String firstName, String lastName, String email, String langKey, String imageUrl) {
|
*/
|
||||||
SecurityUtils.getCurrentUserLogin()
|
public void updateUser(String firstName, String lastName, String email, String langKey, String imageUrl) {
|
||||||
.flatMap(userRepository::findOneByLogin)
|
SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneByLogin).ifPresent(user -> {
|
||||||
.ifPresent(user -> {
|
user.setFirstName(firstName);
|
||||||
user.setFirstName(firstName);
|
user.setLastName(lastName);
|
||||||
user.setLastName(lastName);
|
if (email != null) {
|
||||||
if (email != null) {
|
user.setEmail(email.toLowerCase());
|
||||||
user.setEmail(email.toLowerCase());
|
}
|
||||||
}
|
user.setLangKey(langKey);
|
||||||
user.setLangKey(langKey);
|
user.setImageUrl(imageUrl);
|
||||||
user.setImageUrl(imageUrl);
|
logger.debug("Changed Information for User: {}", user);
|
||||||
log.debug("Changed Information for User: {}", user);
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@Transactional(value = "epasMedTransactionManager")
|
||||||
|
public void changePassword(String currentClearTextPassword, String newPassword) {
|
||||||
|
//logger.debug("CurrenClearTextPassword: {}", currentClearTextPassword);
|
||||||
|
SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneByLogin).ifPresent(user -> {
|
||||||
|
String currentEncryptedPassword = user.getPassword();
|
||||||
|
//logger.debug("CurrentEncryptedPassword: {}", currentEncryptedPassword);
|
||||||
|
if (!passwordEncoder.matches(currentClearTextPassword, currentEncryptedPassword)) {
|
||||||
|
throw new InvalidPasswordException();
|
||||||
|
}
|
||||||
|
String encryptedPassword = passwordEncoder.encode(newPassword);
|
||||||
|
user.setPassword(encryptedPassword);
|
||||||
|
logger.debug("Changed password for User: {}", user);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(value="epasMedTransactionManager")
|
@Transactional(value = "epasMedTransactionManager", readOnly = true)
|
||||||
public void changePassword(String currentClearTextPassword, String newPassword) {
|
public Page<UserDTO> getAllManagedUsers(Pageable pageable) {
|
||||||
SecurityUtils.getCurrentUserLogin()
|
return userRepository.findAllByLoginNot(pageable, Constants.ANONYMOUS_USER).map(UserDTO::new);
|
||||||
.flatMap(userRepository::findOneByLogin)
|
}
|
||||||
.ifPresent(user -> {
|
|
||||||
String currentEncryptedPassword = user.getPassword();
|
|
||||||
if (!passwordEncoder.matches(currentClearTextPassword, currentEncryptedPassword)) {
|
|
||||||
throw new InvalidPasswordException();
|
|
||||||
}
|
|
||||||
String encryptedPassword = passwordEncoder.encode(newPassword);
|
|
||||||
user.setPassword(encryptedPassword);
|
|
||||||
log.debug("Changed password for User: {}", user);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(value="epasMedTransactionManager",readOnly = true)
|
@Transactional(value = "epasMedTransactionManager", readOnly = true)
|
||||||
public Page<UserDTO> getAllManagedUsers(Pageable pageable) {
|
public Optional<User> getUserWithAuthoritiesByLogin(String login) {
|
||||||
return userRepository.findAllByLoginNot(pageable, Constants.ANONYMOUS_USER).map(UserDTO::new);
|
return userRepository.findOneWithAuthoritiesByLogin(login);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value="epasMedTransactionManager",readOnly = true)
|
@Transactional(value = "epasMedTransactionManager", readOnly = true)
|
||||||
public Optional<User> getUserWithAuthoritiesByLogin(String login) {
|
public Optional<User> getUserWithAuthorities() {
|
||||||
return userRepository.findOneWithAuthoritiesByLogin(login);
|
return SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneWithAuthoritiesByLogin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value="epasMedTransactionManager",readOnly = true)
|
/**
|
||||||
public Optional<User> getUserWithAuthorities() {
|
* Persistent Token are used for providing automatic authentication, they should
|
||||||
return SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneWithAuthoritiesByLogin);
|
* be automatically deleted after 30 days.
|
||||||
}
|
* <p>
|
||||||
|
* This is scheduled to get fired everyday, at midnight.
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 0 * * ?")
|
||||||
|
public void removeOldPersistentTokens() {
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
|
||||||
|
logger.debug("Deleting token {}", token.getSeries());
|
||||||
|
User user = token.getUser();
|
||||||
|
user.getPersistentTokens().remove(token);
|
||||||
|
persistentTokenRepository.delete(token);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persistent Token are used for providing automatic authentication, they should be automatically deleted after
|
* Not activated users should be automatically deleted after 3 days.
|
||||||
* 30 days.
|
* <p>
|
||||||
* <p>
|
* This is scheduled to get fired everyday, at 01:00 (am).
|
||||||
* This is scheduled to get fired everyday, at midnight.
|
*/
|
||||||
*/
|
@Scheduled(cron = "0 0 1 * * ?")
|
||||||
@Scheduled(cron = "0 0 0 * * ?")
|
public void removeNotActivatedUsers() {
|
||||||
public void removeOldPersistentTokens() {
|
userRepository.findAllByActivatedIsFalseAndActivationKeyIsNotNullAndCreatedDateBefore(
|
||||||
LocalDate now = LocalDate.now();
|
Instant.now().minus(3, ChronoUnit.DAYS)).forEach(user -> {
|
||||||
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
|
logger.debug("Deleting not activated user {}", user.getLogin());
|
||||||
log.debug("Deleting token {}", token.getSeries());
|
userRepository.delete(user);
|
||||||
User user = token.getUser();
|
});
|
||||||
user.getPersistentTokens().remove(token);
|
}
|
||||||
persistentTokenRepository.delete(token);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not activated users should be automatically deleted after 3 days.
|
* Gets a list of all the authorities.
|
||||||
* <p>
|
*
|
||||||
* This is scheduled to get fired everyday, at 01:00 (am).
|
* @return a list of all the authorities.
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 1 * * ?")
|
@Transactional(value = "epasMedTransactionManager", readOnly = true)
|
||||||
public void removeNotActivatedUsers() {
|
public List<String> getAuthorities() {
|
||||||
userRepository
|
return authorityRepository.findAll().stream().map(Authority::getName).collect(Collectors.toList());
|
||||||
.findAllByActivatedIsFalseAndActivationKeyIsNotNullAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS))
|
}
|
||||||
.forEach(user -> {
|
|
||||||
log.debug("Deleting not activated user {}", user.getLogin());
|
|
||||||
userRepository.delete(user);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all the authorities.
|
|
||||||
* @return a list of all the authorities.
|
|
||||||
*/
|
|
||||||
@Transactional(value="epasMedTransactionManager",readOnly = true)
|
|
||||||
public List<String> getAuthorities() {
|
|
||||||
return authorityRepository.findAll().stream().map(Authority::getName).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1074,7 +1074,8 @@ public class SyncService {
|
||||||
if (eWTT.getUpdatedAt() != null && !eWTT.getUpdatedAt().isEmpty()) {
|
if (eWTT.getUpdatedAt() != null && !eWTT.getUpdatedAt().isEmpty()) {
|
||||||
LocalDateTime updatedAt = LocalDateTime.parse(eWTT.getUpdatedAt(), formatter);
|
LocalDateTime updatedAt = LocalDateTime.parse(eWTT.getUpdatedAt(), formatter);
|
||||||
if (lastUpdate.compareTo(updatedAt) < 0) {
|
if (lastUpdate.compareTo(updatedAt) < 0) {
|
||||||
Timestamp dataMod = Timestamp.valueOf(updatedAt);
|
LocalDateTime dMod=updatedAt.truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Timestamp dataMod = Timestamp.valueOf(dMod);
|
||||||
SIOrario siOrario = new SIOrario(Long.valueOf(eWTT.getId()), eWTT.getDescription(),
|
SIOrario siOrario = new SIOrario(Long.valueOf(eWTT.getId()), eWTT.getDescription(),
|
||||||
Boolean.valueOf(eWTT.getHorizontal()), Boolean.valueOf(eWTT.getDisabled()), dataMod,
|
Boolean.valueOf(eWTT.getHorizontal()), Boolean.valueOf(eWTT.getDisabled()), dataMod,
|
||||||
SI_FLAG_DEL_FALSE, fluxId);
|
SI_FLAG_DEL_FALSE, fluxId);
|
||||||
|
@ -1178,6 +1179,7 @@ public class SyncService {
|
||||||
Timestamp dataMod;
|
Timestamp dataMod;
|
||||||
try {
|
try {
|
||||||
LocalDateTime dMod = LocalDateTime.parse(epasStamping.getDate(), formatter);
|
LocalDateTime dMod = LocalDateTime.parse(epasStamping.getDate(), formatter);
|
||||||
|
dMod=dMod.truncatedTo(ChronoUnit.SECONDS);
|
||||||
dataMod = Timestamp.valueOf(dMod);
|
dataMod = Timestamp.valueOf(dMod);
|
||||||
} catch (IllegalArgumentException | DateTimeParseException e) {
|
} catch (IllegalArgumentException | DateTimeParseException e) {
|
||||||
logger.error("Invalid stamping data format: {}", e.getLocalizedMessage(), e);
|
logger.error("Invalid stamping data format: {}", e.getLocalizedMessage(), e);
|
||||||
|
@ -1334,7 +1336,9 @@ public class SyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp dataMod = Timestamp.valueOf(now);
|
LocalDateTime dMod=now.truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Timestamp dataMod = Timestamp.valueOf(dMod);
|
||||||
|
|
||||||
Integer durata = 0;
|
Integer durata = 0;
|
||||||
if (startDate != null && endDate != null) {
|
if (startDate != null && endDate != null) {
|
||||||
LocalDate startD = LocalDate.parse(leave.getStart());
|
LocalDate startD = LocalDate.parse(leave.getStart());
|
||||||
|
@ -1447,7 +1451,8 @@ public class SyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp dataMod = Timestamp.valueOf(now);
|
LocalDateTime dMod=now.truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Timestamp dataMod = Timestamp.valueOf(dMod);
|
||||||
|
|
||||||
SIPersOrario siPersOrario = new SIPersOrario(id, idPersona, pwtDTO.getCf(), startDate, endDate,
|
SIPersOrario siPersOrario = new SIPersOrario(id, idPersona, pwtDTO.getCf(), startDate, endDate,
|
||||||
pwtDTO.getDescrizione(), pwtDTO.getLun(), pwtDTO.getMar(), pwtDTO.getMer(), pwtDTO.getGio(),
|
pwtDTO.getDescrizione(), pwtDTO.getLun(), pwtDTO.getMar(), pwtDTO.getMer(), pwtDTO.getGio(),
|
||||||
|
@ -1482,7 +1487,8 @@ public class SyncService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Set Update DateTime
|
// Set Update DateTime
|
||||||
Timestamp dataMod = Timestamp.valueOf(now);
|
LocalDateTime dMod=now.truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Timestamp dataMod = Timestamp.valueOf(dMod);
|
||||||
|
|
||||||
logger.info("Persons Validated: {}", epasValidates.getValidatedPersons().length);
|
logger.info("Persons Validated: {}", epasValidates.getValidatedPersons().length);
|
||||||
checkFiscalCode(epasValidates.getValidatedPersons());
|
checkFiscalCode(epasValidates.getValidatedPersons());
|
||||||
|
@ -1554,7 +1560,8 @@ public class SyncService {
|
||||||
logger.info("Reference: {}-{}", year, month);
|
logger.info("Reference: {}-{}", year, month);
|
||||||
|
|
||||||
// Set Update DateTime
|
// Set Update DateTime
|
||||||
Timestamp dataMod = Timestamp.valueOf(now);
|
LocalDateTime dMod=now.truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Timestamp dataMod = Timestamp.valueOf(dMod);
|
||||||
|
|
||||||
// logger.info("Persons Validated: {}",
|
// logger.info("Persons Validated: {}",
|
||||||
// epasValidates.getValidatedPersons().length);
|
// epasValidates.getValidatedPersons().length);
|
||||||
|
|
|
@ -36,6 +36,9 @@ export class PasswordComponent implements OnInit {
|
||||||
if (newPassword !== this.passwordForm.get(['confirmPassword'])!.value) {
|
if (newPassword !== this.passwordForm.get(['confirmPassword'])!.value) {
|
||||||
this.doNotMatch = true;
|
this.doNotMatch = true;
|
||||||
} else {
|
} else {
|
||||||
|
// const cpwd=this.passwordForm.get(['currentPassword'])!.value;
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
// console.log(cpwd)
|
||||||
this.passwordService.save(newPassword, this.passwordForm.get(['currentPassword'])!.value).subscribe(
|
this.passwordService.save(newPassword, this.passwordForm.get(['currentPassword'])!.value).subscribe(
|
||||||
() => (this.success = true),
|
() => (this.success = true),
|
||||||
() => (this.error = true)
|
() => (this.error = true)
|
||||||
|
|
|
@ -58,6 +58,10 @@
|
||||||
(click)="sync('writesTimeCards')">Scrivi Cartellini</button>
|
(click)="sync('writesTimeCards')">Scrivi Cartellini</button>
|
||||||
<button class="btn btn-primary" type="button"
|
<button class="btn btn-primary" type="button"
|
||||||
(click)="sync('writesOffSiteWorks')">Scrivi Lavoro Fuori Sede</button>
|
(click)="sync('writesOffSiteWorks')">Scrivi Lavoro Fuori Sede</button>
|
||||||
|
<button class="btn btn-primary" type="button"
|
||||||
|
(click)="sync('writesLeaves')">Scrivi Aspettative</button>
|
||||||
|
<button class="btn btn-primary" type="button"
|
||||||
|
(click)="sync('writesPersonWorkingTime')">Scrivi Pers Orario</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
export type SyncType = 'test' | 'reads' | 'writesOrario' | 'writesTimeCards' | 'writesOffSiteWorks';
|
export type SyncType =
|
||||||
|
| 'test'
|
||||||
|
| 'reads'
|
||||||
|
| 'writesOrario'
|
||||||
|
| 'writesTimeCards'
|
||||||
|
| 'writesOffSiteWorks'
|
||||||
|
| 'writesLeaves'
|
||||||
|
| 'writesPersonWorkingTime';
|
||||||
|
|
|
@ -121,6 +121,8 @@ public class SyncResourceIT {
|
||||||
//dataMod = Timestamp.valueOf(dMod.format(formatterDataMod));
|
//dataMod = Timestamp.valueOf(dMod.format(formatterDataMod));
|
||||||
dataMod = Timestamp.valueOf(dMod);
|
dataMod = Timestamp.valueOf(dMod);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IllegalArgumentException | DateTimeParseException e) {
|
} catch (IllegalArgumentException | DateTimeParseException e) {
|
||||||
logger.error("Invalid stamping data format: {}", e.getLocalizedMessage(), e);
|
logger.error("Invalid stamping data format: {}", e.getLocalizedMessage(), e);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue