Source:
public Page<Device> findDevices(@Identification final String organisationIdentification, final Integer pageSize, final Integer pageNumber, final DeviceFilter deviceFilter) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); this.domainHelperService.isAllowed(organisation, PlatformFunction.FIND_DEVICES); this.pagingSettings.updatePagingSettings(pageSize, pageNumber); Sort.Direction sortDir = Sort.Direction.DESC; String sortedBy = "creationTime"; if (deviceFilter != null) { if (!StringUtils.isEmpty(deviceFilter.getSortDir()) && deviceFilter.getSortDir().contains("asc")) { sortDir = Sort.Direction.ASC; } if (!StringUtils.isEmpty(deviceFilter.getSortedBy())) { sortedBy = deviceFilter.getSortedBy(); } } final PageRequest request = new PageRequest(this.pagingSettings.getPageNumber(), this.pagingSettings.getPageSize(), sortDir, sortedBy); Page<Device> devices = null; if (!this.netManagementOrganisation.equals(organisationIdentification)) { if (deviceFilter == null) { final DeviceFilter df = new DeviceFilter(organisationIdentification, null, null, null, null, null, null, null, DeviceExternallyManagedFilterType.BOTH, DeviceActivatedFilterType.BOTH, DeviceInMaintenanceFilterType.BOTH, null, null); devices = this.applyFilter(df, organisation, request); } else { deviceFilter.updateOrganisationIdentification(organisationIdentification); devices = this.applyFilter(deviceFilter, organisation, request); } } else { devices = this.applyFilter(deviceFilter, organisation, request); } if (devices == null) { LOGGER.info("No devices found"); return null; } for (final Device device : devices.getContent()) { for (final DeviceAuthorization deviceAutorization : device.getAuthorizations()) { device.addOrganisation(deviceAutorization.getOrganisation().getOrganisationIdentification()); } } return devices; }

Target:
public Page<Device> findDevices(@Identification final String organisationIdentification, final Integer pageSize, final Integer pageNumber, final DeviceFilter deviceFilter) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); this.domainHelperService.isAllowed(organisation, PlatformFunction.FIND_DEVICES); this.pagingSettings.updatePagingSettings(pageSize, pageNumber); Sort.Direction sortDir = Sort.Direction.DESC; String sortedBy = "creationTime"; if (deviceFilter != null) { if (!StringUtils.isEmpty(deviceFilter.getSortDir()) && deviceFilter.getSortDir().contains("asc")) { sortDir = Sort.Direction.ASC; } if (!StringUtils.isEmpty(deviceFilter.getSortedBy())) { sortedBy = deviceFilter.getSortedBy(); } } final PageRequest request = new PageRequest(this.pagingSettings.getPageNumber(), this.pagingSettings.getPageSize(), sortDir, sortedBy); Page<Device> devices = null; if (!this.netManagementOrganisation.equals(organisationIdentification)) { if (deviceFilter == null) { final DeviceFilter df = new DeviceFilter(organisationIdentification, null, null, null, null, null, null, null, DeviceExternalManagedFilterType.BOTH, DeviceActivatedFilterType.BOTH, DeviceInMaintenanceFilterType.BOTH, null, null); devices = this.applyFilter(df, organisation, request); } else { deviceFilter.updateOrganisationIdentification(organisationIdentification); devices = this.applyFilter(deviceFilter, organisation, request); } } else { devices = this.applyFilter(deviceFilter, organisation, request); } if (devices == null) { LOGGER.info("No devices found"); return null; } for (final Device device : devices.getContent()) { for (final DeviceAuthorization deviceAutorization : device.getAuthorizations()) { device.addOrganisation(deviceAutorization.getOrganisation().getOrganisationIdentification()); } } return devices; }