use of core.framework.web.exception.NotFoundException in project core-ng-project by neowu.
the class Scheduler method triggerNow.
public void triggerNow(String name) {
Trigger trigger = triggers.get(name);
if (trigger == null)
throw new NotFoundException("job not found, name=" + name);
submitJob(trigger, true);
}
use of core.framework.web.exception.NotFoundException in project core-ng-project by neowu.
the class CacheController method get.
public Response get(Request request) {
ControllerHelper.assertFromLocalNetwork(request.clientIP());
String name = request.pathParam("name");
String key = request.pathParam("key");
CacheImpl<?> cache = cache(name);
String value = cache.get(key).orElseThrow(() -> new NotFoundException("cache key not found, name=" + name + ", key=" + key));
return Response.text(value).contentType(ContentType.APPLICATION_JSON);
}
use of core.framework.web.exception.NotFoundException in project core-ng-demo-project by neowu.
the class CustomerService method update.
public CustomerView update(Long id, UpdateCustomerRequest request) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
customer.updatedTime = LocalDateTime.now();
customer.firstName = request.firstName;
if (request.lastName != null) {
customer.lastName = request.lastName;
}
customerRepository.update(customer);
return view(customer);
}
use of core.framework.web.exception.NotFoundException in project core-ng-project by neowu.
the class HTTPServerErrorHandlerTest method errorResponseWithErrorCodeException.
@Test
void errorResponseWithErrorCodeException() {
ErrorResponse response = handler.errorResponse(new NotFoundException("test-message", "TEST_ERROR_CODE"), null);
assertEquals("test-message", response.message);
assertEquals("TEST_ERROR_CODE", response.errorCode);
assertEquals("WARN", response.severity);
}
use of core.framework.web.exception.NotFoundException in project core-ng-project by neowu.
the class StaticDirectoryController method execute.
@Override
public Response execute(Request request) {
String path = request.pathParam("path");
Path filePath = contentDirectory.resolve(path);
logger.debug("requestFile={}", filePath);
if (!Files.isRegularFile(filePath, LinkOption.NOFOLLOW_LINKS) || !filePath.startsWith(contentDirectory))
throw new NotFoundException("not found, path=" + request.path());
Response response = Response.file(filePath);
ContentType contentType = MimeTypes.get(filePath.getFileName().toString());
if (contentType != null)
response.contentType(contentType);
if (cacheHeader != null)
response.header(HTTPHeaders.CACHE_CONTROL, cacheHeader);
return response;
}
Aggregations