static void verifyValueRange(final String name, final double value, final double min, final double max) throws VerificationFailedException { if (value < min) { throw new VerificationFailedException("The value of " + name + " is " + value + " which is lower than the defined minimum of " + min); } else if (value > max) { throw new VerificationFailedException("The value of " + name + " is " + value + " which is higher than the defined maximum of " + max); } } }
private void verify() throws VerificationFailedException { if (itemId.contains("-")) { throw new VerificationFailedException("Found \"-\" in item id which is not allowed for openhab configurations!"); } }
/** * {@inheritDoc} * * @throws VerificationFailedException {@inheritDoc} */ @Override public void verifyMaintainability() throws VerificationFailedException { if (isLocked()) { throw new VerificationFailedException("Manipulation of " + this + "is currently not valid because the maintains is protected by another instance! " + "Did you try to modify an instance which is locked by a managed instance pool?"); } }
static void verifyTemperatureState(final TemperatureState temperatureState) throws VerificationFailedException { if (!temperatureState.hasTemperature()) { throw new VerificationFailedException("Temperature value unknown!"); } switch (temperatureState.getTemperatureDataUnit()) { case UNKNOWN: throw new VerificationFailedException("TemperatureState data unit unknown!"); default: return; } }
/** * {@inheritDoc} * * @throws VerificationFailedException {@inheritDoc} */ @Override public void verifyMaintainability() throws VerificationFailedException { if (isLocked()) { throw new VerificationFailedException("Manipulation of " + this + "is currently not valid because the maintains is protected by another instance! " + "Did you try to modify an instance which is locked by a managed instance pool?"); } }
public static void verifyOperationServiceStateValue(final Enum value) throws VerificationFailedException { if (value == null) { throw new VerificationFailedException(new NotAvailableException("ServiceStateValue")); } if (value.name().equals("UNKNOWN")) { throw new VerificationFailedException("UNKNOWN." + value.getClass().getSimpleName() + " is an invalid operation service state!"); } }
public static void verifyUnitType(final UnitConfigOrBuilder unitConfig, final UnitType unitType) throws VerificationFailedException { // verify if unit type is defined if (!unitConfig.hasType()) { throw new VerificationFailedException("UnitType not available!"); } // verify unit type if (unitConfig.getType() != unitType) { throw new VerificationFailedException("UnitType verification failed. Expected[" + unitType + "] but was[" + unitConfig.getType() + "]!"); } }
@Override public void verify() throws VerificationFailedException { if (!getLaunchable().isConsistent()) { throw new VerificationFailedException(getLaunchable().getClass().getSimpleName() + " is inconsistent"); } } }
protected <U extends AbstractUnitController<?, ?>> void registerUnit(final U unit) throws CouldNotPerformException { synchronized (unitMapLock) { try { if (unitMap.containsKey(unit.getId())) { throw new VerificationFailedException("Could not register " + unit + "! Unit with same name already registered!"); } unitMap.put(unit.getId(), unit); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not registerUnit!", ex); } } }
@Override public void processData(final String id, final IdentifiableMessage<String, UnitTemplate, Builder> entry, final ProtoBufMessageMap<String, UnitTemplate, Builder> entryMap, ProtoBufRegistry<String, UnitTemplate, Builder> registry) throws CouldNotPerformException, EntryModification { final UnitTemplate unitTemplate = entry.getMessage(); if (unitTypeUnitTemplateMap.containsKey(unitTemplate.getType()) && !unitTemplate.getId().equals(unitTypeUnitTemplateMap.get(unitTemplate.getType()).getId())) { throw new VerificationFailedException("UnitTemplate[" + unitTypeUnitTemplateMap.get(unitTemplate.getType()) + "] and unitTemplate[" + unitTemplate + "] both contain the same type"); } unitTypeUnitTemplateMap.put(unitTemplate.getType(), unitTemplate); }
protected Element getElementFromXPath(final String xPath, final Document document) throws VerificationFailedException { Nodes regNodes = document.query(xPath); if (regNodes.size() != 1) { throw new VerificationFailedException("Invalide data from XPath[" + xPath + "]!"); } return (Element) regNodes.get(0); }
public static void verifyUnitType(final Unit<?> unit) throws VerificationFailedException { try { UnitConfigProcessor.verifyUnitType(unit.getConfig(), unit.getUnitType()); } catch (NotAvailableException ex) { throw new VerificationFailedException("Could not verify unit type!", ex); } }
public static void verifyUnitConfig(final Unit<?> unit) throws VerificationFailedException { try { UnitConfigProcessor.verifyUnitConfig(unit.getConfig(), unit.getUnitType()); } catch (NotAvailableException ex) { throw new VerificationFailedException("Could not verify unit type!", ex); } }
static void verifyColorState(final ColorState colorState) throws VerificationFailedException { if(!colorState.hasColor()) { throw new VerificationFailedException("Color state unknown!"); } verifyColor(colorState.getColor()); }
private void verifyUnitConfig(final UnitConfig unitConfig) throws VerificationFailedException { if (!unitConfig.getEnablingState().getValue().equals(EnablingStateType.EnablingState.State.ENABLED)) { try { throw new VerificationFailedException("Referred Unit[" + ScopeGenerator.generateStringRep(unitConfig.getScope()) + "] is disabled!"); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, LOGGER, LogLevel.WARN); throw new VerificationFailedException("Referred Unit[" + unitConfig.getLabel() + "] is disabled!"); } } }
@Override public void addServiceStateObserver(final ServiceType serviceType, final Observer observer) { try { if (serviceType != getServiceType()) { throw new VerificationFailedException("ServiceType[" + serviceType.name() + "] is not compatible with " + this); } addDataObserver(observer); } catch (final CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not add service state observer!", ex), logger); } }
@Override public void removeServiceStateObserver(final ServiceType serviceType, final Observer observer) { try { if (serviceType != getServiceType()) { throw new VerificationFailedException("ServiceType[" + serviceType.name() + "] is not compatible with " + this); } addDataObserver(observer); } catch (final CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not remove service state observer!", ex), logger, LogLevel.WARN); } }
static void verifyColor(final Color color) throws VerificationFailedException { if (color.hasHsbColor()) { verifyHsbColor(color.getHsbColor()); } else if (color.hasRgbColor()) { verifyRgbColor(color.getRgbColor()); } else { throw new VerificationFailedException("Could not detect color type!"); } }
public void verifyConnectionState(ConnectionType connectionType) throws VerificationFailedException, NotAvailableException { if (getConnectionType() != connectionType) { throw new VerificationFailedException("ConnectionType verification failed. Connection [" + getConfig().getId() + "] has type [" + getConfig().getConnectionConfig().getType().name() + "] and not [" + connectionType.name() + "]"); } }
@Override public void processData(String id, IdentifiableMessage<String, UserActivityConfig, UserActivityConfig.Builder> entry, ProtoBufMessageMap<String, UserActivityConfig, UserActivityConfig.Builder> entryMap, ProtoBufRegistry<String, UserActivityConfig, Builder> registry) throws CouldNotPerformException, EntryModification { if (!entry.getMessage().hasUserActivityClassId()) { throw new VerificationFailedException("UserActivityConfig [" + entry.getMessage() + "] has no userActivityClassId!"); } if (!userActivityClassRegistry.contains(entry.getMessage().getUserActivityClassId())) { throw new NotAvailableException("UserActivityClass[" + entry.getMessage().getUserActivityClassId() + "]"); } } }