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.eTilbudsavis.etasdk.DbHelper.java

/**
 * Get a shoppinglistitem from the db//ww w  . j ava  2 s.co m
 * @param itemId to get from db
 * @return A shoppinglistitem or null if no match is found
 */
public ShoppinglistItem getItem(String itemId, User user) {
    itemId = escape(itemId);
    String q = String.format("SELECT * FROM %s WHERE %s=%s AND  %s=%s", ITEM_TABLE, ID, itemId, USER,
            user.getUserId());
    Cursor c = null;
    ShoppinglistItem sli = null;
    try {
        c = execQuery(q);
        if (c.moveToFirst()) {
            sli = cursorToSli(c);
        }
    } catch (IllegalStateException e) {
        EtaLog.d(TAG, e.getMessage(), e);
    } finally {
        closeCursorAndDB(c);
    }
    return sli;
}

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

public ShoppinglistItem getItemPrevious(String shoppinglistId, String previousId, User user) {
    String id = escape(shoppinglistId);
    String prev = escape(previousId);
    String q = String.format("SELECT * FROM %s WHERE %s=%s AND %s=%s AND %s=%s", ITEM_TABLE, SHOPPINGLIST_ID,
            id, PREVIOUS_ID, prev, USER, user.getUserId());
    ShoppinglistItem sli = null;/*ww  w . j  av a2  s .com*/
    Cursor c = null;
    try {
        c = execQuery(q);
        if (c.moveToFirst()) {
            sli = cursorToSli(c);
        }
    } catch (IllegalStateException e) {
        EtaLog.d(TAG, e.getMessage(), e);
    } finally {
        closeCursorAndDB(c);
    }
    return sli;
}

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

/**
 * Get a shoppinglist by it's id//from   w w  w . java  2 s . co  m
 * @param id to get from db
 * @return A shoppinglist or null if no march is found
 */
public Shoppinglist getList(String id, User user) {
    id = escape(id);
    String q = String.format("SELECT * FROM %s WHERE %s=%s AND %s=%s AND %s!=%s", LIST_TABLE, ID, id, USER,
            user.getUserId(), STATE, SyncState.DELETE);
    Cursor c = null;
    Shoppinglist sl = null;
    try {
        c = execQuery(q);
        sl = c.moveToFirst() ? cursorToSl(c) : null;
    } catch (IllegalStateException e) {
        EtaLog.d(TAG, e.getMessage(), e);
    } finally {
        closeCursorAndDB(c);
    }
    if (sl != null) {
        sl.putShares(getShares(sl, user, false));
        sl = sl.getShares().containsKey(user.getEmail()) ? sl : null;
    }
    return sl;
}

From source file:net.sf.ehcache.CacheManagerTest.java

/**
 * Test using a cache which has been removed and replaced.
 *///from   w  w w  .jav a  2 s.co m
public void testStaleCacheReference() throws CacheException {
    singletonManager = CacheManager.create();
    singletonManager.addCache("test");
    Ehcache cache = singletonManager.getCache("test");
    assertNotNull(cache);
    cache.put(new Element("key1", "value1"));

    assertEquals("value1", cache.get("key1").getObjectValue());
    singletonManager.removeCache("test");
    singletonManager.addCache("test");

    try {
        cache.get("key1");
        fail();
    } catch (IllegalStateException e) {
        assertEquals("The test Cache is not alive.", e.getMessage());
    }
}

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

