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.hyphenated.card.controller.ExceptionController.java

/**
 * Handles any Illegal State Exception from a controller method
 * @param e The exception that was thrown
 * @return JSON Map with error messages specific to the illegal state exception thrown
 *///w w  w .  ja  v  a  2 s . c om
@ExceptionHandler(IllegalStateException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public @ResponseBody Map<String, String> handleIOExcpetion(IllegalStateException e) {
    Map<String, String> error = new HashMap<String, String>();
    error.put("error", "Opperation not currently allowed.");
    error.put("errorDetails", e.getMessage());
    log.error("Error: " + e.getMessage());
    return error;
}

From source file:de.uzk.hki.da.action.ActionRegistryTests.java

/**
 * Test unknown action.//www. j  a v a 2s .c  o m
 */
@Test
public void testUnknownAction() {

    AbstractAction action = new TarAction();

    try {
        registry.registerAction(action);
        fail();
    } catch (IllegalStateException e) {
        System.out.println("Caught expected Exception: " + e.getMessage());
    }
}

From source file:org.openregistry.core.service.DefaultIdentifierNotificationServiceTests.java

@Test
public void sendAccountActivationWithInvalidActivationKey() {
    // Create a valid person with a name, a notifiable identifier and no activation key
    Person person = new MockPerson("testid", true, false);
    person.addName(createMockSorName("Firstname", "Lastname"));
    person.getPreferredContactEmailAddress().setAddress("test-preferred@test.test");
    IdentifierType identifierType = new MockIdentifierType("testNotifiableId", true);
    Identifier id = person.addIdentifier(identifierType, "notifiableId");
    id.setPrimary(true);/*from  ww w.ja  v  a 2s. com*/

    mockPersonRepository.getPersons().clear();
    mockPersonRepository.getPersons().add(person);

    try {
        notificationService.sendAccountActivationNotification(person, identifierType);
        fail("IllegalStateException must be thrown");
    } catch (IllegalStateException ise) {
        assertTrue("The IllegalStateException must contain a message about activation key",
                ise.getMessage().indexOf("activation key") >= 0);
    }
}

From source file:de.uzk.hki.da.action.ActionRegistryTests.java

/**
 * Test active threads lower than zero./*from   w  w  w  . java 2 s  .c o m*/
 */
@Test
public void testActiveThreadsLowerThanZero() {

    AbstractAction tarAction = (AbstractAction) context.getBean("IngestTarAction");

    try {
        registry.registerAction(tarAction);
        registry.deregisterAction(tarAction);
        registry.deregisterAction(tarAction);
        fail();
    } catch (IllegalStateException e) {
        System.out.println("Caught expected Exception: " + e.getMessage());
    }

}

From source file:org.sakaiproject.kernel.jcr.jackrabbit.sakai.SakaiXASessionImpl.java

/**
 * @param transactionManager// ww w .  ja  v  a  2  s. co  m
 * @throws RepositoryException
 */
private void bind(TransactionManager transactionManager) throws RepositoryException {
    try {
        Transaction transaction = transactionManager.getTransaction();
        if (transaction != null) {
            transaction.enlistResource(getXAResource());
        }
    } catch (IllegalStateException e) {
        throw new RepositoryException(e.getMessage(), e);
    } catch (RollbackException e) {
        throw new RepositoryException(e.getMessage(), e);
    } catch (SystemException e) {
        throw new RepositoryException(e.getMessage(), e);
    } catch (Exception e) {
        throw new RepositoryException(e.getMessage(), e);
    }
}

From source file:com.jana.android.net.AbstractHttpConnection.java

protected void connect(HttpRequestBase httpMethod) {

    try {/*w ww  .ja  va 2  s .  c  o m*/

        httpResponse = sHttpClient.execute(httpMethod, httpContext);

    } catch (IllegalStateException e) {

        Logger.w("Invalid url, Error > " + e.getMessage());

        e.printStackTrace();

    } catch (ClientProtocolException e) {

        Logger.w("HTTP Protocol Error > " + e.getMessage());

        e.printStackTrace();

    } catch (IOException e) {

        Logger.w("IO Error > " + e.getMessage());

        e.printStackTrace();
    }
}

From source file:com.sishuok.chapter4.web.servlet.UploadServlet.java

@Override
protected void doPost(final HttpServletRequest req, final HttpServletResponse resp)
        throws ServletException, IOException {

    try {//w w  w  .j  av  a 2  s  .  c o  m

        //servlet?Partnull
        //9.0.4.v20130625 ??
        System.out.println(req.getParameter("name"));

        //?Part
        System.out.println("\n\n==========file1");
        Part file1Part = req.getPart("file1"); //?? ?Part
        InputStream file1PartInputStream = file1Part.getInputStream();
        System.out.println(IOUtils.toString(file1PartInputStream));
        file1PartInputStream.close();

        // ??
        System.out.println("\n\n==========file2");
        Part file2Part = req.getPart("file2");
        InputStream file2PartInputStream = file2Part.getInputStream();
        System.out.println(IOUtils.toString(file2PartInputStream));
        file2PartInputStream.close();

        System.out.println("\n\n==========parameter name");
        //????
        System.out.println(IOUtils.toString(req.getPart("name").getInputStream()));
        //Part??? jettyparameters??
        System.out.println(req.getParameter("name"));

        //?? ? req.getInputStream(); ??

        System.out.println("\n\n=============all part");
        for (Part part : req.getParts()) {
            System.out.println("\n\n=========name:::" + part.getName());
            System.out.println("=========size:::" + part.getSize());
            System.out.println("=========content-type:::" + part.getContentType());
            System.out
                    .println("=========header content-disposition:::" + part.getHeader("content-disposition"));
            System.out.println("=========file name:::" + getFileName(part));
            InputStream partInputStream = part.getInputStream();
            System.out.println("=========value:::" + IOUtils.toString(partInputStream));

            //
            partInputStream.close();
            // ? ? ?
            part.delete();

        }

    } catch (IllegalStateException ise) {
        //
        ise.printStackTrace();
        String errorMsg = ise.getMessage();
        if (errorMsg.contains("Request exceeds maxRequestSize")) {
            //?
        } else if (errorMsg.contains("Multipart Mime part file1 exceeds max filesize")) {
            //? ??
        } else {
            //
        }
    }

}

From source file:org.apache.nifi.lookup.CSVRecordLookupService.java

@OnEnabled
public void onEnabled(final ConfigurationContext context) throws InitializationException, IOException {
    this.csvFile = context.getProperty(CSV_FILE).getValue();
    this.csvFormat = CSVFormat.Predefined.valueOf(context.getProperty(CSV_FORMAT).getValue()).getFormat();
    this.lookupKeyColumn = context.getProperty(LOOKUP_KEY_COLUMN).getValue();
    this.ignoreDuplicates = context.getProperty(IGNORE_DUPLICATES).asBoolean();
    this.watcher = new SynchronousFileWatcher(Paths.get(csvFile), new LastModifiedMonitor(), 30000L);
    try {//  w w w. ja  v a  2  s. c o m
        loadCache();
    } catch (final IllegalStateException e) {
        throw new InitializationException(e.getMessage(), e);
    }
}

From source file:com.blackducksoftware.integration.hub.detect.detector.pip.PipInspectorTreeParser.java

public Optional<PipParseResult> parse(final List<String> pipInspectorOutputAsList, final String sourcePath) {
    PipParseResult parseResult = null;//  ww w  . j a  v  a  2  s.co  m

    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    final DependencyHistory history = new DependencyHistory();
    Dependency project = null;

    for (final String line : pipInspectorOutputAsList) {
        final String trimmedLine = StringUtils.trimToEmpty(line);
        if (StringUtils.isEmpty(trimmedLine) || !trimmedLine.contains(SEPARATOR)
                || trimmedLine.startsWith(UNKNOWN_REQUIREMENTS_PREFIX)
                || trimmedLine.startsWith(UNPARSEABLE_REQUIREMENTS_PREFIX)
                || trimmedLine.startsWith(UNKNOWN_PACKAGE_PREFIX)) {
            parseErrorsFromLine(trimmedLine);
            continue;
        }

        final Dependency currentDependency = parseDependencyFromLine(trimmedLine, sourcePath);
        final int lineLevel = getLineLevel(trimmedLine);
        try {
            history.clearDependenciesDeeperThan(lineLevel);
        } catch (final IllegalStateException e) {
            logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage()));
        }

        if (project == null) {
            project = currentDependency;
        } else if (project.equals(history.getLastDependency())) {
            graph.addChildToRoot(currentDependency);
        } else if (history.isEmpty()) {
            graph.addChildToRoot(currentDependency);
        } else {
            graph.addChildWithParents(currentDependency, history.getLastDependency());
        }

        history.add(currentDependency);
    }

    if (project != null) {
        final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.PIP,
                sourcePath, project.externalId, graph).build();
        parseResult = new PipParseResult(project.name, project.version, codeLocation);
    }

    return Optional.ofNullable(parseResult);
}

From source file:com.oneteam.framework.android.net.AbstractHttpConnection.java

@Override
public InputStream getContent() {

    if (!hasConnection()) {
        return null;
    }/*from  w w w  .j  ava  2 s. c o  m*/

    HttpEntity httpEntity = mHttpResponse.getEntity();

    try {

        InputStream in = httpEntity.getContent();

        return in;

    } catch (IllegalStateException e) {

        Logger.w("No stream content as it has already been obtained, Error > " + e.getMessage());

        e.printStackTrace();

        return null;
    } catch (IOException e) {

        Logger.w("No stream content as stream could not be created, Error > " + e.getMessage());

        e.printStackTrace();

        return null;
    }
}