/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hu.nir.nmail.services;

import hu.nir.nmail.ejb.entity.MailFolder;
import hu.nir.nmail.ejb.entity.NmailUser;
import hu.nir.nmail.ejb.entity.UserRestriction;
import hu.nir.nmail.utils.NmailUtility;
import java.util.Map;

/**
 *
 * @author attila
 * 
 * POP3 kapcsolódási adatok lekérdezése, a felhasználó programhasználattal
 * szembeni korlátozásainak lekérdezése.
 */
public class GetSettingsService implements NmailService {

    public Map<String, Object> processCommand(Object... commands) {
        NmailUser nmailUser = null;
        
        for (Object command : commands) {
            if (command instanceof NmailUser) {
                nmailUser = (NmailUser) command;
            }
        }
        
        if (nmailUser == null) {
            return null;
        }
        
        MailFolder mailFolder = nmailUser.getMailFolder();
        UserRestriction userRestrictions = nmailUser.getUserRestriction();
        
        return NmailUtility.toMap("pop3settings", mailFolder, "restrictions", userRestrictions);
    }
}
