Package net.sf.regain.util.io

Examples of net.sf.regain.util.io.Localizer


      sortingOptions = config.getSortingOptions();
    }

    if (sortingOptions == null) {
      // create default option relevance
      Localizer localizer = new Localizer(request.getResourceBaseUrl(), "msg", request.getLocale());
      String relevText = localizer.msg("relevance", "relevance");
      sortingOptions = new SortingOption[]{new SortingOption(relevText, "relevance", "desc", 1)};
    }

    if (sortingOptions != null) {
      String order = request.getParameter("order");
View Full Code Here


      // We take the first index config
      IndexConfig config = configArr[0];
      showSortFieldContent = config.getShowSortFieldContent();
    }
    if (sortContent != null && showSortFieldContent) {
      Localizer localizer = new Localizer(request.getResourceBaseUrl(), "msg", request.getLocale());
      response.print(" ");
      response.print(localizer.msg("sortContent", "sort field content"));
      response.print(": ");
      response.print(sortContent);
    }
  }
View Full Code Here

   * @throws RegainException If there was an exception.
   */
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());

    // Get the name of the edit list
    String name = getParameter("name", true);
   
    // Get the current value
    String[] currValueArr = (String[]) request.getContextAttribute("settings." + name);
   
    response.print("<select id=\"" + name + "-list\" name=\"" + name + "\" " +
        "size=\"5\" onClick=\"showListSelection('" + name + "')\" multiple");
    String styleSheetClass = getParameter("class");
    if (styleSheetClass != null) {
      response.print(" class=\"" + styleSheetClass + "\"");
    }
    response.print(">");
    for (int i = 0; i < currValueArr.length; i++) {
      response.print("<option>" + currValueArr[i] + "</option>");
    }
    response.print("</select><br/>");
   
    response.print("<input type=\"text\" id=\"" + name + "-entry\"");
    if (styleSheetClass != null) {
      response.print(" class=\"" + styleSheetClass + "\"");
    }
    response.print("/>");
    response.print("<button type=\"button\" onClick=\"addToList('" + name + "')\">"
        + localizer.msg("add", "Add") + "</button>");
    response.print("<button type=\"button\" onClick=\"removeFromList('" + name + "')\">"
        + localizer.msg("remove", "Remove") + "</button>");
  }
