Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into IM-518-Error-in-k.…
Browse files Browse the repository at this point in the history
…hub-when-refreshing-a-page
  • Loading branch information
kristinaBc3 committed Jan 9, 2025
2 parents 54b5fd4 + ce7a6f5 commit 3ee9c8a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class TagNotificationController {
TagNotification tagNotification = tagNotificationService.createTagNotification(
ITagElementEnum.valueOf(tagRequest.getiTagElement()), tagRequest.getiTagElementId(),
HubNotificationMessage.Type.valueOf(tagRequest.getType()), Boolean.valueOf(tagRequest.getVisible()),
tagRequest.getName(), tagRequest.getTitle(), tagRequest.getMessage());
tagRequest.getName(), tagRequest.getTitle(), tagRequest.getMessage(), tagRequest.getNavigateTo());

return ResponseEntity.status(HttpStatus.OK).body(tagNotification);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,28 @@ public class TagNotification {
@DBRef
private MongoTag tag;

/**
* Type of notification
*/
@Enumerated(EnumType.STRING)
private Type type;

/**
* Title of notification
*/
private String title;

/**
* Message of notification
*/
private String message;

/**
* Indicates whether navigation is required and where to navigate to execute an action.
*/
private String navigateTo;


public String getTitle() {
return title;
}
Expand All @@ -44,7 +62,6 @@ public void setTitle(String title) {
this.title = title;
}

private String message;

public void setTag(MongoTag tag) {
this.tag = tag;
Expand Down Expand Up @@ -77,5 +94,7 @@ public void setType(Type type) {
public void setMessage(String message) {
this.message = message;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class TagRequest {
private String title;
private String message;
private String visible;
private String navigateTo;

public String getId() {
return id;
Expand Down Expand Up @@ -59,5 +60,11 @@ public String getVisible() {
public void setVisible(String visible) {
this.visible = visible;
}

public String getNavigateTo() {
return navigateTo;
}
public void setNavigateTo(String navigateTo) {
this.navigateTo = navigateTo;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TagNotificationService {
* @return
*/
public TagNotification createTagNotification(ITagElementEnum iTagElementEnum, String id,
HubNotificationMessage.Type tagNotifactionType, Boolean visible, String tagName, String title, String message) {
HubNotificationMessage.Type tagNotifactionType, Boolean visible, String tagName, String title, String message, String navigateTo) {

/* Create Mongo Tag */
MongoTag tag = new MongoTag();
Expand All @@ -71,6 +71,8 @@ public TagNotification createTagNotification(ITagElementEnum iTagElementEnum, St

tagNotification.setTitle(title);
tagNotification.setMessage(message);

tagNotification.setNavigateTo(navigateTo);

try {
tagNotificationRepository.save(tagNotification);
Expand Down Expand Up @@ -99,18 +101,19 @@ private void setITagElementById(MongoTag tag, ITagElementEnum iTagElementEnum, S
}

public TagNotification createWarningUserTagNotification(User user, String tagName, Boolean visible, String title,
String message) {
String message, String navigateTo) {
MongoTag tag = new MongoTag();
tag.setTagElementId(user.getId().isEmpty() ? null : user.getId());
tag.setITagElement(user);
tag.setName(tagName);
tag.setVisible(visible);
tag.setVisible(visible);

tag = mongoTagRepository.save(tag);
TagNotification tagNotification = new TagNotification();

tagNotification.setTag(tag);
tagNotification.setType(Type.WARNING);
tagNotification.setNavigateTo(navigateTo);

try {
tagNotificationRepository.save(tagNotification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ public interface UserProfileService {
* @throws MessagingException
*/
abstract ProfileResource createNewEmailRequest(String id, String requestNewEmail) throws MessagingException;
/**
* Update the email of user in mongo and ldap
* @param id
* @param email
* @return
*/
abstract ProfileResource updateUserEmail(String id, String email);

abstract User getUser(String username);

}
Original file line number Diff line number Diff line change
Expand Up @@ -168,45 +168,6 @@ public ProfileResource createNewEmailRequest(String username, String email) thro

}

@Override
public ProfileResource updateUserEmail(String username, String email) {
User user = getUser(username);
user.setEmail(email);

/* update mongo repository */
User updatedUser;

try {
updatedUser = new UpdateUser(user, userRepository).execute();
} catch (DuplicateKeyException e) {
logger.error(e.getMessage());
throw new KlabException("Duplicated key, email is already in use.");
} catch (Exception e) {
logger.error(e.getMessage());
throw new KlabException("Error updating mongo user: " + e.getMessage(), e);
}

/* update ldap */
// try {
// ldapServiceImpl.updateUserEmailAddress(username, email);
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// throw new KlabException("Error updating ldap user: " + e.getMessage(), e);
// }

try {
tagNotificationService.createWarningUserTagNotification(updatedUser,
TagNameEnum.downloadCertificateChangeEmail.toString(), false, "", "");

} catch (Exception e) {
logger.error(e.getMessage());
throw new KlabException(e.getMessage(), e);
}

ProfileResource updatedProfile = objectMapper.convertValue(updatedUser, ProfileResource.class);
return updatedProfile.getSafeProfile();
}

private User updateUserFromProfileResource(ProfileResource profile) {
User user;
try {
Expand Down
1 change: 1 addition & 0 deletions klab.hub/src/main/resources/static/ui/js/app.79b52333.js

Large diffs are not rendered by default.

0 comments on commit 3ee9c8a

Please sign in to comment.