public static void waitForData() throws InterruptedException, CouldNotPerformException { getRegistry().waitForData(); }
/** * * @return @throws InterruptedException * @throws NotAvailableException */ public synchronized static UserRegistryRemote getRegistry() throws InterruptedException, NotAvailableException { try { if (shutdown) { throw new InvalidStateException("Remote service is shutting down!"); } if (registryRemote == null) { try { registryRemote = new UserRegistryRemote(); registryRemote.init(); registryRemote.activate(); registryRemote.lock(REMOTE_LOCK); } catch (Exception ex) { if (registryRemote != null) { registryRemote.unlock(REMOTE_LOCK); registryRemote.shutdown(); registryRemote = null; } throw ExceptionPrinter.printHistoryAndReturnThrowable(new CouldNotPerformException("Could not start cached user registry remote!", ex), LOGGER); } } return registryRemote; } catch (CouldNotPerformException ex) { throw new NotAvailableException("cached user registry", ex); } }
@Override protected void bindRegistryRemoteToRemoteRegistries() { try { bindRegistryRemoteToRemoteRegistry(userConfigRemoteRegistry, unitRegistry, UnitRegistryData.USER_UNIT_CONFIG_FIELD_NUMBER); bindRegistryRemoteToRemoteRegistry(authorizationGroupConfigRemoteRegistry, unitRegistry, UnitRegistryData.AUTHORIZATION_GROUP_UNIT_CONFIG_FIELD_NUMBER); } catch (CouldNotPerformException ex) { new FatalImplementationErrorException("Could not bind registries", this, ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws CouldNotPerformException {@inheritDoc} */ @Override public Boolean isUserConfigRegistryConsistent() throws CouldNotPerformException { try { validateData(); return getData().getUserUnitConfigRegistryConsistent(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not check consistency!", ex); } }
@Override public List<UnitConfig> getAuthorizationGroupConfigsbyUserConfig(UnitConfig userConfig) throws CouldNotPerformException { validateData(); List<UnitConfig> groupConfigs = new ArrayList<>(); for (UnitConfig group : getAuthorizationGroupConfigs()) { group.getAuthorizationGroupConfig().getMemberIdList().stream().filter((memeberId) -> (userConfig.getId().equals(memeberId))).forEach((_item) -> { groupConfigs.add(group); }); } return groupConfigs; }
@Override public Boolean isUserConfigRegistryReadOnly() throws CouldNotPerformException { try { if (JPService.getProperty(JPReadOnly.class).getValue() || !isConnected()) { return true; } } catch (JPServiceException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not access java property!", ex), logger); } validateData(); return getData().getUserUnitConfigRegistryReadOnly(); }
@Override public List<UnitConfig> getUserConfigsByAuthorizationGroupConfig(UnitConfig groupConfig) throws CouldNotPerformException { List<UnitConfig> userConfigs = new ArrayList<>(); for (UnitConfig group : getAuthorizationGroupConfigs()) { if (group.getAuthorizationGroupConfig().equals(groupConfig)) { for (String memeberId : group.getAuthorizationGroupConfig().getMemberIdList()) { userConfigs.add(getUserConfigById(memeberId)); } return userConfigs; } } return userConfigs; }
public UserRegistryRemote() throws InstantiationException, InterruptedException { super(JPUserRegistryScope.class, UserRegistryData.class); try { authorizationFilter = new AuthorizationFilter(); userConfigRemoteRegistry = new SynchronizedRemoteRegistry<>(this.getIntenalPriorizedDataObservable(), this, authorizationFilter, UserRegistryData.USER_UNIT_CONFIG_FIELD_NUMBER); authorizationGroupConfigRemoteRegistry = new SynchronizedRemoteRegistry<>(this.getIntenalPriorizedDataObservable(), this, new MockUpFilter(), UserRegistryData.AUTHORIZATION_GROUP_UNIT_CONFIG_FIELD_NUMBER); } catch (CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
public UserManagerController() throws org.openbase.jul.exception.InstantiationException, InterruptedException { try { this.userFactory = UserFactoryImpl.getInstance(); this.authorizationGroupFactory = AuthorizationGroupFactoryImpl.getInstance(); this.userRegistry = new ControllerRegistryImpl<>(); this.authorizationGroupRegistry = new ControllerRegistryImpl<>(); this.userRegistrySynchronizer = new EnableableEntryRegistrySynchronizer<String, UserController, UnitConfig, UnitConfig.Builder>(userRegistry, Registries.getUserRegistry().getUserConfigRemoteRegistry(), Registries.getUserRegistry(), userFactory) { @Override public boolean enablingCondition(UnitConfig config) { return config.getEnablingState().getValue() == EnablingState.State.ENABLED; } }; this.authorizationGroupRegistrySynchronizer = new ActivatableEntryRegistrySynchronizer<String, AuthorizationGroupController, UnitConfig, Builder>(authorizationGroupRegistry, Registries.getUnitRegistry().getAuthorizationGroupUnitConfigRemoteRegistry(), Registries.getUserRegistry(), authorizationGroupFactory) { @Override public boolean activationCondition(UnitConfig config) { return config.getEnablingState().getValue() == State.ENABLED; } }; } catch (CouldNotPerformException ex) { throw new org.openbase.jul.exception.InstantiationException(this, ex); } }
@Override public Boolean isAuthorizationGroupConfigRegistryReadOnly() throws CouldNotPerformException { validateData(); try { if (JPService.getProperty(JPReadOnly.class).getValue() || !isConnected()) { return true; } } catch (JPServiceException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not access java property!", ex), logger); } return getData().getAuthorizationGroupUnitConfigRegistryReadOnly(); }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws CouldNotPerformException {@inheritDoc} */ @Override public Boolean isAuthorizationGroupConfigRegistryConsistent() throws CouldNotPerformException { try { validateData(); return getData().getAuthorizationGroupUnitConfigRegistryConsistent(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not check consistency!", ex); } }
public static void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException { getRegistry().waitForData(timeout, timeUnit); }
/** * Returns an initialized and activated remote registry. * * @param waitForData defines if this call should block until the registry data is available. * @return the remote registry instance. * @throws NotAvailableException * @throws InterruptedException is thrown if thread is externally interrupted. */ public static UserRegistryRemote getUserRegistry(final boolean waitForData) throws CouldNotPerformException, InterruptedException { if (waitForData) { CachedUserRegistryRemote.getRegistry().waitForData(); } return CachedUserRegistryRemote.getRegistry(); }