Skip to content

Instantly share code, notes, and snippets.

@admiyo
Created March 11, 2010 19:10
Show Gist options
  • Select an option

  • Save admiyo/329534 to your computer and use it in GitHub Desktop.

Select an option

Save admiyo/329534 to your computer and use it in GitHub Desktop.
/**
* delete the consumer.
- * @param uuid uuid of the consumer to delete.
+ *
+ * @param uuid
+ * uuid of the consumer to delete.
*/
@DELETE
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@@ -210,70 +225,92 @@ public class ConsumerResource {
public void deleteConsumer(@PathParam("consumer_uuid") String uuid) {
log.debug("deleteing consumer_uuid" + uuid);
try {
- consumerCurator.delete(consumerCurator.lookupByUuid(uuid));
+ Consumer toDelete = consumerCurator.lookupByUuid(uuid);
+ if (toDelete == null)
+ return;
+
+ ConsumerIdentityCertificate certificate = consumerIdentityCertificateCurator
+ .find(toDelete.getId());
+ if (certificate != null) {
+ consumerIdentityCertificateCurator.delete(certificate);
+ }
+ consumerCurator.delete(toDelete);
}
catch (RuntimeException e) {
throw new NotFoundException(e.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment