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:edu.stanford.epad.common.util.EPADFileUtils.java

public static boolean deleteFilesInDirWithoutExtension(File dir, String extension) {
    try {//w w w .  ja v a  2  s  .  c om
        List<File> files = getAllFilesWithoutExtension(dir, extension);

        for (File file : files) {
            if (!file.delete()) {
                throw new IllegalStateException("Could not delete file=" + file.getAbsolutePath());
            }
        }
        return true;
    } catch (IllegalStateException ise) {
        log.warning(ise.getMessage());
        return false;
    } catch (Exception e) {
        log.warning("Had: " + e.getMessage() + " for " + dir.getAbsolutePath(), e);
        return false;
    }
}

From source file:edu.stanford.epad.common.util.EPADFileUtils.java

public static boolean deleteFilesInDirectoryWithExtension(File dir, String extension) {
    try {//from   www  .  j ava2 s. c  o m
        Collection<File> files = getAllFilesWithExtension(dir, extension, true);

        for (File file : files) {
            if (!file.delete()) {
                throw new IllegalStateException("Could not delete file " + file.getAbsolutePath());
            }
        }
        return true;
    } catch (IllegalStateException ise) {
        log.warning(ise.getMessage());
        return false;
    } catch (Exception e) {
        log.warning("Had: " + e.getMessage() + " for " + dir.getAbsolutePath(), e);
        return false;
    }
}

From source file:org.eobjects.datacleaner.user.UserPreferencesImpl.java

public static UserPreferences load(final FileObject userPreferencesFile, final boolean loadDatabaseDrivers) {
    try {/*from   w w  w . ja v a2  s.c  om*/
        if (userPreferencesFile == null || !userPreferencesFile.exists()) {
            logger.info("User preferences file does not exist");
            return new UserPreferencesImpl(userPreferencesFile);
        }
    } catch (FileSystemException e1) {
        logger.debug("Could not determine if file exists: {}", userPreferencesFile);
    }

    ChangeAwareObjectInputStream inputStream = null;
    try {
        inputStream = new ChangeAwareObjectInputStream(userPreferencesFile.getContent().getInputStream());
        inputStream.addRenamedClass("org.eobjects.datacleaner.user.UserPreferences", UserPreferencesImpl.class);
        UserPreferencesImpl result = (UserPreferencesImpl) inputStream.readObject();

        if (loadDatabaseDrivers) {
            List<UserDatabaseDriver> installedDatabaseDrivers = result.getDatabaseDrivers();
            for (UserDatabaseDriver userDatabaseDriver : installedDatabaseDrivers) {
                try {
                    userDatabaseDriver.loadDriver();
                } catch (IllegalStateException e) {
                    logger.error("Could not load database driver", e);
                }
            }
        }

        result._userPreferencesFile = userPreferencesFile;
        result.refreshProxySettings();
        return result;
    } catch (InvalidClassException e) {
        logger.warn("User preferences file version does not match application version: {}", e.getMessage());
        return new UserPreferencesImpl(userPreferencesFile);
    } catch (Exception e) {
        logger.warn("Could not read user preferences file", e);
        return new UserPreferencesImpl(userPreferencesFile);
    } finally {
        FileHelper.safeClose(inputStream);
    }
}

From source file:org.datacleaner.user.UserPreferencesImpl.java

/**
 * Loads a user preferences file and initializes a
 * {@link UserPreferencesImpl} object using it.
 * // w w w .  j a  va 2s. co m
 * @param userPreferencesFile
 * @param loadDatabaseDrivers
 * @return
 */
