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:org.ow2.chameleon.core.activators.DirectoryMonitor.java

/**
 * {@inheritDoc}/*from w  w w. j  a v  a2  s .co  m*/
 */
@Override
public void stop(BundleContext context) {
    // To avoid concurrency, we take the write lock here.
    try {
        acquireWriteLockIfNotHeld();
        this.tracker.close();
        if (reg != null) {
            reg.unregister();
            reg = null;
        }
        for (Map.Entry<File, FileAlterationMonitor> entry : monitors.entrySet()) {
            if (entry.getValue() != null) {
                LOGGER.debug("Stopping file monitoring of {}", entry.getKey().getAbsolutePath());
                try {
                    entry.getValue().stop();
                    LOGGER.debug("File monitoring stopped");
                } catch (IllegalStateException e) {
                    LOGGER.warn("Stopping an already stopped file monitor on {}.",
                            entry.getKey().getAbsolutePath());
                    LOGGER.debug(e.getMessage(), e);
                } catch (Exception e) {
                    LOGGER.error("Something bad happened while trying to stop the file monitor", e);
                }
            }
        }
        monitors.clear();
        this.context = null;
    } finally {
        releaseWriteLockIfHeld();
    }

    // No concurrency involved from here (tracker closed)
    for (Deployer deployer : deployers) {
        deployer.close();
    }
}

From source file:org.finra.herd.service.helper.notification.BusinessObjectFormatVersionChangeMessageBuilderTest.java

@Test
public void testBuildBusinessObjectFormatVersionChangeMessagesJsonPayloadInvalidMessageType() throws Exception {
    // Create a business object format key.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME,
            FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION);

    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(//from   w w w. j a  va2 s  .  co  m
            ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS
                    .getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(
            Collections.singletonList(new NotificationMessageDefinition(INVALID_VALUE, MESSAGE_DESTINATION,
                    BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON,
                    NO_MESSAGE_HEADER_DEFINITIONS)))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to build a notification message.
    try {
        businessObjectFormatVersionChangeMessageBuilder.buildNotificationMessages(
                new BusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey,
                        FORMAT_VERSION_2.toString()));
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(
                "Only \"%s\" notification message type is supported. Please update \"%s\" configuration entry.",
                MESSAGE_TYPE_SNS,
                ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS
                        .getKey()),
                e.getMessage());
    }
}

From source file:fr.cph.chicago.fragment.NearbyFragment.java

/**
 * Show progress bar/*from   ww  w. j  a  va  2 s.  co  m*/
 * 
 * @param show
 *            true or falseO
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private final void showProgress(final boolean show) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
            mLoadLayout.setVisibility(View.VISIBLE);
            mLoadLayout.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0)
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            mLoadLayout.setVisibility(show ? View.VISIBLE : View.GONE);
                        }
                    });
        } else {
            mLoadLayout.setVisibility(show ? View.VISIBLE : View.GONE);
        }
        mActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    } catch (IllegalStateException e) {
        Log.w(TAG, e.getMessage(), e);
    }
}

From source file:org.finra.herd.service.helper.DefaultNotificationMessageBuilderTest.java

@Test
public void testBuildSystemMonitorResponseInvalidXpathExpression() throws Exception {
    // Override the configuration to use an invalid XPath expression.
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.HERD_NOTIFICATION_SQS_SYS_MONITOR_RESPONSE_VELOCITY_TEMPLATE.getKey(),
            SYSTEM_MONITOR_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML);
    overrideMap.put(ConfigurationValue.HERD_NOTIFICATION_SQS_SYS_MONITOR_REQUEST_XPATH_PROPERTIES.getKey(),
            "key=///");
    modifyPropertySourceInEnvironment(overrideMap);

    try {//from  w ww. j av a  2 s  . co  m
        // Try to build a system monitor response message when xpath expression is invalid.
        defaultNotificationMessageBuilder.buildSystemMonitorResponse(getTestSystemMonitorIncomingMessage());
        fail();
    } catch (IllegalStateException e) {
        assertTrue(
                e.getMessage().startsWith("XPath expression \"///\" could not be evaluated against payload"));
    } finally {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}

From source file:eu.europa.ec.eci.oct.admin.controller.SettingsController.java

