MUCUserImpl.java 22.6 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision$
 * $Date$
 *
Matt Tucker's avatar
Matt Tucker committed
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
Matt Tucker's avatar
Matt Tucker committed
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10
 */
Matt Tucker's avatar
Matt Tucker committed
11

Matt Tucker's avatar
Matt Tucker committed
12 13 14 15 16 17 18 19 20 21 22 23
package org.jivesoftware.messenger.muc.spi;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import org.dom4j.Element;

import org.jivesoftware.messenger.muc.*;
import org.jivesoftware.util.*;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.user.UserAlreadyExistsException;
24
import org.jivesoftware.messenger.user.UserNotFoundException;
25
import org.xmpp.packet.*;
Matt Tucker's avatar
Matt Tucker committed
26 27 28 29 30 31 32 33 34 35 36 37 38

/**
 * Implementation of MUCUser. There will be a MUCUser per user that is connected to one or more 
 * rooms. A MUCUser contains a collection of MUCRoles for each room where the user has joined.
 * 
 * @author Gaston Dombiak
 */
public class MUCUserImpl implements MUCUser {

    /** The chat server this user belongs to. */
    private MultiUserChatServer server;

    /** Real system XMPPAddress for the user. */
39
    private JID realjid;
Matt Tucker's avatar
Matt Tucker committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

    /** Table: key roomName.toLowerCase(); value MUCRole. */
    private Map<String, MUCRole> roles = new ConcurrentHashMap<String, MUCRole>();

    /** Deliver packets to users. */
    private PacketRouter router;

    /**
     * Time of last packet sent.
     */
    private long lastPacketTime;

    /**
     * Create a new chat user.
     * 
     * @param chatserver the server the user belongs to.
     * @param packetRouter the router for sending packets from this user.
     * @param jid the real address of the user
     */
59
    MUCUserImpl(MultiUserChatServerImpl chatserver, PacketRouter packetRouter, JID jid) {
Matt Tucker's avatar
Matt Tucker committed
60 61 62 63 64
        this.realjid = jid;
        this.router = packetRouter;
        this.server = chatserver;
    }

65
    public long getID() {
Matt Tucker's avatar
Matt Tucker committed
66 67 68
        return -1;
    }

69
    public MUCRole getRole(String roomName) throws NotFoundException {
Matt Tucker's avatar
Matt Tucker committed
70 71 72 73 74 75 76
        MUCRole role = roles.get(roomName.toLowerCase());
        if (role == null) {
            throw new NotFoundException(roomName);
        }
        return role;
    }

77
    public Iterator<MUCRole> getRoles() {
Matt Tucker's avatar
Matt Tucker committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
        return Collections.unmodifiableCollection(roles.values()).iterator();
    }

    public void removeRole(String roomName) {
        roles.remove(roomName.toLowerCase());
    }

    public long getLastPacketTime() {
        return lastPacketTime;
    }

    /**
     * Generate a conflict packet to indicate that the nickname being requested/used is already in
     * use by another user.
     * 
93
     * @param packet the packet to be bounced.
Matt Tucker's avatar
Matt Tucker committed
94
     */
Gaston Dombiak's avatar
Gaston Dombiak committed
95
    private void sendErrorPacket(Packet packet, PacketError.Condition error) {
96 97 98 99 100 101 102 103 104 105 106 107 108
        if (packet instanceof IQ) {
            IQ reply = IQ.createResultIQ((IQ) packet);
            reply.setChildElement(((IQ) packet).getChildElement().createCopy());
            reply.setError(error);
            router.route(reply);
        }
        else {
            Packet reply = packet.createCopy();
            reply.setError(error);
            reply.setFrom(packet.getTo());
            reply.setTo(packet.getFrom());
            router.route(reply);
        }
Matt Tucker's avatar
Matt Tucker committed
109 110
    }

111
    public JID getAddress() {
Matt Tucker's avatar
Matt Tucker committed
112 113 114
        return realjid;
    }

115
    public void process(Packet packet) throws UnauthorizedException, PacketException {
Matt Tucker's avatar
Matt Tucker committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
        if (packet instanceof IQ) {
            process((IQ)packet);
        }
        else if (packet instanceof Message) {
            process((Message)packet);
        }
        else if (packet instanceof Presence) {
            process((Presence)packet);
        }
    }

