Source:
<code>private boolean updateEnvironment(ConsumerDTO updated, Consumer toUpdate) { boolean changesMade = false; boolean environmentFound = false; Environment e = null; String environmentId = updated.getEnvironment() == null ? null : updated.getEnvironment().getId(); String environmentName = updated.getEnvironment() == null ? null : updated.getEnvironment().getName(); if (environmentName != null && environmentId == null) { List<Environment> environment = environmentCurator.listForOwnerByName(toUpdate.getOwner(), environmentName).list(); if (!environment.isEmpty() && environment.size() == 1) { e = environment.get(0); environmentId = environment.get(0).getId(); environmentFound = true; } else { throw new NotFoundException(i18n.tr( <START> "Environment with name \"{0}\" could not be found.", environmentName)); <END> } } if (environmentId != null && (toUpdate.getEnvironmentId() == null || !toUpdate.getEnvironmentId().equals(environmentId))) { if (!environmentFound) { e = environmentCurator.get(environmentId); if (e == null) { throw new NotFoundException(i18n.tr( "Environment with ID \"{0}\" could not be found.", environmentId)); } } changesMade = true; log.info("Updating environment to: {}", environmentId); } if (e != null && changesMade) { toUpdate.setEnvironment(e); Owner owner = ownerCurator.findOwnerById(toUpdate.getOwnerId()); if (owner.isContentAccessEnabled()) { toUpdate.setContentAccessCert(null); contentAccessCertService.removeContentAccessCert(toUpdate); } poolManager.regenerateCertificatesOf(toUpdate, true); } return changesMade; }</code><technical_language>Indentation is long here. If checkstyle is complaining, drop i18n.tr a line it. identical line below</technical_language>

Target:
private boolean updateEnvironment(ConsumerDTO updated, Consumer toUpdate) { if (updated.getEnvironment() == null) { return false; } boolean changesMade = false; String environmentId = updated.getEnvironment() == null ? null : updated.getEnvironment().getId(); String environmentName = updated.getEnvironment() == null ? null : updated.getEnvironment().getName(); String validatedEnvId = null; if (environmentId != null) { if (toUpdate.getEnvironmentId() == null || !toUpdate.getEnvironmentId().equals(environmentId)) { if (!environmentCurator.exists(environmentId)) { throw new NotFoundException(i18n.tr( "Environment with ID \"{0}\" could not be found.", environmentId)); } validatedEnvId = environmentId; } } else if (environmentName != null) { String envId = this.environmentCurator. getEnvironmentIdByName(toUpdate.getOwnerId(), environmentName); if (envId == null) { throw new NotFoundException(i18n.tr( "Environment with name \"{0}\" could not be found.", environmentName)); } if (toUpdate.getEnvironmentId() == null || !envId.equals(toUpdate.getEnvironmentId())) { validatedEnvId = envId; } } if (validatedEnvId != null) { toUpdate.setEnvironmentId(validatedEnvId); Owner owner = ownerCurator.findOwnerById(toUpdate.getOwnerId()); if (owner.isContentAccessEnabled()) { toUpdate.setContentAccessCert(null); contentAccessCertService.removeContentAccessCert(toUpdate); } poolManager.regenerateCertificatesOf(toUpdate, true); changesMade = true; } return changesMade; }