use of org.jivesoftware.openfire.fastpath.commands.DeleteWorkgroup in project Openfire by igniterealtime.
the class WorkgroupManager method createWorkgroup.
/**
* Creates a workgroup with default settings.
*
* @param name the name of the workgroup.
* @return the created workgroup
* @throws UnauthorizedException if not allowed to create the workgroup.
* @throws UserAlreadyExistsException If the address is already in use
*/
public Workgroup createWorkgroup(String name) throws UserAlreadyExistsException, UnauthorizedException {
if (workgroups.containsKey(name + "@" + serviceAddress.toBareJID())) {
throw new UserAlreadyExistsException(name);
}
// Reserve the username - user ID from the jiveUserID table
long id = -1;
Workgroup workgroup = null;
try {
id = SequenceManager.nextID(FastpathConstants.WORKGROUP);
boolean workgroupAdded = addWorkgroup(id, name);
if (workgroupAdded) {
workgroupLock.writeLock().lock();
try {
workgroup = new Workgroup(id, agentManager);
workgroups.put(workgroup.getJID().toBareJID(), workgroup);
workgroupOpenStatus.put(workgroup.getID(), workgroup.getStatus());
} finally {
workgroupLock.writeLock().unlock();
}
// Create a chat room for this workgroup
workgroup.createGroupChatRoom();
// Trigger the event that a workgroup has been created
WorkgroupEventDispatcher.workgroupCreated(workgroup);
} else {
throw new UnauthorizedException("Could not insert workgroup in database");
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
if (id != -1) {
try {
if (workgroup != null) {
workgroups.remove(workgroup.getJID().toBareJID());
workgroupOpenStatus.remove(workgroup.getID());
deleteWorkgroup(id);
}
} catch (Exception e1) {
Log.error(e1.getMessage(), e1);
}
}
if (e instanceof UserAlreadyExistsException) {
throw (UserAlreadyExistsException) e;
} else {
throw new UnauthorizedException();
}
}
return workgroup;
}
use of org.jivesoftware.openfire.fastpath.commands.DeleteWorkgroup in project Openfire by igniterealtime.
the class WorkgroupManager method start.
public void start() {
// anonymous login doesn't have to be enabled for the whole server.
if (!JiveSharedSecretSaslServer.isSharedSecretAllowed()) {
JiveSharedSecretSaslServer.setSharedSecretAllowed(true);
}
// disco stuff
if (!JiveGlobals.getBooleanProperty("fastpath.database.setup")) {
boolean createUser = createDemoUser();
if (createUser) {
createDemoWorkgroup();
}
JiveGlobals.setProperty("fastpath.database.setup", "true");
}
// Register ad-hoc commands
commandManager.addCommand(new CreateWorkgroup());
commandManager.addCommand(new DeleteWorkgroup());
}
Aggregations