use of io.crnk.core.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class MetaResourceRepositoryImpl method findOne.
@SuppressWarnings("unchecked")
@Override
public T findOne(String id, QuerySpec querySpec) {
MetaLookup lookup = lookupSupplier.get();
MetaElement metaElement = lookup.getMetaById().get(id);
Class<T> resourceClass = this.getResourceClass();
if (metaElement != null && resourceClass.isInstance(metaElement)) {
MetaElement wrappedElement = MetaUtils.adjustForRequest(lookup, metaElement);
if (wrappedElement != null) {
return (T) metaElement;
}
}
throw new ResourceNotFoundException(id);
}
use of io.crnk.core.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class ExceptionTest method testUnknownRepository.
@Test
public void testUnknownRepository() {
UnknownResource task = new UnknownResource();
task.setId("test");
ResourceRepositoryV2<UnknownResource, String> taskRepo = client.getRepositoryForType(UnknownResource.class);
try {
taskRepo.create(task);
Assert.fail();
} catch (ResourceNotFoundException e) {
// ok
}
}
use of io.crnk.core.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class ComplexPojoRepository method findOne.
@Override
public ComplexPojo findOne(Long aLong, QueryParams queryParams) {
if (THREAD_LOCAL_REPOSITORY.size() < 1) {
ComplexPojo complexPojo = new ComplexPojo();
complexPojo.setContainedPojo(new ContainedPojo());
complexPojo.getContainedPojo().setUpdateableProperty1("value from repository mock");
complexPojo.getContainedPojo().setUpdateableProperty2("value from repository mock");
complexPojo.setId(1l);
THREAD_LOCAL_REPOSITORY.put(complexPojo.getId(), complexPojo);
}
ComplexPojo complexPojo = THREAD_LOCAL_REPOSITORY.get(aLong);
if (complexPojo == null) {
throw new ResourceNotFoundException("");
}
return complexPojo;
}
Aggregations