Search in sources :

Example 1 with DataTypeNotSupportedException

use of org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException in project geode by apache.

the class AbstractBaseController method getValues.

protected <T> Map<Object, T> getValues(final String regionNamePath, Object... keys) {
    try {
        final Region<Object, T> region = getRegion(regionNamePath);
        final Map<Object, T> entries = region.getAll(Arrays.asList(getKeys(regionNamePath, keys)));
        for (Object key : entries.keySet()) {
            entries.put(key, (T) securityService.postProcess(regionNamePath, key, entries.get(key), false));
        }
        return entries;
    } catch (SerializationException se) {
        throw new DataTypeNotSupportedException("The resource identified could not convert into the supported content characteristics (JSON)!", se);
    }
}
Also used : SerializationException(org.apache.geode.SerializationException) DataTypeNotSupportedException(org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException) JSONObject(org.json.JSONObject)

Example 2 with DataTypeNotSupportedException

use of org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException in project geode by apache.

the class AbstractBaseController method getValue.

protected <T> T getValue(final String regionNamePath, final Object key, boolean postProcess) {
    Assert.notNull(key, "The Cache Region key to read the value for cannot be null!");
    Region r = getRegion(regionNamePath);
    try {
        Object value = r.get(key);
        if (postProcess) {
            return (T) securityService.postProcess(regionNamePath, key, value, false);
        } else {
            return (T) value;
        }
    } catch (SerializationException se) {
        throw new DataTypeNotSupportedException("The resource identified could not convert into the supported content characteristics (JSON)!", se);
    } catch (NullPointerException npe) {
        throw new GemfireRestException(String.format("Resource (%1$s) configuration does not allow null keys!", regionNamePath), npe);
    } catch (IllegalArgumentException iae) {
        throw new GemfireRestException(String.format("Resource (%1$s) configuration does not allow requested operation on specified key!", regionNamePath), iae);
    } catch (LeaseExpiredException lee) {
        throw new GemfireRestException("Server has encountered error while processing this request!", lee);
    } catch (TimeoutException te) {
        throw new GemfireRestException("Server has encountered timeout error while processing this request!", te);
    } catch (CacheLoaderException cle) {
        throw new GemfireRestException("Server has encountered CacheLoader error while processing this request!", cle);
    } catch (PartitionedRegionStorageException prse) {
        throw new GemfireRestException("CacheLoader could not be invoked on partitioned region!", prse);
    }
}
Also used : GemfireRestException(org.apache.geode.rest.internal.web.exception.GemfireRestException) SerializationException(org.apache.geode.SerializationException) LeaseExpiredException(org.apache.geode.distributed.LeaseExpiredException) DataTypeNotSupportedException(org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) Region(org.apache.geode.cache.Region) JSONObject(org.json.JSONObject) TimeoutException(org.apache.geode.cache.TimeoutException)

Aggregations

SerializationException (org.apache.geode.SerializationException)2 DataTypeNotSupportedException (org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException)2 JSONObject (org.json.JSONObject)2 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 PartitionedRegionStorageException (org.apache.geode.cache.PartitionedRegionStorageException)1 Region (org.apache.geode.cache.Region)1 TimeoutException (org.apache.geode.cache.TimeoutException)1 LeaseExpiredException (org.apache.geode.distributed.LeaseExpiredException)1 GemfireRestException (org.apache.geode.rest.internal.web.exception.GemfireRestException)1