use of io.crnk.core.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class ProcessInstanceRepositoryTest method checkDelete.
@Test
public void checkDelete() {
ScheduleApprovalProcessInstance processInstance = postProcess(null, null, null);
processRepository.delete(processInstance.getId());
try {
processRepository.findOne(processInstance.getId(), new QuerySpec(ScheduleApprovalProcessInstance.class));
Assert.fail();
} catch (ResourceNotFoundException e) {
// ok
}
}
use of io.crnk.core.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method deleteTask.
@Test
public void deleteTask() {
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
ApproveTask resource = taskRepository.findOne(task.getId(), querySpec);
taskRepository.delete(resource.getId());
try {
taskRepository.findOne(task.getId(), querySpec);
Assert.fail();
} catch (ResourceNotFoundException e) {
// ok
}
}
use of io.crnk.core.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class ProcessInstanceResourceRepository method save.
@Override
public <S extends T> S save(S resource) {
checkFilter(resource, true);
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(resource.getId()).includeProcessVariables().singleResult();
if (processInstance == null) {
throw new ResourceNotFoundException(resource.getId());
}
checkFilter(processInstance, false);
checkActivate(processInstance, resource);
Map<String, Object> variables = resourceMapper.mapToVariables(resource);
runtimeService.setVariables(processInstance.getId(), variables);
applyUpdates(processInstance, resource);
return (S) findOne(processInstance.getId(), new QuerySpec(getResourceClass()));
}
use of io.crnk.core.exception.ResourceNotFoundException 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.exception.ResourceNotFoundException in project crnk-framework by crnk-project.
the class ResourceRepositoryBase method findOne.
/**
* Forwards to {@link #findAll(QuerySpec)}
*
* @param id of the resource
* @param querySpec for field and relation inclusion
* @return resource
*/
@Override
public T findOne(I id, QuerySpec querySpec) {
RegistryEntry entry = resourceRegistry.findEntry(resourceClass);
String idName = entry.getResourceInformation().getIdField().getUnderlyingName();
QuerySpec idQuerySpec = querySpec.duplicate();
idQuerySpec.addFilter(new FilterSpec(Arrays.asList(idName), FilterOperator.EQ, id));
Iterable<T> iterable = findAll(idQuerySpec);
Iterator<T> iterator = iterable.iterator();
if (iterator.hasNext()) {
T resource = iterator.next();
PreconditionUtil.assertFalse("expected unique result", iterator.hasNext());
return resource;
} else {
throw new ResourceNotFoundException("resource not found");
}
}
Aggregations