public static UserPreferences load(final FileObject userPreferencesFile, final boolean loadDatabaseDrivers) {
    try {
        if (userPreferencesFile == null || !userPreferencesFile.exists()) {
            logger.info("User preferences file does not exist");
            return new UserPreferencesImpl(userPreferencesFile);
        }
    } catch (FileSystemException e1) {
        logger.debug("Could not determine if file exists: {}", userPreferencesFile);
    }

    ChangeAwareObjectInputStream inputStream = null;
    try {
        inputStream = new ChangeAwareObjectInputStream(userPreferencesFile.getContent().getInputStream());
        inputStream.addRenamedClass("org.datacleaner.user.UserPreferences", UserPreferencesImpl.class);
        UserPreferencesImpl result = (UserPreferencesImpl) inputStream.readObject();

        if (loadDatabaseDrivers) {
            List<UserDatabaseDriver> installedDatabaseDrivers = result.getDatabaseDrivers();
            for (UserDatabaseDriver userDatabaseDriver : installedDatabaseDrivers) {
                try {
                    userDatabaseDriver.loadDriver();
                } catch (IllegalStateException e) {
                    logger.error("Could not load database driver", e);
                }
            }
        }

        result._userPreferencesFile = userPreferencesFile;
        result.refreshProxySettings();
        return result;
    } catch (InvalidClassException e) {
        logger.warn("User preferences file version does not match application version: {}", e.getMessage());
        return new UserPreferencesImpl(userPreferencesFile);
    } catch (Exception e) {
        logger.warn("Could not read user preferences file", e);
        return new UserPreferencesImpl(userPreferencesFile);
    } finally {
        FileHelper.safeClose(inputStream);
    }
}

From source file:ome.tools.spring.ShutdownSafeEhcacheManagerFactoryBean.java

@Override
public void destroy() {
    try {//from ww w.j  a  v  a 2s. com
        super.destroy();
    } catch (IllegalStateException e) {
        if (e.getMessage().contains("Shutdown in progress")) {
            // ignore. It's because we're closing the application context
            // during shutdown.
            if (log.isDebugEnabled()) {
                log.debug("Ignoring \"Shutdown in progress\" error.");
            }
        } else {
            throw e;
        }
    }
}

From source file:org.apache.phoenix.kafka.consumer.PhoenixConsumerTool.java

@Override
public int run(String[] args) throws Exception {
    Configuration conf = HBaseConfiguration.create(getConf());

    CommandLine cmdLine = null;//w ww .ja v a2  s  . c  o  m
    try {
        cmdLine = parseOptions(args);
    } catch (IllegalStateException e) {
        printHelpAndExit(e.getMessage(), getOptions());
    }

    String path = cmdLine.getOptionValue(FILE_PATH_OPT.getOpt());
    conf.set("kafka.consumer.file", path);
    new PhoenixConsumer(conf);

    return 1;
}

From source file:org.kuali.rice.krad.uif.lifecycle.ViewLifecycle.java

/**
 * Report an illegal state in the view lifecycle.
 *
 * <p>//from   w w  w .  java 2s  .c  o  m
 * When {@link #isStrict()} returns true, {@link IllegalStateException} will be thrown.
 * Otherwise, a warning will be logged.
 * </p>
 *
 * @param message The message describing the illegal state.
 * @param cause The (potential) cause of the illegal state.
 * @throws IllegalStateException If strict mode is enabled.
 */
public static void reportIllegalState(String message, Throwable cause) {
    IllegalStateException illegalState = new IllegalStateException(
            message + "\nPhase: " + ViewLifecycle.getPhase(), cause);

    if (ViewLifecycle.isStrict()) {
        throw illegalState;
    } else {
        if (LOG.isTraceEnabled()) {
            LOG.trace(illegalState.getMessage(), illegalState);
        }
    }
}

From source file:de.lgblaumeiser.ptm.rest.ActivityRestController.java

@ExceptionHandler(IllegalStateException.class)
public ResponseEntity<?> handleException(IllegalStateException e) {
    return new ResponseEntity<String>(e.getMessage(), BAD_REQUEST);
}

From source file:de.kaiserpfalzEdv.vaadin.i18n.I18nInterceptor.java

private String translate(final String key, final Locale locale) {
    I18NHandler i18n = getI18nHandler(locale);

    try {//from w  ww  .j  a  v a 2  s  .c  o m
        return i18n.get(key);
    } catch (IllegalStateException e) {
        LOG.error(e.getMessage(), e);

        return key;
    }
}

From source file:org.resthub.rpc.hessian.SpringAMQPProxyTest.java

@Test(groups = "hessian-serialization")
public void testSerializationError() throws Exception {
    try {/* w  w w  .j  av  a  2  s.  c  o m*/
        serializationError.getNotSerializable();
        fail("IllegalStateException expected");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("must implement java.io.Serializable"));
    }
}