/**
 * Copyright (c) 2008 Red Hat, Inc.
 *
 * This software is licensed to you under the GNU General Public License,
 * version 2 (GPLv2). There is NO WARRANTY for this software, express or
 * implied, including the implied warranties of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
 * along with this software; if not, see
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 * 
 * Red Hat trademarks are not licensed under GPLv2. No permission is
 * granted to use or replicate Red Hat trademarks that are incorporated
 * in this software or its documentation. 
 */
package com.redhat.rhn.frontend.xmlrpc.system.profile;

import java.util.Collections;
import java.util.SortedSet;

import com.redhat.rhn.domain.kickstart.KickstartCommand;
import com.redhat.rhn.domain.kickstart.KickstartData;
import com.redhat.rhn.domain.kickstart.KickstartFactory;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.serializer.KickstartCustomOptionSerializer;
import com.redhat.rhn.frontend.xmlrpc.system.XmlRpcSystemHelper;

/**
 * ServerConfigChannelHandler
 * @version $Rev$
 * @xmlrpc.namespace system.config
 * @xmlrpc.doc Provides methods to access and modify many aspects of 
 * configuration channels and server association.
 * basically system.config name space
 */
public class ServerProfileHandler extends BaseHandler {
    /**
     * List files in a given server
     * @param sessionKey the session key
     * @param sid the server id
     * @param listLocal true if a list of paths in local override is desired
     *                  false if  list of paths in sandbox channel is desired
     * @return a list of dto's holding this info.
     *
     * @xmlrpc.doc Return the list of files in a given channel.
     * @xmlrpc.param #session_key() 
     * @xmlrpc.param #param("int","serverId")
     * @xmlrpc.param #param("int","listLocal")
     *      #options()
     *          #item_desc ("1", "to return configuration files 
     *              in the system's local override configuration channel")
     *          #item_desc ("0", "to return configuration files 
     *              in the system's sandbox configuration channel")
     *      #options_end()
     *  
     * @xmlrpc.returntype
     * #array()
     * $ConfigFileDtoSerializer
     * #array_end()
     */

    public Object[] getCustomOptions(String sessionKey, String ksLabel) {
        User user = getLoggedInUser(sessionKey);
        KickstartData k = KickstartFactory.lookupKickstartDataByLabelAndOrgId(
                ksLabel, user.getOrg().getId());
        SortedSet options = k.getCustomOptions();
System.out.println("Custom, in API call");

         return options.toArray();
    }

}
