⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldapservlet.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- *  $RCSFile$ $Revision: 1.13 $ $Date: 2006/01/25 16:56:19 $ * *  Copyright (c) 2003-2004 Autonomy Corp.  All Rights Reserved. * *  Permission to use, copy, modify, and distribute this file is hereby *  granted without fee, provided that the above copyright notice appear *  in all copies. */import java.util.*;import com.ultraseek.xpa.ldap.*;import com.ultraseek.xpa.search.*;import com.ultraseek.xpa.server.*;/** * Servlet customized to search both Ultraseek and an LDAP server. * This Servlet demonstrates how to customize the SearchServlet Sample. * In this example, the SearchMenu dropdown is changed * to provide three choices: * <ul> * <li>Search both an Ultraseek and an LDAP server (merging results) * <li>Search LDAP server only. * <li>Search Ultraseek Server only. * </ul> * <p> * This servlet requires version 2.2 of the HttpServlet specification. * <p> * As an additional example, result URLs are rewritten to go through a  * redirection page, where the query, hit number, and URL can be * logged. * <p> * The LDAP server and base distinguished name must be changed to the * right values for your installation. * * @since XPA2.1 * @see SearchServlet * @see CounterServlet * @see LDAPServer * @see CounterSearchable * @see CounterURLRewriter * @requires Servlet 2.2 * @serial exclude */public class LDAPServlet  extends SearchServlet{  /**   * Creates the menu of search choices.   * Overrides the default menu created in SearchServlet.   * In this case we have   * <ul>   * <li>a menu item for searching an Ultraseek server   * <li>a menu item for searching an LDAP server   * <li>and a menu item for searching both servers, merging results.   * </ul>   * The default option for search (the first menu item)    * is to search both servers.   */  protected void initSearchMenu() {    String ldapServerName = getServletConfig().getInitParameter("LDAPServerName");    String ldapOU         = getServletConfig().getInitParameter("LDAPOU");    if (ldapServerName==null) ldapServerName = "ldap.yourcompany.com";    if (ldapOU==null)         ldapOU         = "ou=people,dc=yourcompany,dc=com";    LDAPServer   ldap = new LDAPServer();    ldap.setHost(ldapServerName);    ldap.setTimeout(5*1000);            // five seconds, in milliseconds    LDAPSearchCollection phones =      ldap.defineSearchCollection("phones", ldapOU);    phones.setName("Phonebook");    // Relevance rank the LDAP results, then cache those results    // so they don't need to be re-ranked every time. Base the    // cache lifetime on the LDAP cache.    RankingSearchable phonesRanked = new RankingSearchable(phones);    CachingSearchable cachedPhonesR = new CachingSearchable(phonesRanked);    cachedPhonesR.setCacheLifetime(ldap.getCacheLifetime()/2);    SortedMap newMenu = new TreeMap();    SearchMenuItem sm_phones;    //                              Key       printname         server     Searchable     Spell  QLinks    sm_phones = new SearchMenuItem("phones", "Phonebook Only", ldap,      cachedPhonesR, null,    null);    newMenu.put(sm_phones.ID, sm_phones);    if (ultraseek!=null) {      // Create a searchable which queries both LDAP and Ultraseek,      // combining the results into a single, ranked list.      Searchable bothServers =        new CompositeSearchable(new Searchable[]{ultraseek,cachedPhonesR});      // Rewrite all URLs to go through a redirection page, where      // the hit number, query, and URL can be logged.      CounterURLRewriter allRewriter =        new CounterURLRewriter("/search/count.html", "all");      bothServers = new CounterSearchable(bothServers, allRewriter);      SpellServer speller = ultraseek.getSpeller();      QuickLinksSearchable ql = ultraseek.getQuickLinksSearchable();      SearchMenuItem sm_all, sm_web;      //                              Key       printname         server     Searchable     Spell  QLinks      sm_all    = new SearchMenuItem("all",    "All Ultraseek",  ultraseek, bothServers,   speller, ql);      sm_web    = new SearchMenuItem("web",    "Web Pages Only", ultraseek, ultraseek,     speller, ql);      newMenu.put(sm_all.ID,    sm_all);      newMenu.put(sm_web.ID,    sm_web);    }    searchMenu = newMenu;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -