From f518739a2e87d7a5cbe0f99b6c96f558c6fb5999 Mon Sep 17 00:00:00 2001 From: Wentao Chang Date: Fri, 27 Jun 2025 16:52:12 +0800 Subject: [PATCH 1/3] Compatible with Openfire 5.0.0. --- plugin.xml | 2 +- pom.xml | 42 +++++++-- .../openfire/plugin/rest/AuthFilter.java | 3 +- .../rest/controller/MUCRoomController.java | 88 +++++++++---------- .../service/MUCRoomAffiliationsService.java | 16 ++-- .../rest/service/UserServiceLegacy.java | 2 +- .../plugin/rest/utils/MUCRoomUtils.java | 26 +++--- src/web/rest-api.jsp | 2 +- 8 files changed, 104 insertions(+), 77 deletions(-) diff --git a/plugin.xml b/plugin.xml index cc2c7747f..c87fe275f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -7,7 +7,7 @@ Roman Soldatow ${project.version} 2024-11-17 - 4.8.0 + 5.0.0 diff --git a/pom.xml b/pom.xml index 328c9ac40..60cbe24f7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ plugins org.igniterealtime.openfire - 4.8.0 + 5.0.0 org.igniterealtime.openfire.plugins restAPI @@ -21,7 +21,8 @@ - 2.36 + 2.45 + 2.2.31 @@ -37,8 +38,8 @@ maven-assembly-plugin - org.eclipse.jetty - jetty-jspc-maven-plugin + org.eclipse.jetty.ee8 + jetty-ee8-jspc-maven-plugin @@ -48,11 +49,31 @@ org.glassfish.jersey.containers jersey-container-jetty-http ${jersey.version} + + + org.eclipse.jetty + jetty-server + + + org.eclipse.jetty + jetty-util + + + org.eclipse.jetty + jetty-continuation + + org.glassfish.jersey.containers jersey-container-jetty-servlet ${jersey.version} + + + org.eclipse.jetty + jetty-webapp + + org.glassfish.jersey.inject @@ -72,12 +93,12 @@ io.swagger.core.v3 swagger-jaxrs2 - 2.2.1 + ${swagger.version} io.swagger.core.v3 swagger-jaxrs2-servlet-initializer-v2 - 2.2.1 + ${swagger.version} @@ -91,7 +112,7 @@ org.glassfish.jersey.test-framework.providers jersey-test-framework-provider-grizzly2 - 2.27 + ${jersey.version} test @@ -101,7 +122,12 @@ 4.6.1 test - + + junit + junit + 4.13.1 + test + diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/AuthFilter.java b/src/java/org/jivesoftware/openfire/plugin/rest/AuthFilter.java index 7ab1111cf..2848e52f8 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/AuthFilter.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/AuthFilter.java @@ -52,8 +52,7 @@ public class AuthFilter implements ContainerRequestFilter { private HttpServletRequest httpRequest; /** The plugin. */ - private RESTServicePlugin plugin = (RESTServicePlugin) XMPPServer.getInstance().getPluginManager() - .getPlugin("restapi"); + private RESTServicePlugin plugin = (RESTServicePlugin) XMPPServer.getInstance().getPluginManager().getPluginByName("REST API").orElse(null); @Override public void filter(ContainerRequestContext containerRequest) throws IOException { diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java b/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java index c64df9c00..d9b09f731 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java @@ -452,7 +452,7 @@ private void createRoom(MUCRoomEntity mucRoomEntity, String serviceName, boolean room.setLogEnabled(mucRoomEntity.isLogEnabled()); room.setLoginRestrictedToNickname(mucRoomEntity.isLoginRestrictedToNickname()); room.setMaxUsers(mucRoomEntity.getMaxUsers()); - room.setMembersOnly(mucRoomEntity.isMembersOnly()); + room.setMembersOnly(mucRoomEntity.isMembersOnly(), room.getSelfRepresentation().getAffiliation(), room.getSelfRepresentation().getOccupantJID()); room.setModerated(mucRoomEntity.isModerated()); room.setCanSendPrivateMessage(mucRoomEntity.getAllowPM()); @@ -486,7 +486,7 @@ private void createRoom(MUCRoomEntity mucRoomEntity, String serviceName, boolean // Unlock the room, because the default configuration lock the room. log("Unlocking room that is being " + (room.isLocked() ? "created" : "updated") + ": " + mucRoomEntity.getRoomName()); - room.unlock(room.getRole()); + room.unlock(room.getSelfRepresentation().getAffiliation()); // Save the room to the DB if the room should be persistent if (room.isPersistent()) { @@ -561,7 +561,7 @@ public ParticipantEntities getRoomParticipants(String roomName, String serviceNa log("Get room participants for room: " + roomName); ParticipantEntities participantEntities = new ParticipantEntities(); List participants = new ArrayList<>(); - Collection serverParticipants; + Collection serverParticipants; final MultiUserChatService service = MUCServiceController.getService(serviceName); final Lock lock = getLock(service, roomName); @@ -573,9 +573,9 @@ public ParticipantEntities getRoomParticipants(String roomName, String serviceNa lock.unlock(); } - for (MUCRole role : serverParticipants) { + for (MUCOccupant role : serverParticipants) { ParticipantEntity participantEntity = new ParticipantEntity(); - participantEntity.setJid(role.getRoleAddress().toFullJID()); + participantEntity.setJid(role.getOccupantJID().toFullJID()); participantEntity.setRole(role.getRole().name()); participantEntity.setAffiliation(role.getAffiliation().name()); @@ -602,7 +602,7 @@ public OccupantEntities getRoomOccupants(String roomName, String serviceName) th OccupantEntities occupantEntities = new OccupantEntities(); List occupants = new ArrayList<>(); - Collection serverOccupants; + Collection serverOccupants; final MultiUserChatService service = MUCServiceController.getService(serviceName); final Lock lock = getLock(service, roomName); @@ -614,9 +614,9 @@ public OccupantEntities getRoomOccupants(String roomName, String serviceName) th lock.unlock(); } - for (MUCRole role : serverOccupants) { + for (MUCOccupant role : serverOccupants) { OccupantEntity occupantEntity = new OccupantEntity(); - occupantEntity.setJid(role.getRoleAddress().toFullJID()); + occupantEntity.setJid(role.getOccupantJID().toFullJID()); occupantEntity.setUserAddress(role.getUserAddress().toFullJID()); occupantEntity.setRole(role.getRole().name()); occupantEntity.setAffiliation(role.getAffiliation().name()); @@ -718,7 +718,7 @@ public void inviteUsersAndOrGroups(String serviceName, String roomName, MUCInvit MUCRoom room = getRoom(service, roomName); for (JID jid : targetJIDs) { try { - room.sendInvitation(jid, mucInvitationsEntity.getReason(), room.getRole(), null); + room.sendInvitation(jid, mucInvitationsEntity.getReason(), room.getSelfRepresentation().getAffiliation(), room.getSelfRepresentation().getUserAddress(), null); } catch (ForbiddenException | CannotBeInvitedException e) { throw new ServiceException("Could not invite user", jid.toString(), ExceptionType.NOT_ALLOWED, Response.Status.FORBIDDEN, e); } @@ -755,7 +755,7 @@ public void inviteUsersAndOrGroups(String serviceName, String roomName, MUCInvit */ private void sendInvitationsToSingleJID( MUCRoom room, - EnumSet affiliations, + EnumSet affiliations, JID limitToThisUserOrGroup, String reason, boolean performAffiliationCheck @@ -793,51 +793,51 @@ private void sendInvitationsToSingleJID( */ private void sendInvitationsFromRoom( MUCRoom room, - EnumSet affiliations, + EnumSet affiliations, Collection limitToTheseUsers, String reason, boolean performAffiliationCheck ) throws ForbiddenException { if (affiliations == null) { - affiliations = EnumSet.of(MUCRole.Affiliation.admin, MUCRole.Affiliation.member, MUCRole.Affiliation.owner); + affiliations = EnumSet.of(Affiliation.admin, Affiliation.member, Affiliation.owner); } - MUCRole roomRole = MUCRole.createRoomRole(room); + MUCOccupant roomRole = room.getSelfRepresentation(); - if (affiliations.contains(MUCRole.Affiliation.admin)) { + if (affiliations.contains(Affiliation.admin)) { Collection sendHere = limitToTheseUsers == null ? room.getAdmins() : limitToTheseUsers; for (JID roomAdmin : sendHere) { sendSingleInvitationFromRoom( roomAdmin, room, roomRole, - MUCRole.Affiliation.admin, + Affiliation.admin, reason == null ? "You are admin of room " + room.getName() : reason, performAffiliationCheck ? (r, j) -> r.getAdmins().contains(j) : null ); } } - if (affiliations.contains(MUCRole.Affiliation.owner)) { + if (affiliations.contains(Affiliation.owner)) { Collection sendHere = limitToTheseUsers == null ? room.getOwners() : limitToTheseUsers; for (JID roomOwner : sendHere) { sendSingleInvitationFromRoom( roomOwner, room, roomRole, - MUCRole.Affiliation.owner, + Affiliation.owner, reason == null ? "You are owner of room " + room.getName() : reason, performAffiliationCheck ? (r, j) -> r.getOwners().contains(j) : null ); } } - if (affiliations.contains(MUCRole.Affiliation.member)) { + if (affiliations.contains(Affiliation.member)) { Collection sendHere = limitToTheseUsers == null ? room.getMembers() : limitToTheseUsers; for (JID roomMember : sendHere) { sendSingleInvitationFromRoom( roomMember, room, roomRole, - MUCRole.Affiliation.member, + Affiliation.member, reason == null ? "You are member of room " + room.getName() : reason, performAffiliationCheck ? (r, j) -> r.getMembers().contains(j) : null ); @@ -856,7 +856,7 @@ private void sendInvitationsFromRoom( * @param room * The room * @param roomRole - * Role of the room (added for optimisation, to prevent the MUCRole.createRoomRole(room) from being called + * Role of the room (added for optimisation, to prevent the Role.createRoomRole(room) from being called * many times) * @param affiliation * The affiliation for which the jid is invited @@ -872,8 +872,8 @@ private void sendInvitationsFromRoom( private void sendSingleInvitationFromRoom( JID sendHere, MUCRoom room, - MUCRole roomRole, - MUCRole.Affiliation affiliation, + MUCOccupant roomRole, + Affiliation affiliation, String invitationReason, BiFunction validation ) throws ForbiddenException { @@ -896,7 +896,7 @@ private void sendSingleInvitationFromRoom( if (!jidIsGroup) { try { - room.sendInvitation(sendHere, invitationReason, roomRole, null); + room.sendInvitation(sendHere, invitationReason, roomRole.getAffiliation(), roomRole.getUserAddress(), null); } catch (CannotBeInvitedException e) { log("User " + sendHere + " can not be invited to be " + affiliation + " of room " + room.getName()); } @@ -1016,7 +1016,7 @@ private static Collection setRoles(MUCRoom room, MUCRoomEntity mucRoomEntit // Update the room by adding new owners. for (final JID newOwner : newOwners) { log("Adding new 'owner' affiliation for '" + newOwner + "' to room: " + room.getName()); - room.addOwner(newOwner, room.getRole()); + room.addOwner(newOwner, room.getSelfRepresentation().getAffiliation()); allNewAffiliations.add(newOwner); } @@ -1036,7 +1036,7 @@ private static Collection setRoles(MUCRoom room, MUCRoomEntity mucRoomEntit // Update the room by adding new admins. for (final JID newAdmin : newAdmins) { log("Adding new 'admin' affiliation for '" + newAdmin + "' to room: " + room.getName()); - room.addAdmin(newAdmin, room.getRole()); + room.addAdmin(newAdmin, room.getSelfRepresentation().getAffiliation()); allNewAffiliations.add(newAdmin); } @@ -1056,7 +1056,7 @@ private static Collection setRoles(MUCRoom room, MUCRoomEntity mucRoomEntit // Update the room by adding new members. for (final JID newMember : newMembers) { log("Adding new 'member' affiliation for '" + newMember + "' to room: " + room.getName()); - room.addMember(newMember, null, room.getRole()); + room.addMember(newMember, null, room.getSelfRepresentation().getAffiliation()); allNewAffiliations.add(newMember); } @@ -1076,14 +1076,14 @@ private static Collection setRoles(MUCRoom room, MUCRoomEntity mucRoomEntit // Update the room by adding new outcasts. for (final JID newOutcast : newOutcasts) { log("Adding new 'outcast' affiliation for '" + newOutcast + "' to room: " + room.getName()); - room.addOutcast(newOutcast, null, room.getRole()); + room.addOutcast(newOutcast, null, room.getSelfRepresentation().getUserAddress(), room.getSelfRepresentation().getAffiliation(), room.getSelfRepresentation().getRole()); allNewAffiliations.add(newOutcast); } // Finally, clean up every old affiliation that is not carrying over. for (JID affiliationToReset : affiliationsToReset) { log("Removing old affiliation for '" + affiliationToReset + "' from room: " + room.getName()); - room.addNone(affiliationToReset, room.getRole()); + room.addNone(affiliationToReset, room.getSelfRepresentation().getAffiliation()); } return allNewAffiliations; @@ -1101,7 +1101,7 @@ private static Collection setRoles(MUCRoom room, MUCRoomEntity mucRoomEntit * @return All users that have the specified affiliation to the specified room. * @throws ServiceException On any issue looking up the room or its affiliated users. */ - public Collection getByAffiliation(@Nonnull final String serviceName, @Nonnull final String roomName, @Nonnull final MUCRole.Affiliation affiliation) throws ServiceException + public Collection getByAffiliation(@Nonnull final String serviceName, @Nonnull final String roomName, @Nonnull final Affiliation affiliation) throws ServiceException { final MultiUserChatService service = MUCServiceController.getService(serviceName); final Lock lock = getLock(service, roomName); @@ -1121,7 +1121,7 @@ public Collection getByAffiliation(@Nonnull final String serviceName, @Nonn default: return room.getOccupants().stream() .filter(o -> affiliation.equals(o.getAffiliation())) - .map(MUCRole::getUserAddress) + .map(MUCOccupant::getUserAddress) .collect(Collectors.toSet()); } } finally { @@ -1147,7 +1147,7 @@ public Collection getByAffiliation(@Nonnull final String serviceName, @Nonn * whether to send invitations to newly affiliated users * @throws ServiceException On any issue looking up the room or changing its affiliated users. */ - public void replaceAffiliatedUsers(@Nonnull final String serviceName, @Nonnull final String roomName, @Nonnull final MUCRole.Affiliation affiliation, boolean sendInvitations, @Nonnull final String... jids) throws ServiceException + public void replaceAffiliatedUsers(@Nonnull final String serviceName, @Nonnull final String roomName, @Nonnull final Affiliation affiliation, boolean sendInvitations, @Nonnull final String... jids) throws ServiceException { final Collection replacements = new HashSet<>(); @@ -1180,22 +1180,22 @@ public void replaceAffiliatedUsers(@Nonnull final String serviceName, @Nonnull f // First, add all new affiliations (some affiliations aren't allowed to be empty, so removing things first could cause issues). switch (affiliation) { case admin: - room.addAdmins(toAdd, room.getRole()); + room.addAdmins(toAdd, room.getSelfRepresentation().getAffiliation()); break; case member: for (final JID add : toAdd) { - room.addMember(add, null, room.getRole()); + room.addMember(add, null, room.getSelfRepresentation().getAffiliation()); } break; case owner: - room.addOwners(toAdd, room.getRole()); + room.addOwners(toAdd, room.getSelfRepresentation().getAffiliation()); break; case outcast: for (final JID add : toAdd) { - room.addOutcast(add, null, room.getRole()); + room.addOutcast(add, null, room.getSelfRepresentation().getUserAddress(), room.getSelfRepresentation().getAffiliation(), room.getSelfRepresentation().getRole()); } break; default: @@ -1204,7 +1204,7 @@ public void replaceAffiliatedUsers(@Nonnull final String serviceName, @Nonnull f // Next, remove the affiliations that are no longer wanted. for (final JID remove : toRemove) { - room.addNone(remove, room.getRole()); + room.addNone(remove, room.getSelfRepresentation().getAffiliation()); } } catch (ForbiddenException | NotAllowedException e) { throw new ServiceException("Forbidden to apply modification to list of " + affiliation, roomName, ExceptionType.NOT_ALLOWED, Response.Status.FORBIDDEN, e); @@ -1243,7 +1243,7 @@ public void replaceAffiliatedUsers(@Nonnull final String serviceName, @Nonnull f * whether to send invitations to newly affiliated users * @throws ServiceException On any issue looking up the room or changing its affiliated users. */ - public void addAffiliatedUsers(@Nonnull final String serviceName, @Nonnull final String roomName, @Nonnull final MUCRole.Affiliation affiliation, boolean sendInvitations, @Nonnull final String... jids) throws ServiceException + public void addAffiliatedUsers(@Nonnull final String serviceName, @Nonnull final String roomName, @Nonnull final Affiliation affiliation, boolean sendInvitations, @Nonnull final String... jids) throws ServiceException { final Collection additions = new HashSet<>(); @@ -1272,22 +1272,22 @@ public void addAffiliatedUsers(@Nonnull final String serviceName, @Nonnull final // Add all new affiliations. switch (affiliation) { case admin: - room.addAdmins(toAdd, room.getRole()); + room.addAdmins(toAdd, room.getSelfRepresentation().getAffiliation()); break; case member: for (final JID add : toAdd) { - room.addMember(add, null, room.getRole()); + room.addMember(add, null, room.getSelfRepresentation().getAffiliation()); } break; case owner: - room.addOwners(toAdd, room.getRole()); + room.addOwners(toAdd, room.getSelfRepresentation().getAffiliation()); break; case outcast: for (final JID add : toAdd) { - room.addOutcast(add, null, room.getRole()); + room.addOutcast(add, null, room.getSelfRepresentation().getUserAddress(), room.getSelfRepresentation().getAffiliation(), room.getSelfRepresentation().getRole()); } break; default: @@ -1328,7 +1328,7 @@ public void addAffiliatedUsers(@Nonnull final String serviceName, @Nonnull final * @throws ServiceException * the service exception */ - public void deleteAffiliation(String serviceName, String roomName, MUCRole.Affiliation affiliation, String jid) throws ServiceException { + public void deleteAffiliation(String serviceName, String roomName, Affiliation affiliation, String jid) throws ServiceException { try { JID userJid = UserUtils.checkAndGetJID(jid); @@ -1343,9 +1343,9 @@ public void deleteAffiliation(String serviceName, String roomName, MUCRole.Affil throw new ConflictException("Entity does not have this affiliation with the room."); } // Send a presence to other room members - List addNonePresence = room.addNone(userJid, room.getRole()); + List addNonePresence = room.addNone(userJid, room.getSelfRepresentation().getAffiliation()); for (Presence presence : addNonePresence) { - MUCRoomUtils.send(room, presence, room.getRole()); + MUCRoomUtils.send(room, presence, room.getSelfRepresentation()); } // Make sure that other cluster nodes see the changes made here. diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java b/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java index 85d4eb88c..26871445f 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java @@ -23,7 +23,7 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; -import org.jivesoftware.openfire.muc.MUCRole; +import org.jivesoftware.openfire.muc.Affiliation; import org.jivesoftware.openfire.plugin.rest.controller.MUCRoomController; import org.jivesoftware.openfire.plugin.rest.entity.*; import org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse; @@ -62,7 +62,7 @@ public Response getAffiliations( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { @@ -114,7 +114,7 @@ public Response replaceMUCRoomAffiliation( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { @@ -146,7 +146,7 @@ public Response addMUCRoomAffiliations( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { @@ -177,7 +177,7 @@ public Response addMUCRoomAffiliation( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { @@ -208,7 +208,7 @@ public Response addMUCRoomAffiliationGroup( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { @@ -239,7 +239,7 @@ public Response deleteMUCRoomAffiliation( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { @@ -270,7 +270,7 @@ public Response deleteMUCRoomAffiliationGroup( throws ServiceException { roomName = JID.nodeprep(roomName); - final MUCRole.Affiliation affiliation; + final Affiliation affiliation; try { affiliation = MUCRoomUtils.convertPluralStringToAffiliation(affiliations); } catch (RuntimeException e) { diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/service/UserServiceLegacy.java b/src/java/org/jivesoftware/openfire/plugin/rest/service/UserServiceLegacy.java index 424daebc5..8be8fa197 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/service/UserServiceLegacy.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/service/UserServiceLegacy.java @@ -57,7 +57,7 @@ public class UserServiceLegacy { @PostConstruct public void init() { plugin = (RESTServicePlugin) XMPPServer.getInstance().getPluginManager() - .getPlugin("restapi"); + .getPluginByName("REST API").orElse(null); userServiceController = UserServiceLegacyController.getInstance(); } diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/utils/MUCRoomUtils.java b/src/java/org/jivesoftware/openfire/plugin/rest/utils/MUCRoomUtils.java index 54622c778..3e52ded2b 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/utils/MUCRoomUtils.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/utils/MUCRoomUtils.java @@ -24,7 +24,9 @@ import java.util.stream.Collectors; import org.jivesoftware.openfire.group.Group; -import org.jivesoftware.openfire.muc.MUCRole; +import org.jivesoftware.openfire.muc.Affiliation; +import org.jivesoftware.openfire.muc.MUCOccupant; +import org.jivesoftware.openfire.muc.Role; import org.jivesoftware.openfire.muc.MUCRoom; import org.xmpp.packet.JID; import org.xmpp.packet.Packet; @@ -89,39 +91,39 @@ public static List convertStringsToJIDs(List jids) { } /** - * Convert MUCRole.role instances to string list. + * Convert Role instances to string list. * * @param roles * the roles * @return the array list */ - public static List convertRolesToStringList(Collection roles) { + public static List convertRolesToStringList(Collection roles) { return roles.stream() - .map(MUCRole.Role::toString) + .map(Role::toString) .collect(Collectors.toList()); } /** - * Convert string instances to a MUCRole.role list. + * Convert string instances to a Role list. * * @param roles * the roles - * @return the array list + * @return the array list */ - public static List convertStringsToRoles(Collection roles) { + public static List convertStringsToRoles(Collection roles) { return roles.stream() - .map(MUCRole.Role::valueOf) + .map(Role::valueOf) .collect(Collectors.toList()); } /** - * Returns a MUCRole.Affiliation type for a String value that potentially is a plural (eg: MUCRole.Affiliation.member for 'members'). + * Returns a Affiliation type for a String value that potentially is a plural (eg: Affiliation.member for 'members'). * * @param affiliation The value for which to return an Affiliation type. * @return A string representation of an affiliation (can be in plural form). */ - public static MUCRole.Affiliation convertPluralStringToAffiliation(String affiliation) { - return MUCRole.Affiliation.valueOf( affiliation.endsWith("s") ? affiliation.substring(0, affiliation.length()-1) : affiliation); + public static Affiliation convertPluralStringToAffiliation(String affiliation) { + return Affiliation.valueOf( affiliation.endsWith("s") ? affiliation.substring(0, affiliation.length()-1) : affiliation); } /** @@ -129,7 +131,7 @@ public static MUCRole.Affiliation convertPluralStringToAffiliation(String affili * * Attempts to call the legacy implementation of MUCRoom::send, if an Openfire version < 4.6 is used. */ - public static void send(MUCRoom room, Packet packet, MUCRole role) + public static void send(MUCRoom room, Packet packet, MUCOccupant role) throws InvocationTargetException, IllegalAccessException { Method legacySend = legacySendMethod(); diff --git a/src/web/rest-api.jsp b/src/web/rest-api.jsp index 349100f9d..a4bfccce1 100644 --- a/src/web/rest-api.jsp +++ b/src/web/rest-api.jsp @@ -52,7 +52,7 @@ final PluginManager pluginManager = admin.getXMPPServer().getPluginManager(); RESTServicePlugin plugin = (RESTServicePlugin) XMPPServer.getInstance().getPluginManager() - .getPlugin("restapi"); + .getPluginByName("REST API").orElse(null); // Handle a save Map errors = new HashMap(); From 247a9c0a666808c3a050af25667c2e4a92ee9b48 Mon Sep 17 00:00:00 2001 From: Wentao Chang Date: Fri, 4 Jul 2025 13:51:43 +0800 Subject: [PATCH 2/3] Compatible with Openfire 5.0.0. --- changelog.html | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.html b/changelog.html index 422f099da..25cbf6149 100644 --- a/changelog.html +++ b/changelog.html @@ -48,6 +48,7 @@

  • [#203] - Reduce log level verbosity for some errors.
  • [#200] - Fix compatibility issue with Openfire 4.9.0.
  • +
  • [#208] - Fix compatibility issue with Openfire 5.0.0.

1.11.0 June 25, 2024

From 29aebc8f91a0648e74b6a8f31a73bb47b5092c48 Mon Sep 17 00:00:00 2001 From: Wentao Chang Date: Fri, 4 Jul 2025 14:01:52 +0800 Subject: [PATCH 3/3] Compatible with Openfire 5.0.0, update jersey to 2.45 and swagger to 2.2.31. --- changelog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index 25cbf6149..e4902ac8b 100644 --- a/changelog.html +++ b/changelog.html @@ -48,7 +48,7 @@

  • [#203] - Reduce log level verbosity for some errors.
  • [#200] - Fix compatibility issue with Openfire 4.9.0.
  • -
  • [#208] - Fix compatibility issue with Openfire 5.0.0.
  • +
  • [#208] - Fix compatibility issue with Openfire 5.0.0, update jersey to 2.45 and swagger to 2.2.31.

1.11.0 June 25, 2024