Search in sources :

Example 21 with UserNotFoundException

use of org.jivesoftware.openfire.user.UserNotFoundException 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)

Example 22 with UserNotFoundException

use of org.jivesoftware.openfire.user.UserNotFoundException 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");
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) JID(org.xmpp.packet.JID) Element(org.dom4j.Element) Workgroup(org.jivesoftware.xmpp.workgroup.Workgroup) WorkgroupManager(org.jivesoftware.xmpp.workgroup.WorkgroupManager) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException)

Example 23 with UserNotFoundException

use of org.jivesoftware.openfire.user.UserNotFoundException in project Openfire by igniterealtime.

the class MSNBuddy method setMsnContact.

public void setMsnContact(MsnContact msnContact) {
    if (JiveGlobals.getBooleanProperty("plugin.gateway.msn.autonickname", false)) {
        if (!getNickname().equals(msnContact.getDisplayName())) {
            setNickname(msnContact.getDisplayName());
            try {
                final JID owner = getManager().getSession().getJID();
                getManager().getSession().getTransport().addOrUpdateRosterItem(owner, getJID(), getNickname(), getGroups());
            } catch (UserNotFoundException e) {
            // Can't update something that's not really in our list.
            }
        }
    }
    this.msnContact = msnContact;
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) JID(org.xmpp.packet.JID)

Example 24 with UserNotFoundException

use of org.jivesoftware.openfire.user.UserNotFoundException in project Openfire by igniterealtime.

the class MSNSession method completedPendingContactAdd.

/**
     * Completes the addition of groups to a new contact after the contact has been created.
     *
     * @param msnContact Contact that was added.
     */
public void completedPendingContactAdd(MsnContact msnContact) {
    try {
        Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
        Email contact = msnContact.getEmail();
        JID contactJID = getTransport().convertIDToJID(contact.toString());
        RosterItem item = roster.getRosterItem(contactJID);
        getBuddyManager().storeBuddy(new MSNBuddy(getBuddyManager(), msnContact));
        syncContactGroups(contact, item.getGroups());
    } catch (UserNotFoundException e) {
        Log.debug("MSN: Unable to find roster when adding pendingcontact for " + getJID());
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) RosterItem(org.jivesoftware.openfire.roster.RosterItem) Email(net.sf.jml.Email) Roster(org.jivesoftware.openfire.roster.Roster) JID(org.xmpp.packet.JID)

Example 25 with UserNotFoundException

use of org.jivesoftware.openfire.user.UserNotFoundException in project Openfire by igniterealtime.

the class MSNSession method completedPendingGroupAdd.

/**
     * Completes the addition of a contact to a new group after the group has been created.
     *
     * @param msnGroup Group that was added.
     */
public void completedPendingGroupAdd(MsnGroup msnGroup) {
    if (!msnPendingGroups.containsKey(msnGroup.getGroupName())) {
        // Nothing to do, no pending.
        return;
    }
    try {
        Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
        for (Email contact : msnPendingGroups.get(msnGroup.getGroupName())) {
            JID contactJID = getTransport().convertIDToJID(contact.toString());
            RosterItem item = roster.getRosterItem(contactJID);
            syncContactGroups(contact, item.getGroups());
        }
    } catch (UserNotFoundException e) {
        Log.debug("MSN: Unable to find roster when adding pending group contacts for " + getJID());
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) RosterItem(org.jivesoftware.openfire.roster.RosterItem) Email(net.sf.jml.Email) Roster(org.jivesoftware.openfire.roster.Roster) JID(org.xmpp.packet.JID)

Aggregations

UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)118 JID (org.xmpp.packet.JID)50 Element (org.dom4j.Element)28 Roster (org.jivesoftware.openfire.roster.Roster)27 RosterItem (org.jivesoftware.openfire.roster.RosterItem)26 User (org.jivesoftware.openfire.user.User)25 UserAlreadyExistsException (org.jivesoftware.openfire.user.UserAlreadyExistsException)23 IQ (org.xmpp.packet.IQ)15 ArrayList (java.util.ArrayList)14 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)12 SharedGroupException (org.jivesoftware.openfire.SharedGroupException)11 Group (org.jivesoftware.openfire.group.Group)10 UserManager (org.jivesoftware.openfire.user.UserManager)10 Workgroup (org.jivesoftware.xmpp.workgroup.Workgroup)10 Presence (org.xmpp.packet.Presence)10 NotFoundException (org.jivesoftware.util.NotFoundException)9 SQLException (java.sql.SQLException)8 List (java.util.List)8 IOException (java.io.IOException)7 Connection (java.sql.Connection)7