Package org.apache.nutch.webapp.common

Examples of org.apache.nutch.webapp.common.ServiceLocator


      request.setAttribute(REQ_ATTR_COLLECTION_SELECTED,"1");
    }
  }

  public void start(ServletContext servletContext) {
    ServiceLocator serviceLocator=getServiceLocator(servletContext);
    collectionManager=CollectionManager.getCollectionManager(serviceLocator.getConfiguration());
  }
View Full Code Here


  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);

    if (ClusteringPresearchExtension.isClusteringActive(locator)) {

      // display top N clusters and top Q documents inside them.
      int N = locator.getConfiguration().getInt(
          "extension.clustering.cluster-count", 10);
      int Q = locator.getConfiguration().getInt(
          "extension.clustering.cluster-top-documents-count", 3);
      int maxLabels = 2;

      HitDetails[] details = locator.getSearch().getDetails();
      Summary[] summaries = locator.getSearch().getSummaries();

      HitsCluster[] clusters = null;
      if (clusterer != null) {
        final long clusteringStart = System.currentTimeMillis();
        try {
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    LOG.info("Cache request from " + request.getRemoteAddr());

    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")),
                      Integer.parseInt(request.getParameter("id")));

    HitDetails details = bean.getDetails(hit);
    String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo();

    Metadata metaData = bean.getParseData(details).getContentMeta();

    String content = null;
    String contentType = (String) metaData.get(Metadata.CONTENT_TYPE);


    if (contentType.startsWith("text/html")) {
      // FIXME : it's better to emit the original 'byte' sequence
      // with 'charset' set to the value of 'CharEncoding',
      // but I don't know how to emit 'byte sequence' in JSP.
      // out.getOutputStream().write(bean.getContent(details)) may work,
      // but I'm not sure.
      String encoding = (String) metaData.get("CharEncodingForConversion");
      if (encoding != null) {
        try {
          content = new String(bean.getContent(details), encoding);
        } catch (UnsupportedEncodingException e) {
          //fallback to configured charset
          content = new String(bean.getContent(details), locator
              .getConfiguration().get("parser.character.encoding.default"));
        }
      } else {
        //construct String with system default encoding
        content = new String(bean.getContent(details));
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext)
      throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);

    Search search = locator.getSearch();
    search.launchSearch();
  }
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);

    // get base page from tiles context
    String baseName = (String) tileContext.getAttribute("basePage");

    // get arequest attribute name (where content will be put)
    // from tiles context
    String attrName = (String) tileContext.getAttribute("attrName");

    // if not available use default
    if (attrName == null) {
      attrName = "content";
    }

    // get users preferred locale
    Locale locale = locator.getLocale();

    // see if we have a cached content available
    StringBuffer content = (StringBuffer) cached.get(baseName + locale);

    // not available, try to read from file
View Full Code Here

  }

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    LOG.info("anchors request from " + request.getRemoteAddr());
    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer
        .parseInt(request.getParameter("id")));
View Full Code Here

   * session from being created.
   */
  protected void processLocale(HttpServletRequest request,
      HttpServletResponse response) {

    ServiceLocator locator = WebappInstanceServiceLocator.getFrom(request);

    if (locator == null) {
      locator = new WebappInstanceServiceLocator(request, getServletContext());
      WebappInstanceServiceLocator.register(request,
          (WebappInstanceServiceLocator) locator);
    }

    Config.set(request, Config.FMT_LOCALE, locator.getLocale());
  }
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer
        .parseInt(request.getParameter("id")));
    HitDetails details = bean.getDetails(hit);
    Query query = Query.parse(request.getParameter("query"), locator
        .getConfiguration());

    // put explanation and hitDetails into request so view can access them
    request.setAttribute("explanation", bean.getExplanation(query, hit));
    request.setAttribute("hitDetails", details.toHtml());
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);

    if (tileContext.getAttribute("action").equals("save")) {
      LOG.info("save");
      Preferences p = Preferences.parse(request.getQueryString(), "&", "=");
      LOG.info("setting cookie");
      Preferences.setPreferencesCookie(request, response, p);
      LOG.info("setting attribute");
      request.setAttribute("preferences", p);
    } else {
      LOG.info("view");
      request.setAttribute("preferences", locator.getPreferences());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.nutch.webapp.common.ServiceLocator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.