Source:
<code>public void selectTenant(final WebContext ctx, String id) { if ("main".equals(id) || Strings.areEqual(determineOriginalTenantId(ctx), id)) { UserAccount<?, ?> account = UserContext.getCurrentUser().as(UserAccount.class); auditLog.neutral("AuditLog.switchedToMainTenant") .hideFromUser() .causedByUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) <START> .forTenant(String.valueOf(account.getTenant().getId()), <END> account.getTenant().getValue().getTenantData().getName()) .log(); ctx.setSessionValue(UserContext.getCurrentScope().getScopeId() + TenantUserManager.TENANT_SPY_ID_SUFFIX, null); ctx.respondWith().redirectTemporarily(ctx.get("goto").asString(wondergemRoot)); return; } assertPermission(TenantUserManager.PERMISSION_SELECT_TENANT); Optional<T> tenant = resolveAccessibleTenant(id, determineCurrentTenant(ctx)); if (!tenant.isPresent()) { UserContext.get().addMessage(Message.error(NLS.get("TenantController.cannotBecomeTenant"))); selectTenants(ctx); return; } T effectiveTenant = tenant.get(); auditLog.neutral("AuditLog.selectedTenant") .hideFromUser() .causedByCurrentUser() .forCurrentUser() .forTenant(String.valueOf(effectiveTenant.getId()), effectiveTenant.getTenantData().getName()) .log(); ctx.setSessionValue(UserContext.getCurrentScope().getScopeId() + TenantUserManager.TENANT_SPY_ID_SUFFIX, effectiveTenant.getIdAsString()); ctx.respondWith().redirectTemporarily(ctx.get("goto").asString(wondergemRoot)); }</code><technical_language>getIdAsString</technical_language>

Target:
public void selectTenant(final WebContext ctx, String id) { if ("main".equals(id) || Strings.areEqual(determineOriginalTenantId(ctx), id)) { String originalUserId = tenants.getTenantUserManager().getOriginalUserId(); UserAccount<?, ?> account = tenants.getTenantUserManager().fetchAccount(originalUserId); auditLog.neutral("AuditLog.switchedToMainTenant") .hideFromUser() .causedByUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forTenant(account.getTenant().getIdAsString(), account.getTenant().getValue().getTenantData().getName()) .log(); ctx.setSessionValue(UserContext.getCurrentScope().getScopeId() + TenantUserManager.TENANT_SPY_ID_SUFFIX, null); ctx.respondWith().redirectTemporarily(ctx.get("goto").asString(wondergemRoot)); return; } assertPermission(TenantUserManager.PERMISSION_SELECT_TENANT); Optional<T> tenant = resolveAccessibleTenant(id, determineCurrentTenant(ctx)); if (!tenant.isPresent()) { UserContext.get().addMessage(Message.error(NLS.get("TenantController.cannotBecomeTenant"))); selectTenants(ctx); return; } T effectiveTenant = tenant.get(); auditLog.neutral("AuditLog.selectedTenant") .hideFromUser() .causedByCurrentUser() .forCurrentUser() .forTenant(effectiveTenant.getIdAsString(), effectiveTenant.getTenantData().getName()) .log(); ctx.setSessionValue(UserContext.getCurrentScope().getScopeId() + TenantUserManager.TENANT_SPY_ID_SUFFIX, effectiveTenant.getIdAsString()); ctx.respondWith().redirectTemporarily(ctx.get("goto").asString(wondergemRoot)); }