Skip to content

Commit 573b6af

Browse files
guusdkakrherz
authored andcommitted
fixes igniterealtime#33: update API to be compatible with Openfire 4.8
1 parent 6ed8280 commit 573b6af

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

changelog.html

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<h1>HTTP File Upload Plugin Changelog</h1>
4343

4444
<p><b>1.2.0</b> -- (tbd)</p>
45+
<ul>
46+
<li>Now requires Openfire 4.7.0 or later</li>
47+
<li><a href="https://github.com/igniterealtime/openfire-httpFileUpload-plugin/issues/33">Issue #33:</a> Fix API incompatiblities with upcoming Openfire 4.8.</li>
48+
</ul>
4549

4650
<p><b>1.1.5</b> -- (September 12, 2022)</p>
4751

plugin.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
<author>Guus der Kinderen</author>
77
<version>${project.version}</version>
88
<date>2022-09-12</date>
9-
<minServerVersion>4.1.0</minServerVersion>
10-
<maxServerVersion>4.8.0</maxServerVersion>
9+
<minServerVersion>4.7.0</minServerVersion>
1110
</plugin>

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>plugins</artifactId>
66
<groupId>org.igniterealtime.openfire</groupId>
7-
<version>4.3.0</version>
7+
<version>4.7.0</version>
88
</parent>
99
<groupId>org.igniterealtime.openfire.plugins</groupId>
1010
<artifactId>httpfileupload</artifactId>

src/java/org/igniterealtime/openfire/plugins/httpfileupload/CORSServlet.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ protected void service( HttpServletRequest request, HttpServletResponse response
2020
final HttpBindManager boshManager = HttpBindManager.getInstance();
2121

2222
// add CORS headers for all HTTP responses (errors, etc.)
23-
if (boshManager.isCORSEnabled())
23+
if (HttpBindManager.HTTP_BIND_CORS_ENABLED.getValue())
2424
{
2525
if (boshManager.isAllOriginsAllowed()) {
2626
// Set the Access-Control-Allow-Origin header to * to allow all Origin to do the CORS
27-
response.setHeader( "Access-Control-Allow-Origin", HttpBindManager.HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT);
27+
response.setHeader( "Access-Control-Allow-Origin", HttpBindManager.HTTP_BIND_CORS_ALLOW_ORIGIN_ALL);
2828
} else {
2929
// Get the Origin header from the request and check if it is in the allowed Origin Map.
3030
// If it is allowed write it back to the Access-Control-Allow-Origin header of the respond.
@@ -33,9 +33,9 @@ protected void service( HttpServletRequest request, HttpServletResponse response
3333
response.setHeader("Access-Control-Allow-Origin", origin);
3434
}
3535
}
36-
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
37-
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT);
38-
response.setHeader("Access-Control-Max-Age", HttpBindManager.HTTP_BIND_CORS_MAX_AGE_DEFAULT);
36+
response.setHeader("Access-Control-Allow-Methods", String.join(", ", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getDefaultValue()));
37+
response.setHeader("Access-Control-Allow-Headers", String.join(", ", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getDefaultValue()));
38+
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getDefaultValue().getSeconds())); // // TODO: replace with 'toSeconds()' after dropping support for Java 8.
3939
}
4040
super.service(request, response);
4141
}

src/java/org/igniterealtime/openfire/plugins/httpfileupload/HttpFileUploadPlugin.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void initializePlugin( PluginManager manager, File pluginDirectory )
5555
{
5656
SlotManager.getInstance().setWebProtocol( JiveGlobals.getProperty( "plugin.httpfileupload.announcedWebProtocol", "https" ) );
5757
SlotManager.getInstance().setWebHost( JiveGlobals.getProperty( "plugin.httpfileupload.announcedWebHost", XMPPServer.getInstance().getServerInfo().getHostname() ) );
58-
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.getInstance().getHttpBindSecurePort() ) );
58+
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.HTTP_BIND_SECURE_PORT.getValue() ) );
5959
SlotManager.getInstance().setWebContextRoot( JiveGlobals.getProperty( "plugin.httpfileupload.announcedWebContextRoot", "/httpfileupload" ) );
6060
SlotManager.getInstance().setMaxFileSize( JiveGlobals.getLongProperty( "plugin.httpfileupload.maxFileSize", SlotManager.DEFAULT_MAX_FILE_SIZE ) );
6161

@@ -177,7 +177,7 @@ public final void setProperty( String property )
177177

178178
if ( "plugin.httpfileupload.announcedWebPort".equals( property ) )
179179
{
180-
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.getInstance().getHttpBindSecurePort() ) );
180+
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.HTTP_BIND_SECURE_PORT.getValue() ) );
181181
}
182182
}
183183

@@ -203,7 +203,7 @@ public final void deleteProperty( String property )
203203

204204
if ( "plugin.httpfileupload.announcedWebPort".equals( property ) )
205205
{
206-
SlotManager.getInstance().setWebPort( HttpBindManager.getInstance().getHttpBindSecurePort() );
206+
SlotManager.getInstance().setWebPort( HttpBindManager.HTTP_BIND_SECURE_PORT.getValue() );
207207
}
208208
}
209209
}

0 commit comments

Comments
 (0)