Search in sources :

Example 1 with ConsoleProviders

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;
}
Also used : ConsoleProviders(org.openremote.model.console.ConsoleProviders)

Example 2 with ConsoleProviders

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;
}
Also used : ConsoleAsset(org.openremote.model.asset.impl.ConsoleAsset) ConsoleProviders(org.openremote.model.console.ConsoleProviders) BadRequestException(javax.ws.rs.BadRequestException) UserAssetLink(org.openremote.model.asset.UserAssetLink)

Aggregations

ConsoleProviders (org.openremote.model.console.ConsoleProviders)2 BadRequestException (javax.ws.rs.BadRequestException)1 UserAssetLink (org.openremote.model.asset.UserAssetLink)1 ConsoleAsset (org.openremote.model.asset.impl.ConsoleAsset)1