Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace API no longer available in Openfire 4.9.0 #477

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ <h1>
Pade Changelog
</h1>

<p><b>1.8.3</b> -- <i>May 31, 2024</i></p>
<p><b>1.8.3</b> -- <i>(tbd)</i></p>
<ul>
<li>Fixed <a href="https://github.com/igniterealtime/openfire-pade-plugin/issues/476">Issue #476 - Compatibility issue with Openfire 4.9.0.</a></li>
</ul>

<p><b>1.8.2</b> -- <i>April 30, 2024</i></p>
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>${project.description}</description>
<author>Ignite Realtime</author>
<version>${project.version}</version>
<date>04/30/2024</date>
<date>2024-09-19</date>
<minServerVersion>4.8.0</minServerVersion>
<minJavaVersion>1.11</minJavaVersion>
<adminconsole>
Expand Down
14 changes: 8 additions & 6 deletions src/java/org/ifsoft/mta/MtaManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ifsoft.mta;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -63,13 +65,13 @@ public final class MtaManager {

static {
keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore", "resources" + File.separator + "security" + File.separator + "keystore");
keyStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + keyStoreLocation;
keyStoreLocation = JiveGlobals.getHomePath().toString() + File.separator + keyStoreLocation;

keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
keypass = keypass.trim();

c2sTrustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.client.truststore", "resources" + File.separator + "security" + File.separator + "client.truststore");
c2sTrustStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + c2sTrustStoreLocation;
c2sTrustStoreLocation = JiveGlobals.getHomePath().toString() + File.separator + c2sTrustStoreLocation;

c2sTrustpass = JiveGlobals.getProperty("xmpp.socket.ssl.client.trustpass", "changeit");
c2sTrustpass = c2sTrustpass.trim();
Expand Down Expand Up @@ -217,13 +219,13 @@ private String getBindInterface() {
*/
protected Handler createStaticContentHandler()
{
final File mtaDirectory = new File( JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "mta" );
final Path mtaDirectory = JiveGlobals.getHomePath().resolve("resources").resolve("mta");

if ( mtaDirectory.exists() )
if (Files.exists(mtaDirectory) )
{
if ( mtaDirectory.canRead() )
if ( Files.isReadable(mtaDirectory) )
{
final WebAppContext context = new WebAppContext( null, mtaDirectory.getPath(), "/" );
final WebAppContext context = new WebAppContext( null, mtaDirectory.normalize().toString(), "/" );
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add(new ContainerInitializer(new JettyJasperInitializer(), null));
context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
Expand Down
12 changes: 6 additions & 6 deletions src/java/org/ifsoft/upload/Servlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ protected void doPut( HttpServletRequest request, HttpServletResponse response )

if (name.endsWith(".webm"))
{
String dir = JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" + File.separator + "ofmeet-cdn" + File.separator + "recordings";
Path path = Paths.get( dir, name);
Path path = JiveGlobals.getHomePath().resolve("resources").resolve("spank").resolve("ofmeet-cdn").resolve("recordings").resolve(name);

try {
writeFile(path, request);
Expand All @@ -85,12 +84,13 @@ protected void doPut( HttpServletRequest request, HttpServletResponse response )

String source = path.toString();
String folder = name.substring(0, name.lastIndexOf("."));
String destination = JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" + File.separator + username + File.separator + folder;
Path destination = JiveGlobals.getHomePath().resolve("resources").resolve("spank").resolve(username).resolve(folder);

Log.debug( "Extracting application..." + source + " " + destination);

ZipFile zipFile = new ZipFile(path.toFile());
zipFile.extractAll(destination);
try (ZipFile zipFile = new ZipFile(path.toFile())) {
zipFile.extractAll(destination.toString());
}

Files.deleteIfExists(path);

Expand Down Expand Up @@ -142,4 +142,4 @@ private void writeFile(Path path, HttpServletRequest request) throws Exception

outStream.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void interceptPacket( final Packet packet, final Session session, final b
}

message.addChildElement("origin-id", "urn:xmpp:sid:0").addAttribute("id", msgId);
XMPPServer.getInstance().getRoutingTable().routePacket(packet.getTo(), message, true);
XMPPServer.getInstance().getRoutingTable().routePacket(packet.getTo(), message);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.jivesoftware.openfire.archive;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -98,15 +100,15 @@ public Collection<Conversation> search(ArchiveSearch search) {
private Collection<Conversation> luceneSearch(ArchiveSearch search) {
Log.debug( "Executing new Lucene search for query string {}", search.getQueryString() );
try {
File searchDir = new File(JiveGlobals.getHomeDirectory() + File.separator + MonitoringConstants.NAME + File.separator + "search");
Path searchDir = JiveGlobals.getHomePath().resolve(MonitoringConstants.NAME).resolve("search");

if (!searchDir.exists())
if (!Files.exists(searchDir))
{
Log.error("Search folder missing " + searchDir);
return Collections.emptySet();
}
try {
directory = FSDirectory.open(searchDir.toPath());
directory = FSDirectory.open(searchDir);
}
catch (IOException ioe) {
Log.error(ioe.getMessage(), ioe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.jivesoftware.openfire.archive;

import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.text.*;
import java.io.*;
Expand Down Expand Up @@ -91,19 +93,18 @@ public static void doSearch(OutputStream out, String username, String keywords,

if (start != null)
{
Date startDate = null;
Instant startDate;

try {
if (start.contains("T"))
{
startDate = Date.from(Instant.parse(start));
startDate = Instant.parse(start);
}
else {
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
startDate = formatter.parse(start);
startDate = DateTimeFormatter.ofPattern("MM/dd/yy").parse(start, Instant::from);
}
startDate = new Date(startDate.getTime() - JiveConstants.MINUTE * 5);
search.setDateRangeMin(startDate);
startDate = startDate.plus(5, ChronoUnit.MINUTES);
search.setDateRangeMin(Date.from(startDate));
}
catch (Exception e) {
Log.error("ConversationPDFServlet", e);
Expand All @@ -112,19 +113,18 @@ public static void doSearch(OutputStream out, String username, String keywords,

if (end != null)
{
Date endDate = null;
Instant endDate;

try {
if (end.contains("T"))
{
endDate = Date.from(Instant.parse(end));
endDate = Instant.parse(end);
}
else {
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
endDate = formatter.parse(end);
endDate = DateTimeFormatter.ofPattern("MM/dd/yy").parse(end, Instant::from);
}
endDate = new Date(endDate.getTime() + JiveConstants.DAY - 1);
search.setDateRangeMax(endDate);
endDate = endDate.plus(1, ChronoUnit.DAYS).minus(1, ChronoUnit.MILLIS);
search.setDateRangeMax(Date.from(endDate));
}
catch (Exception e) {
Log.error("ConversationPDFServlet", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void broadcast_json_msg(JID to, JID from, JSONObject jsonMsg)
message.setType(Message.Type.groupchat);
Element json = message.addChildElement("json-message", "http://jitsi.org/jitmeet");
json.setText(jsonMsg.toString());
XMPPServer.getInstance().getRoutingTable().routePacket(to, message, true);
XMPPServer.getInstance().getRoutingTable().routePacket(to, message);
}

private void notify_configuration_change(JID to, String from)
Expand All @@ -98,7 +98,7 @@ private void notify_configuration_change(JID to, String from)
message.setType(Message.Type.groupchat);
Element x = message.addChildElement("x", "http://jabber.org/protocol/muc#user");
x.addElement("status").addAttribute("code", "104");
XMPPServer.getInstance().getRoutingTable().routePacket(to, message, true);
XMPPServer.getInstance().getRoutingTable().routePacket(to, message);
}

private void notify_lobby_enabled(JID to, JID from, boolean value)
Expand Down
34 changes: 15 additions & 19 deletions src/java/org/jivesoftware/openfire/plugin/ofmeet/OfMeetPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ protected void loadPublicWebApp() throws Exception
Log.debug( "Initialized public web application", publicWebApp.toString() );

File source = new File(pluginDirectory.getPath() + "/classes/docs");
File destination = new File(JiveGlobals.getHomeDirectory() + "/resources/spank/pade");
File destination = JiveGlobals.getHomePath().resolve("resources").resolve("spank").resolve("pade").toFile();

if ("/".equals(config.getWebappContextPath())) {
destination = new File(pluginDirectory.getPath() + "/classes/jitsi-meet/pade");
Expand Down Expand Up @@ -575,33 +575,29 @@ public URL getWebappURL()

private void checkDownloadFolder(File pluginDirectory)
{
String ofmeetHome = JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" + File.separator + "ofmeet-cdn";
Path ofmeetHome = JiveGlobals.getHomePath().resolve("resources").resolve("spank").resolve("ofmeet-cdn");

try
{
File ofmeetFolderPath = new File(ofmeetHome);

if(!ofmeetFolderPath.exists())
if(!Files.exists(ofmeetHome))
{
ofmeetFolderPath.mkdirs();

Files.createDirectories(ofmeetHome);
}

List<String> lines = Arrays.asList("Move on, nothing here....");
Path file = Paths.get(ofmeetHome + File.separator + "index.html");
Files.write(file, lines, Charset.forName("UTF-8"));
List<String> lines = List.of("Move on, nothing here....");
Path file = ofmeetHome.resolve("index.html");
Files.write(file, lines, StandardCharsets.UTF_8);

File downloadHome = new File(ofmeetHome + File.separator + "download");
Path downloadHome = ofmeetHome.resolve("download");

if(!downloadHome.exists())
if(!Files.exists(downloadHome))
{
downloadHome.mkdirs();

Files.createDirectories(downloadHome);
}

lines = Arrays.asList("Move on, nothing here....");
file = Paths.get(downloadHome + File.separator + "index.html");
Files.write(file, lines, Charset.forName("UTF-8"));
lines = List.of("Move on, nothing here....");
file = downloadHome.resolve("index.html");
Files.write(file, lines, StandardCharsets.UTF_8);
}
catch (Exception e)
{
Expand Down Expand Up @@ -1157,7 +1153,7 @@ public void occupantJoined(final JID roomJID, JID user, String nickname)
pollMsg.setTo(user);
Element pollJson = pollMsg.addChildElement("json-message", "http://jitsi.org/jitmeet");
pollJson.setText(pollsMsg.toString());
XMPPServer.getInstance().getRoutingTable().routePacket(user, pollMsg, true);
XMPPServer.getInstance().getRoutingTable().routePacket(user, pollMsg);

Log.debug("occupantJoined polls\n" + pollsMsg);
}
Expand All @@ -1180,7 +1176,7 @@ public void occupantJoined(final JID roomJID, JID user, String nickname)
message.setTo(user);
Element json = message.addChildElement("json", "urn:xmpp:json:0");
json.setText(jsonMsg.toString());
XMPPServer.getInstance().getRoutingTable().routePacket(user, message, true);
XMPPServer.getInstance().getRoutingTable().routePacket(user, message);

Log.debug("occupantJoined json\n" + jsonMsg);
}
Expand Down
38 changes: 19 additions & 19 deletions src/java/uk/ifsoft/openfire/plugins/pade/PadePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.jivesoftware.openfire.group.*;
import org.jivesoftware.util.*;

import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -252,44 +253,43 @@ public OfMeetPlugin getContainer()

private void checkRecordingsFolder()
{
String resourcesHome = JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank";
Path resourcesHome = JiveGlobals.getHomePath().resolve("resources").resolve("spank");

try
{
File ofmeetHome = new File(resourcesHome + File.separator + "ofmeet-cdn");
Path ofmeetHome = resourcesHome.resolve("ofmeet-cdn");

if(!ofmeetHome.exists())
if(!Files.exists(ofmeetHome))
{
ofmeetHome.mkdirs();

List<String> lines = Arrays.asList("Move on, nothing here....");
Path file = Paths.get(ofmeetHome + File.separator + "index.html");
Files.write(file, lines, Charset.forName("UTF-8"));
Files.createDirectory(ofmeetHome);
List<String> lines = List.of("Move on, nothing here....");
Path file = ofmeetHome.resolve("index.html");
Files.write(file, lines, StandardCharsets.UTF_8);
}

File recordingsHome = new File(ofmeetHome + File.separator + "recordings");
Path recordingsHome = ofmeetHome.resolve("recordings");

if(!recordingsHome.exists())
if(!Files.exists(recordingsHome))
{
recordingsHome.mkdirs();
Files.createDirectory(recordingsHome);

List<String> lines = Arrays.asList("Move on, nothing here....");
List<String> lines = List.of("Move on, nothing here....");
Path file = Paths.get(recordingsHome + File.separator + "index.html");
Files.write(file, lines, Charset.forName("UTF-8"));
Files.write(file, lines, StandardCharsets.UTF_8);
}

// create .well-known/host-meta

File wellknownFolder = new File(resourcesHome + File.separator + ".well-known");
Path wellknownFolder = resourcesHome.resolve(".well-known");

if(!wellknownFolder.exists())
if(!Files.exists(wellknownFolder))
{
wellknownFolder.mkdirs();
Files.createDirectory(wellknownFolder);
}

List<String> lines = Arrays.asList("<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\">", "<Link rel=\"urn:xmpp:alt-connections:xbosh\" href=\"https://" + server + "/http-bind/\"/>", "<Link rel=\"urn:xmpp:alt-connections:websocket\" href=\"wss://" + server + "/ws/\"/>", "</XRD>");
Path file = Paths.get(wellknownFolder + File.separator + "host-meta");
Files.write(file, lines, Charset.forName("UTF-8"));
Path file = wellknownFolder.resolve("host-meta");
Files.write(file, lines, StandardCharsets.UTF_8);

}
catch (Exception e)
Expand Down Expand Up @@ -448,7 +448,7 @@ private void notifyRoomActivity(JID subscriberJID, MUCRoom room, JID roomJID, Me
notification.setTo(subscriberJID);
Element rai = notification.addChildElement("rai", "urn:xmpp:rai:0");
rai.addElement("activity").setText(roomJID.toString());
XMPPServer.getInstance().getRoutingTable().routePacket(subscriberJID, notification, true);
XMPPServer.getInstance().getRoutingTable().routePacket(subscriberJID, notification);
}
else {
// user is offline, send web push notification if user mentioned
Expand Down
Loading