    /**
     * This method does all packet routing in the chat server. Packet routing is actually very
     * simple:
     * 
     * <ul>
     * <li>Discover the room the user is talking to (server packets are dropped)</li>
     * <li>If the room is not registered and this is a presence "available" packet, try to join the
     * room</li>
     * <li>If the room is registered, and presence "unavailable" leave the room</li>
     * <li>Otherwise, rewrite the sender address and send to the room.</li>
     * </ul>
     * 
     * @param packet The packet to route.
     */
    public void process(Message packet) {
142 143 144 145
        // Ignore messages of type ERROR sent to a room 
        if (Message.Type.error == packet.getType()) {
            return;
        }
Matt Tucker's avatar
Matt Tucker committed
146
        lastPacketTime = System.currentTimeMillis();
147 148
        JID recipient = packet.getTo();
        String group = recipient.getNode();
Matt Tucker's avatar
Matt Tucker committed
149 150 151 152 153 154 155 156 157 158 159
        if (group == null) {
            // Ignore packets to the groupchat server
            // In the future, we'll need to support TYPE_IQ queries to the server for MUC
            Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " "
                    + packet.toString());
        }
        else {
            MUCRole role = roles.get(group.toLowerCase());
            if (role == null) {
                if (server.hasChatRoom(group)) {
                    boolean declinedInvitation = false;
160 161
                    Element userInfo = null;
                    if (Message.Type.normal == packet.getType()) {
Matt Tucker's avatar
Matt Tucker committed
162
                        // An user that is not an occupant could be declining an invitation
163 164
                        userInfo = packet.getChildElement(
                                "x", "http://jabber.org/protocol/muc#user");
Matt Tucker's avatar
Matt Tucker committed
165
                        if (userInfo != null
166
                                && userInfo.element("decline") != null) {
Matt Tucker's avatar
Matt Tucker committed
167 168 169 170 171 172 173
                            // A user has declined an invitation to a room
                            // WARNING: Potential fraud if someone fakes the "from" of the
                            // message with the JID of a member and sends a "decline"
                            declinedInvitation = true;
                        }
                    }
                    if (declinedInvitation) {
174
                        Element info = userInfo.element("decline");
Matt Tucker's avatar
Matt Tucker committed
175
                        server.getChatRoom(group).sendInvitationRejection(
Gaston Dombiak's avatar
Gaston Dombiak committed
176
                            new JID(info.attributeValue("to")),
Matt Tucker's avatar
Matt Tucker committed
177
                            info.elementTextTrim("reason"),
178
                            packet.getFrom());
Matt Tucker's avatar
Matt Tucker committed
179 180 181
                    }
                    else {
                        // The sender is not an occupant of the room
Gaston Dombiak's avatar
Gaston Dombiak committed
182
                        sendErrorPacket(packet, PacketError.Condition.not_acceptable);
Matt Tucker's avatar
Matt Tucker committed
183 184 185 186
                    }
                }
                else {
                    // The sender is not an occupant of a NON-EXISTENT room!!!
Gaston Dombiak's avatar
Gaston Dombiak committed
187
                    sendErrorPacket(packet, PacketError.Condition.recipient_unavailable);
Matt Tucker's avatar
Matt Tucker committed
188 189 190 191 192
                }
            }
            else {
                // Check and reject conflicting packets with conflicting roles
                // In other words, another user already has this nickname
Gaston Dombiak's avatar
Gaston Dombiak committed
193 194
                if (!role.getChatUser().getAddress().equals(packet.getFrom())) {
                    sendErrorPacket(packet, PacketError.Condition.conflict);
Matt Tucker's avatar
Matt Tucker committed
195 196 197 198
                }
                else {
                    try {
                        if (packet.getSubject() != null && packet.getSubject().trim().length() > 0
Gaston Dombiak's avatar
Gaston Dombiak committed
199
                                && Message.Type.groupchat == packet.getType()) {
Matt Tucker's avatar
Matt Tucker committed
200 201 202 203 204 205 206 207
                            // An occupant is trying to change the room's subject
                            role.getChatRoom().changeSubject(packet, role);

                        }
                        else {
                            // An occupant is trying to send a private, send public message,
                            // invite someone to the room or reject an invitation
                            Message.Type type = packet.getType();
Gaston Dombiak's avatar
Gaston Dombiak committed
208
                            String resource = packet.getTo().getResource();
Matt Tucker's avatar
Matt Tucker committed
209 210 211
                            if (resource == null || resource.trim().length() == 0) {
                                resource = null;
                            }
Gaston Dombiak's avatar
Gaston Dombiak committed
212
                            if (resource == null && Message.Type.groupchat == type) {
Matt Tucker's avatar
Matt Tucker committed
213 214 215 216
                                // An occupant is trying to send a public message
                                role.getChatRoom().sendPublicMessage(packet, role);
                            }
                            else if (resource != null
Gaston Dombiak's avatar
Gaston Dombiak committed
217
                                    && (Message.Type.chat == type || Message.Type.normal == type)) {
Matt Tucker's avatar
Matt Tucker committed
218 219 220
                                // An occupant is trying to send a private message
                                role.getChatRoom().sendPrivateMessage(packet, role);
                            }
Gaston Dombiak's avatar
Gaston Dombiak committed
221
                            else if (resource == null && Message.Type.normal == type) {
Matt Tucker's avatar
Matt Tucker committed
222 223
                                // An occupant could be sending an invitation or declining an
                                // invitation
Gaston Dombiak's avatar
Gaston Dombiak committed
224
                                Element userInfo = packet.getChildElement(
Matt Tucker's avatar
Matt Tucker committed
225 226 227 228 229
                                    "x",
                                    "http://jabber.org/protocol/muc#user");
                                // Real real real UGLY TRICK!!! Will and MUST be solved when
                                // persistence will be added. Replace locking with transactions!
                                MUCRoomImpl room = (MUCRoomImpl) role.getChatRoom();
Gaston Dombiak's avatar
Gaston Dombiak committed
230
                                if (userInfo != null && userInfo.element("invite") != null) {
Matt Tucker's avatar
Matt Tucker committed
231
                                    // An occupant is sending an invitation
Gaston Dombiak's avatar
Gaston Dombiak committed
232
                                    Element info = userInfo.element("invite");
Matt Tucker's avatar
Matt Tucker committed
233 234 235

                                    // Add the user as a member of the room if the room is
                                    // members only
236
                                    if (room.isMembersOnly()) {
Matt Tucker's avatar
Matt Tucker committed
237 238 239 240 241 242 243 244
                                        room.lock.writeLock().lock();
                                        try {
                                            room.addMember(info.attributeValue("to"), null, role);
                                        }
                                        finally {
                                            room.lock.writeLock().unlock();
                                        }
                                    }
245 246 247 248 249 250
                                    // Try to keep the list of extensions sent together with the 
                                    // message invitation. These extensions will be sent to the 
                                    // invitee.
                                    List<Element> extensions = new ArrayList<Element>(packet
                                            .getElement().elements());
                                    extensions.remove(userInfo);
Matt Tucker's avatar
Matt Tucker committed
251 252

                                    // Send the invitation to the user
Gaston Dombiak's avatar
Gaston Dombiak committed
253
                                    room.sendInvitation(new JID(info.attributeValue("to")),
254
                                            info.elementTextTrim("reason"), role, extensions);
Matt Tucker's avatar
Matt Tucker committed
255 256
                                }
                                else if (userInfo != null
Gaston Dombiak's avatar
Gaston Dombiak committed
257
                                        && userInfo.element("decline") != null) {
Matt Tucker's avatar
Matt Tucker committed
258
                                    // An occupant has declined an invitation
Gaston Dombiak's avatar
Gaston Dombiak committed
259 260 261
                                    Element info = userInfo.element("decline");
                                    room.sendInvitationRejection(new JID(info.attributeValue("to")),
                                            info.elementTextTrim("reason"), packet.getFrom());
Matt Tucker's avatar
Matt Tucker committed
262 263
                                }
                                else {
Gaston Dombiak's avatar
Gaston Dombiak committed
264
                                    sendErrorPacket(packet, PacketError.Condition.bad_request);
Matt Tucker's avatar
Matt Tucker committed
265 266 267
                                }
                            }
                            else {
Gaston Dombiak's avatar
Gaston Dombiak committed
268
                                sendErrorPacket(packet, PacketError.Condition.bad_request);
Matt Tucker's avatar
Matt Tucker committed
269 270 271 272
                            }
                        }
                    }
                    catch (ForbiddenException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
273
                        sendErrorPacket(packet, PacketError.Condition.forbidden);
Matt Tucker's avatar
Matt Tucker committed
274 275
                    }
                    catch (NotFoundException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
276
                        sendErrorPacket(packet, PacketError.Condition.recipient_unavailable);
Matt Tucker's avatar
Matt Tucker committed
277 278
                    }
                    catch (ConflictException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
279
                        sendErrorPacket(packet, PacketError.Condition.conflict);
Matt Tucker's avatar
Matt Tucker committed
280 281 282 283 284 285 286 287
                    }
                }
            }
        }
    }

    public void process(IQ packet) {
        lastPacketTime = System.currentTimeMillis();
Gaston Dombiak's avatar
Gaston Dombiak committed
288 289
        JID recipient = packet.getTo();
        String group = recipient.getNode();
Matt Tucker's avatar
Matt Tucker committed
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
        if (group == null) {
            // Ignore packets to the groupchat server
            // In the future, we'll need to support TYPE_IQ queries to the server for MUC
            Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " "
                    + packet.toString());
        }
        else {
            MUCRole role = roles.get(group.toLowerCase());
            if (role == null) {
                // TODO: send error message to user (can't send packets to group you haven't
                // joined)
            }
            else {
                // Check and reject conflicting packets with conflicting roles
                // In other words, another user already has this nickname
Gaston Dombiak's avatar
Gaston Dombiak committed
305 306
                if (!role.getChatUser().getAddress().equals(packet.getFrom())) {
                    sendErrorPacket(packet, PacketError.Condition.conflict);
Matt Tucker's avatar
Matt Tucker committed
307 308 309
                }
                else {
                    try {
Gaston Dombiak's avatar
Gaston Dombiak committed
310 311 312
                        Element query = packet.getElement().element("query");
                        if (query != null &&
                                "http://jabber.org/protocol/muc#owner".equals(query.getNamespaceURI())) {
Matt Tucker's avatar
Matt Tucker committed
313 314
                            role.getChatRoom().getIQOwnerHandler().handleIQ(packet, role);
                        }
Gaston Dombiak's avatar
Gaston Dombiak committed
315 316
                        else if (query != null &&
                                "http://jabber.org/protocol/muc#admin".equals(query.getNamespaceURI())) {
Matt Tucker's avatar
Matt Tucker committed
317 318 319
                            role.getChatRoom().getIQAdminHandler().handleIQ(packet, role);
                        }
                        else {
Gaston Dombiak's avatar
Gaston Dombiak committed
320
                            sendErrorPacket(packet, PacketError.Condition.bad_request);
Matt Tucker's avatar
Matt Tucker committed
321 322 323
                        }
                    }
                    catch (ForbiddenException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
324
                        sendErrorPacket(packet, PacketError.Condition.forbidden);
Matt Tucker's avatar
Matt Tucker committed
325 326
                    }
                    catch (ConflictException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
327
                        sendErrorPacket(packet, PacketError.Condition.conflict);
Matt Tucker's avatar
Matt Tucker committed
328
                    }
329
                    catch (NotAllowedException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
330
                        sendErrorPacket(packet, PacketError.Condition.not_allowed);
331
                    }
Matt Tucker's avatar
Matt Tucker committed
332 333 334 335 336 337 338
                }
            }
        }
    }

    public void process(Presence packet) {
        lastPacketTime = System.currentTimeMillis();
Gaston Dombiak's avatar
Gaston Dombiak committed
339 340
        JID recipient = packet.getTo();
        String group = recipient.getNode();
341
        if (group == null) {
Gaston Dombiak's avatar
Gaston Dombiak committed
342 343
            if (Presence.Type.unavailable == packet.getType()) {
                server.removeUser(packet.getFrom());
Matt Tucker's avatar
Matt Tucker committed
344
            }
345 346 347 348 349 350 351 352
        }
        else {
            MUCRole role = roles.get(group.toLowerCase());
            if (role == null) {
                // If we're not already in a room, we either are joining it or it's not
                // properly addressed and we drop it silently
                if (recipient.getResource() != null
                        && recipient.getResource().trim().length() > 0) {
Gaston Dombiak's avatar
Gaston Dombiak committed
353
                    if (packet.isAvailable()) {
354 355
                        try {
                            // Get or create the room
Gaston Dombiak's avatar
Gaston Dombiak committed
356
                            MUCRoom room = server.getChatRoom(group, packet.getFrom());
357
                            // User must support MUC in order to create a room
Gaston Dombiak's avatar
Gaston Dombiak committed
358
                            Element mucInfo = packet.getChildElement("x",
359 360 361 362 363
                                    "http://jabber.org/protocol/muc");
                            HistoryRequest historyRequest = null;
                            String password = null;
                            // Check for password & requested history if client supports MUC
                            if (mucInfo != null) {
Gaston Dombiak's avatar
Gaston Dombiak committed
364 365
                                password = mucInfo.elementTextTrim("password");
                                if (mucInfo.element("history") != null) {
366
                                    historyRequest = new HistoryRequest(mucInfo);
Matt Tucker's avatar
Matt Tucker committed
367 368
                                }
                            }
369 370 371 372
                            // The user joins the room
                            role = room.joinRoom(recipient.getResource().trim(),
                                    password,
                                    historyRequest,
373 374
                                    this,
                                    packet.createCopy());
375
                            roles.put(group.toLowerCase(), role);
376 377
                            // If the client that created the room is non-MUC compliant then
                            // unlock the room thus creating an "instant" room
378 379
                            if (mucInfo == null && room.isLocked() && !room.isManuallyLocked()) {
                                room.unlock(role);
Matt Tucker's avatar
Matt Tucker committed
380 381
                            }
                        }
382
                        catch (UnauthorizedException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
383
                            sendErrorPacket(packet, PacketError.Condition.not_authorized);
384
                        }
385 386
                        catch (ServiceUnavailableException e) {
                            sendErrorPacket(packet, PacketError.Condition.service_unavailable);
387 388
                        }
                        catch (UserAlreadyExistsException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
389
                            sendErrorPacket(packet, PacketError.Condition.conflict);
390 391
                        }
                        catch (RoomLockedException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
392
                            sendErrorPacket(packet, PacketError.Condition.recipient_unavailable);
393 394
                        }
                        catch (ForbiddenException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
395
                            sendErrorPacket(packet, PacketError.Condition.forbidden);
396 397
                        }
                        catch (RegistrationRequiredException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
398
                            sendErrorPacket(packet, PacketError.Condition.registration_required);
399 400
                        }
                        catch (ConflictException e) {
Gaston Dombiak's avatar
Gaston Dombiak committed
401
                            sendErrorPacket(packet, PacketError.Condition.conflict);
Matt Tucker's avatar
Matt Tucker committed
402 403 404
                        }
                    }
                    else {
405 406
                        // TODO: send error message to user (can't send presence to group you
                        // haven't joined)
Matt Tucker's avatar
Matt Tucker committed
407 408 409
                    }
                }
                else {
Gaston Dombiak's avatar
Gaston Dombiak committed
410
                    if (packet.isAvailable()) {
411
                        // A resource is required in order to join a room
Gaston Dombiak's avatar
Gaston Dombiak committed
412
                        sendErrorPacket(packet, PacketError.Condition.bad_request);
413 414 415 416 417 418 419 420
                    }
                    // TODO: send error message to user (can't send packets to group you haven't
                    // joined)
                }
            }
            else {
                // Check and reject conflicting packets with conflicting roles
                // In other words, another user already has this nickname
Gaston Dombiak's avatar
Gaston Dombiak committed
421 422
                if (!role.getChatUser().getAddress().equals(packet.getFrom())) {
                    sendErrorPacket(packet, PacketError.Condition.conflict);
423 424
                }
                else {
Gaston Dombiak's avatar
Gaston Dombiak committed
425
                    if (Presence.Type.unavailable == packet.getType()) {
426 427 428 429 430 431 432 433 434 435
                        try {
                            roles.remove(group.toLowerCase());
                            role.getChatRoom().leaveRoom(role.getNickname());
                        }
                        catch (UserNotFoundException e) {
                            // Do nothing since the users has already left the room
                        }
                        catch (Exception e) {
                            Log.error(e);
                        }
Matt Tucker's avatar
Matt Tucker committed
436 437
                    }
                    else {
438 439 440 441 442 443 444
                        try {
                            String resource = (recipient.getResource() == null
                                    || recipient.getResource().trim().length() == 0 ? null
                                    : recipient.getResource().trim());
                            if (resource == null
                                    || role.getNickname().equalsIgnoreCase(resource)) {
                                // Occupant has changed his availability status
445 446
                                role.setPresence(packet.createCopy());
                                role.getChatRoom().send(role.getPresence().createCopy());
447
                            }
448 449 450 451 452 453
                            else {
                                // Occupant has changed his nickname. Send two presences
                                // to each room occupant

                                // Answer a conflic error if the new nickname is taken
                                if (role.getChatRoom().hasOccupant(resource)) {
Gaston Dombiak's avatar
Gaston Dombiak committed
454
                                    sendErrorPacket(packet, PacketError.Condition.conflict);
455 456 457
                                }
                                else {
                                    // Send "unavailable" presence for the old nickname
458
                                    Presence presence = role.getPresence().createCopy();
459
                                    // Switch the presence to OFFLINE
Gaston Dombiak's avatar
Gaston Dombiak committed
460
                                    presence.setType(Presence.Type.unavailable);
461
                                    presence.setStatus(null);
462
                                    // Add the new nickname and status 303 as properties
Gaston Dombiak's avatar
Gaston Dombiak committed
463 464 465
                                    Element frag = presence.getChildElement("x",
                                            "http://jabber.org/protocol/muc#user");
                                    frag.element("item").addAttribute("nick", resource);
Gaston Dombiak's avatar
Gaston Dombiak committed
466
                                    frag.addElement("status").addAttribute("code", "303");
Matt Tucker's avatar
Matt Tucker committed
467 468
                                    role.getChatRoom().send(presence);

469 470
                                    // Send availability presence for the new nickname
                                    String oldNick = role.getNickname();
471
                                    role.setPresence(packet.createCopy());
472 473
                                    role.changeNickname(resource);
                                    role.getChatRoom().nicknameChanged(oldNick, resource);
474
                                    role.getChatRoom().send(role.getPresence().createCopy());
Matt Tucker's avatar
Matt Tucker committed
475 476
                                }
                            }
477 478 479
                        }
                        catch (Exception e) {
                            Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
Matt Tucker's avatar
Matt Tucker committed
480 481 482 483 484 485 486
                        }
                    }
                }
            }
        }
    }
}