Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:gov.nih.nci.ncicb.tcgaportal.level4.webservice.ParticipantWS.java

private Results processRequest() {
    validateQueryParams();/*w  w  w  . j  a v a  2s. c  om*/
    final Level4Queries l4Queries = l4QueriesGetter.getLevel4Queries(disease);
    final Results res;
    CopyNumberType cnt = new CopyNumberType();
    try {
        for (ColumnType col : l4Queries.getColumnTypes(disease)) {
            if (col instanceof CopyNumberType) {
                if ("broad.mit.edu".equals(((CopyNumberType) col).getDisplayCenter())
                        && "Genome_Wide_SNP_6".equals(((CopyNumberType) col).getDisplayPlatform())) {
                    cnt = (CopyNumberType) col;
                    break;
                }
            }
        }
        final List<ColumnType> cList = new ArrayList<ColumnType>();
        cnt.setPicked(true);
        cnt.setFrequency((frequency == 0f) ? 0f : frequency / 100f);
        cnt.setLowerLimit(lowerLimit);
        cnt.setUpperLimit(upperLimit);
        cnt.setLowerOperator(UpperAndLowerLimits.Operator.LTE);
        cnt.setUpperOperator(UpperAndLowerLimits.Operator.GTE);
        cList.add(cnt);
        final FilterSpecifier filter = new FilterSpecifier();
        filter.setDisease(disease);
        filter.setGeneList(genes);
        filter.setGeneListOptions(FilterSpecifier.GeneListOptions.List);
        filter.setListBy(FilterSpecifier.ListBy.Patients);
        filter.setColumnTypes(cList);
        res = l4Queries.getAnomalyResults(filter);
    } catch (QueriesException e) {
        throw new WebApplicationException(
                WebServiceUtil.getStatusResponse(HttpStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
    } catch (IllegalArgumentException ill) {
        throw new WebApplicationException(
                WebServiceUtil.getStatusResponse(HttpStatusCode.INTERNAL_SERVER_ERROR, ill.getMessage()));
    }
    return res;
}

From source file:org.alfresco.bm.mongo.MongoFactoriesTest.java

@Test
public void testMongoClientFactory() throws Exception {
    // Check that we kick out URIs with credentials
    try {//from   ww w  .  j a  va2s .  c o  m
        new MongoClientFactory(new MongoClientURI("mongodb://jack:daw@168.10.0.4:27017"), null, null);
    } catch (IllegalArgumentException e) {
        // Expected
        Assert.assertTrue(e.getMessage().contains("***:***@"));
        Assert.assertTrue(e.getMessage().contains("username"));
    }
    // Check that we kick out URIs with DB name
    try {
        new MongoClientFactory(new MongoClientURI("mongodb://168.10.0.4:27017/data"), null, null);
    } catch (IllegalArgumentException e) {
        // Expected
        Assert.assertTrue(e.getMessage().contains("/data"));
        Assert.assertTrue(e.getMessage().contains("specific database"));
    }
    // But we must not get confused by the optional options
    new MongoClientFactory(new MongoClientURI("mongodb://168.10.0.4:27017/?safe=true"), null, null).destroy();

    // Get a DB running
    MongoDBForTestsFactory mockDBFactory = new MongoDBForTestsFactory();
    try {
        String uriWithDB = mockDBFactory.getMongoURI();
        int idx = uriWithDB.lastIndexOf("/");
        String uriWithoutDB = uriWithDB.substring(0, idx);
        MongoClientURI mongoClientURI = new MongoClientURI(uriWithoutDB);
        Assert.assertEquals(uriWithoutDB, mockDBFactory.getMongoURIWithoutDB());

        // Now connect to the DB
        MongoClientFactory clientFactoryOne = new MongoClientFactory(mongoClientURI, null, null);
        MongoClientFactory clientFactoryTwo = new MongoClientFactory(mongoClientURI, null, null);

        // Each of the factories must produce distinct instances
        MongoClient clientOne = clientFactoryOne.getObject();
        MongoClient clientTwo = clientFactoryTwo.getObject();
        Assert.assertTrue(clientOne != clientTwo);
        Assert.assertTrue(clientOne == clientFactoryOne.getObject());
        Assert.assertTrue(clientTwo == clientFactoryTwo.getObject());

        // Use them
        DB dbOneA = clientOne.getDB("oneA");
        DB dbOneB = clientOne.getDB("oneB");
        DB dbTwoA = clientTwo.getDB("twoA");
        DB dbTwoB = clientTwo.getDB("twoB");

        dbOneA.getStats();
        dbOneB.getStats();
        dbTwoA.getStats();
        dbTwoB.getStats();

        // Shutdown the client factory
        clientFactoryTwo.destroy();
        dbOneA.getStats();
        dbOneB.getStats();
        try {
            dbTwoA.getStats();
            Assert.fail("Second set of DBs did not close with second client factory.");
        } catch (IllegalStateException e) {
            // Expected
        }
        try {
            dbTwoB.getStats();
            Assert.fail("Second set of DBs did not close with second client factory.");
        } catch (IllegalStateException e) {
            // Expected
        }
        // Cleanup the last factory
        clientFactoryOne.destroy();
    } finally {
        mockDBFactory.destroy();
    }
}

From source file:com.transwarp.hbase.bulkload.TextSortReducer.java

@Override
protected void reduce(ImmutableBytesWritable rowKey, java.lang.Iterable<Text> lines,
        Reducer<ImmutableBytesWritable, Text, ImmutableBytesWritable, KeyValue>.Context context)
        throws java.io.IOException, InterruptedException {
    // although reduce() is called per-row, handle pathological case
    long threshold = context.getConfiguration().getLong("reducer.row.threshold", 1L * (1 << 30));
    Iterator<Text> iter = lines.iterator();
    while (iter.hasNext()) {
        Set<KeyValue> map = new TreeSet<KeyValue>(KeyValue.COMPARATOR);
        long curSize = 0;
        // stop at the end or the RAM threshold
        while (iter.hasNext() && curSize < threshold) {
            Text line = iter.next();
            String lineStr = line.toString();
            try {
                ArrayList<String> parsedLine = ParsedLine.parse(converter.getRecordSpec(), lineStr);
                Put p = converter.convert(parsedLine, rowKey.get());

                for (List<KeyValue> kvs : p.getFamilyMap().values()) {
                    for (KeyValue kv : kvs) {
                        map.add(kv);/*from  w  w  w.j  a  v a2  s.  c om*/
                        curSize += kv.getLength();
                    }
                }
            } catch (FormatException badLine) {
                if (skipBadLines) {
                    System.err.println("Bad line." + badLine.getMessage());
                    incrementBadLineCount(1);
                    return;
                }
                throw new IOException(badLine);
            } catch (IllegalArgumentException e) {
                if (skipBadLines) {
                    System.err.println("Bad line." + e.getMessage());
                    incrementBadLineCount(1);
                    return;
                }
                throw new IOException(e);
            }
        }
        context.setStatus("Read " + map.size() + " entries of " + map.getClass() + "("
                + StringUtils.humanReadableInt(curSize) + ")");
        int index = 0;
        for (KeyValue kv : map) {
            if (isDelete) {
                kv = new KeyValue(kv.getRow(), kv.getFamily(), kv.getQualifier(), 0, KeyValue.Type.Delete,
                        kv.getValue());
            }
            context.write(rowKey, kv);
            if (++index > 0 && index % 100 == 0)
                context.setStatus("Wrote " + index + " key values.");
        }

        // if we have more entries to process
        if (iter.hasNext()) {
            // force flush because we cannot guarantee intra-row sorted order
            context.write(null, null);
        }
    }
}

From source file:com.sun.portal.rssportlet.FeedHelper.java

/**
 * Get the ROME SyndFeed object for the specified feed. The object may come
 * from a cache; the data in the feed may not be read at the time
 * this method is called.//  ww  w.  ja v a2s .c  o m
 *
 * The <code>RssPortletBean</code> object is used to identify the feed
 * of interest, and the timeout value to be used when managing this
 * feed's cached value.
 *
 * @param bean an <code>RssPortletBean</code> object that describes
 * the feed of interest, and the cache timeout value for the feed.
 * @return a ROME <code>SyndFeed</code> object encapsulating the
 * feed specified by the URL.
 */
public SyndFeed getFeed(SettingsBean bean, String selectedFeed) throws IOException, FeedException {
    SyndFeed feed = null;
    FeedElement feedElement = (FeedElement) feeds.get(selectedFeed);

    if (feedElement != null && !feedElement.isExpired()) {
        feed = feedElement.getFeed();
    } else {
        GetMethod httpget = null;
        try {
            SyndFeedInput input = new SyndFeedInput();

            HttpClient httpclient = new HttpClient();
            httpclient.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECTION_TIMEOUT);
            // SO_TIMEOUT -- timeout for blocking reads
            httpclient.getHttpConnectionManager().getParams().setSoTimeout(SOCKET_TIMEOUT);

            httpget = new GetMethod(selectedFeed);

            //httpget.getParams().setParameter("http.socket.timeout", new Integer(20000));
            // Internally the parameter collections will be linked together
            // by performing the following operations: 
            // hostconfig.getParams().setDefaults(httpclient.getParams());
            // httpget.getParams().setDefaults(hostconfig.getParams());
            //httpclient.executeMethod(hostconfig, httpget);
            // Execute the method.

            int statusCode = httpclient.executeMethod(httpget);
            if (statusCode != HttpStatus.SC_OK) {
                log.info("Method failed: " + httpget.getStatusLine());
            }
            // Read the response body.
            InputSource src = new InputSource(httpget.getResponseBodyAsStream());
            // Deal with the response.
            // Use caution: ensure correct character encoding and is not binary data
            feed = input.build(src);
            //
            // only cache the feed if the cache timeout is not equal to 0
            // a cache timeout of 0 means "don't cache"
            //
            int timeout = bean.getCacheTimeout();
            if (timeout != 0) {
                putFeed(selectedFeed, feed, timeout);
            }
        } catch (MalformedURLException mfurlex) {
            log.info("MalformedURLException: " + mfurlex.getMessage());
            mfurlex.printStackTrace();
            throw new IOException("MalformedURLException: " + mfurlex.getMessage());
        } catch (HttpException httpex) {
            log.info("Fatal protocol violation: " + httpex.getMessage());
            httpex.printStackTrace();
            throw new IOException("Fatal protocol violation: " + httpex.getMessage());
        } catch (IllegalArgumentException iae) {
            log.info("IllegalArgumentException: " + iae.getMessage());
            iae.printStackTrace();
            throw new IOException("IllegalArgumentException: " + iae.getMessage());
        } catch (IOException ioe) {
            log.info("Fatal transport error: " + ioe.getMessage());
            ioe.printStackTrace();
            throw new IOException("Fatal transport error: " + ioe.getMessage());
        } catch (ParsingFeedException parsingfeedex) {
            log.info("ParsingFeedException: " + parsingfeedex.getMessage());
            parsingfeedex.printStackTrace();
            throw new FeedException("ParsingFeedException: " + parsingfeedex.getMessage());
        } catch (FeedException feedex) {
            log.info("FeedException: " + feedex.getMessage());
            feedex.printStackTrace();
            throw new FeedException("FeedException: " + feedex.getMessage());
        } catch (Exception ex) {
            log.info("Exception ERROR: " + ex.getMessage());
            ex.printStackTrace();
        } finally {
            // Release the connection.
            httpget.releaseConnection();
        }
    }
    return feed;
}

From source file:jp.co.opentone.bsol.linkbinder.dto.AbstractDto.java

@Override
public String toString() {
    // ????????/*from   w  w  w . ja  va2  s.c o m*/
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
    try {
        for (Field field : getFields(this.getClass())) {
            if (isToStringIgnoreField(field.getName())) {
                continue;
            }
            // ???ON????
            field.setAccessible(true);
            tsb.append(field.getName(), field.get(this));
        }
    } catch (IllegalArgumentException e) {
        log.warn(e.getMessage(), e);
    } catch (IllegalAccessException e) {
        log.warn(e.getMessage(), e);
    }

    // ?????????????
    // Object?ID???
    return removeObjectId(tsb.toString());
}

From source file:fr.landel.utils.commons.function.BiSupplierThrowableTest.java

/**
 * Test method for {@link BiSupplierThrowable#getThrows()}.
 *///from  ww w .  j  av  a  2  s . co  m
@Test
public void testGetThrows() {
    boolean test = false;
    final String error = "error";

    final BiSupplierThrowable<String, String, IllegalArgumentException> s1 = () -> Pair.of("l", "r");
    final BiSupplierThrowable<String, String, IOException> s2 = () -> {
        if (test) {
            return Pair.of("l", "r");
        }
        throw new IOException(error);
    };

    try {
        assertEquals("(l,r)", s1.getThrows().toString());
    } catch (IllegalArgumentException e) {
        fail("Supplier failed");
    }

    try {
        s2.getThrows();
        fail("Supplier has to fail");
    } catch (IOException e) {
        assertNotNull(e);
        assertEquals(error, e.getMessage());
    }
}

From source file:it.ferogrammer.ui.MainAppFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    jPanel2.setLayout(new BorderLayout());
    NucleotideSeq seq = null;//  www .  j  a  va 2  s  .  co m
    try {
        seq = new NucleotideSeq(jTextField1.getText(), (int) jSpinner1.getValue());
        ElectropherogramChartPanel chartPanel = new ElectropherogramChartPanel(seq);
        //        jPanel2.add(new JButton("bubububu"),BorderLayout.NORTH);
        jPanel2.removeAll();
        jPanel2.add(chartPanel, BorderLayout.CENTER);
    } catch (IllegalArgumentException e) {
        JLabel errorLabel = new JLabel("unable to generate graph: " + e.getMessage());
        errorLabel.setForeground(Color.red);
        jPanel2.removeAll();
        jPanel2.add(errorLabel, BorderLayout.NORTH);
    }
    jPanel2.revalidate();
    //        this.repaint();
}

