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:com.almende.eve.state.file.ConcurrentJsonFileState.java

@Override
public int size() {
    int result = -1;
    try {/*from w  w  w  .j a v a  2 s.  c  om*/
        openFile();
        read();
        result = properties.size();

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

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

@Override
public Object remove(final String key) {
    Object result = null;//from   w ww.j a va 2  s .c om
    try {
        openFile();
        read();
        result = properties.remove(key);

        write();
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e);
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}

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

@Override
public JsonNode locPut(final String key, JsonNode value) {
    try {//from  ww  w . j a  v a  2s.c om
        openFile();
        read();
        if (value == null) {
            value = NullNode.getInstance();
        }
        properties.put(key, value);
        write();
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e);
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return value;
}

From source file:com.blackducksoftware.integration.hub.teamcity.agent.scan.HubBuildProcess.java

private HubServerConfig getHubServerConfig(final IntLogger logger,
        final CIEnvironmentVariables commonVariables) {
    final HubServerConfigBuilder configBuilder = new HubServerConfigBuilder();

    // read the credentials and proxy info using the existing objects.
    final String serverUrl = commonVariables.getValue(HubConstantValues.HUB_URL);
    final String timeout = commonVariables.getValue(HubConstantValues.HUB_CONNECTION_TIMEOUT);
    final String username = commonVariables.getValue(HubConstantValues.HUB_USERNAME);
    final String password = commonVariables.getValue(HubConstantValues.HUB_PASSWORD);
    final String passwordLength = commonVariables.getValue(HubConstantValues.HUB_PASSWORD_LENGTH);

    final String alwaysTrustServerCertificate = commonVariables
            .getValue(HubConstantValues.HUB_TRUST_SERVER_CERT);

    final String proxyHost = commonVariables.getValue(HubConstantValues.HUB_PROXY_HOST);
    final String proxyPort = commonVariables.getValue(HubConstantValues.HUB_PROXY_PORT);
    final String ignoredProxyHosts = commonVariables.getValue(HubConstantValues.HUB_NO_PROXY_HOSTS);
    final String proxyUsername = commonVariables.getValue(HubConstantValues.HUB_PROXY_USER);
    final String proxyPassword = commonVariables.getValue(HubConstantValues.HUB_PROXY_PASS);
    final String proxyPasswordLength = commonVariables.getValue(HubConstantValues.HUB_PROXY_PASS_LENGTH);

    configBuilder.setHubUrl(serverUrl);/*from  w  ww  .j ava2  s . c  o m*/
    configBuilder.setUsername(username);
    configBuilder.setPassword(password);
    configBuilder.setPasswordLength(NumberUtils.toInt(passwordLength));
    configBuilder.setTimeout(timeout);

    configBuilder.setAlwaysTrustServerCertificate(Boolean.valueOf(alwaysTrustServerCertificate));

    configBuilder.setProxyHost(proxyHost);
    configBuilder.setProxyPort(proxyPort);
    configBuilder.setIgnoredProxyHosts(ignoredProxyHosts);
    configBuilder.setProxyUsername(proxyUsername);
    configBuilder.setProxyPassword(proxyPassword);
    configBuilder.setProxyPasswordLength(NumberUtils.toInt(proxyPasswordLength));

    try {
        return configBuilder.build();
    } catch (final IllegalStateException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

From source file:org.sakaiproject.evaluation.logic.scheduling.GroupMembershipSyncImpl.java

public void execute(JobExecutionContext context) throws JobExecutionException {
    LOG.debug("GroupMembershipSync.execute()");
    String syncServerId = (String) this.evalSettings.get(EvalSettings.SYNC_SERVER);
    String thisServerId = this.externalLogic.getServerId();
    if (thisServerId != null && thisServerId.equals(syncServerId)) {
        JobDetail jobDetail = context.getJobDetail();
        JobDataMap data = jobDetail.getJobDataMap();
        String statusStr = (String) data.get(GroupMembershipSync.GROUP_MEMBERSHIP_SYNC_PROPNAME_STATE_LIST);
        LOG.info("GroupMembershipSync.execute() starting sync of evals by state: " + statusStr);
        if (statusStr == null || statusStr.trim().equals("")) {
            // better throw something?
        } else {//from  w  w  w . ja v a2  s.  c  om
            String[] stateList = statusStr.trim().split(" ");

            LOG.info("GroupMembershipSync.execute() syncing " + statusStr);

            for (String state : stateList) {
                List<EvalEvaluation> evals = evaluationService.getEvaluationsByState(state);
                int count = evals.size();
                if (LOG.isInfoEnabled()) {
                    StringBuilder buf1 = new StringBuilder();
                    buf1.append("GroupMembershipSync.execute() syncing ");
                    buf1.append(count);
                    buf1.append("groups for evals in state: ");
                    buf1.append(state);
                    LOG.info(buf1.toString());
                }
                for (EvalEvaluation eval : evals) {
                    if (this.evaluationSetupService instanceof EvalEvaluationSetupServiceImpl) {
                        if (LOG.isDebugEnabled()) {
                            StringBuilder buf = new StringBuilder();
                            buf.append("====> ");
                            buf.append(state);
                            buf.append("          ==> ");
                            buf.append(eval.getEid());
                            buf.append(" using impl");
                            LOG.debug(buf.toString());
                        }
                        try {
                            ((EvalEvaluationSetupServiceImpl) this.evaluationSetupService)
                                    .synchronizeUserAssignmentsForced(eval, null, true);
                        } catch (IllegalStateException e) {
                            StringBuilder buf = new StringBuilder();
                            buf.append("Unable to user assignments for eval (");
                            buf.append(eval.getId());
                            buf.append(") due to IllegalStateException: ");
                            buf.append(e.getMessage());
                            LOG.warn(buf.toString());

                            // TODO: should update the state so it is not selected next time ??
                        }
                    } else {
                        if (LOG.isDebugEnabled()) {
                            StringBuilder buf = new StringBuilder();
                            buf.append("====> ");
                            buf.append(state);
                            buf.append("          ==> ");
                            buf.append(eval.getEid());
                            buf.append(" using api");
                            LOG.debug(buf.toString());
                        }
                        this.evaluationSetupService.synchronizeUserAssignments(eval.getId(), null);
                    }
                }
            }
        }
        LOG.info("GroupMembershipSync.execute() done with sync of evals by state: " + statusStr);
    }
}

From source file:com.kylinolap.metadata.MetadataManager.java

/**
 * Create a new CubeDesc//from   w  w  w  .ja  v  a  2  s . co  m
 * 
 * @param cubeDesc
 * @return
 * @throws IOException
 */
public CubeDesc createCubeDesc(CubeDesc cubeDesc) throws IOException {
    if (cubeDesc.getUuid() == null || cubeDesc.getName() == null)
        throw new IllegalArgumentException();
    if (cubeDescMap.containsKey(cubeDesc.getName()))
        throw new IllegalArgumentException("CubeDesc '" + cubeDesc.getName() + "' already exists");

    try {
        cubeDesc.init(config, srcTableMap.getMap());
    } catch (IllegalStateException e) {
        cubeDesc.addError(e.getMessage(), true);
    }
    // Check base validation
    if (!cubeDesc.getError().isEmpty()) {
        return cubeDesc;
    }
    // Semantic validation
    CubeMetadataValidator validator = new CubeMetadataValidator();
    ValidateContext context = validator.validate(cubeDesc, true);
    if (!context.ifPass()) {
        return cubeDesc;
    }

    cubeDesc.setSignature(cubeDesc.calculateSignature());

    String path = cubeDesc.getResourcePath();
    getStore().putResource(path, cubeDesc, CUBE_SERIALIZER);
    cubeDescMap.put(cubeDesc.getName(), cubeDesc);

    return cubeDesc;
}

From source file:io.fabric8.msg.jnatsd.TestProtocol.java

@Test(expected = IllegalStateException.class)
public void testDoubleUnsubscribe() {
    try (Connection c = connectionFactory.createConnection()) {
        try (SyncSubscription s = c.subscribeSync("foo")) {
            s.unsubscribe();/*from w  w w. j a va 2s  .  c o m*/
            try {
                s.unsubscribe();
            } catch (IllegalStateException e) {
                throw e;
            }
        }
    } catch (IOException | TimeoutException e) {
        fail(e.getMessage());
    }
}

From source file:com.kylinolap.metadata.MetadataManager.java

/**
 * Update CubeDesc with the input. Broadcast the event into cluster
 * /*from   w w  w  .j  a  va 2 s . c o  m*/
 * @param desc
 * @return
 * @throws IOException
 */
public CubeDesc updateCubeDesc(CubeDesc desc) throws IOException {
    // Validate CubeDesc
    if (desc.getUuid() == null || desc.getName() == null) {
        throw new IllegalArgumentException();
    }
    String name = desc.getName();
    if (!cubeDescMap.containsKey(name)) {
        throw new IllegalArgumentException("CubeDesc '" + name + "' does not exist.");
    }

    try {
        desc.init(config, srcTableMap.getMap());
    } catch (IllegalStateException e) {
        desc.addError(e.getMessage(), true);
        return desc;
    } catch (IllegalArgumentException e) {
        desc.addError(e.getMessage(), true);
        return desc;
    }

    // Semantic validation
    CubeMetadataValidator validator = new CubeMetadataValidator();
    ValidateContext context = validator.validate(desc, true);
    if (!context.ifPass()) {
        return desc;
    }

    desc.setSignature(desc.calculateSignature());

    // Save Source
    String path = desc.getResourcePath();
    getStore().putResource(path, desc, CUBE_SERIALIZER);

    // Reload the CubeDesc
    CubeDesc ndesc = loadCubeDesc(path);
    // Here replace the old one
    cubeDescMap.put(ndesc.getName(), desc);

    return ndesc;
}

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

@Override
public boolean locPutIfUnchanged(final String key, final JsonNode newVal, JsonNode oldVal) {
    boolean result = false;
    try {/*from  w  w w.j  av a 2 s. c  om*/
        openFile();
        read();

        JsonNode cur = NullNode.getInstance();
        if (properties.containsKey(key)) {
            cur = properties.get(key);
        }
        if (oldVal == null) {
            oldVal = NullNode.getInstance();
        }

        // Poor mans equality as some Numbers are compared incorrectly: e.g.
        // IntNode versus LongNode
        if (oldVal.equals(cur) || oldVal.toString().equals(cur.toString())) {
            properties.put(key, newVal);
            write();
            result = true;
        }
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e);
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
        // Don't let users loop if exception is thrown. They
        // would get into a deadlock....
        result = true;
    }
    closeFile();
    return result;
}

From source file:de.vandermeer.skb.interfaces.application.IsApplication.java

/**
 * Executes the application./*  w  ww. ja va 2 s.c  om*/
 * The default implementation will try to parse the command line with the application's CLI object and if that does not return success (0), call the help screen automatically.
 * @param args arguments for execution
 * @return 0 on success, negative integer on error, positive integer on no-error but exit application
 */
default int executeApplication(String[] args) {
    //add help and version options if required
    if (this.cliSimpleHelpOption() != null && !this.getCliParser().hasOption(this.cliSimpleHelpOption())) {
        this.getCliParser().addOption(this.cliSimpleHelpOption());
    } else if (this.cliTypedHelpOption() != null && !this.getCliParser().hasOption(this.cliTypedHelpOption())) {
        this.getCliParser().addOption(this.cliTypedHelpOption());
    }
    if (this.cliVersionOption() != null && !this.getCliParser().hasOption(this.cliVersionOption())) {
        this.getCliParser().addOption(this.cliVersionOption());
    }

    if (IN_ARRAY(args, this.cliVersionOption())) {
        System.out.println(this.getAppVersion());
        return 1;
    }
    if (IN_ARRAY(args, this.cliSimpleHelpOption())) {
        this.appHelpScreen();
        return 1;
    }
    if (IN_ARRAY(args, this.cliTypedHelpOption())) {
        if (args.length == 1) {
            this.appHelpScreen();
            return 1;
        } else if (args.length == 2) {
            this.appHelpScreen(args[1]);
            return 1;
        }
        System.err.println(this.getAppName() + ": help requested but too many arguments given");
        return -1;
    }

    try {
        this.getCliParser().parse(args);
    } catch (IllegalStateException ex) {
        System.err.println(this.getAppName() + ": error parsing command line -> " + ex.getMessage());
        System.err.println(this.getAppName()
                + ": try '--help' for list of CLI options or '--help <option>' for detailed help on a CLI option");
        return -1;
    } catch (CliParseException e) {
        System.err.println(this.getAppName() + ": error: " + e.getMessage());
        System.err.println(this.getAppName()
                + ": try '--help' for list of CLI options or '--help <option>' for detailed help on a CLI option");
        return e.getErrorCode();
    }

    return 0;
}