Search in sources :

Example 1 with FlowResourceImpl

use of org.openremote.manager.rules.flow.FlowResourceImpl in project openremote by openremote.

the class RulesService method init.

@Override
public void init(Container container) throws Exception {
    executorService = container.getExecutorService();
    timerService = container.getService(TimerService.class);
    persistenceService = container.getService(PersistenceService.class);
    rulesetStorageService = container.getService(RulesetStorageService.class);
    identityService = container.getService(ManagerIdentityService.class);
    notificationService = container.getService(NotificationService.class);
    assetStorageService = container.getService(AssetStorageService.class);
    assetProcessingService = container.getService(AssetProcessingService.class);
    assetDatapointService = container.getService(AssetDatapointService.class);
    assetPredictedDatapointService = container.getService(AssetPredictedDatapointService.class);
    clientEventService = container.getService(ClientEventService.class);
    gatewayService = container.getService(GatewayService.class);
    if (initDone) {
        return;
    }
    clientEventService.addSubscriptionAuthorizer((realm, auth, subscription) -> {
        if (subscription.isEventType(RulesEngineStatusEvent.class) || subscription.isEventType(RulesetChangedEvent.class)) {
            if (auth == null) {
                return false;
            }
            if (auth.isSuperUser()) {
                return true;
            }
            // Regular user must have role
            if (!auth.hasResourceRole(ClientRole.READ_ASSETS.getValue(), auth.getClientId())) {
                return false;
            }
            boolean isRestrictedUser = identityService.getIdentityProvider().isRestrictedUser(auth);
            return !isRestrictedUser;
        }
        return false;
    });
    ServiceLoader.load(GeofenceAssetAdapter.class).forEach(geofenceAssetAdapter -> {
        LOG.fine("Adding GeofenceAssetAdapter: " + geofenceAssetAdapter.getClass().getName());
        geofenceAssetAdapters.add(geofenceAssetAdapter);
    });
    geofenceAssetAdapters.addAll(container.getServices(GeofenceAssetAdapter.class));
    geofenceAssetAdapters.sort(Comparator.comparingInt(GeofenceAssetAdapter::getPriority));
    container.getService(MessageBrokerService.class).getContext().addRoutes(this);
    configEventExpires = getString(container.getConfig(), RULE_EVENT_EXPIRES, RULE_EVENT_EXPIRES_DEFAULT);
    container.getService(ManagerWebService.class).addApiSingleton(new FlowResourceImpl(container.getService(TimerService.class), container.getService(ManagerIdentityService.class)));
    initDone = true;
}
Also used : AssetStorageService(org.openremote.manager.asset.AssetStorageService) AssetPredictedDatapointService(org.openremote.manager.datapoint.AssetPredictedDatapointService) AssetProcessingService(org.openremote.manager.asset.AssetProcessingService) GeofenceAssetAdapter(org.openremote.manager.rules.geofence.GeofenceAssetAdapter) NotificationService(org.openremote.manager.notification.NotificationService) TimerService(org.openremote.container.timer.TimerService) GatewayService(org.openremote.manager.gateway.GatewayService) PersistenceService(org.openremote.container.persistence.PersistenceService) ManagerIdentityService(org.openremote.manager.security.ManagerIdentityService) AssetDatapointService(org.openremote.manager.datapoint.AssetDatapointService) ManagerWebService(org.openremote.manager.web.ManagerWebService) ClientEventService(org.openremote.manager.event.ClientEventService) FlowResourceImpl(org.openremote.manager.rules.flow.FlowResourceImpl)

Aggregations

PersistenceService (org.openremote.container.persistence.PersistenceService)1 TimerService (org.openremote.container.timer.TimerService)1 AssetProcessingService (org.openremote.manager.asset.AssetProcessingService)1 AssetStorageService (org.openremote.manager.asset.AssetStorageService)1 AssetDatapointService (org.openremote.manager.datapoint.AssetDatapointService)1 AssetPredictedDatapointService (org.openremote.manager.datapoint.AssetPredictedDatapointService)1 ClientEventService (org.openremote.manager.event.ClientEventService)1 GatewayService (org.openremote.manager.gateway.GatewayService)1 NotificationService (org.openremote.manager.notification.NotificationService)1 FlowResourceImpl (org.openremote.manager.rules.flow.FlowResourceImpl)1 GeofenceAssetAdapter (org.openremote.manager.rules.geofence.GeofenceAssetAdapter)1 ManagerIdentityService (org.openremote.manager.security.ManagerIdentityService)1 ManagerWebService (org.openremote.manager.web.ManagerWebService)1