Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public DeviceDTO getDevice(String deviceId) {
* Get device by user ID.
*
* @return Device.
* @deprecated Use {@link #getDevicesByUserId()} instead to get all devices for a user.
*/
@Deprecated
public List<DeviceDTO> getDeviceByUserId() {

List<DeviceDTO> deviceDTOList = new ArrayList<>();
Expand All @@ -120,6 +122,24 @@ public List<DeviceDTO> getDeviceByUserId() {
return deviceDTOList;
}

/**
* Get all devices registered for the current user.
Comment thread
raviendalpatadu marked this conversation as resolved.
*
* @return List of device DTOs for the current user; empty list if none are registered.
*/
public List<DeviceDTO> getDevicesByUserId() {

try {
User user = ContextLoader.getUserFromContext();
String tenantDomain = user.getTenantDomain();
String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId();
List<Device> devices = deviceHandlerService.getDevicesByUserId(userId, tenantDomain);
return buildListDeviceDTO(devices);
} catch (PushDeviceHandlerException e) {
throw handlePushDeviceHandlerException(e);
}
}

/**
* Remove device by device ID.
*
Expand Down Expand Up @@ -202,6 +222,21 @@ private DeviceDTO buildDeviceDTO(Device device) {
return deviceDTO;
}

/**
* Build a list of device DTOs from the given devices.
*
* @param deviceList List of devices.
* @return List of device DTOs.
*/
private List<DeviceDTO> buildListDeviceDTO(List<Device> deviceList) {

List<DeviceDTO> deviceDTOList = new ArrayList<>();
for (Device device : deviceList) {
deviceDTOList.add(buildDeviceDTO(device));
}
return deviceDTOList;
}

/**
* Build registration request.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Response getDeviceById(String deviceId) {
@Override
public Response getDevices() {

List<DeviceDTO> deviceDTOList = pushDeviceManagementService.getDeviceByUserId();
List<DeviceDTO> deviceDTOList = pushDeviceManagementService.getDevicesByUserId();
return Response.ok().entity(deviceDTOList).build();
}

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,14 @@
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
<carbon.kernel.version>4.10.25</carbon.kernel.version>
<identity.governance.version>1.11.60</identity.governance.version>
<carbon.identity.framework.version>7.10.17</carbon.identity.framework.version>
<carbon.identity.framework.version>7.11.159</carbon.identity.framework.version>
<carbon.identity.framework.version.range>[5.14.67, 8.0.0]</carbon.identity.framework.version.range>
<carbon.identity.account.association.version>5.5.10</carbon.identity.account.association.version>
<maven.spotbugsplugin.version>4.9.8.2</maven.spotbugsplugin.version>
<findsecbugs-plugin.version>1.12.0</findsecbugs-plugin.version>
<identity.oauth.version>7.0.169</identity.oauth.version>
<identity.org.mgt.core.version>1.1.52</identity.org.mgt.core.version>
<identity.notification.push.version>1.1.1</identity.notification.push.version>
<identity.notification.push.version>1.2.2</identity.notification.push.version>
<identity.notification.push.version.range>[1.0.0, 2.0.0)</identity.notification.push.version.range>
<testng.version>6.9.10</testng.version>
<fido2.version>6.0.3</fido2.version>
Expand Down
Loading