Show username in tables (#946)
* formatting the username is slightly improved Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io> * formatting the username without steams Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io> * formatting the username without information about first or last name Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>
This commit is contained in:
@@ -34,7 +34,6 @@ import com.vaadin.server.VaadinService;
|
|||||||
public final class UserDetailsFormatter {
|
public final class UserDetailsFormatter {
|
||||||
|
|
||||||
private static final String TRIM_APPENDIX = "...";
|
private static final String TRIM_APPENDIX = "...";
|
||||||
private static final String DETAIL_SEPERATOR = ", ";
|
|
||||||
|
|
||||||
private UserDetailsFormatter() {
|
private UserDetailsFormatter() {
|
||||||
}
|
}
|
||||||
@@ -76,7 +75,7 @@ public final class UserDetailsFormatter {
|
|||||||
*
|
*
|
||||||
* @param baseEntity
|
* @param baseEntity
|
||||||
* the entity
|
* the entity
|
||||||
* @return the formatted 'last modefied by user name' (max 100 characters)
|
* @return the formatted 'last modified by user name' (max 100 characters)
|
||||||
* cannot be <null>
|
* cannot be <null>
|
||||||
*/
|
*/
|
||||||
public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) {
|
public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) {
|
||||||
@@ -125,21 +124,7 @@ public final class UserDetailsFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
|
final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
|
||||||
|
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
|
||||||
String lastname = StringUtils.defaultIfEmpty(userPrincipal.getLastname(), "");
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(lastname)) {
|
|
||||||
lastname += DETAIL_SEPERATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String firstAndLastname = lastname + StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), "");
|
|
||||||
|
|
||||||
final String trimmedUsername = trimAndFormatDetail(firstAndLastname, expectedNameLength);
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(trimmedUsername)) {
|
|
||||||
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
|
|
||||||
}
|
|
||||||
return trimmedUsername;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user