} else if (statusCode == Code.FORBIDDEN) {
logger.debug("Fobidden, serviceReponse was {}, ", content);
if (result instanceof Response<?> errorResponse) {
- throw new FreeboxException(errorResponse.getErrorCode(), errorResponse.getMsg());
+ if (errorResponse.getErrorCode() == Response.ErrorCode.INSUFFICIENT_RIGHTS) {
+ throw new PermissionException(errorResponse.getMissingRight(), errorResponse.getMsg());
+ } else {
+ throw new FreeboxException(errorResponse.getErrorCode(), errorResponse.getMsg());
+ }
}
}
package org.openhab.binding.freeboxos.internal.api;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.freeboxos.internal.api.Response.ErrorCode;
import org.openhab.binding.freeboxos.internal.api.rest.LoginManager;
/**
private final LoginManager.Permission permission;
+ public PermissionException(LoginManager.Permission permission, String message) {
+ super(ErrorCode.INSUFFICIENT_RIGHTS, message);
+ this.permission = permission;
+ }
+
public PermissionException(LoginManager.Permission permission, String format, Object... args) {
super(format, args);
this.permission = permission;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.freeboxos.internal.api.FreeboxException;
+import org.openhab.binding.freeboxos.internal.api.PermissionException;
import org.openhab.binding.freeboxos.internal.api.rest.LanBrowserManager.Source;
import org.openhab.binding.freeboxos.internal.api.rest.MediaReceiverManager;
import org.openhab.binding.freeboxos.internal.api.rest.MediaReceiverManager.MediaType;
logger.debug("Unexpected command {} on channel {}", command, channelUID.getId());
}
}
+ } catch (PermissionException e) {
+ logger.warn("Missing permission {} for handling command {} on channel {}: {}", e.getPermission(), command,
+ channelUID.getId(), e.getMessage());
} catch (FreeboxException e) {
- logger.warn("Error handling command: {}", e.getMessage());
+ logger.warn("Error handling command {} on channel {}: {}", command, channelUID.getId(), e.getMessage());
}
}