List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java
public void setShuffle(Command command) { if ((command != null) && (command instanceof OnOffType || command instanceof OpenClosedType || command instanceof UpDownType)) { try {// ww w. j a v a 2 s . c o m ZonePlayerHandler coordinator = getCoordinatorHandler(); if (command.equals(OnOffType.ON) || command.equals(UpDownType.UP) || command.equals(OpenClosedType.OPEN)) { switch (coordinator.getRepeatMode()) { case "ALL": coordinator.updatePlayMode("SHUFFLE"); break; case "ONE": coordinator.updatePlayMode("SHUFFLE_REPEAT_ONE"); break; case "OFF": coordinator.updatePlayMode("SHUFFLE_NOREPEAT"); break; } } else if (command.equals(OnOffType.OFF) || command.equals(UpDownType.DOWN) || command.equals(OpenClosedType.CLOSED)) { switch (coordinator.getRepeatMode()) { case "ALL": coordinator.updatePlayMode("REPEAT_ALL"); break; case "ONE": coordinator.updatePlayMode("REPEAT_ONE"); break; case "OFF": coordinator.updatePlayMode("NORMAL"); break; } } } catch (IllegalStateException e) { logger.warn("Cannot handle shuffle command ({})", e.getMessage()); } } }
From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java
/** * This will attempt to match the station string with a entry in the * favorites list, this supports both single entries and playlists * * @param favorite to match//from w ww . j av a 2s . c o m * @return true if a match was found and played. */ public void playFavorite(Command command) { if (command instanceof StringType) { String favorite = command.toString(); List<SonosEntry> favorites = getFavorites(); SonosEntry theEntry = null; // search for the appropriate favorite based on its name (title) for (SonosEntry entry : favorites) { if (entry.getTitle().equals(favorite)) { theEntry = entry; break; } } // set the URI of the group coordinator if (theEntry != null) { try { ZonePlayerHandler coordinator = getCoordinatorHandler(); /** * If this is a playlist we need to treat it as such */ if (theEntry.getResourceMetaData() != null && theEntry.getResourceMetaData().getUpnpClass().startsWith("object.container")) { coordinator.removeAllTracksFromQueue(); coordinator.addURIToQueue(theEntry); coordinator.setCurrentURI(QUEUE_URI + coordinator.getUDN() + "#0", ""); String firstTrackNumberEnqueued = stateMap.get("FirstTrackNumberEnqueued"); if (firstTrackNumberEnqueued != null) { coordinator.seek("TRACK_NR", firstTrackNumberEnqueued); } } else { coordinator.setCurrentURI(theEntry); } coordinator.play(); } catch (IllegalStateException e) { logger.warn("Cannot paly favorite ({})", e.getMessage()); } } else { logger.warn("Favorite '{}' not found", favorite); } } }
From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java
public boolean publicAddress() { // check if sourcePlayer has a line-in connected if (isAnalogLineInConnected() || isOpticalLineInConnected()) { // first remove this player from its own group if any becomeStandAlonePlayer();//from w w w . j a v a2s . co m List<SonosZoneGroup> currentSonosZoneGroups = new ArrayList<SonosZoneGroup>(); for (SonosZoneGroup grp : SonosXMLParser.getZoneGroupFromXML(stateMap.get("ZoneGroupState"))) { currentSonosZoneGroups.add((SonosZoneGroup) grp.clone()); } // add all other players to this new group for (SonosZoneGroup group : currentSonosZoneGroups) { for (String player : group.getMembers()) { try { ZonePlayerHandler somePlayer = getHandlerByName(player); if (somePlayer != this) { somePlayer.becomeStandAlonePlayer(); somePlayer.stop(); addMember(StringType.valueOf(somePlayer.getUDN())); } } catch (IllegalStateException e) { logger.warn("Cannot add to group ({})", e.getMessage()); } } } try { ZonePlayerHandler coordinator = getCoordinatorHandler(); // set the URI of the group to the line-in SonosEntry entry = new SonosEntry("", "", "", "", "", "", "", ANALOG_LINE_IN_URI + getUDN()); if (isOpticalLineInConnected()) { entry = new SonosEntry("", "", "", "", "", "", "", OPTICAL_LINE_IN_URI + getUDN() + SPDIF); } coordinator.setCurrentURI(entry); coordinator.play(); return true; } catch (IllegalStateException e) { logger.warn("Cannot handle command ({})", e.getMessage()); return false; } } else { logger.warn("Line-in of {} is not connected", getUDN()); return false; } }
From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java
@Override public void handleCommand(ChannelUID channelUID, Command command) { if (command instanceof RefreshType) { updateChannel(channelUID.getId()); } else {//from www. ja va 2s . c o m switch (channelUID.getId()) { case LED: setLed(command); break; case MUTE: setMute(command); break; case NOTIFICATIONSOUND: scheduleNotificationSound(command); break; case NOTIFICATIONVOLUME: setNotificationSoundVolume(command); break; case STOP: try { getCoordinatorHandler().stop(); } catch (IllegalStateException e) { logger.warn("Cannot handle stop command ({})", e.getMessage()); } break; case VOLUME: setVolumeForGroup(command); break; case ADD: addMember(command); break; case REMOVE: removeMember(command); break; case STANDALONE: becomeStandAlonePlayer(); break; case PUBLICADDRESS: publicAddress(); break; case RADIO: playRadio(command); break; case FAVORITE: playFavorite(command); break; case ALARM: setAlarm(command); break; case SNOOZE: snoozeAlarm(command); break; case SAVEALL: saveAllPlayerState(); break; case RESTOREALL: restoreAllPlayerState(); break; case SAVE: saveState(); break; case RESTORE: restoreState(); break; case PLAYLIST: playPlayList(command); break; case PLAYQUEUE: playQueue(); break; case PLAYTRACK: playTrack(command); break; case PLAYURI: playURI(command); break; case PLAYLINEIN: playLineIn(command); break; case CONTROL: try { if (command instanceof PlayPauseType) { if (command == PlayPauseType.PLAY) { getCoordinatorHandler().play(); } else if (command == PlayPauseType.PAUSE) { getCoordinatorHandler().pause(); } } if (command instanceof NextPreviousType) { if (command == NextPreviousType.NEXT) { getCoordinatorHandler().next(); } else if (command == NextPreviousType.PREVIOUS) { getCoordinatorHandler().previous(); } } if (command instanceof RewindFastforwardType) { // Rewind and Fast Forward are currently not implemented by the binding } } catch (IllegalStateException e) { logger.warn("Cannot handle control command ({})", e.getMessage()); } break; case SLEEPTIMER: setSleepTimer(command); break; case SHUFFLE: setShuffle(command); break; case REPEAT: setRepeat(command); break; default: break; } } }
From source file:edu.bu.kuali.kra.award.sapintegration.SapIntegrationServiceImpl.java
protected SapTransmissionResponse executeSapService(SapTransmission transmission) { List<Long> interfacedSponsoredProgramIds = new ArrayList<Long>(); ZGMKCRMINTERFACE kcrmInterface = constructSapInterface(transmission, interfacedSponsoredProgramIds); // execute the service StringWriter sendWriter = new StringWriter(); StringWriter receiveWriter = new StringWriter(); SIKCRMPROCESSOUTBOUND sapService = newWebServicePort(new PrintWriter(sendWriter), new PrintWriter(receiveWriter)); LOG.info("Outbound Message: " + getTransmitXml(transmission)); //TODO mkousheh delete once in production ZGMKCRMINTERFACEResponse response = null; try {//from ww w .j a v a2 s . c om response = sapService.siKCRMPROCESSOUTBOUND(kcrmInterface); } catch (Fault fault) { Throwable nestedCause = fault.getCause(); if (nestedCause instanceof SocketTimeoutException) { LOG.error("A SocketTimeoutException was thrown from service invocation.", fault); return SapTransmissionResponse.transmissionFailure(nestedCause.getMessage(), null, sendWriter.toString(), receiveWriter.toString()); } // BU Customization ID: N/A mkousheh N/A - N/A // errorReporter.reportError("A SocketTimeoutException was thrown from service invocation.", DATE_FORMAT_PATTERN); throw fault; } // BU Customization ID: N/A mukadder 20130429 - ENHC0010154 - Issue 55 - KC_SAP Interface to display warning message List<String> warningMessages = processWarningMessages(response); String failureMessage = processResponseMessages(response); if (failureMessage != null) { return SapTransmissionResponse.transmissionFailure(failureMessage, warningMessages, sendWriter.toString(), receiveWriter.toString()); } Map<Long, String> sponsoredProgramIds = null; SPONSOREDPROGRAMSMESSAGES sponsoredProgramsMessages = response.getSPONSOREDPROGRAMSMESSAGES(); try { sponsoredProgramIds = extractSponsoredProgramIds(interfacedSponsoredProgramIds, transmission, sponsoredProgramsMessages); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage() + "/n/n" + receiveWriter.toString()); } // BU Customization ID: N/A mukadder 20130306 - Handle SAP Walker number Map<Long, String> walkerIds = null; SPXWALKT walkerMessages = response.getSPXWALKT(); try { walkerIds = extractWalkerIds(interfacedSponsoredProgramIds, transmission, walkerMessages); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage() + "/n/n" + receiveWriter.toString()); } // BU Customization ID: N/A mukadder 20130429 - ENHC0010154 - Issue 55 - KC_SAP Interface to display warning message return SapTransmissionResponse.success(sponsoredProgramIds, walkerIds, warningMessages, sendWriter.toString(), receiveWriter.toString()); }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
public void clearQueue() { try {/*from w ww .ja va 2s .c om*/ ZonePlayerHandler coordinator = getCoordinatorHandler(); coordinator.removeAllTracksFromQueue(); } catch (IllegalStateException e) { logger.debug("Cannot clear queue ({})", e.getMessage()); } }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
public void playQueue() { try {/* w w w .jav a2s. c om*/ ZonePlayerHandler coordinator = getCoordinatorHandler(); // set the current playlist to our new queue coordinator.setCurrentURI(QUEUE_URI + coordinator.getUDN() + "#0", ""); // take the system off mute coordinator.setMute(OnOffType.OFF); // start jammin' coordinator.play(); } catch (IllegalStateException e) { logger.debug("Cannot play queue ({})", e.getMessage()); } }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
public void stopPlaying(Command command) { try {/* w w w.java 2s . c o m*/ if (command instanceof OnOffType) { getCoordinatorHandler().stop(); } } catch (IllegalStateException e) { logger.debug("Cannot handle stop command ({})", e.getMessage(), e); } }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
public void addMember(Command command) { if (command != null && command instanceof StringType) { SonosEntry entry = new SonosEntry("", "", "", "", "", "", "", GROUP_URI + getUDN()); try {/*from w ww . j a v a2s . c om*/ getHandlerByName(command.toString()).setCurrentURI(entry); } catch (IllegalStateException e) { logger.debug("Cannot add group member ({})", e.getMessage()); } } }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
/** * Set the VOLUME command specific to the current grouping according to the Sonos behaviour. * AdHoc groups handles the volume specifically for each player. * Bonded groups delegate the volume to the coordinator which applies the same level to all group members. *//* w ww. j a v a 2s .c o m*/ public void setVolumeForGroup(Command command) { if (isAdHocGroup() || isStandalonePlayer()) { setVolume(command); } else { try { getCoordinatorHandler().setVolume(command); } catch (IllegalStateException e) { logger.debug("Cannot set group volume ({})", e.getMessage()); } } }