MultiUserChatException.java

  1. /**
  2.  *
  3.  * Copyright © 2014-2024 Florian Schmaus
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.muc;

  18. import org.jivesoftware.smack.SmackException;

  19. import org.jxmpp.jid.DomainBareJid;

  20. public abstract class MultiUserChatException extends SmackException {

  21.     protected MultiUserChatException() {
  22.     }

  23.     protected MultiUserChatException(String message) {
  24.         super(message);
  25.     }

  26.     /**
  27.      *
  28.      */
  29.     private static final long serialVersionUID = 1L;

  30.     // This could eventually become an unchecked exception. But be aware that it's required in the
  31.     // control flow of MultiUserChat.createOrJoinIfNecessary
  32.     public static class MucAlreadyJoinedException extends MultiUserChatException {

  33.         /**
  34.          *
  35.          */
  36.         private static final long serialVersionUID = 1L;

  37.     }

  38.     /**
  39.      * Thrown if the requested operation required the MUC to be joined by the
  40.      * client, while the client is currently joined.
  41.      *
  42.      */
  43.     public static class MucNotJoinedException extends MultiUserChatException {

  44.         /**
  45.          *
  46.          */
  47.         private static final long serialVersionUID = 1L;

  48.         public MucNotJoinedException(MultiUserChat multiUserChat) {
  49.             super("Client not currently joined " + multiUserChat.getRoom());
  50.         }
  51.     }

  52.     public static class MissingMucCreationAcknowledgeException extends MultiUserChatException {

  53.         /**
  54.          *
  55.          */
  56.         private static final long serialVersionUID = 1L;

  57.     }

  58.     /**
  59.      * Thrown if the MUC room does not support the requested configuration option.
  60.      */
  61.     public static class MucConfigurationNotSupportedException extends MultiUserChatException {

  62.         /**
  63.          *
  64.          */
  65.         private static final long serialVersionUID = 1L;

  66.         public MucConfigurationNotSupportedException(String configString) {
  67.             super("The MUC configuration '" + configString + "' is not supported by the MUC service");
  68.         }
  69.     }

  70.     /**
  71.      * Thrown when trying to enter a MUC room that is not hosted a domain providing a MUC service.
  72.      * Try {@link MultiUserChatManager#getMucServiceDomains()} for a list of client-local domains
  73.      * providing a MUC service.
  74.      */
  75.     public static class NotAMucServiceException extends MultiUserChatException {

  76.         /**
  77.          *
  78.          */
  79.         private static final long serialVersionUID = 1L;

  80.         NotAMucServiceException(DomainBareJid service) {
  81.             super("Can't perform operation because " + service
  82.                             + " does not provide a MUC (XEP-45) service.");
  83.         }

  84.         NotAMucServiceException(MultiUserChat multiUserChat) {
  85.             super("Can not join '" + multiUserChat.getRoom() + "', because '"
  86.                             + multiUserChat.getRoom().asDomainBareJid()
  87.                             + "' does not provide a MUC (XEP-45) service.");
  88.         }
  89.     }
  90. }