package haipham.webnntp.ejb.session;

import java.rmi.RemoteException;
import javax.ejb.*;
import java.util.Collection;
import haipham.webnntp.ejb.user.*;
import haipham.webnntp.ejb.folder.Folder;
import haipham.webnntp.ejb.message.Message;

public interface UserSession extends EJBObject{
    /** Invoked when the user is done with the session */
    public void logout() throws RemoteException;

    /** Return the user name */
    public String getUserName() throws RemoteException;

    /** Return all top level folder (ie: folders having parent = null */
    public Collection getTopLevelFolders() throws RemoteException;

    public Collection getMessages(Folder folder) 
        throws RemoteException;

    public Collection getSubFolders(Folder folder) throws RemoteException;

    public Collection getSubFolders(long id) throws RemoteException;

    public Folder getFolder(long id) throws RemoteException;

    public Folder createFolder(String name, String type) throws RemoteException;

    public Folder createFolder(Folder parent, String name, String type) 
        throws RemoteException;
    
    public void removeFolder(long folderId) throws RemoteException;

    public Message getMessage(String msgId) throws RemoteException;

    public Message addMessage(Folder folder, String id, 
            String subject, String from,
            String body) throws RemoteException;

    /** Add a message without the messageId. An unique id will be generated
     *  automatically
     */ 
    public Message addMessage(Folder folder, String subject, String from,
            String body) throws RemoteException;

    public void removeMessage(String messageId) throws RemoteException;

    public Setting getSettings() throws RemoteException;
}
