use of org.openremote.model.console.ConsoleProviders in project openremote by openremote.
the class ConsoleAsset method setConsoleProvider.
public ConsoleAsset setConsoleProvider(String name, ConsoleProvider consoleProvider) {
ConsoleProviders providers = getAttributes().getValue(CONSOLE_PROVIDERS).orElse(new ConsoleProviders());
providers.put(name, consoleProvider);
setConsoleProviders(providers);
return this;
}
use of org.openremote.model.console.ConsoleProviders in project openremote by openremote.
the class ConsoleResourceImpl method register.
@Override
public ConsoleRegistration register(RequestParams requestParams, ConsoleRegistration consoleRegistration) {
if (getRequestTenant() == null) {
throw new BadRequestException("Invalid realm");
}
ConsoleAsset consoleAsset = null;
// If console registration has an id and asset exists then ensure asset type is console
if (!TextUtil.isNullOrEmpty(consoleRegistration.getId())) {
Asset<?> existingAsset = assetStorageService.find(consoleRegistration.getId(), true);
if (existingAsset != null && !(existingAsset instanceof ConsoleAsset)) {
throw new BadRequestException("Console registration ID is not for a Console asset: " + consoleRegistration.getId());
}
consoleAsset = (ConsoleAsset) existingAsset;
}
if (consoleAsset == null) {
consoleAsset = initConsoleAsset(consoleRegistration, true, true);
consoleAsset.setRealm(getRequestRealm());
consoleAsset.setParentId(getConsoleParentAssetId(getRequestRealm()));
consoleAsset.setId(consoleRegistration.getId());
}
consoleAsset.setConsoleName(consoleRegistration.getName()).setConsoleVersion(consoleRegistration.getVersion()).setConsoleProviders(new ConsoleProviders(consoleRegistration.getProviders())).setConsolePlatform(consoleRegistration.getPlatform());
consoleAsset = assetStorageService.merge(consoleAsset);
consoleRegistration.setId(consoleAsset.getId());
// If authenticated link the console to this user
if (isAuthenticated()) {
assetStorageService.storeUserAssetLinks(Collections.singletonList(new UserAssetLink(getAuthenticatedRealm(), getUserId(), consoleAsset.getId())));
}
return consoleRegistration;
}
Aggregations