Skip to content

Commit

Permalink
enable set appName for external navigation API
Browse files Browse the repository at this point in the history
  • Loading branch information
shenqinb-star committed Feb 24, 2023
1 parent 4ae7600 commit bc889ef
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.boomerang.model.profile.Navigation;
import io.boomerang.model.profile.NavigationResponse;
import io.boomerang.model.profile.Platform;
import io.boomerang.mongo.model.Config;
import io.boomerang.mongo.service.FlowSettingsService;
import io.boomerang.security.model.UserToken;
import io.boomerang.security.service.ApiTokenService;
Expand Down Expand Up @@ -127,16 +128,29 @@ private NavigationResponse getExternalNavigationResponse(String email) {
NavigationResponse result = response.getBody();
if (result != null && result.getPlatform() != null) {
if(Strings.isBlank(result.getPlatform().getAppName())) {
// set default appName if the external Navigation API does NOT return appName.
String defaultAppName = settingsService.getConfiguration("customizations", "appName").getValue();
result.getPlatform().setAppName(defaultAppName);
// set default appName from settings if the external Navigation API does NOT return appName.
result.getPlatform().setAppName(this.getAppNameInSettings());
}
if(!Strings.isBlank(result.getPlatform().getPlatformName())) {
// add | to the end of the platformName
if(!Strings.isBlank(result.getPlatform().getPlatformName())
&& !Strings.isBlank(result.getPlatform().getAppName())) {
/*
* add | to the end of the platformName when both platformName and appName exist.
* The UI header will display like "platformName | appName"
*/
result.getPlatform().setPlatformName(result.getPlatform().getPlatformName() + " |");
}
}
return response.getBody();
return result;
}

private String getAppNameInSettings() {
try {
Config config = settingsService.getConfiguration("customizations", "appName");
return config == null ? null : config.getValue();
} catch (Exception e) {
}
// return null instead of throwing exception when appName is not configured in settings.
return null;
}

private HttpHeaders buildHeaders(String email) {
Expand All @@ -146,4 +160,4 @@ private HttpHeaders buildHeaders(String email) {
headers.setContentType(MediaType.APPLICATION_JSON);
return headers;
}
}
}

0 comments on commit bc889ef

Please sign in to comment.