<%@ page import="com.atlassian.jira.util.BuildUtils,
                 com.atlassian.jira.util.EasyList,
                 com.atlassian.jira.web.action.util.JiraLicenseUtils,
                 com.atlassian.license.License,
                 com.atlassian.license.LicenseManager,
                 com.atlassian.license.LicenseType"%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>


<html>
<head>
<%--	<title>Setup Enterprise License </title>--%>
</head>

<body>

<webwork:if test="licenseUpdated == true">
    <page:applyDecorator name="jirapanel">
	    <page:param name="width">100%</page:param>
	    <page:param name="title">Update License</page:param>
        <page:param name="description">
            <b>Your license has been successfully updated. Please restart your server so that all necessary changes can take affect.
            <p>
            Changes will not take place until server is restarted. Please click <a href="<%= request.getContextPath() %>/secure/Dashboard.jspa">here</a> when your server has been restarted.</b>
        </page:param>
    </page:applyDecorator>
</webwork:if>
<webwork:else>
    <page:applyDecorator name="jiraform">
        <page:param name="action">SetupLicense.jspa</page:param>
        <page:param name="submitName"><webwork:text name="'common.forms.update'"/></page:param>
        <page:param name="width">100%</page:param>
        <page:param name="title">Update License</page:param>
        <page:param name="description">
        <%
            License license = LicenseManager.getInstance().getLicense(JiraLicenseUtils.JIRA_LICENSE_KEY);
            String licenseEdition = "standard";
            if (license !=null)
            {
                if (license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL)))
                {
                   licenseEdition = "Enterprise";
                }
                else if (license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL)))
                {
                   licenseEdition = "Professional";
                }
            }
            String jiraEdition = BuildUtils.getEdition();
        %>
            Update your license to a valid <%= jiraEdition %> license. You cannot run JIRA <%= jiraEdition %> with a JIRA <%= licenseEdition %> license.
            <p>
            You must provide a valid Administrator username and password and a valid JIRA <%= jiraEdition %> License
        </page:param>

        <ui:component label="'Admin User Name'" name="'userName'" template="userselect.jsp">
            <ui:param name="'formname'" value="'jiraform'" />
            <ui:param name="'imageName'" value="'userImage'"/>
            <ui:param name="'size'" value="40"/>
        </ui:component>
<%--        <ui:textfield label="'Admin User Name'" name="'userName'">--%>
<%--            <ui:param name="'size'">40</ui:param>--%>
<%--        </ui:textfield>--%>

        <ui:component label="'Password'" name="'password'" template="password.jsp">
            <ui:param name="'size'">40</ui:param>
        </ui:component>

        <page:param name="licenseString">Copy and paste the license key that you received via email below.</page:param>

        <ui:textarea label="'License'" name="'license'" cols="50" rows="10" />

    </page:applyDecorator>
</webwork:else>
</p>

</body>
</html>