/**
 * Copyright (c) 2012 EBM WebSourcing, 2012-2013 Linagora
 * 
 * This program/library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * This program/library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program/library; If not, see <http://www.gnu.org/licenses/>
 * for the GNU Lesser General Public License version 2.1.
 */
package org.ow2.petals.admin.api;

import java.util.List;
import java.util.Properties;

import org.ow2.petals.admin.api.artifact.Logger;
import org.ow2.petals.admin.api.exception.ContainerAdministrationException;
import org.ow2.petals.admin.api.exception.InvalidLogLevelException;
import org.ow2.petals.admin.api.exception.LoggerNotFoundException;
import org.ow2.petals.admin.api.exception.NoConnectionException;
import org.ow2.petals.admin.topology.Domain;

/**
 * 
 * @author Nicolas Oddoux - EBM WebSourcing
 */
public interface ContainerAdministration {

    public void connect(String host, int port, String user, String password)
            throws ContainerAdministrationException;

    /**
     * @return <code>true</code> if connected to a Petals ESB container,
     *         <code>false</code> otherwise.
     * @throws ContainerAdministrationException
     *             An error occurs checking the connection.
     */
    public boolean isConnected() throws ContainerAdministrationException;

    /**
     * @throws NoConnectionException
     *             There is no current JMX connection to the remote petals ESB.
     * @throws ContainerAdministrationException
     *             An error occurs releasing the connection.
     */
    public void disconnect() throws NoConnectionException, ContainerAdministrationException;

    public String getSystemInfo() throws ContainerAdministrationException;

    public void stopContainer() throws ContainerAdministrationException;

    public void shutdownContainer() throws ContainerAdministrationException;

    public Domain getTopology(final String securityPassPhrase)
            throws ContainerAdministrationException;

    public Properties getServerProperties() throws ContainerAdministrationException;

    /**
     * Change the level of a logger.
     * 
     * @param loggerName
     *            The logger for which the level will be updated.
     * @param loggerLevel
     *            The level to set to the logger
     * @throws InvalidLogLevelException
     *             The level is invalid (does not exist).
     * @throws LoggerNotFoundException
     *             The logger does not exist.
     * @throws ContainerAdministrationException
     *             An error occurs updating the logger level.
     */
    public void changeLoggerLevel(String loggerName, String loggerLevel)
            throws InvalidLogLevelException, LoggerNotFoundException,
            ContainerAdministrationException;

    /**
     * Get loggers available on the container.
     * 
     * @return The list of loggers available on the container.
     * @throws ContainerAdministrationException
     *             An error occurs getting loggers.
     */
    public List<Logger> getLoggers() throws ContainerAdministrationException;
}
