Skip to content

Commit 753864b

Browse files
authored
Merge pull request #388 from guusdk/387_Openfire-4.9.0-compat
Fix compatibility issue with Openfire 4.9.0
2 parents a9247d7 + 87e056f commit 753864b

File tree

14 files changed

+151
-101
lines changed

14 files changed

+151
-101
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
java: [ "8", "11" ]
10+
java: [ "11" ]
1111

1212
steps:
1313
# Checkout Repo

changelog.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ <h1>
4444
Monitoring Plugin Changelog
4545
</h1>
4646

47-
<p><b>2.5.1</b> -- (tbd)</p>
47+
<p><b>2.6.0</b> -- (tbd)</p>
4848
<ul>
49-
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/377'>Issue #383</a>] - Fixes: Database query fails on Oracle</li>
49+
<li>Requires Openfire 4.8.0</li>
50+
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/387'>Issue #387</a>] - Fixes: Compatibility issue with Openfire 4.9.0</li>
51+
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/383'>Issue #383</a>] - Fixes: Database query fails on Oracle</li>
5052
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/377'>Issue #377</a>] - Fixes: Erroneous index confirmation message</li>
5153
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/367'>Issue #367</a>] - Fixes: JRobin's repository uses invalid certificate</li>
5254
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/249'>Issue #249</a>] - Fixes: Erroneous index rebuild progress indicator</li>

plugin.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
<description>Monitors conversations and statistics of the server.</description>
77
<author>Ignite Realtime</author>
88
<version>${project.version}</version>
9-
<date>2024-04-17</date>
10-
<minServerVersion>4.7.0</minServerVersion>
11-
<minJavaVersion>1.8</minJavaVersion>
9+
<date>2024-08-23</date>
10+
<minServerVersion>4.8.0</minServerVersion>
1211
<databaseKey>monitoring</databaseKey>
1312
<databaseVersion>8</databaseVersion>
1413

pom.xml

+10-12
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<parent>
55
<artifactId>plugins</artifactId>
66
<groupId>org.igniterealtime.openfire</groupId>
7-
<version>4.7.0</version>
7+
<version>4.8.0</version>
88
</parent>
99
<groupId>org.igniterealtime.openfire.plugins</groupId>
1010
<artifactId>monitoring</artifactId>
11-
<version>2.5.1-SNAPSHOT</version>
11+
<version>2.6.0-SNAPSHOT</version>
1212
<name>Monitoring Plugin</name>
1313
<description>Monitors conversations and statistics of the server.</description>
1414

@@ -53,9 +53,9 @@
5353
<version>${jersey.version}</version>
5454
</dependency>
5555
<dependency>
56-
<groupId>org.jrobin</groupId>
56+
<groupId>com.purej</groupId>
5757
<artifactId>jrobin</artifactId>
58-
<version>1.6.0</version>
58+
<version>1.7.1</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>jfree</groupId>
@@ -103,7 +103,12 @@
103103
<artifactId>jaxb-runtime</artifactId>
104104
<version>2.3.3</version>
105105
</dependency>
106-
106+
<dependency>
107+
<groupId>junit</groupId>
108+
<artifactId>junit</artifactId>
109+
<version>4.13.1</version>
110+
<scope>test</scope>
111+
</dependency>
107112
</dependencies>
108113

109114
<repositories>
@@ -113,13 +118,6 @@
113118
<name>Ignite Realtime Repository</name>
114119
<url>https://igniterealtime.org/archiva/repository/maven/</url>
115120
</repository>
116-
117-
<!-- For jrobin -->
118-
<repository>
119-
<id>opennms-repo</id>
120-
<name>OpenNMS Release Repository</name>
121-
<url>https://maven.mirrors.opennms.org/maven2/</url>
122-
</repository>
123121
</repositories>
124122

125123
<pluginRepositories>

src/java/com/reucon/openfire/plugin/archive/impl/MessageIndexer.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (C) 2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.reucon.openfire.plugin.archive.impl;
217

318
import org.apache.lucene.document.*;
@@ -17,6 +32,7 @@
1732
import javax.print.Doc;
1833
import java.io.File;
1934
import java.io.IOException;
35+
import java.nio.file.Path;
2036
import java.sql.Connection;
2137
import java.sql.PreparedStatement;
2238
import java.sql.ResultSet;
@@ -53,7 +69,7 @@ public class MessageIndexer extends LuceneIndexer
5369

5470
public MessageIndexer( final TaskEngine taskEngine, final ConversationManager conversationManager )
5571
{
56-
super(taskEngine, new File(JiveGlobals.getHomeDirectory() + File.separator + MonitoringConstants.NAME + File.separator + "msgsearch"), "MESSAGE", SCHEMA_VERSION);
72+
super(taskEngine, JiveGlobals.getHomePath().resolve(Path.of(MonitoringConstants.NAME, "msgsearch")), "MESSAGE", SCHEMA_VERSION);
5773
this.conversationManager = conversationManager;
5874
}
5975

src/java/com/reucon/openfire/plugin/archive/impl/MucIndexer.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (C) 2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.reucon.openfire.plugin.archive.impl;
217

