Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java

private void updateChannel(String channeldD, State state, boolean allGroup) {
    if (allGroup) {
        for (String member : getZoneGroupMembers()) {
            try {
                ZonePlayerHandler memberHandler = getHandlerByName(member);
                if (memberHandler != null && ThingStatus.ONLINE.equals(memberHandler.getThing().getStatus())
                        && memberHandler.isLinked(channeldD)) {
                    memberHandler.updateState(channeldD, state);
                }// ww  w .j a v  a  2 s.  c o m
            } catch (IllegalStateException e) {
                logger.debug("Cannot update channel for group member ({})", e.getMessage());
            }
        }
    } else if (ThingStatus.ONLINE.equals(getThing().getStatus()) && isLinked(channeldD)) {
        updateState(channeldD, state);
    }
}

From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java

public void playPlayList(Command command) {
    if (command != null && command instanceof StringType) {
        String playlist = command.toString();
        List<SonosEntry> playlists = getPlayLists();

        SonosEntry theEntry = null;/*  w  w w.  j ava 2  s  . c o  m*/
        // search for the appropriate play list based on its name (title)
        for (SonosEntry somePlaylist : playlists) {
            if (somePlaylist.getTitle().equals(playlist)) {
                theEntry = somePlaylist;
                break;
            }
        }

        // set the URI of the group coordinator
        if (theEntry != null) {
            try {
                ZonePlayerHandler coordinator = getCoordinatorHandler();

                coordinator.addURIToQueue(theEntry);

                coordinator.setCurrentURI(QUEUE_URI + coordinator.getUDN() + "#0", "");

                String firstTrackNumberEnqueued = stateMap.get("FirstTrackNumberEnqueued");
                if (firstTrackNumberEnqueued != null) {
                    coordinator.seek("TRACK_NR", firstTrackNumberEnqueued);
                }

                coordinator.play();
            } catch (IllegalStateException e) {
                logger.debug("Cannot play playlist ({})", e.getMessage());
            }
        } else {
            logger.debug("Playlist '{}' not found", playlist);
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java

public void setShuffle(Command command) {
    if ((command != null) && (command instanceof OnOffType || command instanceof OpenClosedType
            || command instanceof UpDownType)) {
        try {//from   w  w  w . j av a  2s  . 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.debug("Cannot handle shuffle command ({})", e.getMessage());
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.internal.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 w w.ja v  a2 s  .  c om
 * @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.debug("Cannot paly favorite ({})", e.getMessage());
            }
        } else {
            logger.debug("Favorite '{}' not found", favorite);
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.internal.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  . jav  a 2 s.  com

        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.debug("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.debug("Cannot handle command ({})", e.getMessage());
            return false;
        }
    } else {
        logger.debug("Line-in of {} is not connected", getUDN());
        return false;
    }
}

From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java

public void playTuneinStation(Command command) {
    if (command instanceof StringType) {
        String stationId = command.toString();
        List<SonosMusicService> allServices = getAvailableMusicServices();

        SonosMusicService tuneinService = null;
        // search for the TuneIn music service based on its name
        if (allServices != null) {
            for (SonosMusicService service : allServices) {
                if (service.getName().equals("TuneIn")) {
                    tuneinService = service;
                    break;
                }/*from   ww  w . j  a  v a2s .c o m*/
            }
        }

        // set the URI of the group coordinator
        if (tuneinService != null) {
            try {
                ZonePlayerHandler coordinator = getCoordinatorHandler();
                SonosEntry entry = new SonosEntry("", "TuneIn station", "", "", "", "",
                        "object.item.audioItem.audioBroadcast",
                        String.format(TUNEIN_URI, stationId, tuneinService.getId()));
                entry.setDesc("SA_RINCON" + tuneinService.getType().toString() + "_");
                coordinator.setCurrentURI(entry);
                coordinator.play();
            } catch (IllegalStateException e) {
                logger.debug("Cannot play TuneIn station {} ({})", stationId, e.getMessage());
            }
        } else {
            logger.debug("TuneIn service not found");
        }
    }
}

From source file:edu.ku.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 va  2  s . co  m*/
        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

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
    if (command instanceof RefreshType) {
        updateChannel(channelUID.getId());
    } else {/*from   w  ww.java  2  s.c  om*/
        switch (channelUID.getId()) {
        case LED:
            setLed(command);
            break;
        case MUTE:
            setMute(command);
            break;
        case NOTIFICATIONSOUND:
            scheduleNotificationSound(command);
            break;
        case STOP:
            stopPlaying(command);
            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 TUNEINSTATIONID:
            playTuneinStation(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 CLEARQUEUE:
            clearQueue();
            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();
                    }
                }
                // Rewind and Fast Forward are currently not implemented by the binding
            } catch (IllegalStateException e) {
                logger.debug("Cannot handle control command ({})", e.getMessage());
            }
            break;
        case SLEEPTIMER:
            setSleepTimer(command);
            break;
        case SHUFFLE:
            setShuffle(command);
            break;
        case REPEAT:
            setRepeat(command);
            break;
        case NIGHTMODE:
            setNightMode(command);
            break;
        case SPEECHENHANCEMENT:
            setSpeechEnhancement(command);
            break;
        default:
            break;
        }
    }
}

From source file:org.eclipse.equinox.http.servlet.tests.ServletTest.java

public void test_Registration15() throws Exception {
    Servlet initError = new HttpServlet() {
        private static final long serialVersionUID = 1L;

        @Override/*from   w w w  . j  a v  a 2 s . c  om*/
        public void init(ServletConfig config) throws ServletException {
            throw new IllegalStateException("Init error.");
        }

    };
    ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService();
    try {
        extendedHttpService.registerServlet("/foo", initError, null, null);
        fail("Expected an init failure.");
    } catch (IllegalStateException e) {
        //expected
        assertEquals("Wrong exception message.", "Init error.", e.getMessage());
    }
}

From source file:org.finra.herd.dao.S3DaoTest.java

/**
 * Test S3 file copy with an invalid KMS Id that throws an IllegalStateException because no AmazonServiceException was found.
 *//*w w w  . j ava2 s  .c  o m*/
@Test
public void testCopyFileInvalidKmsIdIllegalStateException() throws InterruptedException {
    // Put a 1 byte file in S3.
    s3Operations.putObject(new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(),
            TARGET_S3_KEY, new ByteArrayInputStream(new byte[1]), null), null);

    try {
        S3FileCopyRequestParamsDto transferDto = new S3FileCopyRequestParamsDto();
        transferDto.setSourceBucketName(storageDaoTestHelper.getS3LoadingDockBucketName());
        transferDto.setTargetBucketName(storageDaoTestHelper.getS3ExternalBucketName());
        transferDto.setSourceObjectKey(TARGET_S3_KEY);
        transferDto.setTargetObjectKey(TARGET_S3_KEY);
        transferDto.setKmsKeyId(MockS3OperationsImpl.MOCK_KMS_ID_FAILED_TRANSFER_NO_EXCEPTION);
        s3Dao.copyFile(transferDto);
        fail("An IllegalStateException was expected but not thrown.");
    } catch (IllegalStateException ex) {
        assertEquals(
                "Invalid IllegalStateException message returned.", "The transfer operation \""
                        + MockS3OperationsImpl.MOCK_TRANSFER_DESCRIPTION + "\" failed for an unknown reason.",
                ex.getMessage());
    }
}