Skip to content

Commit

Permalink
Merge pull request #69 from guusdk/68_Openfire-4.7.0
Browse files Browse the repository at this point in the history
Make compatible with / depend on / require Openfire 4.7.0
  • Loading branch information
Fishbowler authored Jan 1, 2022
2 parents 01cf5bd + a50375b commit e8b3d6c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 38 deletions.
8 changes: 8 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ <h1>
REST API Plugin Changelog
</h1>

<p><b>1.7.0</b> (tbd)</p>
<ul>
<li>This plugin now requires Openfire 4.7.0-beta or later</li>
<li>[<a href='https://github.com/igniterealtime/openfire-restAPI-plugin/issues/25'>#25</a>] - Java 11 Jaxb issue</li>
<li>[<a href='https://github.com/igniterealtime/openfire-restAPI-plugin/issues/39'>#39</a>] - Requests fail when using XML as accept type on Openfire servers running java 11</li>
<li>[<a href='https://github.com/igniterealtime/openfire-restAPI-plugin/issues/68'>#68</a>] - Fix for incompatibility with Openfire v4.7.0-beta and later</li>
</ul>

<p><b>1.6.0</b> June 18, 2021</p>
<ul>
<li>This plugin now requires Openfire 4.6.1 or later</li>
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<description>Allows administration over a RESTful API.</description>
<author>Roman Soldatow</author>
<version>${project.version}</version>
<date>06/18/2021</date>
<minServerVersion>4.6.1</minServerVersion>
<date>12/17/2021</date>
<minServerVersion>4.7.0</minServerVersion>
<adminconsole>
<tab id="tab-server">
<sidebar id="sidebar-server-settings">
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.6.1</version>
<version>4.7.0-beta</version>
</parent>
<groupId>org.igniterealtime.openfire.plugins</groupId>
<artifactId>restAPI</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
package org.jivesoftware.openfire.plugin.rest.controller;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Iterator;
import java.util.Set;
import java.util.HashSet;
import java.util.stream.Collectors;

import javax.ws.rs.core.Response;

import org.dom4j.Element;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.group.ConcurrentGroupList;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.muc.*;
import org.jivesoftware.openfire.muc.cluster.RoomUpdatedEvent;
import org.jivesoftware.openfire.muc.cluster.RoomRemovedEvent;
import org.jivesoftware.openfire.muc.spi.LocalMUCRoom;
import org.jivesoftware.openfire.plugin.rest.RESTServicePlugin;
import org.jivesoftware.openfire.plugin.rest.entity.*;
import org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType;
import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException;
import org.jivesoftware.openfire.plugin.rest.utils.MUCRoomUtils;
import org.jivesoftware.openfire.plugin.rest.utils.UserUtils;
import org.jivesoftware.util.AlreadyExistsException;
import org.jivesoftware.util.cache.CacheFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;

import org.xmpp.packet.Message;
import org.dom4j.Element;
import org.xmpp.packet.Presence;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
import java.lang.reflect.InvocationTargetException;
import java.util.*;

/**
* The Class MUCRoomController.
Expand Down Expand Up @@ -76,18 +61,19 @@ public static void log(String logMessage) {
*/
public MUCRoomEntities getChatRooms(String serviceName, String channelType, String roomSearch, boolean expand) {
log("Get the chat rooms");
List<MUCRoom> rooms = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName)
.getChatRooms();
final MultiUserChatService service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName);
Set<String> roomNames = service.getAllRoomNames();

List<MUCRoomEntity> mucRoomEntities = new ArrayList<MUCRoomEntity>();

for (MUCRoom chatRoom : rooms) {
for (String roomName : roomNames) {
if (roomSearch != null) {
if (!chatRoom.getName().contains(roomSearch)) {
if (!roomName.contains(roomSearch)) {
continue;
}
}

final MUCRoom chatRoom = service.getChatRoom(roomName);
if (channelType.equals(MUCChannelType.ALL)) {
mucRoomEntities.add(convertToMUCRoomEntity(chatRoom, expand));
} else if (channelType.equals(MUCChannelType.PUBLIC) && chatRoom.isPublicRoom()) {
Expand Down Expand Up @@ -139,9 +125,6 @@ public void deleteChatRoom(String roomName, String serviceName) throws ServiceEx

if (chatRoom != null) {
chatRoom.destroyRoom(null, null);
if (ClusterManager.isClusteringStarted()) {
CacheFactory.doClusterTask(new RoomRemovedEvent((LocalMUCRoom) chatRoom));
}
} else {
throw new ServiceException("Could not remove the channel", roomName, ExceptionType.ROOM_NOT_FOUND, Response.Status.NOT_FOUND);
}
Expand Down Expand Up @@ -290,12 +273,7 @@ private void createRoom(MUCRoomEntity mucRoomEntity, String serviceName) throws
// Unlock the room, because the default configuration lock the room.
room.unlock(room.getRole());

// Fire RoomUpdateEvent if cluster is started
if (ClusterManager.isClusteringStarted()) {
CacheFactory.doClusterTask(new RoomUpdatedEvent((LocalMUCRoom) room));
}

// Save the room to the DB if the room should be persistant
// Save the room to the DB if the room should be persistent
if (room.isPersistent()) {
room.saveToDB();
}
Expand Down

0 comments on commit e8b3d6c

Please sign in to comment.