318
import org.apache.lucene.document.*;
@@ -13,6 +28,7 @@
1328

1429
import java.io.File;
1530
import java.io.IOException;
31+
import java.nio.file.Path;
1632
import java.sql.Connection;
1733
import java.sql.PreparedStatement;
1834
import java.sql.ResultSet;
@@ -41,7 +57,7 @@ public class MucIndexer extends LuceneIndexer
4157

4258
public MucIndexer( final TaskEngine taskEngine, final ConversationManager conversationManager )
4359
{
44-
super(taskEngine, new File(JiveGlobals.getHomeDirectory() + File.separator + MonitoringConstants.NAME + File.separator + "mucsearch"), "MUCSEARCH", SCHEMA_VERSION);
60+
super(taskEngine, JiveGlobals.getHomePath().resolve(Path.of(MonitoringConstants.NAME, "mucsearch")), "MUCSEARCH", SCHEMA_VERSION);
4561
this.conversationManager = conversationManager;
4662
}
4763

src/java/org/jivesoftware/openfire/archive/ArchiveIndexer.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008 Jive Software. All rights reserved.
2+
* Copyright (C) 2008 Jive Software, Ignite Realtime Foundation 2024. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727

2828
import java.io.File;
2929
import java.io.IOException;
30+
import java.nio.file.Path;
3031
import java.sql.Connection;
3132
import java.sql.PreparedStatement;
3233
import java.sql.ResultSet;
@@ -67,7 +68,7 @@ public class ArchiveIndexer extends org.jivesoftware.openfire.index.LuceneIndexe
6768
* @param taskEngine a task engine instance.
6869
*/
6970
public ArchiveIndexer(ConversationManager conversationManager, TaskEngine taskEngine) {
70-
super(taskEngine, new File(JiveGlobals.getHomeDirectory() + File.separator + MonitoringConstants.NAME + File.separator + "search"), "CONVERSATION", SCHEMA_VERSION);
71+
super(taskEngine, JiveGlobals.getHomePath().resolve(Path.of(MonitoringConstants.NAME, "search")), "CONVERSATION", SCHEMA_VERSION);
7172
this.conversationManager = conversationManager;
7273
}
7374

src/java/org/jivesoftware/openfire/archive/ConversationEventsQueue.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008 Jive Software. All rights reserved.
2+
* Copyright (C) 2008 Jive Software, Ignite Realtime Foundation 2024. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.jivesoftware.openfire.archive;
1818

19+
import java.time.Duration;
1920
import java.util.ArrayList;
2021
import java.util.HashMap;
2122
import java.util.List;
@@ -96,7 +97,7 @@ public void run() {
9697
}
9798
}
9899
};
99-
taskEngine.scheduleAtFixedRate(sendTask, JiveConstants.SECOND * 3, JiveConstants.SECOND * 3);
100+
taskEngine.scheduleAtFixedRate(sendTask, Duration.ofSeconds(3), Duration.ofSeconds(3));
100101
}
101102

