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:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeClassClassTypeint02() <br>
 * <br>//w  ww . j a  v  a 2  s .c o m
 *  <br>
 * G <br>
 * <br>
 * () genericClass:List.class<br>
 * () clazz:null<br>
 * () index:0<br>
 * <br>
 * () :IllegalStateException<br>
 * genericClass+ " is not assignable from " + clazz<br>
 * <br>
 * clazz?null???IllegalStateException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeClassClassTypeint02() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(List.class, (Class<?>) null, null, 0);
        // 
        fail("???????");
    } catch (IllegalStateException e) {
        String message = List.class + " is not assignable from " + "null";
        assertEquals(message, e.getMessage());
        assertEquals(IllegalStateException.class.getName(), e.getClass().getName());
    }
}

From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java

@Test
public void testProcessBusinessObjectDataStatusChangeNotificationEventInvalidMessageType() throws Exception {
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper
            .createTestValidBusinessObjectData();

    // Get a business object data key.
    BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper
            .getBusinessObjectDataKey(businessObjectDataEntity);

    // Override configuration, so there will be an invalid message type specified in the relative notification message definition.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity/*  w  w w  .j  a  va2 s.co  m*/
            .setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS
                    .getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(
            Collections.singletonList(new NotificationMessageDefinition(INVALID_VALUE, MESSAGE_DESTINATION,
                    MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to trigger the notification.
    try {
        messageNotificationEventService.processBusinessObjectDataStatusChangeNotificationEvent(
                businessObjectDataKey, BusinessObjectDataStatusEntity.VALID,
                BusinessObjectDataStatusEntity.UPLOADING);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(
                "Only \"%s\" notification message type is supported. Please update \"%s\" configuration entry.",
                MESSAGE_TYPE_SNS,
                ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS
                        .getKey()),
                e.getMessage());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeClassClassTypeint03() <br>
 * <br>/*from  w ww  .ja va  2 s  . c  o m*/
 *  <br>
 * G <br>
 * <br>
 * () genericClass:List.class<br>
 * () clazz:Object.class<br>
 * () index:0<br>
 * <br>
 * () :IllegalStateException<br>
 * genericClass+ " is not assignable from " + clazz<br>
 * <br>
 * clazz?genericClass???????IllegalStateException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeClassClassTypeint03() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(List.class, Object.class, null, 0);
        // 
        fail("???????");
    } catch (IllegalStateException e) {
        String message = List.class + " is not assignable from " + Object.class;
        assertEquals(message, e.getMessage());
        assertEquals(IllegalStateException.class.getName(), e.getClass().getName());
    }
}

From source file:Default.YTDownloadThread.java

public boolean downloadOne(String url) throws IOException {

    boolean rc = false;
    boolean rc204 = false;
    boolean rc302 = false;

    this.recursionCount++;

    // stop recursion
    try {//from w  w w  .  j a  v  a  2 s  .c o m
        if (url.equals("")) {
            return (false);
        }
    } catch (NullPointerException npe) {
        return (false);
    }
    //      if (JFCMainClient.getQuitRequested()) {
    //         return(false); // try to get information about application shutdown
    //      }

    outputDebugMessage("start.");

    // TODO GUI option for proxy?
    // http://wiki.squid-cache.org/ConfigExamples/DynamicContent/YouTube
    // using local squid to save download time for tests

    try {

        this.request = new HttpGet(url);
        this.request.setConfig(this.config);
        this.httpClient = HttpClients.createDefault();

    } catch (Exception e) {
        outputDebugMessage(e.getMessage());
    }
    outputDebugMessage("executing request: ".concat(this.request.getRequestLine().toString()));
    outputDebugMessage("uri: ".concat(this.request.getURI().toString()));
    outputDebugMessage("using proxy: ".concat(this.getProxy()));

    try {
        this.response = this.httpClient.execute(this.request);
    } catch (ClientProtocolException cpe) {
        outputDebugMessage(cpe.getMessage());
    } catch (UnknownHostException uhe) {
        output(("error connecting to: ").concat(uhe.getMessage()));
        outputDebugMessage(uhe.getMessage());
    } catch (IOException ioe) {
        outputDebugMessage(ioe.getMessage());
    } catch (IllegalStateException ise) {
        outputDebugMessage(ise.getMessage());
    }

    try {
        outputDebugMessage("HTTP response status line:".concat(this.response.getStatusLine().toString()));

        // abort if HTTP response code is != 200, != 302 and !=204 - wrong URL?
        if (!(rc = this.response.getStatusLine().toString().toLowerCase().matches("^(http)(.*)200(.*)"))
                & !(rc204 = this.response.getStatusLine().toString().toLowerCase()
                        .matches("^(http)(.*)204(.*)"))
                & !(rc302 = this.response.getStatusLine().toString().toLowerCase()
                        .matches("^(http)(.*)302(.*)"))) {
            outputDebugMessage(this.response.getStatusLine().toString().concat(" ").concat(url));
            output(this.response.getStatusLine().toString().concat(" \"").concat(this.title).concat("\""));
            return (rc & rc204 & rc302);
        }
        if (rc204) {
            rc = downloadOne(this.nextVideoUrl.get(0).getUrl());
            return (rc);
        }
        if (rc302) {
            outputDebugMessage(
                    "location from HTTP Header: ".concat(this.response.getFirstHeader("Location").toString()));
        }

    } catch (NullPointerException npe) {
        // if an IllegalStateException was catched while calling httpclient.execute(httpget) a NPE is caught here because
        // response.getStatusLine() == null
        this.videoUrl = null;
    }

    HttpEntity entity = null;
    try {
        entity = this.response.getEntity();
    } catch (NullPointerException npe) {
        //TODO catch must not be empty
    }

    // try to read HTTP response body
    if (entity != null) {
        try {
            if (this.response.getFirstHeader("Content-Type").getValue().toLowerCase()
                    .matches("^text/html(.*)")) {
                this.textReader = new BufferedReader(new InputStreamReader(entity.getContent()));
            } else {
                this.binaryReader = new BufferedInputStream(entity.getContent());
            }
        } catch (IllegalStateException e1) {
            e1.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        try {
            // test if we got a webpage
            this.contentType = this.response.getFirstHeader("Content-Type").getValue().toLowerCase();
            if (this.contentType.matches("^text/html(.*)")) {
                rc = saveTextData();
                // test if we got the binary content
            } else if (this.contentType.matches("(audio|video)/(.*)|application/octet-stream")) {

                // add audio stream URL if necessary
                if (this.recursionCount == 1) {
                    outputDebugMessage(("last response code==true - download: ")
                            .concat(this.nextVideoUrl.get(0).getYoutubeId()));
                    if (this.nextVideoUrl.get(0).getAudioStreamUrl().equals("")) {
                        outputDebugMessage("download audio stream? no");
                    } else {
                        // FIXME audio stream has no filename if we add the direct URL to the GUI url list - we should add YTURL objects, not Strings!
                        outputDebugMessage("download audio stream? yes - "
                                .concat(this.nextVideoUrl.get(0).getAudioStreamUrl()));
                        this.youtubeUrl.setTitle(this.getTitle());
                        //JFCMainClient.addYoutubeUrlToList(this.nextVideoUrl.get(0).getAudioStreamUrl(),this.getTitle(),"AUDIO");
                    }
                }
                //                  if (JFCMainClient.getNoDownload())
                //                    reportHeaderInfo();
                //                  else
                saveBinaryData();
            } else { // content-type is not video/
                rc = false;
                this.videoUrl = null;
            }
        } catch (IOException ex) {
            try {
                throw ex;
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (RuntimeException ex) {
            try {
                throw ex;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } //if (entity != null)

    this.httpClient.close();

    outputDebugMessage("done: ".concat(url));
    if (this.videoUrl == null) {
        this.videoUrl = ""; // to prevent NPE
    }
    if (this.videoUrl.matches(URL_REGEX)) {
        // enter recursion - download video resource
        outputDebugMessage("try to download video from URL: ".concat(this.videoUrl));
        rc = downloadOne(this.videoUrl);
    } else {
        // no more recursion - html source hase been read
        // rc==false if video could not downloaded because of some error (like wrong protocol or country restriction)
        if (!rc) {
            outputDebugMessage("cannot download video - URL does not seem to be valid or could not be found: "
                    .concat(this.url));
            output("there was a problem getting the video URL! perhaps not allowed in your country?!");
            output(("consider reporting the URL to author! - ").concat(this.url));
            this.videoUrl = null;
        }
    }

    this.videoUrl = null;

    return (rc);
}

From source file:org.sakaiproject.evaluation.logic.EvalEvaluationServiceImpl.java

public boolean canRemoveEvaluation(String userId, Long evaluationId) {
    LOG.debug("evalId: " + evaluationId + ",userId: " + userId);
    EvalEvaluation eval = getEvaluationOrFail(evaluationId);

    boolean allowed;
    try {/*from  ww w . j  a v  a 2s  . c o m*/
        allowed = securityChecks.canUserRemoveEval(userId, eval);
    } catch (IllegalStateException e) {
        allowed = false;
    } catch (SecurityException e) {
        LOG.debug("User (" + userId + ") cannot remove evalaution: " + eval.getId() + ", " + e.getMessage());
        allowed = false;
    }
    return allowed;
}

From source file:com.markuspage.android.atimetracker.Tasks.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //android.os.Debug.waitForDebugger();
    preferences = getSharedPreferences(TIMETRACKERPREF, MODE_PRIVATE);
    fontSize = preferences.getInt(FONTSIZE, 16);
    concurrency = preferences.getBoolean(CONCURRENT, false);
    if (preferences.getBoolean(MILITARY, true)) {
        TimeRange.FORMAT = new SimpleDateFormat("HH:mm");
    } else {//from  w ww.j  a va2 s .c  o m
        TimeRange.FORMAT = new SimpleDateFormat("hh:mm a");
    }

    int which = preferences.getInt(VIEW_MODE, 0);
    if (adapter == null) {
        adapter = new TaskAdapter(this);
        setListAdapter(adapter);
        switchView(which);
    }
    if (timer == null) {
        timer = new Handler();
    }
    if (updater == null) {
        updater = new TimerTask() {
            @Override
            public void run() {
                if (running) {
                    adapter.notifyDataSetChanged();
                    setTitle();
                    Tasks.this.getListView().invalidate();
                }
                timer.postDelayed(this, REFRESH_MS);
            }
        };
    }
    playClick = preferences.getBoolean(SOUND, false);
    if (playClick && clickPlayer == null) {
        clickPlayer = MediaPlayer.create(this, R.raw.click);
        try {
            clickPlayer.prepareAsync();
        } catch (IllegalStateException illegalStateException) {
            // ignore this.  There's nothing the user can do about it.
            Logger.getLogger("TimeTracker").log(Level.SEVERE,
                    "Failed to set up audio player: " + illegalStateException.getMessage());
        }
    }
    decimalFormat = preferences.getBoolean(TIMEDISPLAY, false);
    registerForContextMenu(getListView());
    if (adapter.tasks.isEmpty()) {
        showDialog(HELP);
    }
    vibrateAgent = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vibrateClick = preferences.getBoolean(VIBRATE, true);

    // Start the notification thread
    this.notificationThread = TaskNotificationThread.getInstance();
    this.notificationThread.init(this, this.adapter);
    this.notificationThread.start();
}

From source file:com.markuspage.android.atimetracker.Tasks.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PREFERENCES && data != null) {
        Bundle extras = data.getExtras();
        if (extras.getBoolean(START_DAY)) {
            switchView(preferences.getInt(VIEW_MODE, 0));
        }/*from w w w.ja  va  2 s .c  om*/
        if (extras.getBoolean(MILITARY)) {
            if (preferences.getBoolean(MILITARY, true)) {
                TimeRange.FORMAT = new SimpleDateFormat("HH:mm");
            } else {
                TimeRange.FORMAT = new SimpleDateFormat("hh:mm a");
            }
        }
        if (extras.getBoolean(CONCURRENT)) {
            concurrency = preferences.getBoolean(CONCURRENT, false);
        }
        if (extras.getBoolean(SOUND)) {
            playClick = preferences.getBoolean(SOUND, false);
            if (playClick && clickPlayer == null) {
                clickPlayer = MediaPlayer.create(this, R.raw.click);
                try {
                    clickPlayer.prepareAsync();
                    clickPlayer.setVolume(1, 1);
                } catch (IllegalStateException illegalStateException) {
                    // ignore this.  There's nothing the user can do about it.
                    Logger.getLogger("TimeTracker").log(Level.SEVERE,
                            "Failed to set up audio player: " + illegalStateException.getMessage());
                }
            }
        }
        if (extras.getBoolean(VIBRATE)) {
            vibrateClick = preferences.getBoolean(VIBRATE, true);
        }
        if (extras.getBoolean(FONTSIZE)) {
            fontSize = preferences.getInt(FONTSIZE, 16);
        }
        if (extras.getBoolean(TIMEDISPLAY)) {
            decimalFormat = preferences.getBoolean(TIMEDISPLAY, false);
        }
    }

    if (getListView() != null) {
        getListView().invalidate();
    }
}

From source file:org.libreplan.web.tree.TreeController.java

public void addElement() {
    viewStateSnapshot = TreeViewStateSnapshot.takeSnapshot(tree);
    try {//w  w  w.  ja v  a2s . c o m
        if (tree.getSelectedCount() == 1) {
            getModel().addElementAt(getSelectedNode());
        } else {
            getModel().addElement();
        }
        reloadTreeUIAfterChanges();
    } catch (IllegalStateException e) {
        LOG.warn("exception ocurred adding element", e);
        messagesForUser.showMessage(Level.ERROR, e.getMessage());
    }

}

From source file:org.rhq.enterprise.installer.ServerInformation.java

/**
 * Get the list of existing servers from an existing RHQ schema.
 *
 * <p>The given set of properties provides settings that allow for a successful database connection. If <code>
 * props</code> is <code>null</code>, it will use the server properties from {@link #getServerProperties()}.</p>
 *
 * <p>Do not call this method unless {@link #isDatabaseConnectionValid(Properties)} is <code>true</code>.</p>
 *
 * @param  props set of properties where the connection information is found
 *
 * @return List of server names registered in the database. Empty list if the table does not exist or there are no entries in the table.
 *
 * @throws Exception if failed to communicate with the database
 *///from  w  w w  . j a va 2  s.c om
public List<String> getServerNames(Properties props) throws Exception {
    DatabaseType db = null;
    Connection conn = null;
    Statement stm = null;
    ResultSet rs = null;
    List<String> result = new ArrayList<String>();

    try {
        conn = getDatabaseConnection(props);
        db = DatabaseTypeFactory.getDatabaseType(conn);

        if (db.checkTableExists(conn, "rhq_server")) {

            stm = conn.createStatement();
            rs = stm.executeQuery("SELECT name FROM rhq_server ORDER BY name asc");

            while (rs.next()) {
                result.add(rs.getString(1));
            }
        }
    } catch (IllegalStateException e) {
        // table does not exist
    } catch (SQLException e) {
        LOG.info("Unable to fetch existing server info: " + e.getMessage());
    } finally {
        if (null != db) {
            db.closeJDBCObjects(conn, stm, rs);
        }
    }

    return result;
}

From source file:com.blackducksoftware.integration.jira.config.HubJiraConfigController.java

private RestConnection createRestConnection(final PluginSettings settings,
        final HubJiraConfigSerializable config) {
    final String hubUrl = getStringValue(settings, HubConfigKeys.CONFIG_HUB_URL);
    final String hubUser = getStringValue(settings, HubConfigKeys.CONFIG_HUB_USER);
    logger.debug(String.format("Establishing connection to hub server: %s as %s", hubUrl, hubUser));
    final String encHubPassword = getStringValue(settings, HubConfigKeys.CONFIG_HUB_PASS);
    final String encHubPasswordLength = getStringValue(settings, HubConfigKeys.CONFIG_HUB_PASS_LENGTH);
    final String hubTimeout = getStringValue(settings, HubConfigKeys.CONFIG_HUB_TIMEOUT);

    if (StringUtils.isBlank(hubUrl) && StringUtils.isBlank(hubUser) && StringUtils.isBlank(encHubPassword)
            && StringUtils.isBlank(hubTimeout)) {
        config.setErrorMessage(JiraConfigErrors.HUB_CONFIG_PLUGIN_MISSING);
        return null;
    } else if (StringUtils.isBlank(hubUrl) || StringUtils.isBlank(hubUser)
            || StringUtils.isBlank(encHubPassword) || StringUtils.isBlank(hubTimeout)) {
        config.setErrorMessage(/*from   w  w  w  .  j  a  v  a2 s  .  co  m*/
                JiraConfigErrors.HUB_SERVER_MISCONFIGURATION + JiraConfigErrors.CHECK_HUB_SERVER_CONFIGURATION);
        return null;
    }

    final String hubProxyHost = getStringValue(settings, HubConfigKeys.CONFIG_PROXY_HOST);
    final String hubProxyPort = getStringValue(settings, HubConfigKeys.CONFIG_PROXY_PORT);
    final String hubNoProxyHost = getStringValue(settings, HubConfigKeys.CONFIG_PROXY_NO_HOST);
    final String hubProxyUser = getStringValue(settings, HubConfigKeys.CONFIG_PROXY_USER);
    final String encHubProxyPassword = getStringValue(settings, HubConfigKeys.CONFIG_PROXY_PASS);
    final String hubProxyPasswordLength = getStringValue(settings, HubConfigKeys.CONFIG_PROXY_PASS_LENGTH);

    CredentialsRestConnection restConnection = null;
    try {
        final HubServerConfigBuilder configBuilder = new HubServerConfigBuilder();
        configBuilder.setHubUrl(hubUrl);
        configBuilder.setUsername(hubUser);
        configBuilder.setPassword(encHubPassword);
        configBuilder.setPasswordLength(NumberUtils.toInt(encHubPasswordLength));
        configBuilder.setTimeout(hubTimeout);
        configBuilder.setProxyHost(hubProxyHost);
        configBuilder.setProxyPort(hubProxyPort);
        configBuilder.setIgnoredProxyHosts(hubNoProxyHost);
        configBuilder.setProxyUsername(hubProxyUser);
        configBuilder.setProxyPassword(encHubProxyPassword);
        configBuilder.setProxyPasswordLength(NumberUtils.toInt(hubProxyPasswordLength));

        final HubServerConfig serverConfig;
        try {
            serverConfig = configBuilder.build();
        } catch (final IllegalStateException e) {
            logger.error("Error in Hub server configuration: " + e.getMessage());
            config.setErrorMessage(JiraConfigErrors.CHECK_HUB_SERVER_CONFIGURATION);
            return null;
        }

        restConnection = new CredentialsRestConnection(logger, serverConfig.getHubUrl(),
                serverConfig.getGlobalCredentials().getUsername(),
                serverConfig.getGlobalCredentials().getDecryptedPassword(), serverConfig.getTimeout());
        restConnection.connect();

    } catch (IllegalArgumentException | IntegrationException e) {
        config.setErrorMessage(JiraConfigErrors.CHECK_HUB_SERVER_CONFIGURATION + " :: " + e.getMessage());
        return null;
    }
    return restConnection;
}