FileDocCategorySizeDatePackage
SearchImpl.javaAPI DocExample2838Sat Feb 28 14:35:44 GMT 2004com.develop.ss.axis

SearchImpl

public class SearchImpl extends Object implements SiteSearch

Fields Summary
Constructors Summary
Methods Summary
public voiddoIndex(java.lang.String indexUrl)

         try
            {

            ConfigBean config = new ConfigBean();
            String nextIndex;
            try
            {
               nextIndex = config.getNextIndexPath();
            }
            catch(Exception ex)
            {
                return;
            }

            IndexLinks lts = new IndexLinks(nextIndex, config.getMaxLinks(), config.getSkippedLinksFile());
            lts.initFollowPrefixesFromSystemProperties();
            lts.initAvoidPrefixesFromSystemProperties();
            lts.setInitialLink(indexUrl);

            config.flipIndexPath();

            }
            catch(Exception e)
            {
                //System.out.print(e.getStackTrace());
            }
    
public javax.servlet.ServletContextgetServletContext()

    MessageContext mctx = MessageContext.getCurrentContext();
    GenericServlet axis = (GenericServlet)mctx.getProperty("transport.http.servlet");
    return axis.getServletContext();
  
public ResponseType[]searchContents(QueryType request)

    try {
      ConfigBean config = new ConfigBean();
      ServletContext context = getServletContext();
      if (context == null) {
        throw new Error("null servlet context");
      }
      //indexPathBean.setContext(context);
      QueryBean query = new QueryBean(config.getCurIndexPath(), request.getSeachString());
      query.execute();
      HitBean[] fullResults = query.getResults();
      ArrayList result = new ArrayList();
      for (int n=0; n<fullResults.length; n++) {
        HitBean hit = fullResults[n];
        if (hit.getScore() >= request.getThreshold()) {
          ResponseType rt = new ResponseType();
          rt.setScore(hit.getScore());
          rt.setUrl(new URI(hit.getUrl()));
          result.add(rt);
        }
      }
      return (ResponseType[]) result.toArray(new ResponseType[result.size()]);
    } catch (Exception e) {
      getServletContext().log(e, "fail");
      throw new AxisFault(e.getMessage());
    }