View Full Code Here

   * @throws RegainException If there was an exception.
   */
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());
    String currValue = (String) request.getContextAttribute("settings.interval");
   
    response.print("<select name=\"interval\">");
    for (int i = 0; i < CHOICES.length; i++) {
      String value = CHOICES[i];
      String name  = localizer.msg("choice." + value, value);
     
      response.print("<option value=\"" + value + "\"");
      if (value.equals(currValue)) {
        response.print(" selected=\"selected\"");
      }
View Full Code Here

    String[] dirblacklist;
    String[] sitelist;
    String[] siteblacklist;
    String[] imaplist;

    Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());

    int port;
    if (interval == -1) {
      // This is the first call -> Load the settings
      DesktopConfig desktopConfig = DesktopToolkit.getDesktopConfig();
      Document crawlerDoc = XmlToolkit.loadXmlDocument(CRAWLER_CONFIG_FILE);

      interval = desktopConfig.getInterval();
      dirlist = getStartlistEntries(crawlerDoc, FILE_PROTOCOL);
      dirblacklist = getBlacklistEntries(crawlerDoc, FILE_PROTOCOL);
      sitelist = getStartlistEntries(crawlerDoc, HTTP_PROTOCOL);
      siteblacklist = getBlacklistEntries(crawlerDoc, HTTP_PROTOCOL);
      imaplist = getCompleteStartlistEntries(crawlerDoc, IMAP_PROTOCOL);
      port = desktopConfig.getPort();
    } else {
      // There were new settings sent -> Check the input
      ArrayList<String> errorList = new ArrayList<String>();

      // Get the input
      dirlist = request.getParametersNotNull("dirlist");
      dirblacklist = request.getParametersNotNull("dirblacklist");
      sitelist = request.getParametersNotNull("sitelist");
      siteblacklist = request.getParametersNotNull("siteblacklist");
      imaplist = request.getParametersNotNull("imaplist");
      port = request.getParameterAsInt("port", DEFAULT_PORT);

      // Check the input
      checkDirectoryList(errorList, dirlist, localizer);
      checkDirectoryList(errorList, dirblacklist, localizer);
      checkWebsiteList(errorList, sitelist, localizer);
      checkWebsiteList(errorList, siteblacklist, localizer);
      checkImapList(errorList, imaplist, localizer);

      if (errorList.isEmpty()) {
        // There were no errors -> Save the values
        saveSettings(interval, dirlist, dirblacklist, sitelist, siteblacklist, imaplist, port);
        DesktopToolkit.checkWebserver();
        response.print(localizer.msg("settingsSaved", "Your settings where saved!"));
//        response.print("Ihre Einstellungen wurden gespeichert!");
      } else {
        // There were errors -> Show them
        response.print(localizer.msg("settingsContainsError", "The following errors where detected:<ul>"));
//        response.print("Leider enth&auml;lt Ihre Eingabe noch Fehler:<ul>");
        for (int i = 0; i < errorList.size(); i++) {
          response.print("<li>" + errorList.get(i) + "</li>");
        }
        response.print("</ul>");
View Full Code Here

   */
  @Override
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());
   
    // Get the IndexConfig
    IndexConfig[] configArr = SearchToolkit.getIndexConfigArr(request);
    if (configArr.length > 1) {
      throw new RegainException("The currentindex tag can only be used for one index!");
    }
    IndexConfig config = configArr[0];
   
    File currentIndexDir = new File(config.getDirectory(), "new");
    if (! currentIndexDir.exists()) {
      currentIndexDir = new File(config.getDirectory(), "index");
    }
   
    if (currentIndexDir.exists()) {
      // Get the last update
      String timestamp = RegainToolkit.readStringFromFile(LASTUPDATE_FILE);
      Date lastUpdate = RegainToolkit.stringToLastModified(timestamp);
     
      // Get the index size
      long size = RegainToolkit.getDirectorySize(currentIndexDir);
      String sizeAsString = RegainToolkit.bytesToString(size, request.getLocale());
     
      // Get the document count
      IndexSearcherManager manager = IndexSearcherManager.getInstance(config.getDirectory());
      int docCount = manager.getDocumentCount();
     
      // Print the results
      response.print(localizer.msg("indexInfo", "Last update: {0}<br/>Size: {1}<br/>Document count: {2}",
          lastUpdate, sizeAsString, new Integer(docCount)));
    } else {
      response.print(localizer.msg("noIndex", "There was no search index created so far."));
    }
  }
View Full Code Here

   */
  @Override
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());

    Crawler crawler = IndexUpdateManager.getInstance().getCurrentCrawler();
    if (crawler == null) {
      response.print(localizer.msg("noIndexUpdate", "Currently is no index update running."));
    } else {
      // Get the IndexConfig
      IndexConfig[] configArr = SearchToolkit.getIndexConfigArr(request);
      if (configArr.length > 1) {
        throw new RegainException("The indexupdate tag can only be used for one index!");
      }
      IndexConfig config = configArr[0];

      // Get the index size
      File indexUpdateDir = new File(config.getDirectory(), "temp");
      long size = RegainToolkit.getDirectorySize(indexUpdateDir);
      String sizeAsString = RegainToolkit.bytesToString(size, request.getLocale());
      String currentJobUrl = crawler.getCurrentJobUrl();
     
      Object[] args = new Object[] {
        new Integer(crawler.getFinishedJobCount()),
        sizeAsString,
        new Integer(crawler.getInitialDocCount()),
        new Integer(crawler.getAddedDocCount()),
        new Integer(crawler.getRemovedDocCount()),
        (currentJobUrl == null) ? "?" : currentJobUrl,
        RegainToolkit.toTimeString(crawler.getCurrentJobTime())
      };
      response.print(localizer.msg("indexInfo", "Processed documents: {0}<br/>" +
            "Size: {1}<br/>Initial document count: {2}<br/>" +
            "Added document count: {3}<br/>Removed document count: {4}<br/>" +
            "Current job: {5} (since {6})", args));
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.regain.util.io.Localizer

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.