/*
 * Created on 27-Oct-2009
 *
 * TODO 
 */
package uk.ac.roe.wfau;

import javax.servlet.http.HttpSession;

/**
 * @author mar
 *
 */
public class VDFSSession {

    public static String getProgID(HttpSession sess) {
        if (sess.getAttribute("programmeID") != null) {
        return ((String) sess.getAttribute("programmeID")).trim();
        }
        else {
            return "-999";
        }
    }
    public static String getCommunity(HttpSession sess) {
        if (sess.getAttribute("community") != null) {
            String community = ((String) sess.getAttribute("community")).toLowerCase().trim();
            if (community != null) {
                return community;
            } else {
                return "world";
            }
        } else {
            return "world";
        }
    }
 
    public static boolean getLoginBoolean(HttpSession sess,String archive) {
        if (archive.equalsIgnoreCase(VDFSSchema.VSAARCHIVE)) {
            return VSASession.getLoginBoolean(sess);
        }
        else {
            return WSASession.getLoginBoolean(sess);
        }
    }      
    
    public static String getDBUser(HttpSession sess, String archive){
        if (archive.equalsIgnoreCase(VDFSSchema.VSAARCHIVE)) {
            return VSASession.getDBUser(sess);
        }
        else {
            return WSASession.getDBUser(sess);
        }
    }

    public static String [] getServers(String community, String archive, String [] WSASERVERS,String [] WSACUSERVERS,String [] VSASERVERS,String [] VSACUSERVERS) {
        if (archive != null && archive.equalsIgnoreCase("vsa")) {
            if (!community.equalsIgnoreCase(VSASchema.PRERELEASECOMMUNITY)) {
                return VSASERVERS;
            }
            else {
                return VSACUSERVERS;
            }
        }
        else {
            if (!community.equalsIgnoreCase(WSASchema.PRERELEASECOMMUNITY)) {
                return WSASERVERS;
            }
            else {
                return WSACUSERVERS;
            }
        }
    }
    public static String [] getServers(HttpSession sess, String archive, String [] WSASERVERS,String [] WSACUSERVERS,String [] VSASERVERS,String [] VSACUSERVERS) {
      return getServers(WSASession.getCommunity(sess),archive,WSASERVERS,WSACUSERVERS,VSASERVERS,VSACUSERVERS);
    }
    
}
