<%--
 The contents of this file are subject to the terms 
 of the Common Development and Distribution License 
 (the License).  You may not use this file except in
 compliance with the License.
 
 You can obtain a copy of the license at 
 https://glassfish.dev.java.net/public/CDDLv1.0.html or
 glassfish/bootstrap/legal/CDDLv1.0.txt.
 See the License for the specific language governing 
 permissions and limitations under the License.
 
 When distributing Covered Code, include this CDDL 
 Header Notice in each file and include the License file 
 at glassfish/bootstrap/legal/CDDLv1.0.txt.  
 If applicable, add the following below the CDDL Header, 
 with the fields enclosed by brackets [] replaced by
 you own identifying information: 
 "Portions Copyrighted [year] [name of copyright owner]"
 
 Copyright 2006 Sun Microsystems, Inc. All rights reserved.
--%>

<%@ page info="redeploy" language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import = "com.sun.enterprise.tools.admingui.ConfigProperties" %>
<%@taglib uri="/jato.tld" prefix="jato"%>
<%@taglib uri="/cc.tld" prefix="cc"%>

<jato:useViewBean type="com.iplanet.jato.view.ViewBean" className="redeploy">
<script language="JavaScript" src="../js/iasadmin.js"></script>
<SCRIPT language = "Javascript" >
	function okButtonClicked(button) {
            
		var theForm = document.forms[0];
		<% String name = request.getParameter("appName"); %>
		<% String contextRoot = request.getParameter("contextRoot"); %>
		var type = getType();
		if(uploadFileChecked() == 'server') {
		    directoryDeploy(theForm, button);
		}
		else if(checkFileType(theForm))
            	{
                    var cancelPage = getValueOf("cancelPage");
                    var appFileField = getFileField("AppFile");
                    if(cancelPage == null || cancelPage=='' || isWhitespace(cancelPage) ) {
                        document.forms[0].action = '../admingui/UploadServlet?&AppFile='+appFileField.value+'&name=<%= name %>'+'&appType='+type+'&uploadType=redeploy&contextRoot=<%= contextRoot %>';
                    } else {
                        document.forms[0].action = '../admingui/UploadServlet?&uploadType=redeploy&cancelPage='+cancelPage;
                    }
                    disable(button);		    
		    document.forms[0].submit();
		}
		return false;
	}
	function directoryDeploy(theForm, button) {
	    var type = getType();
		theForm.encoding="application/x-www-form-urlencoded";
		var filePath = getFileField("DirectoryDeployField").value;
		filePath = escape(filePath);
		if(filePath == null || filePath == '' || isWhitespace(filePath)) {
		    //alert("Specify a valid directory, or a packaged file name");
                    alert(getMessage("upload.DirOrFile"));
		    getFileField("DirectoryDeployField").focus();
		    return false;
		}
		var cancelPage = getValueOf("cancelPage");
		var location = getFileField("DirectoryDeployField");
                if(cancelPage == null || cancelPage=='' || isWhitespace(cancelPage) ) {
                    document.forms[0].action = '../admingui/UploadServlet?&AppFile='+location.value+'&name=<%= name %>'+'&appType='+type+'&uploadType=redeploy&contextRoot=<%= contextRoot %>';
                } else {
                    document.forms[0].action = '../admingui/UploadServlet?cancelPage='+cancelPage;
                }
            disable(button);
	    theForm.submit();
	}
	
    function cancelButtonClicked() {
                var theForm = document.forms[0];
                
                var fromHome = getValueOf("cancelPage");
                if (fromHome!=null && fromHome !=""){
                    var head = "../admingui/";
                    //theForm.action = head.concat(fromHome);
                    theForm.action = '../admingui/'+fromHome;
                    theForm.submit();
                    return false;
                }
                <%Boolean isTargetSupported = ConfigProperties.getInstance().getTargetSupported();%>
                isEE = <%=isTargetSupported.booleanValue()%>;
		var type = getType();
		if(type == "ear") {
                    if(isEE)
                        theForm.action = '../admingui/eeEnterpriseApplications';
                    else
                         theForm.action = '../admingui/enterpriseApplications';
		}
		else if(type == "jar") {
		    if(isEE)
                        theForm.action = '../admingui/eeEjbModules';
                    else
                         theForm.action = '../admingui/ejbModules';
		}
		else if(type == "rar") {
		    if(isEE)
                        theForm.action = '../admingui/eeConnectorModules';
                    else
                         theForm.action = '../admingui/connectorModules';
		}
		else if(type == "all") {
                    if(isEE)
                        theForm.action = '../admingui/eeAppclientModules';
                    else
                         theForm.action = '../admingui/appclientModules';
		}
		else {
		    if(isEE)
                        theForm.action = '../admingui/eeWebApplications';
                    else
                         theForm.action = '../admingui/webApplications';
		}
		theForm.submit();
		return false;
	}
	   
</SCRIPT>

<cc:header pageTitle="redeploy.PageTitle" copyrightYear="2003" name="HtmlHeader"
 baseName="com.sun.enterprise.tools.admingui.resources.Resources" bundleID="testBundle">

<!-- Bread Crumb component -->
<cc:breadcrumbs name="BreadCrumb" bundleID="testBundle" useGrayBg="true" />
<cc:alertinline name="Alert" bundleID="testBundle" />
<!-- Form -->
<form name="redeploy"  method="POST" ENCTYPE="multipart/form-data" onSubmit="return submitForm()" >
<jato:content name="resourceStrings">
msg.wait
upload.needEAR
upload.needWAR
upload.needRAR
upload.wrongType
upload.enterFilename
upload.DirOrFile
</jato:content>

<!-- Page Title --> 
<cc:pagetitle name="PageTitle" bundleID="testBundle"
 pageTitleText="redeploy.PageTitle" 
 showPageTitleSeparator="true"
 showPageButtonsTop="true"
 showPageButtonsBottom="false"
 pageTitleHelpMessage="uploadPageHelp" >

<!-- PropertySheet -->
<cc:propertysheet name="redeploy" bundleID="testBundle" addJavaScript="true"/>

<jato:hidden name="HiddenApplicationType"/>
<jato:hidden name="cancelPage"/>
<jato:content name="extra">
</jato:content>
</cc:pagetitle>
<form>
</cc:header>
</jato:useViewBean>
