Fix widgets bundle and widget type alias creation.

This commit is contained in:
Igor Kulikov 2017-07-05 14:12:20 +03:00
parent 2543063e4a
commit 2ce15d5f6f
2 changed files with 8 additions and 3 deletions

View File

@ -124,8 +124,10 @@ public class WidgetTypeServiceImpl implements WidgetTypeService {
if (widgetsBundle == null) { if (widgetsBundle == null) {
throw new DataValidationException("Widget type is referencing to non-existent widgets bundle!"); throw new DataValidationException("Widget type is referencing to non-existent widgets bundle!");
} }
String alias = widgetType.getAlias();
String alias = widgetType.getName().toLowerCase().replaceAll("\\W+", "_"); if (alias == null || alias.trim().isEmpty()) {
alias = widgetType.getName().toLowerCase().replaceAll("\\W+", "_");
}
String originalAlias = alias; String originalAlias = alias;
int c = 1; int c = 1;
WidgetType withSameAlias; WidgetType withSameAlias;

View File

@ -169,7 +169,10 @@ public class WidgetsBundleServiceImpl implements WidgetsBundleService {
@Override @Override
protected void validateCreate(WidgetsBundle widgetsBundle) { protected void validateCreate(WidgetsBundle widgetsBundle) {
String alias = widgetsBundle.getTitle().toLowerCase().replaceAll("\\W+", "_"); String alias = widgetsBundle.getAlias();
if (alias == null || alias.trim().isEmpty()) {
alias = widgetsBundle.getTitle().toLowerCase().replaceAll("\\W+", "_");
}
String originalAlias = alias; String originalAlias = alias;
int c = 1; int c = 1;
WidgetsBundle withSameAlias; WidgetsBundle withSameAlias;