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.rhq.enterprise.gui.installer.server.servlet.ServerInstallUtil.java

/**
 * Get the list of existing servers from an existing schema.
 *
 * @param connectionUrl/*from  w  w  w  .  ja v a 2  s.  c  o m*/
 * @param username
 * @param password
 * @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
 */
public static ArrayList<String> getServerNames(String connectionUrl, String username, String password)
        throws Exception {
    DatabaseType db = null;
    Connection conn = null;
    Statement stm = null;
    ResultSet rs = null;
    ArrayList<String> result = new ArrayList<String>();

    try {
        conn = getDatabaseConnection(connectionUrl, username, password);
        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.sonicle.webtop.core.app.WebTopApp.java

/**
 * Gets WebTopApp object stored as context's attribute.
 * @param request The http request/*  w w w  .  ja va2  s  .  com*/
 * @return WebTopApp object
 * @throws javax.servlet.ServletException
 */
public static WebTopApp get(HttpServletRequest request) throws ServletException {
    try {
        return get(request.getServletContext());
    } catch (IllegalStateException ex) {
        throw new ServletException(ex.getMessage());
    }
}

From source file:org.apache.cxf.fediz.service.idp.protocols.TrustedIdpWSFedProtocolHandler.java

@Override
public SecurityToken mapSignInResponse(RequestContext context, Idp idp, TrustedIdp trustedIdp) {

    try {//  w  w w  .j  a  v a  2  s.c  o  m
        String whr = (String) WebUtils.getAttributeFromFlowScope(context, FederationConstants.PARAM_HOME_REALM);

        if (whr == null) {
            LOG.warn("Home realm is null");
            throw new IllegalStateException("Home realm is null");
        }

        String wresult = (String) WebUtils.getAttributeFromFlowScope(context, FederationConstants.PARAM_RESULT);

        if (wresult == null) {
            LOG.warn("Parameter wresult not found");
            throw new IllegalStateException("No security token issued");
        }

        FedizContext fedContext = getFedizContext(idp, trustedIdp);

        FedizRequest wfReq = new FedizRequest();
        wfReq.setAction(FederationConstants.ACTION_SIGNIN);
        wfReq.setResponseToken(wresult);

        FedizProcessor wfProc = new FederationProcessorImpl();
        FedizResponse wfResp = wfProc.processRequest(wfReq, fedContext);

        fedContext.close();

        Element e = wfResp.getToken();

        // Create new Security token with new id. 
        // Parameters for freshness computation are copied from original IDP_TOKEN
        String id = IDGenerator.generateID("_");
        SecurityToken idpToken = new SecurityToken(id, wfResp.getTokenCreated(), wfResp.getTokenExpires());

        idpToken.setToken(e);
        LOG.info("[IDP_TOKEN={}] for user '{}' created from [RP_TOKEN={}] issued by home realm [{}/{}]", id,
                wfResp.getUsername(), wfResp.getUniqueTokenId(), whr, wfResp.getIssuer());
        LOG.debug("Created date={}", wfResp.getTokenCreated());
        LOG.debug("Expired date={}", wfResp.getTokenExpires());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Validated 'wresult' : " + System.getProperty("line.separator") + wresult);
        }
        return idpToken;
    } catch (IllegalStateException ex) {
        throw ex;
    } catch (Exception ex) {
        LOG.warn("Unexpected exception occured", ex);
        throw new IllegalStateException("Unexpected exception occured: " + ex.getMessage());
    }
}

From source file:org.apache.eagle.alert.engine.publisher.dedup.SimpleEmbedMongo.java

public void shutdown() {

    if (mongod != null) {
        try {/*from w w w.  j av a2 s .  c  o  m*/
            mongod.stop();
        } catch (IllegalStateException e) {
            // catch this exception for the unstable stopping mongodb
            // reason: the exception is usually thrown out with below message format when stop() returns null value,
            //         but actually this should have been captured in ProcessControl.stopOrDestroyProcess() by destroying
            //         the process ultimately
            if (e.getMessage() != null && e.getMessage().matches("^Couldn't kill.*process!.*")) {
                // if matches, do nothing, just ignore the exception
            } else {
                LOG.warn(String.format("Ignored error for stopping mongod process, see stack trace: %s",
                        ExceptionUtils.getStackTrace(e)));
            }
        }
        mongodExe.stop();
    }
}

From source file:com.cedarsoftware.ncube.NCubeManager.java

/**
 * Change the SNAPSHOT version value./*from   w  ww .j av a 2  s .  c om*/
 */
public static void changeVersionValue(Connection connection, String app, String currVersion,
        String newSnapVer) {
    validate(connection, app, currVersion);
    validateVersion(newSnapVer);

    synchronized (cubeList) {
        PreparedStatement stmt1 = null;
        PreparedStatement stmt2 = null;

        try {
            stmt1 = connection.prepareStatement(
                    "SELECT n_cube_id FROM n_cube WHERE app_cd = ? AND version_no_cd = ? AND status_cd = '"
                            + ReleaseStatus.RELEASE + "'");
            stmt1.setString(1, app);
            stmt1.setString(2, newSnapVer);
            ResultSet rs = stmt1.executeQuery();
            if (rs.next()) {
                throw new IllegalStateException("RELEASE n-cubes found with version " + newSnapVer
                        + ".  Choose a different SNAPSHOT version.");
            }

            stmt2 = connection.prepareStatement(
                    "UPDATE n_cube SET update_dt = ?, version_no_cd = ? WHERE app_cd = ? AND version_no_cd = ? AND status_cd = '"
                            + ReleaseStatus.SNAPSHOT + "'");
            stmt2.setDate(1, new java.sql.Date(System.currentTimeMillis()));
            stmt2.setString(2, newSnapVer);
            stmt2.setString(3, app);
            stmt2.setString(4, currVersion);
            int count = stmt2.executeUpdate();
            if (count < 1) {
                throw new IllegalStateException("No SNAPSHOT n-cubes found with version " + currVersion
                        + ", therefore nothing changed.");
            }
        } catch (IllegalStateException e) {
            throw e;
        } catch (Exception e) {
            String s = "Unable to change SNAPSHOT version from " + currVersion + " to " + newSnapVer
                    + " for app: " + app + ", due to an error: " + e.getMessage();
            LOG.error(s, e);
            throw new RuntimeException(s, e);
        } finally {
            jdbcCleanup(stmt1);
            jdbcCleanup(stmt2);
        }
    }
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized void clear() {
    try {/*from  w  w w  .j  a v  a 2  s  .  c  om*/
        openFile();
        properties.clear();
        write();
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized Serializable get(final String key) {
    Serializable result = null;/*  w w  w.j  a  v a 2  s  .  c om*/
    try {
        openFile();
        read();
        result = properties.get(key);
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized int size() {
    int result = -1;
    try {// w w  w .  j  av  a  2 s. co  m
        openFile();
        read();
        result = properties.size();
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized Set<String> keySet() {
    Set<String> result = null;
    try {// www.ja v  a2s .c o m
        openFile();
        read();
        result = new HashSet<String>(properties.keySet());

    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized boolean containsKey(final String key) {
    boolean result = false;
    try {/*from   www .j  a  va  2  s.  co m*/
        openFile();
        read();
        result = properties.containsKey(key);

    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}