Search in sources :

Example 1 with ExceptionMapperLookup

use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.

the class ModuleRegistryTest method testExceptionMappers.

@Test
public void testExceptionMappers() {
    ExceptionMapperLookup exceptionMapperLookup = moduleRegistry.getExceptionMapperLookup();
    Set<JsonApiExceptionMapper> exceptionMappers = exceptionMapperLookup.getExceptionMappers();
    Set<Class<?>> classes = new HashSet<>();
    for (JsonApiExceptionMapper exceptionMapper : exceptionMappers) {
        classes.add(exceptionMapper.getClass());
    }
    Assert.assertTrue(classes.contains(IllegalStateExceptionMapper.class));
    Assert.assertTrue(classes.contains(SomeIllegalStateExceptionMapper.class));
}
Also used : SomeIllegalStateExceptionMapper(io.crnk.core.engine.internal.exception.ExceptionMapperRegistryTest.SomeIllegalStateExceptionMapper) ExceptionMapperLookup(io.crnk.core.engine.internal.exception.ExceptionMapperLookup) IllegalStateExceptionMapper(io.crnk.core.engine.internal.exception.ExceptionMapperRegistryTest.IllegalStateExceptionMapper) SomeIllegalStateExceptionMapper(io.crnk.core.engine.internal.exception.ExceptionMapperRegistryTest.SomeIllegalStateExceptionMapper) JsonApiExceptionMapper(io.crnk.core.engine.error.JsonApiExceptionMapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ExceptionMapperLookup

use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.

the class SimpleModule method addExceptionMapper.

public void addExceptionMapper(@SuppressWarnings("rawtypes") JsonApiExceptionMapper exceptionMapper) {
    checkInitialized();
    ExceptionMapperLookup exceptionMapperLookup = new CollectionExceptionMapperLookup(exceptionMapper);
    exceptionMapperLookups.add(exceptionMapperLookup);
}
Also used : ExceptionMapperLookup(io.crnk.core.engine.internal.exception.ExceptionMapperLookup)

Example 3 with ExceptionMapperLookup

use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.

the class ModuleRegistry method init.

/**
 * Initializes the {@link ModuleRegistry} and applies all pending changes.
 * After the initialization completed, it is not possible to add any further
 * modules.
 *
 * @param objectMapper object mapper
 */
public void init(ObjectMapper objectMapper) {
    PreconditionUtil.assertEquals("already initialized", InitializedState.NOT_INITIALIZED, initializedState);
    this.initializedState = InitializedState.INITIALIZING;
    this.objectMapper = objectMapper;
    this.objectMapper.registerModules(getJacksonModules());
    initializeModules();
    applyRepositoryRegistrations();
    ExceptionMapperLookup exceptionMapperLookup = getExceptionMapperLookup();
    ExceptionMapperRegistryBuilder mapperRegistryBuilder = new ExceptionMapperRegistryBuilder();
    exceptionMapperRegistry = mapperRegistryBuilder.build(exceptionMapperLookup);
    filterBehaviorProvider = new ResourceFilterDirectoryImpl(aggregatedModule.getResourceFilters(), httpRequestContextProvider, resourceRegistry);
    this.initializedState = InitializedState.INITIALIZED;
}
Also used : ExceptionMapperLookup(io.crnk.core.engine.internal.exception.ExceptionMapperLookup) ResourceFilterDirectoryImpl(io.crnk.core.module.internal.ResourceFilterDirectoryImpl) ExceptionMapperRegistryBuilder(io.crnk.core.engine.internal.exception.ExceptionMapperRegistryBuilder)

Example 4 with ExceptionMapperLookup

use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.

the class CrnkClient method initExceptionMapperRegistry.

private void initExceptionMapperRegistry() {
    ExceptionMapperLookup exceptionMapperLookup = moduleRegistry.getExceptionMapperLookup();
    exceptionMapperRegistry = new ExceptionMapperRegistryBuilder().build(exceptionMapperLookup);
}
Also used : ExceptionMapperLookup(io.crnk.core.engine.internal.exception.ExceptionMapperLookup) ExceptionMapperRegistryBuilder(io.crnk.core.engine.internal.exception.ExceptionMapperRegistryBuilder)

Aggregations

ExceptionMapperLookup (io.crnk.core.engine.internal.exception.ExceptionMapperLookup)4 ExceptionMapperRegistryBuilder (io.crnk.core.engine.internal.exception.ExceptionMapperRegistryBuilder)2 JsonApiExceptionMapper (io.crnk.core.engine.error.JsonApiExceptionMapper)1 IllegalStateExceptionMapper (io.crnk.core.engine.internal.exception.ExceptionMapperRegistryTest.IllegalStateExceptionMapper)1 SomeIllegalStateExceptionMapper (io.crnk.core.engine.internal.exception.ExceptionMapperRegistryTest.SomeIllegalStateExceptionMapper)1 ResourceFilterDirectoryImpl (io.crnk.core.module.internal.ResourceFilterDirectoryImpl)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1