Пример #1
0
  /**
   * Retourne la liste des champs "snippet".
   *
   * @param node
   * @param source
   * @param target
   * @throws IllegalAccessException
   * @throws InstantiationException
   */
  public static void copySnippetFields(Node node, SchemaFieldList source, SnippetFieldList target)
      throws InstantiationException, IllegalAccessException {
    String fieldName = XPathParser.getAttributeString(node, "name");
    String tag = XPathParser.getAttributeString(node, "tag");
    if (tag == null) tag = "em";
    int maxSnippetNumber = XPathParser.getAttributeValue(node, "maxSnippetNumber");
    if (maxSnippetNumber == 0) maxSnippetNumber = 1;
    int maxSnippetSize = XPathParser.getAttributeValue(node, "maxSnippetSize");
    if (maxSnippetSize == 0) maxSnippetSize = 200;
    int timeLimit = DomUtils.getAttributeInteger(node, "timeLimit", 0);

    FragmenterAbstract fragmenter =
        FragmenterAbstract.newInstance(XPathParser.getAttributeString(node, "fragmenterClass"));
    fragmenter.setAttributes(node.getAttributes());
    String separator = XPathParser.getAttributeString(node, "separator");
    if (separator == null) separator = "...";
    SchemaField schemaField = source.get(fieldName);
    if (schemaField == null) return;
    SnippetField field =
        new SnippetField(
            schemaField.getName(),
            tag,
            separator,
            maxSnippetSize,
            maxSnippetNumber,
            fragmenter,
            timeLimit);
    target.put(field);
  }
Пример #2
0
 public AuthManager(Config config, File indexDir)
     throws SAXException, IOException, ParserConfigurationException {
   this.config = config;
   authFile = new File(indexDir, AUTH_CONFIG_FILENAME);
   if (!authFile.exists()) return;
   StreamSource streamSource = new StreamSource(authFile);
   Node docNode = DomUtils.readXml(streamSource, false);
   Node authNode = DomUtils.getFirstNode(docNode, AUTH_ITEM_ROOT_NODE);
   if (authNode == null) return;
   enabled = DomUtils.getAttributeBoolean(authNode, AUTH_ATTR_ENABLED, false);
   index = DomUtils.getAttributeText(authNode, AUTH_ATTR_INDEX);
   userAllowField = DomUtils.getAttributeText(authNode, AUTH_ATTR_USER_ALLOW_FIELD);
   userDenyField = DomUtils.getAttributeText(authNode, AUTH_ATTR_USER_DENY_FIELD);
   groupAllowField = DomUtils.getAttributeText(authNode, AUTH_ATTR_GROUP_ALLOW_FIELD);
   groupDenyField = DomUtils.getAttributeText(authNode, AUTH_ATTR_GROUP_DENY_FIELD);
   defaultUser = DomUtils.getAttributeText(authNode, AUTH_ATTR_DEFAULT_USER);
   defaultGroup = DomUtils.getAttributeText(authNode, AUTH_ATTR_DEFAULT_GROUP);
 }