Source:
<code>public ConsumerDTO create( @ApiParam(name = "consumer", required = true) ConsumerDTO dto, @Context Principal principal, @QueryParam("username") String userName, @QueryParam("owner") String ownerKey, @QueryParam("activation_keys") String activationKeys, @QueryParam("identity_cert_creation") @DefaultValue("true") boolean identityCertCreation) throws BadRequestException { Consumer consumer = null; if (ownerKey != null && dto.getFact("system_uuid") != null && !"true".equalsIgnoreCase(dto.getFact("virt.is_guest"))) { Owner owner = ownerCurator.lookupByKey(ownerKey); if (owner != null) { consumer = consumerCurator.getHypervisor(dto.getFact("system_uuid"), owner); if (consumer != null) { consumer.setIdCert(generateIdCert(consumer, false)); this.updateConsumer(consumer.getUuid(), dto, principal); return translator.translate( <START> consumerCurator.findByUuid(consumer.getUuid()), ConsumerDTO.class); <END> } } } if (consumer == null) { consumer = new Consumer(); } if (dto.getUuid() != null) { consumer.setUuid(dto.getUuid()); } populateEntity(consumer, dto); if (dto.getType() == null) { throw new BadRequestException(i18n.tr("Unit type must be specified.")); } ConsumerType ctype = this.consumerTypeCurator.lookupByLabel(dto.getType().getLabel()); if (ctype == null) { throw new BadRequestException(i18n.tr("Invalid unit type: {0}", dto.getType().getLabel())); } consumer.setType(ctype); if (dto.getCreated() != null) { consumer.setCreated(dto.getCreated()); } return translator.translate(createConsumerFromEntity(consumer, principal, userName, ownerKey, activationKeys, identityCertCreation), ConsumerDTO.class); }</code><technical_language>Do need do another lookup here? consumer already, is a reason translating straight away</technical_language>

Target:
public ConsumerDTO create( @ApiParam(name = "consumer", required = true) ConsumerDTO dto, @Context Principal principal, @QueryParam("username") String userName, @QueryParam("owner") String ownerKey, @QueryParam("activation_keys") String activationKeys, @QueryParam("identity_cert_creation") @DefaultValue("true") boolean identityCertCreation) throws BadRequestException { Consumer consumer = null; if (ownerKey != null && dto.getFact("system_uuid") != null && !"true".equalsIgnoreCase(dto.getFact("virt.is_guest"))) { Owner owner = ownerCurator.lookupByKey(ownerKey); if (owner != null) { consumer = consumerCurator.getHypervisor(dto.getFact("system_uuid"), owner); if (consumer != null) { consumer.setIdCert(generateIdCert(consumer, false)); this.updateConsumer(consumer.getUuid(), dto, principal); return translator.translate(consumer, ConsumerDTO.class); } } } if (consumer == null) { consumer = new Consumer(); } if (dto.getUuid() != null) { consumer.setUuid(dto.getUuid()); } consumer.setOwner(ownerCurator.lookupByKey(ownerKey)); populateEntity(consumer, dto); if (dto.getType() == null) { throw new BadRequestException(i18n.tr("Unit type must be specified.")); } ConsumerType ctype = this.consumerTypeCurator.lookupByLabel(dto.getType().getLabel()); if (ctype == null) { throw new BadRequestException(i18n.tr("Invalid unit type: {0}", dto.getType().getLabel())); } return translator.translate(createConsumerFromDTO(dto, ctype, principal, userName, ownerKey, activationKeys, identityCertCreation), ConsumerDTO.class); }