use of org.apache.commons.lang.IllegalClassException in project openhab1-addons by openhab.
the class KNXBinding method sendTypeToItemButNotToKnx.
private void sendTypeToItemButNotToKnx(GroupAddress destination, String itemName, Type type) {
// we need to make sure that we won't send out this event to
// the knx bus again, when receiving it on the openHAB bus
ignoreEventList.add(itemName + type.toString());
logger.trace("Added event (item='{}', type='{}') to the ignore event list", itemName, type.toString());
if (type instanceof Command && isCommandGA(destination)) {
eventPublisher.postCommand(itemName, (Command) type);
} else if (type instanceof State) {
eventPublisher.postUpdate(itemName, (State) type);
} else {
throw new IllegalClassException("Cannot process datapoint of type " + type.toString());
}
logger.trace("Processed event (item='{}', type='{}', destination='{}')", itemName, type.toString(), destination.toString());
}
use of org.apache.commons.lang.IllegalClassException in project openhab1-addons by openhab.
the class SonosBinding method processVariableMap.
@SuppressWarnings("rawtypes")
public void processVariableMap(RemoteDevice device, Map<String, StateVariableValue> values) {
if (device != null && values != null) {
SonosZonePlayer associatedPlayer = sonosZonePlayerCache.getByDevice(device);
if (associatedPlayer == null) {
logger.debug("There is no Sonos Player defined matching the device {}", device);
return;
}
for (String stateVariable : values.keySet()) {
// find all the CommandTypes that are defined for each
// StateVariable
List<SonosCommandType> supportedCommands = SonosCommandType.getCommandByVariable(stateVariable);
StateVariableValue status = values.get(stateVariable);
for (SonosCommandType sonosCommandType : supportedCommands) {
// create a new State based on the type of Sonos Command and
// the status value in the map
Type newState = null;
try {
newState = createStateForType((Class<? extends State>) sonosCommandType.getTypeClass(), status.getValue().toString());
} catch (BindingConfigParseException e) {
logger.error("Error parsing a value {} to a state variable of type {}", status.toString(), sonosCommandType.getTypeClass().toString());
}
for (SonosBindingProvider provider : providers) {
List<String> qualifiedItems = provider.getItemNames(sonosZonePlayerCache.getByDevice(device).getId(), sonosCommandType.getSonosCommand());
List<String> qualifiedItemsByUDN = provider.getItemNames(sonosZonePlayerCache.getByDevice(device).getUdn().getIdentifierString(), sonosCommandType.getSonosCommand());
for (String item : qualifiedItemsByUDN) {
if (!qualifiedItems.contains(item)) {
qualifiedItems.add(item);
}
}
for (String anItem : qualifiedItems) {
// get the openHAB commands attached to each Item at
// this given Provider
List<Command> commands = provider.getCommands(anItem, sonosCommandType.getSonosCommand());
if (provider.getAcceptedDataTypes(anItem).contains(sonosCommandType.getTypeClass())) {
if (newState != null) {
eventPublisher.postUpdate(anItem, (State) newState);
} else {
throw new IllegalClassException("Cannot process update for the command of type " + sonosCommandType.toString());
}
} else {
logger.warn("Cannot cast {} to an accepted state type for item {}", sonosCommandType.getTypeClass().toString(), anItem);
}
}
}
}
}
}
}
use of org.apache.commons.lang.IllegalClassException in project jstorm by alibaba.
the class WindowsStateUpdater method updateState.
@Override
public void updateState(WindowsState state, List<TridentTuple> tuples, TridentCollector collector) {
Long currentTxId = state.getCurrentTxId();
LOG.debug("Removing triggers using WindowStateUpdater, txnId: [{}] ", currentTxId);
for (TridentTuple tuple : tuples) {
try {
Object fieldValue = tuple.getValueByField(WindowTridentProcessor.TRIGGER_FIELD_NAME);
if (!(fieldValue instanceof WindowTridentProcessor.TriggerInfo)) {
throw new IllegalClassException(WindowTridentProcessor.TriggerInfo.class, fieldValue.getClass());
}
WindowTridentProcessor.TriggerInfo triggerInfo = (WindowTridentProcessor.TriggerInfo) fieldValue;
String triggerCompletedKey = WindowTridentProcessor.getWindowTriggerInprocessIdPrefix(triggerInfo.windowTaskId) + currentTxId;
LOG.debug("Removing trigger key [{}] and trigger completed key [{}] from store: [{}]", triggerInfo, triggerCompletedKey, windowsStore);
windowsStore.removeAll(Lists.newArrayList(triggerInfo.generateTriggerKey(), triggerCompletedKey));
} catch (Exception ex) {
LOG.warn(ex.getMessage());
collector.reportError(ex);
throw new FailedException(ex);
}
}
}
use of org.apache.commons.lang.IllegalClassException in project openhab1-addons by openhab.
the class PlugwiseBinding method postUpdate.
/**
* Method to post updates to the OH runtime.
*
*
* @param MAC of the Plugwise device concerned
* @param ctype is the Plugwise Command type
* @param value is the value (to be converted) to post
*/
public void postUpdate(String MAC, PlugwiseCommandType ctype, Object value) {
if (MAC != null && ctype != null && value != null) {
for (PlugwiseBindingProvider provider : providers) {
Set<String> qualifiedItems = provider.getItemNames(MAC, ctype);
// Make sure we also capture those devices that were pre-defined with a friendly name in a .cfg or alike
Set<String> qualifiedItemsFriendly = provider.getItemNames(stick.getDevice(MAC).getName(), ctype);
qualifiedItems.addAll(qualifiedItemsFriendly);
State type = null;
try {
type = createStateForType(ctype, value);
} catch (BindingConfigParseException e) {
logger.error("Error parsing a value {} to a state variable of type {}", value.toString(), ctype.getTypeClass().toString());
}
for (String item : qualifiedItems) {
if (type instanceof State) {
eventPublisher.postUpdate(item, type);
} else {
throw new IllegalClassException("Cannot process update of type " + (type == null ? "null" : type.toString()));
}
}
}
}
}
Aggregations