@Override
protected String _doPost(Model model, SettingsBean bean, BindingResult result, SessionStatus status,
        HttpServletRequest request, HttpServletResponse response) throws OCTException {
    if (request.getParameter("saveSettings") != null) {
        ConfigurationParameter param;/*from  w  w w  .  j av a  2 s . co  m*/

        // custom logo settings
        if (bean.isDeleteLogo()) {
            param = configurationService.getConfigurationParameter(Parameter.LOGO_PATH);

            // delete file from disk
            final String storagePath = systemManager.getSystemPreferences().getFileStoragePath();
            final File destFolder = new File(storagePath, "/custom");
            final File dest = new File(destFolder, param.getValue());
            dest.delete();

            // update db
            param.setValue(Parameter.LOGO_PATH.getDefaultValue());
            configurationService.updateParameter(param);
        } else {
            final CommonsMultipartFile file = bean.getLogoFile();
            if (file != null && !"".equals(file.getOriginalFilename())) {
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            "Uploaded new logo file: " + file.getFileItem().getName() + " / " + file.getSize());
                }

                // validate uploaded logo file
                final Map<MultipartFileValidator.RejectReason, String> rejectDetailsMap = new HashMap<MultipartFileValidator.RejectReason, String>();
                rejectDetailsMap.put(RejectReason.EMPTY_CONTENT, "oct.settings.error.logo.missing");
                rejectDetailsMap.put(RejectReason.EMPTY_NAME, "oct.settings.error.logo.missing");
                rejectDetailsMap.put(RejectReason.BAD_EXTENSION, "oct.settings.error.logo.badExtension");
                rejectDetailsMap.put(RejectReason.MAX_SIZE_EXCEEDED, "oct.settings.error.logo.toobig");

                final Validator validator = new MultipartFileValidator(getCurrentMessageBundle(request),
                        "oct.settings.error.logo.upload", rejectDetailsMap, uploadExtensionWhitelist, 150000);
                validator.validate(file, result);
                if (result.hasErrors()) {
                    return doGet(model, request, response);
                }

                // validation passed, save file to needed location and
                // update the db
                final String storagePath = systemManager.getSystemPreferences().getFileStoragePath();
                final File destFolder = new File(storagePath, "/custom");
                if (!destFolder.exists()) {
                    boolean dirCreated = destFolder.mkdirs();
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "Storage directory \"" + destFolder.getPath() + "\" created? => " + dirCreated);
                    }
                }

                final String extension = file.getOriginalFilename()
                        .substring(file.getOriginalFilename().lastIndexOf('.'));
                final String fileName = new StringBuilder().append("customlogo")
                        .append(System.currentTimeMillis()).append(extension).toString();

                final File dest = new File(destFolder, fileName);
                try {
                    file.transferTo(dest);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Uploaded logo file successfully transfered to the local file "
                                + dest.getAbsolutePath());
                    }
                } catch (IllegalStateException e) {
                    logger.error("illegal state error while uploading logo", e);
                    result.reject("oct.settings.error.logo.upload", "Error uploading logo");
                    return doGet(model, request, response);
                } catch (IOException e) {
                    logger.error("input/output error while uploading logo", e);
                    result.reject("oct.settings.error.logo.upload", e.getMessage());
                    return doGet(model, request, response);
                }

                param = new ConfigurationParameter();
                param.setParam(Parameter.LOGO_PATH.getKey());
                param.setValue(fileName);
                configurationService.updateParameter(param);
            }
        }

        // callback url
        final String callbackUrl = bean.getCallbackUrl();
        if (callbackUrl != null && !"".equals(callbackUrl)) {
            // validate url
            UrlValidator validator = UrlValidator.getInstance();
            if (!validator.isValid(callbackUrl)) {
                result.rejectValue("callbackUrl", "oct.settings.error.callback.invalidurl",
                        "An invalid URL has been specified.");
                return doGet(model, request, response);
            }
        }
        param = new ConfigurationParameter();
        param.setParam(Parameter.CALLBACK_URL.getKey());
        param.setValue(callbackUrl);
        configurationService.updateParameter(param);

        // optional validation
        param = new ConfigurationParameter();
        param.setParam(Parameter.OPTIONAL_VALIDATION.getKey());
        param.setValue(new Boolean(bean.getOptionalValidation()).toString());
        configurationService.updateParameter(param);

        // distribution map
        param = new ConfigurationParameter();
        param.setParam(Parameter.SHOW_DISTRIBUTION_MAP.getKey());
        param.setValue(new Boolean(bean.getDisplayMap()).toString());
        configurationService.updateParameter(param);
    }

    return "redirect:settings.do";
}

From source file:com.alibaba.napoli.metamorphosis.client.extension.producer.AsyncMetaMessageProducer.java

@Override
public void asyncSendMessage(final Message message, final long timeout, final TimeUnit unit) {
    try {//from w w w.  j  a v  a2 s .  c o m
        super.sendMessage(message, timeout, unit);
    } catch (final IllegalStateException e) {
        // ?producer
        log.warn(e);
    } catch (final InvalidMessageException e) {
        // ??,??,recover?
        log.warn(e);
    } catch (final MetaClientException e) {
        // ????
        if (log.isDebugEnabled()) {
            log.debug("save to local strage,and waitting for recover. cause:" + e.getMessage());
        }
        this.handleSendFailMessage(message);
    } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (final Throwable e) {
        // 
        if (log.isDebugEnabled()) {
            log.debug("save to local strage,and waitting for recover. cause:", e);
        }
        this.handleSendFailMessage(message);
    }
}

