<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- ImportAgent.jsp --%>

<%@page info="ImportAgent" language="java"%>
<%@taglib uri="/WEB-INF/jato.tld" prefix="jato"%>
<%@taglib uri="/WEB-INF/console.tld" prefix="console"%>
<%@taglib uri="/WEB-INF/searchadmin.tld" prefix="searchadmin"%>

<jato:useViewBean className="com.sun.portal.search.admin.ImportAgentViewBean"> 
<jsp:useBean id="viewBean" type="com.sun.portal.search.admin.ImportAgentViewBean" />


<HTML>
<SCRIPT LANGUAGE=JavaScript>

<!-- Hide script

function validateServer(item) {
   var stringToSplit = item.value;
   var warnStr = '<searchadmin:text key="import.alert.example"/>';
   if (item.value == '') return true;
   arrayOfStrings = stringToSplit.split(':')
   if (arrayOfStrings.length != 2) {
        alert('<searchadmin:text key="import.alert.invalid"/>: ' + item.value + '\n' + warnStr);
        return false;
   }
   hostArray = arrayOfStrings[0].split('.')
   if (hostArray.length < 2) {
        alert('<searchadmin:text key="import.alert.invalid"/>: ' + item.value + '\n' + 
              '<searchadmin:text key="import.alert.host"/>\n' + warnStr);
        return false;
   }
   if (parseInt(arrayOfStrings[1]) < 0 ||
       parseInt(arrayOfStrings[1]) > 66000) {
        alert('<searchadmin:text key="import.alert.invalid"/>: ' + item.value + '\n' + 
              '<searchadmin:text key="import.alert.port"/>\n' + warnStr);
        return false;
   }
   return true;
}

function changeAgentType(type) {
    var a = document.forms['ImportAgent'].elements['ImportAgent.AgentType'];
    if (type =="file") {
	a[0].checked = true;
	a[1].checked = false;
    }
    else {
	a[0].checked = false;
	a[1].checked = true;
    }
    checkAgentType();
}

function checkAgentType() {
    var a = document.forms['ImportAgent'].elements['ImportAgent.AgentType'];
    if (a[0].checked == true) {
	document.forms['ImportAgent'].elements['ImportAgent.ServerPort'].value = "";
	document.forms['ImportAgent'].elements['ImportAgent.InstanceName'].value = "";
	document.forms['ImportAgent'].elements['ImportAgent.SearchURI'].value = "";
	document.forms['ImportAgent'].elements['ImportAgent.IsCompass'].checked = false;
	document.forms['ImportAgent'].elements['ImportAgent.IsSSL'].checked = false;
    }
    else if (a[1].checked == true) {
	document.forms['ImportAgent'].elements['ImportAgent.LocalFile'].value = "";
    }
}

function clearUserPassword() {
    var a = document.forms['ImportAgent'].elements['ImportAgent.UseAuth'];
    if (a[0].checked == true) {
	document.forms['ImportAgent'].elements['ImportAgent.User'].value = "";
	document.forms['ImportAgent'].elements['ImportAgent.Password'].value = "";
    }
}
function enableAuth() {
    var a = document.forms['ImportAgent'].elements['ImportAgent.UseAuth'];
    a[0].checked = false;
    a[1].checked = true;
}

    

function changeToSearchQuery() {
    var c = document.forms['ImportAgent'].elements['ImportAgent.UseGatherer'];
    c[0].checked=false;
    c[1].checked=true;
}

function changeToGatherer() {
    var c = document.forms['ImportAgent'].elements['ImportAgent.UseGatherer'];
    if (c[0].checked == true) {
	var s = document.forms['ImportAgent'].elements['ImportAgent.Scope'];
	var a = document.forms['ImportAgent'].elements['ImportAgent.ViewAttributes'];
	var h = document.forms['ImportAgent'].elements['ImportAgent.ViewHits'];
	s.value = "";
	a.value = "";
	h.value = "";
    }
}

var cleartimestampMessage = '<searchadmin:text key="import.msg.cleantimestamp"/>';



// End script hiding -->

</SCRIPT>