102103
/**

src/java/org/jivesoftware/openfire/archive/ConversationManager.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008 Jive Software. All rights reserved.
2+
* Copyright (C) 2008 Jive Software, Ignite Realtime Foundation 2024. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -255,7 +255,7 @@ public void run() {
255255
}
256256
}
257257
};
258-
taskEngine.scheduleAtFixedRate(cleanupTask, JiveConstants.MINUTE * 5, JiveConstants.MINUTE * 5);
258+
taskEngine.scheduleAtFixedRate(cleanupTask, Duration.ofMinutes(5), Duration.ofMinutes(5));
259259

260260
// Schedule a task to do conversation purging.
261261
maxAgeTask = new TimerTask() {
@@ -304,7 +304,7 @@ public void run() {
304304
}
305305
}
306306
};
307-
taskEngine.scheduleAtFixedRate(maxAgeTask, JiveConstants.MINUTE, JiveConstants.MINUTE);
307+
taskEngine.scheduleAtFixedRate(maxAgeTask, Duration.ofMinutes(1), Duration.ofMinutes(1));
308308

309309
// Register a statistic.
310310
Statistic conversationStat = new Statistic() {

src/java/org/jivesoftware/openfire/index/LuceneIndexer.java

+40-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (C) 2008 Jive Software, 2024 Ignite Realtime Foundation. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.jivesoftware.openfire.index;
217

318
import org.apache.commons.io.FileUtils;
@@ -39,7 +54,7 @@ public abstract class LuceneIndexer
3954
private final int schemaVersion;
4055
protected TaskEngine taskEngine;
4156
protected RebuildFuture rebuildFuture;
42-
private File searchDir;
57+
private Path searchDir;
4358
private XMLProperties indexProperties;
4459
private Directory directory;
4560
private IndexSearcher searcher;
@@ -55,7 +70,7 @@ public abstract class LuceneIndexer
5570
.setPlugin(MonitoringConstants.PLUGIN_NAME)
5671
.build();
5772

58-
public LuceneIndexer(TaskEngine taskEngine, File searchDir, String logName, int schemaVersion)
73+
public LuceneIndexer(TaskEngine taskEngine, Path searchDir, String logName, int schemaVersion)
5974
{
6075
this.taskEngine = taskEngine;
6176
this.searchDir = searchDir;
@@ -66,19 +81,20 @@ public LuceneIndexer(TaskEngine taskEngine, File searchDir, String logName, int
6681
public void start()
6782
{
6883
Log.debug("Starting...");
69-
if ( !searchDir.exists() )
84+
if (!Files.exists(searchDir))
7085
{
71-
if ( !searchDir.mkdirs() )
72-
{
73-
Log.warn("Lucene index directory '{}' does not exist, but cannot be created!", searchDir);
86+
try {
87+
Files.createDirectories(searchDir);
88+
} catch (IOException e) {
89+
Log.warn("Lucene index directory '{}' does not exist, but cannot be created!", searchDir, e);
7490
}
7591
}
7692

7793
boolean indexCreated = false;
7894
try
7995
{
8096
indexProperties = loadPropertiesFile(searchDir);
81-
directory = FSDirectory.open(searchDir.toPath());
97+
directory = FSDirectory.open(searchDir);
8298
if ( !DirectoryReader.indexExists(directory) )
8399
{
84100
Log.info("Unable to find a Lucene index in {}. rebuilding.", directory);
@@ -94,7 +110,7 @@ public void start()
94110
{
95111
// See if the data on disk is of the schema version that we expect to be able to use.
96112
// TODO make this optional through configuration.
97-
final Path schemaVersionFile = searchDir.toPath().resolve("openfire-schema.version");
113+
final Path schemaVersionFile = searchDir.resolve("openfire-schema.version");
98114
final Scanner scanner = new Scanner(schemaVersionFile);
99115
int detectedSchemaVersion = -1;
100116
if (scanner.hasNextInt())
@@ -169,17 +185,22 @@ public void run()
169185
}
170186
};
171187
final Duration updateInterval = UPDATE_INTERVAL.getValue();
172-
taskEngine.schedule(indexUpdater, Duration.ofMinutes(1).toMillis(), updateInterval.toMillis());
188+
taskEngine.schedule(indexUpdater, Duration.ofMinutes(1), updateInterval);
173189
}
174190

175191
private void removeAndRebuildSearchDir() throws IOException {
176192
directory.close();
177-
FileUtils.deleteDirectory(searchDir);
178-
if ( !searchDir.mkdirs() )
193+
FileUtils.deleteDirectory(searchDir.toFile());
194+
if (!Files.exists(searchDir))
179195
{
180-
Log.warn("Lucene index directory '{}' cannot be recreated!", searchDir);
196+
try {
197+
Files.createDirectories(searchDir);
198+
} catch (IOException e) {
199+
Log.warn("Lucene index directory '{}' cannot be recreated!", searchDir, e);
200+
}
181201
}
182-
directory = FSDirectory.open(searchDir.toPath());
202+
203+
directory = FSDirectory.open(searchDir);
183204
}
184205

185206
protected synchronized Instant getLastModified()
@@ -244,7 +265,7 @@ public void stop()
244265
*/
245266
public long getIndexSize()
246267
{
247-
File[] files = searchDir.listFiles(( dir, name ) -> {
268+
File[] files = searchDir.toFile().listFiles(( dir, name ) -> {
248269
// Ignore the index properties file since it's not part of the index.
249270
return !name.equals("indexprops.xml");
250271
});
@@ -331,11 +352,11 @@ public synchronized Future<Integer> rebuildIndex() {
331352

332353
Log.debug("Removing old data from directory: {}", searchDir);
333354
try {
334-
FileUtils.cleanDirectory(searchDir);
335-
Files.write(searchDir.toPath().resolve("openfire-schema.version"), String.valueOf(this.schemaVersion).getBytes());
355+
FileUtils.cleanDirectory(searchDir.toFile());
356+
Files.write(searchDir.resolve("openfire-schema.version"), String.valueOf(this.schemaVersion).getBytes());
336357
indexProperties = loadPropertiesFile(searchDir);
337358
} catch ( IOException e ) {
338-
Log.warn("An exception occurred while trying to clean directory '{}' as part of a rebuild of the Lucene index that's in it.", searchDir);
359+
Log.warn("An exception occurred while trying to clean directory '{}' as part of a rebuild of the Lucene index that's in it.", searchDir, e);
339360
}
340361

341362
final Analyzer analyzer = new StandardAnalyzer();
@@ -431,9 +452,9 @@ public synchronized IndexSearcher getSearcher() throws IOException
431452
* loaded. If an XML file for the search properties isn't already
432453
* created, it will attempt to make a file with default values.
433454
*/
434-
private XMLProperties loadPropertiesFile( File searchDir ) throws IOException
455+
private XMLProperties loadPropertiesFile( Path searchDir ) throws IOException
435456
{
436-
File indexPropertiesFile = new File(searchDir, "indexprops.xml");
457+
File indexPropertiesFile = new File(searchDir.toFile(), "indexprops.xml");
437458

438459
// Make sure the file actually exists. If it doesn't, a new file
439460
// will be created.

0 commit comments

Comments
 (0)