Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/main/java/io/shiftleft/controller/CustomerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,20 @@ public void updateCustomer(@RequestBody Customer customer, @PathVariable("custom
* the customer id
*/
@RequestMapping(value = "/customers/{customerId}", method = RequestMethod.DELETE)
public void removeCustomer(@PathVariable("customerId") Long customerId, HttpServletResponse httpResponse) {
public void removeCustomer(@PathVariable("customerId") Long customerId, HttpServletResponse httpResponse) throws NoSuchAlgorithmException {
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
}
catch (Exception e) {
throw new NoSuchAlgorithmException(e);
}

if (customerRepository.exists(customerId)) {
customerRepository.delete(customerId);
md.update(customerId.toString().getBytes());
byte[] digest = md.digest();
String newCustomerId = new String(digest);
if (customerRepository.exists(Long.parseLong(newCustomerId))) {
customerRepository.delete(Long.parseLong(newCustomerId));
}

httpResponse.setStatus(HttpStatus.NO_CONTENT.value());
Expand Down