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:org.inbio.ait.web.ajax.controller.TableController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String paramLayer = request.getParameter("l");
    String paramTaxon = request.getParameter("tx");
    String paramIndi = request.getParameter("i");
    String type = request.getParameter("t");
    String errorMsj = "Error con los parmetros: " + paramLayer + " " + paramTaxon + " " + paramIndi + " "
            + type;//w  ww  .ja v a2s . co  m

    try {
        //Arrays that contains the parameters data
        String[] layerArray = paramLayer.split("\\|");
        String[] taxonArray = paramTaxon.split("\\|");
        String[] indiArray = paramIndi.split("\\|");

        //Obtain the species list by all criteria
        List<SpeciesNode> species = speciesManager.speciesNodesByCriteria(layerArray, taxonArray, indiArray);

        //Matrix to store the results
        Long[][] matrix;

        //Building the matrix content
        int x = species.size(), y = 0;
        if (type.equals("p")) { //If polygons, show species * indicators
            y = indiArray.length;
            matrix = new Long[x][y];
            //Loop over rows
            for (int i = 0; i < x; i++) {
                SpeciesNode node = species.get(i);
                //Loop over columns
                for (int j = 0; j < y; j++) {
                    matrix[i][j] = queryManager.countByIndicator(node.getName(), indiArray[j],
                            TaxonInfoIndexColums.SPECIMENS.getName(), layerArray[0]); //species,indicator,colunm,polygon
                }
            }
        } else { //if indicators, show species * polygons
            y = layerArray.length;
            matrix = new Long[x][y];
            //Loop over rows
            for (int i = 0; i < x; i++) {
                SpeciesNode node = species.get(i);
                //Loop over columns
                for (int j = 0; j < y; j++) {
                    matrix[i][j] = queryManager.countByPolygon(node.getName(), layerArray[j],
                            TaxonInfoIndexColums.SPECIMENS.getName(), indiArray[0]); //species,polygon,colunm,indicator
                }
            }
        }

        //Return results via xml
        return writeReponse(request, response, matrix, species);

    } catch (IllegalArgumentException iae) {
        throw new Exception(errorMsj + " " + iae.getMessage());
    }
}

From source file:it.txt.ens.core.impl.osgi.test.BasicENSResourceOsgiTest.java

@Test
public void testBasicENSResourceFactoryRetrivalAndUsage() {
    System.out.println("Testing retrieval and usage of an instance of the factory "
            + BasicENSResourceFactory.class.getName());
    assertNotNull(resourcefactory);//from  w w  w  . j a  va 2s . co  m
    try {
        ENSResource r = resourcefactory.create("myHost", "myNamespace", "my.pattern");
        assertNotNull("The resource has not been created.");
        assertTrue(
                "The factory is not an instance of " + BasicENSResourceFactory.class.getName()
                        + ". Actual class: " + resourcefactory.getClass().getName(),
                resourcefactory instanceof BasicENSResourceFactory);
        assertTrue("The resource is not an instance of " + BasicENSResource.class.getName() + ". Actual class: "
                + r.getClass().getName(), r instanceof BasicENSResource);
        System.out.println("TEST SUCCEEDED");
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (URIBuildingException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    System.out.println();
}

From source file:com.blackducksoftware.integration.hub.detect.configuration.ConnectionManager.java

public ProxyInfo getHubProxyInfo() throws DetectUserFriendlyException {
    CredentialsBuilder proxyCredentialsBuilder = new CredentialsBuilder();
    proxyCredentialsBuilder.setUsername(
            detectConfiguration.getProperty(DetectProperty.BLACKDUCK_PROXY_USERNAME, PropertyAuthority.None));
    proxyCredentialsBuilder.setPassword(
            detectConfiguration.getProperty(DetectProperty.BLACKDUCK_PROXY_PASSWORD, PropertyAuthority.None));
    Credentials proxyCredentials = null;
    try {//from w  w  w. j  a  va  2  s  .  co m
        proxyCredentials = proxyCredentialsBuilder.build();
    } catch (final IllegalArgumentException e) {
        throw new DetectUserFriendlyException(
                String.format("Your proxy credentials configuration is not valid: %s", e.getMessage()), e,
                ExitCodeType.FAILURE_PROXY_CONNECTIVITY);
    }

    final ProxyInfoBuilder proxyInfoBuilder = new ProxyInfoBuilder();
    proxyInfoBuilder.setCredentials(proxyCredentials);
    proxyInfoBuilder.setHost(
            detectConfiguration.getProperty(DetectProperty.BLACKDUCK_PROXY_HOST, PropertyAuthority.None));
    String proxyPortFromConfiguration = detectConfiguration.getProperty(DetectProperty.BLACKDUCK_PROXY_PORT,
            PropertyAuthority.None);
    int proxyPort = NumberUtils.toInt(proxyPortFromConfiguration, 0);
    proxyInfoBuilder.setPort(proxyPort);
    proxyInfoBuilder.setNtlmDomain(detectConfiguration.getProperty(DetectProperty.BLACKDUCK_PROXY_NTLM_DOMAIN,
            PropertyAuthority.None));
    proxyInfoBuilder.setNtlmWorkstation(detectConfiguration
            .getProperty(DetectProperty.BLACKDUCK_PROXY_NTLM_WORKSTATION, PropertyAuthority.None));
    try {
        return proxyInfoBuilder.build();
    } catch (final IllegalArgumentException e) {
        throw new DetectUserFriendlyException(
                String.format("Your proxy configuration is not valid: %s", e.getMessage()), e,
                ExitCodeType.FAILURE_PROXY_CONNECTIVITY);
    }
}

From source file:br.com.caelum.vraptor.config.BasicConfigurationTest.java

@Test
public void shouldThrowExceptionWhenProviderClassWasNotFound() throws ServletException {
    when(context.getInitParameter(BasicConfiguration.CONTAINER_PROVIDER)).thenReturn("UnknowClass");

    try {/* ww w  .j a v  a2  s.  c  o  m*/
        config.getProvider();
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), startsWith("You must configure"));
    }
}

