コード例 #1
0
  @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;
  }
コード例 #2
0
  @AccessControlled(guestAccessEnabled = true)
  @Override
  public PushNotificationsDevice deletePushNotificationsDevice(String token)
      throws PortalException {

    PushNotificationsPermission.check(
        getPermissionChecker(), PushNotificationsActionKeys.MANAGE_DEVICES);

    PushNotificationsDevice pushNotificationsDevice =
        pushNotificationsDevicePersistence.fetchByToken(token);

    if (pushNotificationsDevice == null) {
      if (_log.isInfoEnabled()) {
        _log.info("No device found with token " + token);
      }
    } else {
      long userId = getGuestOrUserId();

      if (pushNotificationsDevice.getUserId() == userId) {
        pushNotificationsDevice =
            pushNotificationsDeviceLocalService.deletePushNotificationsDevice(token);
      } else if (_log.isInfoEnabled()) {
        _log.info("Device found with token " + token + " does not belong to user " + userId);
      }
    }

    return pushNotificationsDevice;
  }
コード例 #3
0
 @Override
 public Long get(PushNotificationsDevice pushNotificationsDevice) {
   return pushNotificationsDevice.getPushNotificationsDeviceId();
 }