@Test
public void testBuildStorageUnitStatusChangeMessagesJsonPayloadNoMessageType() throws Exception {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME,
            FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES,
            DATA_VERSION);/*w  w  w .j a va 2 s .  com*/

    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(
            ConfigurationValue.HERD_NOTIFICATION_STORAGE_UNIT_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(
            Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION,
                    BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON,
                    Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to build a notification message.
    try {
        storageUnitStatusChangeMessageBuilder
                .buildNotificationMessages(new StorageUnitStatusChangeNotificationEvent(businessObjectDataKey,
                        STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2));
        fail();
    } catch (IllegalStateException illegalStateException) {
        assertEquals(String.format(
                "Notification message type must be specified. Please update \"%s\" configuration entry.",
                ConfigurationValue.HERD_NOTIFICATION_STORAGE_UNIT_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey()),
                illegalStateException.getMessage());
    }
}

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

/**
 * Get all {@link ShoppinglistItem} from a {@link Shoppinglist}.
 * @param shoppinglistId from which to get items
 * @return A list of shoppinglistitems/*  ww w . j ava2  s  .  c  o m*/
 */
public List<ShoppinglistItem> getItems(String shoppinglistId, User user, boolean includeDeleted) {
    String id = escape(shoppinglistId);
    String q = null;
    if (includeDeleted) {
        q = String.format("SELECT * FROM %s WHERE %s=%s AND %s=%s", ITEM_TABLE, SHOPPINGLIST_ID, id, USER,
                user.getUserId());
    } else {
        q = String.format("SELECT * FROM %s WHERE %s=%s AND %s!=%s AND %s=%s", ITEM_TABLE, SHOPPINGLIST_ID, id,
                STATE, SyncState.DELETE, USER, user.getUserId());
    }
    List<ShoppinglistItem> items = new ArrayList<ShoppinglistItem>();
    Cursor c = null;
    try {
        c = execQuery(q);
        if (c.moveToFirst()) {
            do {
                items.add(cursorToSli(c));
            } while (c.moveToNext());
        }
    } catch (IllegalStateException e) {
        EtaLog.d(TAG, e.getMessage(), e);
    } finally {
        closeCursorAndDB(c);
    }
    return items;
}

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

/**
 * /*from w  ww. ja  v a 2  s  .c  om*/
 * @param sl
 * @param userId
 * @param includeDeleted
 * @return
 */
public List<Share> getShares(Shoppinglist sl, User user, boolean includeDeleted) {
    String slId = escape(sl.getId());
    String q = null;
    if (includeDeleted) {
        q = String.format("SELECT * FROM %s WHERE %s=%s AND %s=%s", SHARE_TABLE, SHOPPINGLIST_ID, slId, USER,
                user.getUserId());
    } else {
        q = String.format("SELECT * FROM %s WHERE %s=%s AND %s!=%s AND %s=%s", SHARE_TABLE, SHOPPINGLIST_ID,
                slId, STATE, SyncState.DELETE, USER, user.getUserId());
    }

    List<Share> shares = new ArrayList<Share>();
    Cursor c = null;
    try {
        c = execQuery(q);
        if (c.moveToFirst()) {
            do {
                shares.add(cursorToShare(c, sl));
            } while (c.moveToNext());
        }
    } catch (IllegalStateException e) {
        EtaLog.d(TAG, e.getMessage(), e);
    } finally {
        closeCursorAndDB(c);
    }

    return shares;
}

From source file:org.libreplan.web.orders.criterionrequirements.AssignedCriterionRequirementController.java

private void showInvalidConstraint(Bandbox bandbox, IllegalStateException e) {
    bandbox.setValue("");
    throw new WrongValueException(bandbox, _(e.getMessage()));
}

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

@Test
public void testBuildStorageUnitStatusChangeMessagesJsonPayloadNoMessageDestination() throws Exception {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME,
            FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES,
            DATA_VERSION);/*from w  ww  .jav  a2s.c om*/

    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(
            ConfigurationValue.HERD_NOTIFICATION_STORAGE_UNIT_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections
            .singletonList(new NotificationMessageDefinition(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION,
                    BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON,
                    Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);

    // Try to build a notification message.
    try {
        storageUnitStatusChangeMessageBuilder
                .buildNotificationMessages(new StorageUnitStatusChangeNotificationEvent(businessObjectDataKey,
                        STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2));
        fail();
    } catch (IllegalStateException illegalStateException) {
        assertEquals(String.format(
                "Notification message destination must be specified. Please update \"%s\" configuration entry.",
                ConfigurationValue.HERD_NOTIFICATION_STORAGE_UNIT_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey()),
                illegalStateException.getMessage());
    }
}

From source file:com.github.cherimojava.data.mongo.io._DeEncoding.java

@Test
public void finalIsFinalAfterSave() throws NoSuchMethodException {
    ExplicitIdEntity e = factory.create(ExplicitIdEntity.class);
    e.setName("some").save();
    try {//from  w ww .ja va 2  s  .co m
        e.setName("change");
        fail("should throw an exception");
    } catch (IllegalStateException ise) {
        assertThat(ise.getMessage(), containsString("@Final property"));
    }
}