private void failOnShutdown(String message) throws InvalidStateException { if (this.shutdownInitiated) { throw new InvalidStateException(message); } }
@Override public Event call(String name, Event event) throws CouldNotPerformException { throw new CouldNotPerformException("Could not call Method["+name+"]!", new InvalidStateException("RemoteServer not initialized!")); }
@Override public void addHandler(Handler handler, boolean wait) throws InterruptedException, CouldNotPerformException { throw new CouldNotPerformException("Could not add handler!", new InvalidStateException("Listener not initialized!")); }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws NotAvailableException {@inheritDoc} */ @Override public Scope getScope() throws NotAvailableException { if (scope == null) { throw new NotAvailableException("scope", new InvalidStateException("communication service not initialized yet!")); } return scope; }
@Override public void setTypeInfo(Class<M> typeInfo) throws CouldNotPerformException { throw new CouldNotPerformException("Could not set type info!", new InvalidStateException("Informer not initialized!")); } }
@Override public void removeHandler(Handler handler, boolean wait) throws InterruptedException, CouldNotPerformException { throw new CouldNotPerformException("Could not remove handler!", new InvalidStateException("Listener not initialized!")); } }
public void validateActivation() throws InvalidStateException { if (!isActive()) { throw new InvalidStateException(this + " not activated!"); } }
public static MockRegistry newMockRegistry() throws InstantiationException { synchronized (mockRegistrySync) { if (mockRegistry != null) { throw new InstantiationException(MockRegistryHolder.class, new InvalidStateException("There is still one MockRegistry instance running!")); } mockRegistry = new MockRegistry(); return mockRegistry; } }
private void markAsProcessed(final UnitConfig locationConfig, List<String> processedLocations) throws InvalidStateException { if (processedLocations.contains(locationConfig.getId())) { throw new InvalidStateException("Location loop detected!"); } processedLocations.add(locationConfig.getId()); } }
@Override public String getId() throws NotAvailableException { try { String id = (String) getDataField(TYPE_FIELD_ID); if (id.isEmpty()) { throw new InvalidStateException("data.id is empty!"); } return id; } catch (CouldNotPerformException ex) { throw new NotAvailableException("data.id", ex); } }
public void validateActivation() throws InvalidStateException { validateInitialization(); if (!isActive()) { throw new InvalidStateException(this + " not activated!"); } }
public void validateMiddleware() throws InvalidStateException { validateActivation(); if (informer == null || !informer.isActive() || !informerWatchDog.isServiceRunning()) { throw new InvalidStateException("Informer of " + this + " not connected to middleware!"); } if (server == null || !server.isActive() || !serverWatchDog.isServiceRunning()) { throw new InvalidStateException("Server of " + this + " not connected to middleware!"); } }
private static UnitConfig getRootLocationUnitConfig(final Map<String, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder>> locations) throws NotAvailableException { try { for (final IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> locationUnitConfig : locations.values()) { if (isRootLocation(locationUnitConfig.getMessage(), locations)) { return locationUnitConfig.getMessage(); } } throw new InvalidStateException("Registry does not provide a root location!"); } catch (CouldNotPerformException ex) { throw new NotAvailableException("RootLocation", ex); } }
public String generateDefaultLabel(final UnitConfig unitConfig) throws CouldNotPerformException { if (unitConfig.getAliasCount() < 1) { throw new InvalidStateException("Alias not provided by Unit[" + unitConfig.getId() + "]!"); } return unitConfig.getAlias(0); }
public synchronized static void reinitialize() throws InterruptedException, CouldNotPerformException { try { if (shutdown) { throw new InvalidStateException("Remote service is shutting down!"); } getRegistry().reinit(REMOTE_LOCK); getRegistry().requestData().get(10, TimeUnit.SECONDS); } catch (ExecutionException | TimeoutException | CouldNotPerformException | CancellationException ex) { throw new CouldNotPerformException("Could not reinitialize " + CachedUserActivityRegistryRemote.class.getSimpleName() + "!", ex); } }
public void validateData() throws InvalidStateException { if (!isDataAvailable()) { throw new InvalidStateException(this + " not synchronized yet!", new NotAvailableException("data")); } }
@Override public void validateData() throws InvalidStateException { if (!isDataAvailable()) { throw new InvalidStateException(this + " not synchronized yet!", new NotAvailableException("data")); } }
@Override public void processData(String id, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> entry, ProtoBufMessageMap<String, UnitConfig, UnitConfig.Builder> entryMap, ProtoBufRegistry<String, UnitConfig, UnitConfig.Builder> registry) throws CouldNotPerformException, EntryModification { UnitConfig locationUnitConfig = entry.getMessage(); for (String childLocationId : new ArrayList<>(locationUnitConfig.getLocationConfig().getChildIdList())) { UnitConfig childLocationUnitConfig = registry.getMessage(childLocationId); if (labelConsistencyMap.containsKey(childLocationUnitConfig.getLabel()) && !labelConsistencyMap.get(childLocationUnitConfig.getLabel()).equals(childLocationId)) { throw new InvalidStateException("Location [" + locationUnitConfig.getId() + "," + locationUnitConfig.getLabel() + "] has more than on child with the same label [" + childLocationUnitConfig.getLabel() + "]"); } else { labelConsistencyMap.put(childLocationUnitConfig.getLabel(), childLocationId); } } }
private void validateCommand(final OpenhabCommand command) throws InvalidStateException { try { if (!command.hasItem() || command.getItem().isEmpty()) { throw new NotAvailableException("command item"); } if (!command.hasType()) { throw new NotAvailableException("command type"); } } catch (CouldNotPerformException ex) { throw new InvalidStateException("Command invalid!", ex); } }
@Override protected void execute() throws CouldNotPerformException, InterruptedException { logger.debug("Execute PartyLightTileFollowerApp[" + getLabel() + "]"); // verify if (!Registries.getLocationRegistry().getLocationConfigById(getConfig().getPlacementConfig().getLocationId()).getLocationConfig().getType().equals(LocationConfigType.LocationConfig.LocationType.TILE)) { throw new InvalidStateException("App location is not a tile!"); } new TileFollower().call(); }