Example usage for java.lang IllegalStateException IllegalStateException

List of usage examples for java.lang IllegalStateException IllegalStateException

Introduction

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

Prototype

public IllegalStateException(Throwable cause) 

Source Link

Document

Constructs a new exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:com.amalto.core.save.context.Delete.java

public void save(SaverSession session, DocumentSaverContext context) {
    String typeName = context.getUserDocument().getType().getName();
    savedId = context.getId();/*from  ww w.j a  v  a  2  s . c om*/
    if (savedId.length == 0) {
        throw new IllegalStateException("No ID information to save instance of '" + typeName + "'");
    }
    MutableDocument databaseDocument = context.getDatabaseDocument();
    if (!StringUtils.EMPTY.equals(context.getTaskId())) {
        databaseDocument.setTaskId(context.getTaskId());
    }
    session.delete(context.getDataCluster(), databaseDocument, databaseDocument.getDeleteType());
    // Save update report (if any)
    MutableDocument updateReportDocument = context.getUpdateReportDocument();
    if (updateReportDocument != null) {
        saveUpdateReport(updateReportDocument, session.getSaverSource(), session);
    }
}

From source file:io.github.kitarek.elasthttpd.server.networking.HttpConfiguredServerSocket.java

private static ServerSocket createServerSocket(SocketConfiguration socketConfiguration) {
    try {/*from w  w  w  . j a  v  a 2  s .  co  m*/
        return createServerSocketUnchecked(socketConfiguration);
    } catch (Exception e) {
        logger.error("An error creating server socket", e);
        throw new IllegalStateException(e);
    }
}

From source file:at.molindo.notify.channel.mail.PatternMailClient.java

@Override
public void afterPropertiesSet() throws Exception {
    if (_defaultClient == null) {
        throw new IllegalStateException("defaultClient not configured");
    }/* w ww  .ja  v a 2s .  co  m*/
    if (_clientPatterns.length > 0 && _alternativeClient == null) {
        throw new IllegalStateException("clientPatterns but no alternativeClient configured");
    }
}

From source file:TempConverter3.java

protected String prependSpaces(int n, String s) {
    String[] res = { "", " ", "  ", "   ", "    ", "     " };
    if (n < res.length)
        return res[n] + s;
    throw new IllegalStateException("Rebuild with bigger \"res\" array.");
}

From source file:com.enterra.batch.admin.util.TestTasklet.java

public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    if (fail) {/* w  w  w .  j  a v  a  2 s  .  c  o m*/
        throw new IllegalStateException("Planned Tasklet failure");
    }
    return RepeatStatus.FINISHED;
}

From source file:com.kinesisboard.amazonaws.utils.S3Utils.java

/**
 * Create an Amazon S3 bucket if it does not exist.
 * //from  w ww  .ja va 2 s  .  co m
 * @param client
 *        The {@link AmazonS3Client} with read and write permissions
 * @param bucketName
 *        The bucket to create
 * @throws IllegalStateException
 *         The bucket is not created before timeout occurs
 */
public static void createBucket(AmazonS3Client client, String bucketName) {
    if (!bucketExists(client, bucketName)) {
        CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
        createBucketRequest.setRegion(Region.US_Standard.toString());
        client.createBucket(createBucketRequest);
    }
    long startTime = System.currentTimeMillis();
    long endTime = startTime + 60 * 1000;
    while (!bucketExists(client, bucketName) && endTime > System.currentTimeMillis()) {
        try {
            LOG.info("Waiting for Amazon S3 to create bucket " + bucketName);
            Thread.sleep(1000 * 10);
        } catch (InterruptedException e) {
        }
    }
    if (!bucketExists(client, bucketName)) {
        throw new IllegalStateException("Could not create bucket " + bucketName);
    }
    LOG.info("Created Amazon S3 bucket " + bucketName);
}

From source file:gov.nih.nci.caintegrator.web.DisplayableGenomicSource.java

/**
 * Contructor which wraps the GenomicDataSource.
 * @param genomicDataSourceConfiguration - genomic data source.
 *///ww  w. ja v a 2 s .c  o  m
public DisplayableGenomicSource(GenomicDataSourceConfiguration genomicDataSourceConfiguration) {
    if (genomicDataSourceConfiguration == null) {
        throw new IllegalStateException("GenomicDataSourceConfiguration cannot be null.");
    }
    this.genomicDataSourceConfiguration = genomicDataSourceConfiguration;
}