From source file:fr.landel.utils.commons.function.TriSupplierThrowableTest.java

/**
 * Test method for {@link TriSupplierThrowable#getThrows()}.
 *///from  ww  w  .j ava2s .  c  o m
@Test
public void testGetThrows() {
    boolean test = false;
    final String error = "error";

    final TriSupplierThrowable<String, String, String, IllegalArgumentException> s1 = () -> Triple.of("l", "m",
            "r");
    final TriSupplierThrowable<String, String, String, IOException> s2 = () -> {
        if (test) {
            return Triple.of("l", "m", "r");
        }
        throw new IOException(error);
    };

    try {
        assertEquals("(l,m,r)", s1.getThrows().toString());
    } catch (IllegalArgumentException e) {
        fail("Supplier failed");
    }

    try {
        s2.getThrows();
        fail("Supplier has to fail");
    } catch (IOException e) {
        assertNotNull(e);
        assertEquals(error, e.getMessage());
    }
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testAssertNotNull() {
    final String CONST_MESSAGE = "test";
    CommonUtils.assertNotNull(new Object(), CONST_MESSAGE);
    try {/* w  w  w .  j a v a2s .co  m*/
        CommonUtils.assertNotNull(null, CONST_MESSAGE);
    } catch (IllegalArgumentException e) {
        assertEquals(CONST_MESSAGE, e.getMessage());
    }
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testAssertTrue() {
    final String CONST_MESSAGE = "test";
    CommonUtils.assertTrue(true, CONST_MESSAGE);
    try {/*from   w ww . j  a  v a2 s. c  o m*/
        CommonUtils.assertTrue(false, CONST_MESSAGE);
    } catch (IllegalArgumentException e) {
        assertEquals(CONST_MESSAGE, e.getMessage());
    }
}