use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class CrnkFeature method registerActionRepositories.
/**
* All repositories with JAX-RS action need to be registered with JAX-RS as singletons.
*
* @param context of jaxrs
* @param boot of crnk
*/
private void registerActionRepositories(FeatureContext context, CrnkBoot boot) {
ResourceRegistry resourceRegistry = boot.getResourceRegistry();
Collection<RegistryEntry> registryEntries = resourceRegistry.getResources();
for (RegistryEntry registryEntry : registryEntries) {
ResourceRepositoryInformation repositoryInformation = registryEntry.getRepositoryInformation();
if (repositoryInformation != null && !repositoryInformation.getActions().isEmpty()) {
ResourceRepositoryAdapter<?, Serializable> repositoryAdapter = registryEntry.getResourceRepository(null);
Object resourceRepository = repositoryAdapter.getResourceRepository();
context.register(resourceRepository);
}
}
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class SecurityModule method toType.
private <T> String toType(Class<T> resourceClass) {
ResourceRegistry resourceRegistry = context.getResourceRegistry();
RegistryEntry entry = resourceRegistry.getEntryForClass(resourceClass);
if (entry == null) {
throw new ResourceNotFoundException("resource type not found: " + resourceClass.getName());
}
ResourceInformation resourceInformation = entry.getResourceInformation();
return resourceInformation.getResourceType();
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class FieldResourcePostTest method onNonRelationRequestShouldDenyIt.
@Test
public void onNonRelationRequestShouldDenyIt() {
// GIVEN
JsonPath jsonPath = new ResourcePath("tasks");
ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
FieldResourcePost sut = new FieldResourcePost(resourceRegistry, PROPERTIES_PROVIDER, typeParser, objectMapper, documentMapper, modificationFilters);
// WHEN
boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
// THEN
assertThat(result).isFalse();
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class FieldResourcePostTest method onValidRequestShouldAcceptIt.
@Test
public void onValidRequestShouldAcceptIt() {
// GIVEN
JsonPath jsonPath = pathBuilder.build("tasks/1/project");
ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
FieldResourcePost sut = new FieldResourcePost(resourceRegistry, PROPERTIES_PROVIDER, typeParser, objectMapper, documentMapper, modificationFilters);
// WHEN
boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
// THEN
assertThat(result).isTrue();
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class RelationshipsResourceGetTest method onValidRequestShouldAcceptIt.
@Test
public void onValidRequestShouldAcceptIt() {
// GIVEN
JsonPath jsonPath = pathBuilder.build("tasks/1/relationships/project");
ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
RelationshipsResourceGet sut = new RelationshipsResourceGet(resourceRegistry, typeParser, documentMapper);
// WHEN
boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
// THEN
assertThat(result).isTrue();
}
Aggregations