@POST @Path("wwrelations/wwdocuments") public Response receptionSearch(SearchRequestV2_1 searchRequest) { Optional<SearchResult> otherSearch = searchStore.getSearchResult( UUID.fromString(searchRequest.getOtherSearchId())); LOG.info("Using other search ID: {}", searchRequest.getOtherSearchId()); if (otherSearch.isPresent()) { LOG.info("other search is present"); UUID uuid = searchStore.add(getDescription("wwrelations", otherSearch.get()) .get().execute(graphWrapper, searchRequest)); URI uri = createUri(uuid); return Response.created(uri).build(); } return Response.status(Response.Status.BAD_REQUEST) .entity(new NotFoundMessage(new UUIDParam(searchRequest.getOtherSearchId()))).build(); }
@GET @Path("{id}") /* * Use UUIDParam instead of UUID, because we want to be explicit to the user of this API the request is not * supported. When UUID is used Jersery returns a '404 Not Found' if the request contains a malformed one. The * UUIDParam will return a '400 Bad Request' for malformed UUID's. * See: http://www.dropwizard.io/0.9.1/dropwizard-jersey/apidocs/io/dropwizard/jersey/params/AbstractParam.html * Or: http://codahale.com/what-makes-jersey-interesting-parameter-classes/ */ public Response get(@PathParam("id") UUIDParam id, @QueryParam("rows") @DefaultValue("10") int rows, @QueryParam("start") @DefaultValue("0") int start) { Optional<SearchResult> searchResult = searchStore.getSearchResult(id.get()); if (searchResult.isPresent()) { return Response.ok(searchResponseFactory.createResponse(searchResult.get(), rows, start)).build(); } return Response .status(Response.Status.NOT_FOUND) .entity(new NotFoundMessage(id)) .build(); }
@GET public Response get(@PathParam("id") UUIDParam accountId) { Optional<Account> possibleAccount = accountService.loadAccount(accountId.get()); if (!possibleAccount.isPresent()) return Response.status(NOT_FOUND).build(); AccountDto accountDto = toDto(possibleAccount.get()); return Response.ok(accountDto).build(); }
@POST public Response post(@PathParam("id") UUIDParam accountId, @Valid WithdrawalDto withdrawalDto) throws AccountNotFoundException, OptimisticLockingException { WithdrawAccountCommand command = new WithdrawAccountCommand(accountId.get(), withdrawalDto.getAmount()); try { accountService.process(command); } catch (NonSufficientFundsException e) { return Response.status(BAD_REQUEST).build(); } return Response.noContent().build(); }
@POST public Response post(@PathParam("id") UUIDParam accountId, @Valid DepositDto depositDto) throws AccountNotFoundException, OptimisticLockingException { DepositAccountCommand command = new DepositAccountCommand(accountId.get(), depositDto.getAmount()); accountService.process(command); return Response.noContent().build(); }
@GET public Response get(@PathParam("id") UUIDParam clientId) { Optional<Client> possibleClient = clientService.loadClient(clientId.get()); if (!possibleClient.isPresent()) return Response.status(NOT_FOUND).build(); ClientDto clientDto = toDto(possibleClient.get()); return Response.ok(clientDto).build(); }
@PUT public Response put(@PathParam("id") UUIDParam clientId, @Valid @NotNull ClientDto clientDto) { UpdateClientCommand command = new UpdateClientCommand( clientId.get(), clientDto.getName(), new Email(clientDto.getEmail())); clientService.process(command); return Response.noContent().build(); }
@GET public Response singleEntity(@PathParam("collection") String collectionName, @PathParam("id") UUIDParam id, @QueryParam("rev") Integer rev) { return Response.status(301) .location(uriHelper.fromResourceUri(SingleEntity.makeUrl(collectionName, id.get(), rev))) .build(); }
@GET public Response get(@PathParam("collection") String collectionName, @PathParam("id") UUIDParam id, @QueryParam("depth") int depth, @QueryParam("types") List<String> relationNames) { try { D3Graph result = d3GraphGeneratorService.get(collectionName, id.get(), relationNames, depth); return Response.ok(result).build(); } catch (NotFoundException e) { return Response.status(Response.Status.NOT_FOUND).entity(jsnO("message", jsn("not found"))).build(); } }
@GET public Response get(@PathParam("id") UUIDParam clientId) { List<AccountProjection> accounts = accountsRepository.getAccounts(clientId.get()); return Response.ok(accounts).build(); }
@GET @Path("/uuid") public String getUUID(@QueryParam("uuid") Optional<UUIDParam> uuid) { return uuid.orElse(new UUIDParam("d5672fa8-326b-40f6-bf71-d9dacf44bcdc")).get().toString(); }
@GET @Path("/uuid") public String getUUID(@CookieParam("uuid") Optional<UUIDParam> uuid) { return uuid.orElse(new UUIDParam("d5672fa8-326b-40f6-bf71-d9dacf44bcdc")).get().toString(); }
@POST @Path("/uuid") public String getUUID(@FormParam("uuid") Optional<UUIDParam> uuid) { return uuid.orElse(new UUIDParam("d5672fa8-326b-40f6-bf71-d9dacf44bcdc")).get().toString(); }
@GET @Path("/uuid") public String getUUID(@HeaderParam("uuid") Optional<UUIDParam> uuid) { return uuid.orElse(new UUIDParam("d5672fa8-326b-40f6-bf71-d9dacf44bcdc")).get().toString(); }
public NotFoundMessage(UUIDParam id) { message = String.format("No SearchResult with id '%s'", id.get()); }