diff --git a/changelog.html b/changelog.html
index 162befd6e..f2aafab53 100644
--- a/changelog.html
+++ b/changelog.html
@@ -46,6 +46,8 @@
4.5.1 -- tbd
+ - Now requires Openfire 4.8.0 or later.
+ - [#68] - Fix compatibility issue with Openfire 4.9.0.
4.5.0 -- November 20, 2023
diff --git a/plugin.xml b/plugin.xml
index 4eefa0429..acefc89fb 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -6,8 +6,8 @@
Support for managed queued chat requests, such as a support team might use.
Ignite Realtime
${project.version}
- 2023-11-20
- 4.1.1
+ 2024-09-11
+ 4.8.0
fastpath
1
diff --git a/pom.xml b/pom.xml
index e094811b0..c13a75602 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
plugins
org.igniterealtime.openfire
- 4.7.1
+ 4.8.0
org.igniterealtime.openfire.plugins
fastpath
@@ -20,8 +20,8 @@
maven-compiler-plugin
3.3
-
- 1.8
+
+ 11
true
-XDignore.symbol.file
diff --git a/src/java/org/jivesoftware/openfire/fastpath/FastpathPlugin.java b/src/java/org/jivesoftware/openfire/fastpath/FastpathPlugin.java
index 2a0cc2812..149117c53 100644
--- a/src/java/org/jivesoftware/openfire/fastpath/FastpathPlugin.java
+++ b/src/java/org/jivesoftware/openfire/fastpath/FastpathPlugin.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2008 Jive Software. All rights reserved.
+ * Copyright (C) 2004-2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,9 @@
package org.jivesoftware.openfire.fastpath;
import java.io.File;
-import java.io.FileFilter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.*;
import org.jivesoftware.openfire.cluster.ClusterEventListener;
@@ -40,9 +42,6 @@
import org.eclipse.jetty.apache.jsp.JettyJasperInitializer;
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
-import org.eclipse.jetty.server.handler.ContextHandlerCollection;
-import org.eclipse.jetty.servlet.*;
-import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.webapp.WebAppContext;
import org.apache.tomcat.InstanceManager;
@@ -64,25 +63,14 @@ public class FastpathPlugin implements Plugin, ClusterEventListener {
private WebAppContext context;
public void initializePlugin(PluginManager manager, File pluginDirectory) {
- // Check if we Enterprise is installed and stop loading this plugin if found
- File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
- File[] jars = pluginDir.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- String fileName = pathname.getName().toLowerCase();
- return (fileName.equalsIgnoreCase("enterprise.jar"));
- }
- });
- if (jars.length > 0) {
- // Do not load this plugin since Enterprise is still installed
- System.out.println("Enterprise plugin found. Stopping Fastpath Plugin");
- throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
- }
-
// Make sure that the fastpath folder exists under the home directory
- File fastpathDir = new File(JiveGlobals.getHomeDirectory() +
- File.separator + "fastpath");
- if (!fastpathDir.exists()) {
- fastpathDir.mkdirs();
+ Path fastpathDir = JiveGlobals.getHomePath().resolve("fastpath");
+ if (!Files.exists(fastpathDir)) {
+ try {
+ Files.createDirectories(fastpathDir);
+ } catch (IOException e) {
+ throw new IllegalStateException("Unable to create fastpath directory: " + fastpathDir, e);
+ }
}
workgroupManagerStart();
diff --git a/src/java/org/jivesoftware/xmpp/workgroup/interceptor/UserInterceptor.java b/src/java/org/jivesoftware/xmpp/workgroup/interceptor/UserInterceptor.java
index 6b400ba4b..44560fcbe 100644
--- a/src/java/org/jivesoftware/xmpp/workgroup/interceptor/UserInterceptor.java
+++ b/src/java/org/jivesoftware/xmpp/workgroup/interceptor/UserInterceptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2004-2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jivesoftware.xmpp.workgroup.interceptor;
import org.jivesoftware.util.StringUtils;
@@ -17,11 +32,11 @@ public class UserInterceptor implements PacketInterceptor {
/**
* A Map of banned bare JIDs.
*/
- private Map jidBanMap = new HashMap();
+ private Map jidBanMap = new HashMap<>();
/**
* A Map of banned domains.
*/
- private Map domainBanMap = new HashMap();
+ private Map domainBanMap = new HashMap<>();
private String fromEmail;
private String fromName;
private String emailSubject = "";
@@ -130,7 +145,7 @@ public void setEmailNotifyList(String notifyList) {
emailNotifyList = null;
}
else {
- emailNotifyList = new ArrayList();
+ emailNotifyList = new ArrayList<>();
StringTokenizer tokenizer = new StringTokenizer(notifyList, ",");
while (tokenizer.hasMoreTokens()) {
String emailAddress = tokenizer.nextToken().trim();
@@ -215,14 +230,14 @@ private void sendNotifications(Packet packet, String packetSender) {
return;
}
for (String toEmail : emailNotifyList) {
- body = StringUtils.replace(emailBody, "{packet}", packet.toXML());
- body = StringUtils.replace(body, "{sender}", packetSender);
+ body = emailBody.replaceAll("\\{packet}", packet.toXML());
+ body = body.replaceAll("\\{sender}", packetSender);
emailService.sendMessage(null, toEmail, fromName, fromEmail, emailSubject, body, null);
}
}
private static Map getMap(String iPStr) {
- Map newMap = new HashMap();
+ Map newMap = new HashMap<>();
if (iPStr == null) {
return newMap;
}
@@ -236,7 +251,7 @@ private static Map getMap(String iPStr) {
private static String getString(Map map) {
- if (map == null || map.size() == 0) {
+ if (map == null || map.isEmpty()) {
return "";
}
// Iterate through the elements in the map.
diff --git a/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearch.java b/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearch.java
index b6602f0ae..0832a09d3 100644
--- a/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearch.java
+++ b/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearch.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2008 Jive Software. All rights reserved.
+ * Copyright (C) 2004-2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -334,9 +334,9 @@ else if (beforeDate == null) {
}
private String stripWildcards(String string) {
- string = StringUtils.replace(string, "*", "");
- string = StringUtils.replace(string, "?", "");
- string = StringUtils.replace(string, "~", "");
+ string = string.replaceAll("\\*", "");
+ string = string.replaceAll("\\?", "");
+ string = string.replaceAll("~", "");
return string;
}
diff --git a/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearchManager.java b/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearchManager.java
index 6c4e66c38..ee566d510 100644
--- a/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearchManager.java
+++ b/src/java/org/jivesoftware/xmpp/workgroup/search/ChatSearchManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2008 Jive Software. All rights reserved.
+ * Copyright (C) 2004-2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -137,7 +139,7 @@ public class ChatSearchManager implements WorkgroupEventListener {
* Holds the path to the parent folder of the folders that will store the workgroup
* index files.
*/
- private static String parentFolder = JiveGlobals.getHomeDirectory() + File.separator + "index";
+ private static Path parentFolder = JiveGlobals.getHomePath().resolve("index");
private static final long ONE_HOUR = 60 * 60 * 1000;
/**
@@ -147,7 +149,7 @@ public class ChatSearchManager implements WorkgroupEventListener {
*/
private Workgroup workgroup;
private Analyzer indexerAnalyzer;
- private String searchDirectory;
+ private Path searchDirectory;
private Searcher searcher = null;
private IndexReader searcherReader = null;
ReadWriteLock searcherLock = new ReentrantReadWriteLock();
@@ -180,9 +182,12 @@ public class ChatSearchManager implements WorkgroupEventListener {
static {
// Check if we need to create the parent folder
- File dir = new File(parentFolder);
- if (!dir.exists() || !dir.isDirectory()) {
- dir.mkdir();
+ if (!Files.exists(parentFolder) || !Files.isDirectory(parentFolder)) {
+ try {
+ Files.createDirectories(parentFolder);
+ } catch (IOException e) {
+ Log.warn("Unable to create folder: " + parentFolder, e);
+ }
}
}
@@ -299,7 +304,7 @@ private static int getOptimizationFrequency() {
ChatSearchManager(Workgroup workgroup) {
this.workgroup = workgroup;
- searchDirectory = parentFolder + File.separator + workgroup.getJID().getNode();
+ searchDirectory = parentFolder.resolve(workgroup.getJID().getNode());
loadAnalyzer();
loadLastUpdated();
WorkgroupEventDispatcher.addListener(this);
@@ -460,9 +465,8 @@ public synchronized void rebuildIndex() throws IOException {
* there is a problem adding a document to the index.
*/
public synchronized void updateIndex(boolean forceUpdate) throws IOException {
- // Check that the index files exist
- File dir = new File(searchDirectory);
- boolean create = !dir.exists() || !dir.isDirectory();
+ // Check that the index files exist;
+ boolean create = !Files.exists(searchDirectory) || !Files.isDirectory(searchDirectory);
if (lastUpdated == null || create) {
// Recreate the index since it was never created or the index files disappeared
rebuildIndex();
@@ -511,12 +515,12 @@ public void delete() {
// Ignore.
}
// Delete index files
- String[] files = new File(searchDirectory).list();
+ String[] files = searchDirectory.toFile().list();
for (int i = 0; i < files.length; i++) {
- File file = new File(searchDirectory, files[i]);
+ File file = new File(searchDirectory.toFile(), files[i]);
file.delete();
}
- new File(searchDirectory).delete();
+ searchDirectory.toFile().delete();
// Delete dates from the database
deleteDates();
// Remove this instance from the list of instances
@@ -543,8 +547,8 @@ public void delete() {
public Searcher getSearcher() throws IOException {
synchronized (indexerAnalyzer) {
if (searcherReader == null) {
- if (searchDirectory != null && IndexReader.indexExists(searchDirectory)) {
- searcherReader = IndexReader.open(searchDirectory);
+ if (searchDirectory != null && IndexReader.indexExists(searchDirectory.toFile())) {
+ searcherReader = IndexReader.open(searchDirectory.toFile());
searcher = new IndexSearcher(searcherReader);
}
else {
@@ -553,7 +557,7 @@ public Searcher getSearcher() throws IOException {
Log.warn("Search " +
"directory not set, you must rebuild the index.");
}
- else if (!IndexReader.indexExists(searchDirectory)) {
+ else if (!IndexReader.indexExists(searchDirectory.toFile())) {
Log.warn("Search " +
"directory " + searchDirectory + " does not appear to " +
"be a valid search index. You must rebuild the index.");
@@ -945,7 +949,7 @@ private void addTranscriptToIndex(ChatInformation chat, IndexWriter writer) thro
* existing index should be used if it's found there.
*/
private IndexWriter getWriter(boolean create) throws IOException {
- IndexWriter writer = new IndexWriter(searchDirectory, indexerAnalyzer, create);
+ IndexWriter writer = new IndexWriter(searchDirectory.toFile(), indexerAnalyzer, create);
return writer;
}
diff --git a/src/web/agent-selectors.jsp b/src/web/agent-selectors.jsp
index 97b4dc67a..7dec76c09 100644
--- a/src/web/agent-selectors.jsp
+++ b/src/web/agent-selectors.jsp
@@ -88,7 +88,7 @@
"<%= descriptor.getBeanClass().getName() %>",
"<%= descriptor.getValue("version") %>",
"<%= descriptor.getValue("author") %>",
- "<%= StringUtils.replace(descriptor.getShortDescription(), "\"", "\\\"") %>"
+ "<%= descriptor.getShortDescription().replaceAll("\"", "\\\"") %>"
)
<% if ((availableAgentSelectors.size() - i) > 1) { %>
,
diff --git a/src/web/interceptors.jsp b/src/web/interceptors.jsp
index ba5254daa..1ddf65f6d 100644
--- a/src/web/interceptors.jsp
+++ b/src/web/interceptors.jsp
@@ -192,7 +192,7 @@
}
private String escapeHTML(String html) {
- html = StringUtils.replace(html, "\"", """);
+ html = html.replaceAll("\"", """);
return StringUtils.escapeHTMLTags(html);
}
%>
@@ -598,7 +598,7 @@ var routerInfo = new Array(
"<%= descriptor.getBeanClass().getName() %>",
"<%= descriptor.getValue("version") %>",
"<%= descriptor.getValue("author") %>",
- "<%= StringUtils.replace(descriptor.getShortDescription(), "\"", "\\\"") %>"
+ "<%= descriptor.getShortDescription().replaceAll("\"", "\\\"") %>"
)
<% if ((interceptorManager.getAvailableInterceptors().size() - i) > 1) { %>
,