from parallels.core.hosting_repository.tomcat import TomcatModel
from parallels.core.logging import get_logger
from parallels.plesk.hosting_repository.tomcat import PleskTomcatModel
from parallels.plesk_multi_server.hosting_repository.base import PleskMultiServerBaseModel

logger = get_logger(__name__)


class PleskMultiServerTomcatModel(TomcatModel, PleskMultiServerBaseModel):
    def install_application(self, subscription_name, domain_name, application_war_file):
        """Install Java (Tomcat) application from specified WAR file

        :type subscription_name: str | unicode
        :type domain_name: str | unicode
        :type application_war_file: str | unicode
        :rtype: None
        """
        server = self.get_subscription_service_server(subscription_name)
        return PleskTomcatModel(server).install_application(
            subscription_name, domain_name, application_war_file
        )

    def list_applications(self, subscription_name, domain_name):
        """List Java (Tomcat) applications installed on specified domain

        :type subscription_name: str | unicode
        :type domain_name: str | unicode
        :rtype: list[parallels.core.hosting_repository.tomcat.TomcatApplicationEntity]
        """
        server = self.get_subscription_service_server(subscription_name)
        return PleskTomcatModel(server).list_applications(
            subscription_name, domain_name
        )