From source file:com.atlassian.jira.bc.user.TestDefaultUserService.java

@Test
public void testCreateUserInvalidResult() throws PermissionException, CreateException {
    final ErrorCollection errors = new SimpleErrorCollection();
    errors.addErrorMessage("Something went wrong");
    final UserService.CreateUserValidationResult result = new UserService.CreateUserValidationResult(errors);
    final UserService userService = new DefaultUserService(null, null, null, null, null, null, null, null, null,
            passwordPolicyManager);/*from   w w w  .ja v  a  2  s  .  c  om*/

    try {
        userService.createUserWithNotification(result);
        fail("Should not be able to create a user with an invalid validation result.");
    } catch (final IllegalStateException e) {
        assertEquals("You can not create a user with an invalid validation result.", e.getMessage());
    }
}

From source file:com.evolveum.midpoint.prism.PrismPropertyValue.java

@Override
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw,
        ConsistencyCheckScope scope) {//from  w ww  .ja  v a2s .  c  om
    if (!scope.isThorough()) {
        return;
    }

    ItemPath myPath = getPath();
    if (prohibitRaw && rawElement != null) {
        throw new IllegalStateException(
                "Raw element in property value " + this + " (" + myPath + " in " + rootItem + ")");
    }
    if (value == null && rawElement == null) {
        throw new IllegalStateException("Neither value nor raw element specified in property value " + this
                + " (" + myPath + " in " + rootItem + ")");
    }
    if (value != null && rawElement != null) {
        throw new IllegalStateException("Both value and raw element specified in property value " + this + " ("
                + myPath + " in " + rootItem + ")");
    }
    if (value != null) {
        if (value instanceof Recomputable) {
            try {
                ((Recomputable) value).checkConsistence();
            } catch (IllegalStateException e) {
                throw new IllegalStateException(
                        e.getMessage() + " in property value " + this + " (" + myPath + " in " + rootItem + ")",
                        e);
            }
        }
        if (value instanceof PolyStringType) {
            throw new IllegalStateException(
                    "PolyStringType found in property value " + this + " (" + myPath + " in " + rootItem + ")");
        }
        PrismContext prismContext = getPrismContext();
        if (value instanceof PolyString && prismContext != null) {
            PolyString poly = (PolyString) value;
            String orig = poly.getOrig();
            String norm = poly.getNorm();
            PolyStringNormalizer polyStringNormalizer = prismContext.getDefaultPolyStringNormalizer();
            String expectedNorm = polyStringNormalizer.normalize(orig);
            if (!norm.equals(expectedNorm)) {
                throw new IllegalStateException("PolyString has inconsistent orig (" + orig + ") and norm ("
                        + norm + ") in property value " + this + " (" + myPath + " in " + rootItem + ")");
            }
        }
    }
}

From source file:com.sunchenbin.store.feilong.servlet.http.builder.RequestLogBuilder.java

/**
 * ?./* ww w .j  a v  a 2  s . co  m*/
 * 
 * <p>
 * ?log, Cannot create a session after the response has been committed <br>
 * 
 * </p>
 * 
 * <p>
 * I have learnt that maybe my 8K buffer gets full in some cases (as you said, my contect is dynamic and sometimes could be large). <br>
 * 
 * In that case, I have understanded that a full buffer triggers a commit, and when that happens the JSP error page can not do its job
 * and then "java.lang.IllegalStateException: Cannot create a session after the response has been committed" happens. <br>
 * 
 * OK, but is there any other possible reason for the early commit? <br>
 * My session is created early enough, and in fact the JSP page creates it if necessary, by default.
 * </p>
 *
 * @return the session id,,  {@link java.lang.Throwable#getMessage()}
 * @since 1.4.1
 */
private String getSessionId() {
    try {
        HttpSession session = request.getSession(false);
        return null == session ? StringUtils.EMPTY : session.getId();
    } catch (IllegalStateException e) {//Cannot create a session after the response has been committed 
        String msg = Slf4jUtil.formatMessage("uri:[{}],paramMap:{}", request.getRequestURI(),
                request.getParameterMap());
        LOGGER.error(msg, e);
        return e.getMessage();
    }
}

From source file:com.eTilbudsavis.etasdk.DbHelper.java

public Shoppinglist getListPrevious(String previousId, User user) {
    String prev = escape(previousId);
    String q = String.format("SELECT * FROM %s WHERE %s=%s AND %s=%s", LIST_TABLE, PREVIOUS_ID, prev, USER,
            user.getUserId());/*from  w ww.j a  v a  2  s  . c  o m*/
    Shoppinglist sl = null;
    Cursor c = null;
    try {
        c = execQuery(q);
        if (c.moveToFirst()) {
            sl = cursorToSl(c);
        }
    } catch (IllegalStateException e) {
        EtaLog.d(TAG, e.getMessage(), e);
    } finally {
        closeCursorAndDB(c);
    }
    return sl;
}