<%@include file="/ps/searchadmin/CSHeader.jsp"%>
<script language="javascript">
if (parent.headerFrame) {
    parent.headerFrame.helpDocURL = "<jato:text name="helpDocURL"/>";
    parent.headerFrame.helpPage = "<searchadmin:text key="help.database.import"/>";
}
</script>

<searchadmin:AdminMenu selected="ImportAgents" images="../ps/searchadmin/images"/>

<console:form name="ImportAgent" defaultCommandChild="/Submit">
<jato:hidden name="ID"/>

<TABLE border="0" cellpadding="0" cellspacing="10" width="100%">
    <TR>
	<TD align="center" colspan="2" height="2">
	 <console:messagebox name="ccMessageBox" imageURI="../console/images"/>
	 </TD>
    </TR>
    <TR>
	 
      <TD width="50%" height="2"> </TD>
      <TD align="right" width="50%" height="2"> 
        <TABLE border="0" cellpadding="0" cellspacing="0">
          <TR> 
            <TD> 
		   <console:button name="SubmitButton"  />
            </TD>
            <TD width="5"><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
	    <TD> 
		   <console:button name="CancelButton" href="ImportAgents"/>
            </TD>
            <TD width="5"><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>

            <TD> 
		   <console:button name="ResetButton" />
            </TD>
            <TD><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
            <TD>  </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR>
	<TD colspan="2" height="2">
	<DIV class="help-text"><searchadmin:text key="import.desc"/></DIV>
	</TD>
    </TR>
    
    <!-- Resource Description Source Section -->
    <TR> 
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="import.rdsrc.sect" label="rdsrc"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR> 
	<TD colspan=2>
	<TABLE BORDER=0 >
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.type.label" label="agenttype"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
	    <jato:radioButtons name="AgentType" elementId="agenttype" onClick="this.form.elements['jato.defaultCommand'].value='/ChangeButton';this.form.submit();"/>
	    </TD>
	</TR>
	<jato:content name="SrcFileSection">
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.localfile.label" label="localfile"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
	    <jato:textField name="LocalFile" elementId="localfile" size="30"/>
	    </TD>
	</TR>
	</jato:content> <!--name="SrcFileSection"-->
	<jato:content name="SrcServerSection">
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.server.label" label="server"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
	    <jato:textField name="ServerPort" elementId="server" onChange="if (validateServer(this) && this.value != '') { } else { this.focus(); this.select(); }" size="30"/>
	    </TD>
	</TR>
	<TR>
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.instance" label="instance"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="InstanceName" elementId="instance" />
	</TD>
	</TR>
	<jato:content name="NotCompassSection">
	<TR>
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.uri" label="uri"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="SearchURI" elementId="uri" />
	</TD>
	</TR>
	<TR>
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.dbname" label="db"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="SearchDB" elementId="db" />
	</TD>
	</TR>
	</jato:content> <!-- name="NotCompassSection"-->
	<TR>
	<TD><DIV class="properties-level3-label-text">&nbsp;</DIV></TD>
	<TD>
	    <jato:checkBox name="IsCompass" elementId="import.iscompass" onClick="this.form.elements['jato.defaultCommand'].value='/ChangeButton';this.form.submit();"/><LABEL for="import.iscompass"><searchadmin:text key="import.iscompass"/></LABEL></TD>
	</TR>
	<TD><DIV class="properties-level3-label-text">&nbsp;</DIV></TD>
	<TD>
	    <jato:checkBox name="IsSSL" elementId="import.ssl"/><LABEL for="import.ssl"><searchadmin:text key="import.ssl"/></LABEL></TD>
	</TR>
	
	</jato:content> <!--name="SrcServerSection"-->

	</TABLE>
	</TD>
    </TR>
	<!-- END OF Resource Description Source Section -->
	
    <!-- Destination Section -->
    <TR> 
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="import.dest.sect" label="dest"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR> 
	<TD colspan=2>
	<TABLE BORDER=0 >
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.dbname" label="localdb"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
	    <jato:combobox name="LocalDB" elementId="localdb"/>
	    </TD>
	</TR>
	</TABLE>
	</TD>
    </TR>
	<!-- END OF Destination Section -->

    <jato:content name="SrcServerSection">

    <!-- Authentication Section -->
    <TR> 
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="import.auth.sect" label="auth"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR> 
	<TD colspan=2>
	    <DIV class="properties-level3-label-text"><jato:radioButtons name="UseAuth" elementId="auth" layout="vertical" onClick="clearUserPassword();"/></DIV>
	</TD>
    </TD>
    <TR>
	<TD colspan=2>
	<TABLE BORDER=0 >
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.user" label="user"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
	    <jato:textField name="User" elementId="user" onChange="enableAuth();"/></TD>
	</TR>
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.password" label="passwd"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
	    <jato:password name="Password" elementId="passwd"/>
	    </TD>
	</TR>
	</TABLE>
	</TD>
    </TR>
    <!-- END OF Authentication Section -->

    <!-- Content Transfer Section -->
    <TR> 
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="import.content.sect" label="content"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR>
	<TD colspan=2>
	<TABLE BORDER=0>
	<TR>
	<TD colspan=2>
	<DIV class="properties-level3-label-text"><console:button name="ClearTimeStamp" onClick="javascript:alert(cleartimestampMessage);document.forms['ImportAgent'].elements['ImportAgent.TimeStamp'].value=''; return false;"/><searchadmin:text key="import.nextrunonly"/></DIV>
	</TD>
	</TR>
	<TR>
	<TD colspan=2>
	    <DIV class="properties-level3-label-text"><jato:radioButtons name="UseGatherer" elementId="content" layout="vertical" onClick="changeToGatherer();"/></DIV>
	</TD>
	</TR>
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.scope" label="scope"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
		<jato:textField name="Scope" elementId="scope" onChange="changeToSearchQuery();"/>
	    </TD>
	</TR>
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.attributes" label="attrs"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
		<jato:textField name="ViewAttributes" elementId="attrs" onChange="changeToSearchQuery();"/>
	    </TD>
	</TR>
	<TR>
	    <TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.hits" label="hits"/>&nbsp;:&nbsp;</DIV>
	    </TD>
	    <TD>
		<jato:textField name="ViewHits" elementId="hits" onChange="changeToSearchQuery();"/>
	    </TD>
	</TR>
	</TABLE>
	</TD>
    </TR>
    <!-- END OF Content Transfer Section -->

    </jato:content> <!-- name="SrcServerSection" -->

    <!-- Advanced Section -->
    <TR> 
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="import.advanced.sect"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    
    <TR> 
	<TD colspan=2>
	<TABLE border="0" cellspacing="0" cellpadding="0">
	<jato:content name="SrcServerSection">
        <TR> 
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.agentdesc" label="nickname"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="NickName" size="30" elementId="nickname"/>
	</TD>
	</TR>
        <TR> 
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.timestamp.label" label="timestamp"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="TimeStamp" size="30" elementId="timestamp"/>
	</TD>
	</TR>
	<TR>
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.timeout" label="timeout"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="TimeOut" size="6" elementId="timeout"/> <searchadmin:text key="import.second.abbr"/></TD>
	</TR>
	
	</jato:content> <!-- name="SrcServerSection"-->
	<TR>
	<TD>
	    <DIV class="properties-level3-label-text"><searchadmin:text key="import.charset" label="charset"/>&nbsp;:&nbsp;</DIV>
	</TD>
	<TD>
	    <jato:textField name="soifCharset" elementId="charset"/>
	</TD>
	</TR>
	</TABLE>
	</TD>
    <TR>
    <!-- END OF Advanced Section -->

    <TR> 
      <TD width="50%" height="2"> </TD>
      <TD align="right" width="50%" height="2"> 
        <TABLE border="0" cellpadding="0" cellspacing="0">
          <TR> 
            <TD> 
		   <console:button name="SubmitButton" />
            </TD>
            <TD width="5"><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
	    <TD> 
		   <console:button name="CancelButton" href="ImportAgents"/>
            </TD>
            <TD width="5"><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
            <TD> 
		   <console:button name="ResetButton" />
            </TD>
            <TD><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
            <TD>  </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>

</TABLE>


</console:form>
</BODY>
<script language="javascript">
pageLoaded = 1;
</script>

</HTML>
</jato:useViewBean>


