Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-05-13 14:19:11 +03:00
commit c2f34f0299
2 changed files with 29 additions and 23 deletions

View File

@ -433,11 +433,17 @@ public class UserServiceImpl implements UserService {
UserEntity user = this.queryFactory.query(UserQuery.class).ids(userContactInfoEntity.getUserId()).isActive(IsActive.Active).first(); UserEntity user = this.queryFactory.query(UserQuery.class).ids(userContactInfoEntity.getUserId()).isActive(IsActive.Active).first();
if (user == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{userContactInfoEntity.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (user == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{userContactInfoEntity.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (this.userScope.getUserIdSafe() == null) throw new MyForbiddenException(this.errors.getForbidden().getCode(), this.errors.getForbidden().getMessage());
String token = this.createMergeAccountConfirmation(model.getEmail()); String token = this.createMergeAccountConfirmation(model.getEmail());
this.createMergeNotificationEvent(token, user, model.getEmail(), NotificationContactType.EMAIL); this.createMergeNotificationEvent(token, user, model.getEmail(), NotificationContactType.EMAIL);
} }
private void createMergeNotificationEvent(String token, UserEntity user, String email, NotificationContactType type) throws InvalidApplicationException { private void createMergeNotificationEvent(String token, UserEntity user, String email, NotificationContactType type) throws InvalidApplicationException {
UserEntity currentUser = this.entityManager.find(UserEntity.class, this.userScope.getUserIdSafe());
if (currentUser == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{ this.userScope.getUserIdSafe(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
NotifyIntegrationEvent event = new NotifyIntegrationEvent(); NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(user.getId()); event.setUserId(user.getId());
List<ContactPair> contactPairs = new ArrayList<>(); List<ContactPair> contactPairs = new ArrayList<>();
@ -448,7 +454,7 @@ public class UserServiceImpl implements UserService {
event.setNotificationType(this.notificationProperties.getMergeAccountConfirmationType()); event.setNotificationType(this.notificationProperties.getMergeAccountConfirmationType());
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{userName}", DataType.String, user.getName())); fieldInfoList.add(new FieldInfo("{userName}", DataType.String, currentUser.getName()));
fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token)); fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token));
fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(this.notificationProperties.getEmailExpirationTimeSeconds()))); fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(this.notificationProperties.getEmailExpirationTimeSeconds())));
data.setFields(fieldInfoList); data.setFields(fieldInfoList);
@ -515,7 +521,7 @@ public class UserServiceImpl implements UserService {
int hour = seconds / 60; int hour = seconds / 60;
int min = hour % 60; int min = hour % 60;
hour = hour / 60; hour = hour / 60;
return (hour + ":" + min + ":" + sec); return (String.format("%02d", hour) + ":" + String.format("%02d", min) + ":" + String.format("%02d", sec));
} }
public void confirmMergeAccount(String token) throws IOException, InvalidApplicationException { public void confirmMergeAccount(String token) throws IOException, InvalidApplicationException {

View File

@ -323,7 +323,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
this.userService.removeCredentialAccount({ credentialId: userCredential.user.id }).subscribe(result => { this.userService.removeCredentialAccount({ credentialId: userCredential.user.id }).subscribe(result => {
//TODO //TODO
}, },
error => console.error(error)); error => this.onCallbackError(error));
//TODO: refactor //TODO: refactor
// const unlinkAccountModel: UnlinkAccountRequestModel = { // const unlinkAccountModel: UnlinkAccountRequestModel = {
@ -373,7 +373,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
}); });
} }
}, },
error => console.error(error)); //TODO how to handle this error => this.onCallbackError(error)); //TODO how to handle this
//TODO refactor //TODO refactor