this.deletedConsumerCurator = deletedConsumerCurator;
this.i18n = i18n;
}
public ConsumerPrincipal createPrincipal(String consumerUuid) {
ConsumerPrincipal principal = null;
if (consumerUuid != null) {
// If this UUID has been deleted, return a 410.
if (deletedConsumerCurator.countByConsumerUuid(consumerUuid) > 0) {
log.debug("Key " + consumerUuid + " is deleted, throwing GoneException");
throw new GoneException(
i18n.tr("Unit {0} has been deleted", consumerUuid), consumerUuid);
}
Consumer consumer = this.consumerCurator.getConsumer(consumerUuid);
if (consumer != null) {
principal = new ConsumerPrincipal(consumer);
if (log.isDebugEnabled() && principal != null) {
log.debug("principal created for consumer '" +
principal.getConsumer().getUuid());
}
}
}
return principal;