Package org.eclipse.ecf.presence.chatroom

Examples of org.eclipse.ecf.presence.chatroom.ChatRoomCreateException


   * @see org.eclipse.ecf.presence.chatroom.IChatRoomManager#createChatRoom(java.lang.String,
   *      java.util.Map)
   */
  public IChatRoomInfo createChatRoom(String roomname, Map properties) throws ChatRoomCreateException {
    if (roomname == null)
      throw new ChatRoomCreateException(roomname, Messages.XMPPChatRoomManager_EXCEPTION_ROOM_CANNOT_BE_NULL);
    try {
      final String nickname = ecfConnection.getXMPPConnection().getUser();
      final String server = ecfConnection.getXMPPConnection().getHost();
      final String domain = (properties == null) ? XMPPRoomID.DOMAIN_DEFAULT : (String) properties.get(PROP_XMPP_CONFERENCE);
      final String conference = XMPPRoomID.fixConferenceDomain(domain, server);
      final String roomID = roomname + XMPPRoomID.AT_SIGN + conference;
      // create proxy to the room
      final MultiUserChat muc = new MultiUserChat(ecfConnection.getXMPPConnection(), roomID);

      if (!checkRoom(conference, roomID)) {
        // otherwise create a new one
        muc.create(nickname);
        muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
        final String subject = (properties == null) ? null : (String) properties.get(PROP_XMPP_SUBJECT);
        if (subject != null)
          muc.changeSubject(subject);
      }

      String longname = muc.getRoom();
      if (longname == null || longname.length() <= 0) {
        longname = roomID;
      }

      final RoomInfo info = MultiUserChat.getRoomInfo(ecfConnection.getXMPPConnection(), roomID);

      if (info != null) {
        final XMPPRoomID xid = new XMPPRoomID(connectedID.getNamespace(), ecfConnection.getXMPPConnection(), roomID, longname);
        return new ECFRoomInfo(xid, info, connectedID);
      } else
        throw new XMPPException(NLS.bind(Messages.XMPPChatRoomManager_EXCEPTION_NO_ROOM_INFO, roomID));
    } catch (final XMPPException e) {
      throw new ChatRoomCreateException(roomname, e.getMessage(), e);
    } catch (final URISyntaxException e) {
      throw new ChatRoomCreateException(roomname, e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.presence.chatroom.ChatRoomCreateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.