Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
d7eade45
Commit
d7eade45
authored
Sep 24, 2014
by
daryl herzmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72 from Redor/master
MUC Service Plugin update to 0.2.2
parents
5110ec0f
72898bc7
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
819 additions
and
82 deletions
+819
-82
changelog.html
src/plugins/mucservice/changelog.html
+5
-0
plugin.xml
src/plugins/mucservice/plugin.xml
+2
-2
readme.html
src/plugins/mucservice/readme.html
+511
-73
MUCRoomEntity.java
.../java/org/jivesoftware/openfire/entity/MUCRoomEntity.java
+6
-0
MUCRoomController.java
...a/org/jivesoftware/openfire/plugin/MUCRoomController.java
+141
-3
JerseyWrapper.java
...g/jivesoftware/openfire/plugin/servlet/JerseyWrapper.java
+9
-0
MUCRoomAdminsService.java
...g/jivesoftware/openfire/service/MUCRoomAdminsService.java
+34
-0
MUCRoomMembersService.java
.../jivesoftware/openfire/service/MUCRoomMembersService.java
+34
-0
MUCRoomOutcastsService.java
...jivesoftware/openfire/service/MUCRoomOutcastsService.java
+34
-0
MUCRoomOwnersService.java
...g/jivesoftware/openfire/service/MUCRoomOwnersService.java
+34
-0
MUCRoomService.java
...ava/org/jivesoftware/openfire/service/MUCRoomService.java
+9
-4
No files found.
src/plugins/mucservice/changelog.html
View file @
d7eade45
...
...
@@ -44,6 +44,11 @@
MUC Service Plugin Changelog
</h1>
<p><b>
0.2.2
</b>
-- 09.17.2014
</p>
<ul>
<li>
Room user roles can now be added and removed individually
</li>
</ul>
<p><b>
0.2.1
</b>
-- 08.09.2014
</p>
<ul>
<li>
Creation and modification dates, are now optional
</li>
...
...
src/plugins/mucservice/plugin.xml
View file @
d7eade45
...
...
@@ -5,7 +5,7 @@
<name>
MUC Service
</name>
<description>
MUC administration over REST Interface
</description>
<author>
Roman Soldatow
</author>
<version>
0.2.1
</version>
<date>
0
8.09
.2014
</date>
<version>
0.2.2
</version>
<date>
0
9.17
.2014
</date>
<minServerVersion>
3.9.1
</minServerVersion>
</plugin>
src/plugins/mucservice/readme.html
View file @
d7eade45
This diff is collapsed.
Click to expand it.
src/plugins/mucservice/src/java/org/jivesoftware/openfire/entity/MUCRoomEntity.java
View file @
d7eade45
...
...
@@ -6,8 +6,14 @@ import java.util.List;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlType
;
@XmlRootElement
(
name
=
"chatRoom"
)
@XmlType
(
propOrder
=
{
"roomName"
,
"naturalName"
,
"description"
,
"password"
,
"subject"
,
"creationDate"
,
"modificationDate"
,
"maxUsers"
,
"persistent"
,
"publicRoom"
,
"registrationEnabled"
,
"canAnyoneDiscoverJID"
,
"canOccupantsChangeSubject"
,
"canOccupantsInvite"
,
"canChangeNickname"
,
"logEnabled"
,
"loginRestrictedToNickname"
,
"membersOnly"
,
"moderated"
,
"broadcastPresenceRoles"
,
"owners"
,
"admins"
,
"members"
,
"outcasts"
})
public
class
MUCRoomEntity
{
private
String
roomName
;
...
...
src/plugins/mucservice/src/java/org/jivesoftware/openfire/plugin/MUCRoomController.java
View file @
d7eade45
...
...
@@ -18,6 +18,8 @@ import org.jivesoftware.openfire.muc.MUCRole;
import
org.jivesoftware.openfire.muc.MUCRoom
;
import
org.jivesoftware.openfire.muc.NotAllowedException
;
import
org.jivesoftware.openfire.utils.MUCRoomUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.JID
;
/**
...
...
@@ -25,6 +27,8 @@ import org.xmpp.packet.JID;
*/
public
class
MUCRoomController
{
/** The Constant LOG. */
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MUCRoomController
.
class
);
/** The Constant INSTANCE. */
public
static
final
MUCRoomController
INSTANCE
=
new
MUCRoomController
();
...
...
@@ -106,7 +110,7 @@ public class MUCRoomController {
*/
public
void
deleteChatRoom
(
String
roomName
,
String
serviceName
)
throws
MUCServiceException
{
MUCRoom
chatRoom
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
().
getMultiUserChatService
(
serviceName
)
.
getChatRoom
(
roomName
);
.
getChatRoom
(
roomName
.
toLowerCase
()
);
if
(
chatRoom
!=
null
)
{
chatRoom
.
destroyRoom
(
null
,
null
);
...
...
@@ -221,8 +225,12 @@ public class MUCRoomController {
room
.
setMembersOnly
(
mucRoomEntity
.
isMembersOnly
());
room
.
setModerated
(
mucRoomEntity
.
isModerated
());
// Set broadcast presence roles
if
(
mucRoomEntity
.
getBroadcastPresenceRoles
()
!=
null
)
{
room
.
setRolesToBroadcastPresence
(
mucRoomEntity
.
getBroadcastPresenceRoles
());
}
else
{
room
.
setRolesToBroadcastPresence
(
new
ArrayList
<
String
>());
}
// Set all roles
setRoles
(
room
,
mucRoomEntity
);
...
...
@@ -373,4 +381,134 @@ public class MUCRoomController {
}
}
}
/**
* Adds the admin.
*
* @param serviceName
* the service name
* @param roomName
* the room name
* @param jid
* the jid
* @throws MUCServiceException
* the MUC service exception
*/
public
void
addAdmin
(
String
serviceName
,
String
roomName
,
String
jid
)
throws
MUCServiceException
{
MUCRoom
room
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
().
getMultiUserChatService
(
serviceName
)
.
getChatRoom
(
roomName
.
toLowerCase
());
try
{
room
.
addAdmin
(
new
JID
(
jid
),
room
.
getRole
());
}
catch
(
ForbiddenException
e
)
{
LOG
.
error
(
"Could not add admin"
,
e
);
throw
new
MUCServiceException
(
"Could not add admin"
,
jid
,
"ForbiddenException"
);
}
catch
(
ConflictException
e
)
{
LOG
.
error
(
"Could not add admin"
,
e
);
throw
new
MUCServiceException
(
"Could not add admin"
,
jid
,
"ConflictException"
);
}
}
/**
* Adds the owner.
*
* @param serviceName
* the service name
* @param roomName
* the room name
* @param jid
* the jid
* @throws MUCServiceException
* the MUC service exception
*/
public
void
addOwner
(
String
serviceName
,
String
roomName
,
String
jid
)
throws
MUCServiceException
{
MUCRoom
room
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
().
getMultiUserChatService
(
serviceName
)
.
getChatRoom
(
roomName
.
toLowerCase
());
try
{
room
.
addOwner
(
new
JID
(
jid
),
room
.
getRole
());
}
catch
(
ForbiddenException
e
)
{
LOG
.
error
(
"Could not add owner"
,
e
);
throw
new
MUCServiceException
(
"Could not add owner"
,
jid
,
"ForbiddenException"
);
}
}
/**
* Adds the member.
*
* @param serviceName
* the service name
* @param roomName
* the room name
* @param jid
* the jid
* @throws MUCServiceException
* the MUC service exception
*/
public
void
addMember
(
String
serviceName
,
String
roomName
,
String
jid
)
throws
MUCServiceException
{
MUCRoom
room
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
().
getMultiUserChatService
(
serviceName
)
.
getChatRoom
(
roomName
.
toLowerCase
());
try
{
room
.
addMember
(
new
JID
(
jid
),
null
,
room
.
getRole
());
}
catch
(
ForbiddenException
e
)
{
LOG
.
error
(
"Could not add member"
,
e
);
throw
new
MUCServiceException
(
"Could not add member"
,
jid
,
"ForbiddenException"
);
}
catch
(
ConflictException
e
)
{
LOG
.
error
(
"Could not add member"
,
e
);
throw
new
MUCServiceException
(
"Could not add member"
,
jid
,
"ConflictException"
);
}
}
/**
* Adds the outcast.
*
* @param serviceName
* the service name
* @param roomName
* the room name
* @param jid
* the jid
* @throws MUCServiceException
* the MUC service exception
*/
public
void
addOutcast
(
String
serviceName
,
String
roomName
,
String
jid
)
throws
MUCServiceException
{
MUCRoom
room
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
().
getMultiUserChatService
(
serviceName
)
.
getChatRoom
(
roomName
.
toLowerCase
());
try
{
room
.
addOutcast
(
new
JID
(
jid
),
null
,
room
.
getRole
());
}
catch
(
NotAllowedException
e
)
{
LOG
.
error
(
"Could not add outcast"
,
e
);
throw
new
MUCServiceException
(
"Could not add outcast"
,
jid
,
"NotAllowedException"
);
}
catch
(
ForbiddenException
e
)
{
LOG
.
error
(
"Could not add outcast"
,
e
);
throw
new
MUCServiceException
(
"Could not add outcast"
,
jid
,
"ForbiddenException"
);
}
catch
(
ConflictException
e
)
{
LOG
.
error
(
"Could not add outcast"
,
e
);
throw
new
MUCServiceException
(
"Could not add outcast"
,
jid
,
"ConflictException"
);
}
}
/**
* Delete affiliation.
*
* @param serviceName
* the service name
* @param roomName
* the room name
* @param jid
* the jid
* @throws MUCServiceException
* the MUC service exception
*/
public
void
deleteAffiliation
(
String
serviceName
,
String
roomName
,
String
jid
)
throws
MUCServiceException
{
MUCRoom
room
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
().
getMultiUserChatService
(
serviceName
)
.
getChatRoom
(
roomName
.
toLowerCase
());
try
{
room
.
addNone
(
new
JID
(
jid
),
room
.
getRole
());
}
catch
(
ForbiddenException
e
)
{
LOG
.
error
(
"Could not delete affiliation"
,
e
);
throw
new
MUCServiceException
(
"Could not delete affiliation"
,
jid
,
"ForbiddenException"
);
}
catch
(
ConflictException
e
)
{
LOG
.
error
(
"Could not delete affiliation"
,
e
);
throw
new
MUCServiceException
(
"Could not delete affiliation"
,
jid
,
"ConflictException"
);
}
}
}
\ No newline at end of file
src/plugins/mucservice/src/java/org/jivesoftware/openfire/plugin/servlet/JerseyWrapper.java
View file @
d7eade45
...
...
@@ -7,6 +7,10 @@ import javax.servlet.ServletConfig;
import
javax.servlet.ServletException
;
import
org.jivesoftware.admin.AuthCheckFilter
;
import
org.jivesoftware.openfire.service.MUCRoomAdminsService
;
import
org.jivesoftware.openfire.service.MUCRoomMembersService
;
import
org.jivesoftware.openfire.service.MUCRoomOutcastsService
;
import
org.jivesoftware.openfire.service.MUCRoomOwnersService
;
import
org.jivesoftware.openfire.service.MUCRoomService
;
import
com.sun.jersey.api.core.PackagesResourceConfig
;
...
...
@@ -46,6 +50,11 @@ public class JerseyWrapper extends ServletContainer {
prc
.
getProperties
().
put
(
"com.sun.jersey.spi.container.ContainerRequestFilters"
,
"org.jivesoftware.openfire.plugin.servlet.AuthFilter"
);
prc
.
getClasses
().
add
(
MUCRoomService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomOwnersService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomAdminsService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomMembersService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomOutcastsService
.
class
);
prc
.
getClasses
().
add
(
RESTExceptionMapper
.
class
);
}
...
...
src/plugins/mucservice/src/java/org/jivesoftware/openfire/service/MUCRoomAdminsService.java
0 → 100644
View file @
d7eade45
package
org
.
jivesoftware
.
openfire
.
service
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.DefaultValue
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
org.jivesoftware.openfire.exception.MUCServiceException
;
import
org.jivesoftware.openfire.plugin.MUCRoomController
;
@Path
(
"mucservice/chatrooms/{roomName}/admins"
)
public
class
MUCRoomAdminsService
{
@POST
@Path
(
"/{jid}"
)
public
Response
addMUCRoomAdmin
(
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"jid"
)
String
jid
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
addAdmin
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
CREATED
).
build
();
}
@DELETE
@Path
(
"/{jid}"
)
public
Response
deleteMUCRoomAdmin
(
@PathParam
(
"jid"
)
String
jid
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
deleteAffiliation
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
OK
).
build
();
}
}
src/plugins/mucservice/src/java/org/jivesoftware/openfire/service/MUCRoomMembersService.java
0 → 100644
View file @
d7eade45
package
org
.
jivesoftware
.
openfire
.
service
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.DefaultValue
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
org.jivesoftware.openfire.exception.MUCServiceException
;
import
org.jivesoftware.openfire.plugin.MUCRoomController
;
@Path
(
"mucservice/chatrooms/{roomName}/members"
)
public
class
MUCRoomMembersService
{
@POST
@Path
(
"/{jid}"
)
public
Response
addMUCRoomMember
(
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"jid"
)
String
jid
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
addMember
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
CREATED
).
build
();
}
@DELETE
@Path
(
"/{jid}"
)
public
Response
deleteMUCRoomMember
(
@PathParam
(
"jid"
)
String
jid
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
deleteAffiliation
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
OK
).
build
();
}
}
src/plugins/mucservice/src/java/org/jivesoftware/openfire/service/MUCRoomOutcastsService.java
0 → 100644
View file @
d7eade45
package
org
.
jivesoftware
.
openfire
.
service
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.DefaultValue
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
org.jivesoftware.openfire.exception.MUCServiceException
;
import
org.jivesoftware.openfire.plugin.MUCRoomController
;
@Path
(
"mucservice/chatrooms/{roomName}/outcasts"
)
public
class
MUCRoomOutcastsService
{
@POST
@Path
(
"/{jid}"
)
public
Response
addMUCRoomOutcast
(
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"jid"
)
String
jid
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
addOutcast
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
CREATED
).
build
();
}
@DELETE
@Path
(
"/{jid}"
)
public
Response
deleteMUCRoomOutcast
(
@PathParam
(
"jid"
)
String
jid
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
deleteAffiliation
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
OK
).
build
();
}
}
src/plugins/mucservice/src/java/org/jivesoftware/openfire/service/MUCRoomOwnersService.java
0 → 100644
View file @
d7eade45
package
org
.
jivesoftware
.
openfire
.
service
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.DefaultValue
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
org.jivesoftware.openfire.exception.MUCServiceException
;
import
org.jivesoftware.openfire.plugin.MUCRoomController
;
@Path
(
"mucservice/chatrooms/{roomName}/owners"
)
public
class
MUCRoomOwnersService
{
@POST
@Path
(
"/{jid}"
)
public
Response
addMUCRoomOwner
(
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"jid"
)
String
jid
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
addOwner
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
CREATED
).
build
();
}
@DELETE
@Path
(
"/{jid}"
)
public
Response
deleteMUCRoomOwner
(
@PathParam
(
"jid"
)
String
jid
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
@PathParam
(
"roomName"
)
String
roomName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
deleteAffiliation
(
serviceName
,
roomName
,
jid
);
return
Response
.
status
(
Status
.
OK
).
build
();
}
}
src/plugins/mucservice/src/java/org/jivesoftware/openfire/service/MUCRoomService.java
View file @
d7eade45
...
...
@@ -10,6 +10,8 @@ import javax.ws.rs.PathParam;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
org.jivesoftware.openfire.entity.MUCChannelType
;
import
org.jivesoftware.openfire.entity.MUCRoomEntities
;
...
...
@@ -39,30 +41,33 @@ public class MUCRoomService {
@DELETE
@Path
(
"/{roomName}"
)
public
void
deleteMUCRoom
(
@PathParam
(
"roomName"
)
String
roomName
,
public
Response
deleteMUCRoom
(
@PathParam
(
"roomName"
)
String
roomName
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
deleteChatRoom
(
roomName
,
serviceName
);
return
Response
.
status
(
Status
.
OK
).
build
();
}
@POST
public
void
createMUCRoom
(
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
public
Response
createMUCRoom
(
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
MUCRoomEntity
mucRoomEntity
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
createChatRoom
(
serviceName
,
mucRoomEntity
);
return
Response
.
status
(
Status
.
CREATED
).
build
();
}
@PUT
@Path
(
"/{roomName}"
)
public
void
udpateMUCRoom
(
@PathParam
(
"roomName"
)
String
roomName
,
public
Response
udpateMUCRoom
(
@PathParam
(
"roomName"
)
String
roomName
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
,
MUCRoomEntity
mucRoomEntity
)
throws
MUCServiceException
{
MUCRoomController
.
getInstance
().
updateChatRoom
(
roomName
,
serviceName
,
mucRoomEntity
);
return
Response
.
status
(
Status
.
OK
).
build
();
}
@GET
@Path
(
"/{roomName}/participants"
)
@Produces
(
MediaType
.
APPLICATION_XML
)
public
ParticipantEntities
getMUCRoomParticipants
(
@PathParam
(
"roomName"
)
String
roomName
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
)
throws
MUCServiceException
{
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
)
{
return
MUCRoomController
.
getInstance
().
getRoomParticipants
(
roomName
,
serviceName
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment