Search in sources :

Example 1 with ChatSettings

use of org.jivesoftware.openfire.fastpath.settings.chat.ChatSettings 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);
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) ChatSettings(org.jivesoftware.openfire.fastpath.settings.chat.ChatSettings) JID(org.xmpp.packet.JID) ChatSetting(org.jivesoftware.openfire.fastpath.settings.chat.ChatSetting) Workgroup(org.jivesoftware.xmpp.workgroup.Workgroup) WorkgroupManager(org.jivesoftware.xmpp.workgroup.WorkgroupManager)

Aggregations

ChatSetting (org.jivesoftware.openfire.fastpath.settings.chat.ChatSetting)1 ChatSettings (org.jivesoftware.openfire.fastpath.settings.chat.ChatSettings)1 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)1 Workgroup (org.jivesoftware.xmpp.workgroup.Workgroup)1 WorkgroupManager (org.jivesoftware.xmpp.workgroup.WorkgroupManager)1 JID (org.xmpp.packet.JID)1