use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class ChatHistoryUtils method getTotalChatTimeForWorkgroup.
/**
* Returns the total chat length of an individual workgroup.
*
* @param workgroupName the name of the workgroup.
* @return the total length of all chats in the specified workgroup.
*/
public static long getTotalChatTimeForWorkgroup(String workgroupName) {
Workgroup workgroup = null;
try {
workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName));
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
}
int totalWorkgroupChatTime = 0;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(CHAT_TIMES_FOR_WORKGROUPS);
pstmt.setLong(1, workgroup.getID());
rs = pstmt.executeQuery();
while (rs.next()) {
String startTimeString = rs.getString(1);
String endTimeString = rs.getString(2);
if ((startTimeString != null) && (startTimeString.trim().length() > 0) && (endTimeString != null) && (endTimeString.trim().length() > 0)) {
long startLong = Long.parseLong(startTimeString);
long endLong = Long.parseLong(endTimeString);
totalWorkgroupChatTime += endLong - startLong;
}
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
} finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return totalWorkgroupChatTime;
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class ChatHistoryUtils method getNumberOfChatsForWorkgroup.
/**
* Returns the total number of chats that have occured within a workgroup.
*
* @param workgroupName the jid of the workgroup.
* @return the total number of chats that have occured within a workgroup.
*/
public static int getNumberOfChatsForWorkgroup(String workgroupName) {
Workgroup workgroup = null;
try {
workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName));
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
}
int count = 0;
for (RequestQueue requestQueue : workgroup.getRequestQueues()) {
count += requestQueue.getTotalChatCount();
}
return count;
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class ImageServlet method getImage.
/**
* Returns the image bytes of the encoded image.
*
* @param imageName the name of the image.
* @param workgroupName the name of the workgroup.
* @return the image bytes found, otherwise null.
*/
public byte[] getImage(String imageName, String workgroupName) {
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
JID workgroupJID = new JID(workgroupName);
Workgroup workgroup;
try {
workgroup = workgroupManager.getWorkgroup(workgroupJID);
} catch (UserNotFoundException e) {
Log.error(e.getMessage(), e);
return null;
}
ChatSettings chatSettings = chatSettingsManager.getChatSettings(workgroup);
ChatSetting setting = chatSettings.getChatSetting(imageName);
String encodedValue = setting.getValue();
if (encodedValue == null) {
return null;
}
return StringUtils.decodeBase64(encodedValue);
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class DeleteWorkgroup method execute.
@Override
public void execute(SessionData data, Element command) {
Element note = command.addElement("note");
// Get requested group
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
// Load the workgroup
try {
Workgroup workgroup = workgroupManager.getWorkgroup(new JID(data.getData().get("workgroup").get(0)));
workgroupManager.deleteWorkgroup(workgroup);
} catch (UserNotFoundException e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Workgroup not found");
return;
} catch (Exception e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Error executing the command");
return;
}
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class WorkgroupUtils method updateWorkgroup.
public static String updateWorkgroup(String workgroupName, String displayName, String description, int maxSize, int minSize, long requestTimeout, long offerTimeout) {
final WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
Workgroup workgroup;
try {
workgroup = workgroupManager.getWorkgroup(new JID(workgroupName));
} catch (UserNotFoundException e) {
return getUpdateMessage(false, "The JID specified is invalid.");
}
workgroup.setDisplayName(displayName);
workgroup.setDescription(description);
if (maxSize < minSize) {
return getUpdateMessage(false, "Max size must be greater or equal to min size.");
}
workgroup.setMaxChats(maxSize);
workgroup.setMinChats(minSize);
workgroup.setRequestTimeout(requestTimeout);
workgroup.setOfferTimeout(offerTimeout);
return getUpdateMessage(true, "Workgroup has been updated");
}
Aggregations