Fix empty controller name (#925)
* Truncate target name when name is empty and controllerId exceeds name length limit * Add check if controllerId is null * Use seperate method to truncate controllerId + use Array.asList to create list * Make truncateControllerIdToMaxNameLength a static method * Additionally check target name by calling target management Signed-off-by: Sebastian Firsching <sebastian.firsching@bosch-si.com>
This commit is contained in:
committed by
Jeroen Laverman
parent
835757e93a
commit
62c876a435
@@ -192,10 +192,15 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
*/
|
||||
public JpaTarget(final String controllerId, final String securityToken) {
|
||||
this.controllerId = controllerId;
|
||||
setName(controllerId);
|
||||
setName(truncateControllerIdToMaxNameLength(controllerId));
|
||||
this.securityToken = securityToken;
|
||||
}
|
||||
|
||||
private static String truncateControllerIdToMaxNameLength(final String controllerId) {
|
||||
return controllerId != null && controllerId.length() > NAME_MAX_SIZE ? controllerId.substring(0, NAME_MAX_SIZE)
|
||||
: controllerId;
|
||||
}
|
||||
|
||||
JpaTarget() {
|
||||
// empty constructor for JPA.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user