From source file:com.sap.dirigible.runtime.registry.RepositoryServlet.java

@Override
protected void doPut(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String repositoryPath = null;
    final OutputStream out = response.getOutputStream();
    try {//from w w  w .  j  av a2 s  . co  m
        repositoryPath = extractRepositoryPath(request);
        IEntity entity = getEntity(repositoryPath, request);
        if (entity == null) {
            doPost(request, response);
        } else {
            if (entity instanceof IResource) {
                ByteArrayOutputStream buff = new ByteArrayOutputStream();
                IOUtils.copy(request.getInputStream(), buff);
                byte[] data = buff.toByteArray();
                IResource resource = (IResource) entity;
                resource.setContent(data);
            } else {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_COLLECTION_AT_THE_SAME_LOCATION);
            }
        }
    } catch (IllegalArgumentException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage());
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage());
    } catch (MissingResourceException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage());
        response.sendError(HttpServletResponse.SC_NO_CONTENT, ex.getMessage());
    } finally {
        out.flush();
        out.close();
    }
}

From source file:org.venice.piazza.servicecontroller.messaging.handlers.UpdateServiceHandler.java

/**
 * /*from   www  .  j av a 2s  . co m*/
 * @param rMetadata
 * @return resourceId of the registered service
 */
public String handle(Service sMetadata) {
    String result = "";
    try {
        if (sMetadata != null) {
            coreLogger.log(String.format("Updating a registered service with ID %s", sMetadata.getServiceId()),
                    Severity.INFORMATIONAL);

            result = accessor.update(sMetadata);

            if (result.length() > 0) {
                coreLogger.log("The service " + sMetadata.getResourceMetadata().name + " was updated with id "
                        + result, Severity.INFORMATIONAL);

                coreLogger.log(String.format("Service was updated %s", sMetadata.getServiceId()),
                        Severity.INFORMATIONAL, new AuditElement("serviceController",
                                "updatedRegisteredService", sMetadata.getServiceId()));
                // Only when the user service data is updated successfully then
                // update elastic search
                PiazzaResponse response = elasticAccessor.update(sMetadata);
            } else {
                coreLogger.log("The service " + sMetadata.getResourceMetadata().name + " was NOT updated",
                        Severity.INFORMATIONAL);
                coreLogger.log("The service was NOT updated", Severity.ERROR, new AuditElement(
                        "serviceController", "failedToUpdateService", sMetadata.getServiceId()));
            }
            // If an Id was returned then send a kafka message back updating the job iD 
            // with the resourceId

            /*TODO if (ErrorResponse.class.isInstance(response)) {
               ErrorResponse errResponse = (ErrorResponse)response;
               LOGGER.error("The result of the elasticsearch update is " + errResponse.message);
               result = "";  // Indicates that update went wrong,  Mongo and ElasticSearch inconsistent
            }
            else {
               LOGGER.debug("ElasticSearch Successfully updated service " + sMetadata.getServiceId());
            }*/
        }
    } catch (IllegalArgumentException ex) {
        LOGGER.error("IllegalArgumentException occurred", ex);
        coreLogger.log(ex.getMessage(), Severity.ERROR);
    }

    return result;
}

From source file:br.com.caelum.vraptor.config.BasicConfigurationTest.java

@Test
public void shouldThrowIllegalArgumentExceptionWhenProvidersWasNotFound() throws Exception {
    BasicConfiguration configSpy = spy(config);

    when(context.getInitParameter(BasicConfiguration.CONTAINER_PROVIDER)).thenReturn(null);
    doReturn(false).when(configSpy).classExists(anyString());

    try {//from ww w. ja  v a2  s  .com
        configSpy.getProvider();
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), startsWith("You don't have any DI container jars on your classpath."));
    }
}

From source file:com.moneydance.modules.features.importlist.io.FileAdmin.java

public void reloadFiles() {
    synchronized (FileAdmin.class) {
        this.files.clear();
        try {//  www  . j ava 2  s. co  m
            final Collection<File> collection = FileUtils.listFiles(this.getBaseDirectory(),
                    this.readableFileFilter, null); // ignore subdirectories
            this.files.addAll(collection);
        } catch (IllegalArgumentException e) {
            LOG.log(Level.WARNING, e.getMessage(), e);
        }
    }
}

From source file:org.hdiv.web.servlet.view.freemarker.FreeMarkerViewTests.java

@Test
public void testNoTemplateName() throws Exception {
    FreeMarkerView fv = new FreeMarkerView();
    try {/*from   ww w  .  j ava  2  s  .  com*/
        fv.afterPropertiesSet();
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException ex) {
        // Check there's a helpful error message
        assertTrue(ex.getMessage().indexOf("url") != -1);
    }
}

From source file:com.graphhopper.http.GraphHopperServlet.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    try {//  ww w.j  a va  2s .  c o  m
        writePath(req, res);
    } catch (IllegalArgumentException ex) {
        writeError(res, SC_BAD_REQUEST, ex.getMessage());
    } catch (Exception ex) {
        logger.error("Error while executing request: " + req.getQueryString(), ex);
        writeError(res, SC_INTERNAL_SERVER_ERROR, "Problem occured:" + ex.getMessage());
    }
}