@AccessControlled(guestAccessEnabled = true) @Override public PushNotificationsDevice addPushNotificationsDevice(String token, String platform) throws PortalException { PushNotificationsPermission.check( getPermissionChecker(), PushNotificationsActionKeys.MANAGE_DEVICES); PushNotificationsDevice pushNotificationsDevice = pushNotificationsDevicePersistence.fetchByToken(token); if (pushNotificationsDevice == null) { pushNotificationsDevice = pushNotificationsDeviceLocalService.addPushNotificationsDevice( getGuestOrUserId(), platform, token); } else { long userId = getGuestOrUserId(); pushNotificationsDevice.setUserId(userId); pushNotificationsDeviceLocalService.updatePushNotificationsDevice(pushNotificationsDevice); } return pushNotificationsDevice; }