Java Code Examples for org.apache.solr.common.util.NamedList#remove()

The following examples show how to use org.apache.solr.common.util.NamedList#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddSchemaFieldsUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
  inclusions = FieldMutatingUpdateProcessorFactory.parseSelectorParams(args);
  validateSelectorParams(inclusions);
  inclusions.fieldNameMatchesSchemaField = false;  // Explicitly (non-configurably) require unknown field names
  exclusions = FieldMutatingUpdateProcessorFactory.parseSelectorExclusionParams(args);
  for (SelectorParams exclusion : exclusions) {
    validateSelectorParams(exclusion);
  }
  Object defaultFieldTypeParam = args.remove(DEFAULT_FIELD_TYPE_PARAM);
  if (null != defaultFieldTypeParam) {
    if ( ! (defaultFieldTypeParam instanceof CharSequence)) {
      throw new SolrException(SERVER_ERROR, "Init param '" + DEFAULT_FIELD_TYPE_PARAM + "' must be a <str>");
    }
    defaultFieldType = defaultFieldTypeParam.toString();
  }

  typeMappings = parseTypeMappings(args);
  if (null == defaultFieldType && typeMappings.stream().noneMatch(TypeMapping::isDefault)) {
    throw new SolrException(SERVER_ERROR, "Must specify either '" + DEFAULT_FIELD_TYPE_PARAM + 
        "' or declare one typeMapping as default.");
  }

  super.init(args);
}
 
Example 2
Source File: TruncateFieldUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {

  Object lengthParam = args.remove(MAX_LENGTH_PARAM);
  if (null == lengthParam) {
    throw new SolrException(ErrorCode.SERVER_ERROR, 
                            "Missing required init parameter: " + 
                            MAX_LENGTH_PARAM);
  }
  if ( ! (lengthParam instanceof Number) ) {
    throw new SolrException(ErrorCode.SERVER_ERROR, 
                            "Init param " + MAX_LENGTH_PARAM + 
                            "must be a number; found: \"" +
                            lengthParam.toString());
  }
  maxLength = ((Number)lengthParam).intValue();
  if (maxLength < 0) {
    throw new SolrException(ErrorCode.SERVER_ERROR, 
                            "Init param " + MAX_LENGTH_PARAM + 
                            "must be >= 0; found: " + maxLength);
  }

  super.init(args);
}
 
Example 3
Source File: SkipExistingDocumentsProcessorFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args)  {
  Object tmp = args.remove(PARAM_SKIP_INSERT_IF_EXISTS);
  if (null != tmp) {
    if (! (tmp instanceof Boolean) ) {
      throw new SolrException(SERVER_ERROR, "'" + PARAM_SKIP_INSERT_IF_EXISTS + "' must be configured as a <bool>");
    }
    skipInsertIfExists = (Boolean)tmp;
  }
  tmp = args.remove(PARAM_SKIP_UPDATE_IF_MISSING);
  if (null != tmp) {
    if (! (tmp instanceof Boolean) ) {
      throw new SolrException(SERVER_ERROR, "'" + PARAM_SKIP_UPDATE_IF_MISSING + "' must be configured as a <bool>");
    }
    skipUpdateIfMissing = (Boolean)tmp;
  }

  super.init(args);
}
 
Example 4
Source File: ConcatFieldUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
  Object d = args.remove("delimiter");
  if (null != d) delimiter = d.toString();

  super.init(args);
}
 
Example 5
Source File: UUIDUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {

  Object obj = args.remove(FIELD_PARAM);
  if (null != obj) {
    fieldName = obj.toString();
  }
}
 
Example 6
Source File: IgnoreLargeDocumentProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
  maxDocumentSize = args.toSolrParams().required().getLong(LIMIT_SIZE_PARAM);
  args.remove(LIMIT_SIZE_PARAM);

  if (args.size() > 0) {
    throw new SolrException(SERVER_ERROR,
        "Unexpected init param(s): '" +
            args.getName(0) + "'");
  }
}
 
Example 7
Source File: FieldMutatingUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static Collection<SelectorParams> parseSelectorExclusionParams(
        @SuppressWarnings({"rawtypes"})NamedList args) {
  Collection<SelectorParams> exclusions = new ArrayList<>();
  @SuppressWarnings({"unchecked"})
  List<Object> excList = args.getAll("exclude");
  for (Object excObj : excList) {
    if (null == excObj) {
      throw new SolrException (SolrException.ErrorCode.SERVER_ERROR,
          "'exclude' init param can not be null");
    }
    if (! (excObj instanceof NamedList) ) {
      throw new SolrException (SolrException.ErrorCode.SERVER_ERROR,
          "'exclude' init param must be <lst/>");
    }
    @SuppressWarnings({"rawtypes"})
    NamedList exc = (NamedList) excObj;
    exclusions.add(parseSelectorParams(exc));
    if (0 < exc.size()) {
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
          "Unexpected 'exclude' init sub-param(s): '" +
              args.getName(0) + "'");
    }
    // call once per instance
    args.remove("exclude");
  }
  return exclusions;
}
 
Example 8
Source File: PreAnalyzedUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})final NamedList args) {
  parserImpl = (String)args.get("parser");
  args.remove("parser");
  // initialize inclusion / exclusion patterns
  super.init(args);
}
 
Example 9
Source File: DefaultValueUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {

  Object obj = args.remove("value");
  if (null == obj) {
    throw new SolrException
      (SERVER_ERROR, "'value' init param must be specified and non-null"); 
  } else {
    defaultValue = obj;
  }

  super.init(args);
}
 
Example 10
Source File: RegexReplaceProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {

  Object patternParam = args.remove(PATTERN_PARAM);

  if (patternParam == null) {
    throw new SolrException(ErrorCode.SERVER_ERROR, 
                            "Missing required init parameter: " + PATTERN_PARAM);
  }
  
  try {
    pattern = Pattern.compile(patternParam.toString());      
  } catch (PatternSyntaxException e) {
    throw new SolrException(ErrorCode.SERVER_ERROR, 
                            "Invalid regex: " + patternParam, e);
  }                                

  Object replacementParam = args.remove(REPLACEMENT_PARAM);
  if (replacementParam == null) {
    throw new SolrException(ErrorCode.SERVER_ERROR, 
                            "Missing required init parameter: " + REPLACEMENT_PARAM);
  }

  Boolean literalReplacement = args.removeBooleanArg(LITERAL_REPLACEMENT_PARAM);

  if (literalReplacement != null) {
    literalReplacementEnabled = literalReplacement;
  }

  if (literalReplacementEnabled) {
    replacement = Matcher.quoteReplacement(replacementParam.toString());
  } else {
    replacement = replacementParam.toString();
  }

  super.init(args);
}
 
Example 11
Source File: ParseBooleanFieldUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
  Object caseSensitiveParam = args.remove(CASE_SENSITIVE_PARAM);
  if (null != caseSensitiveParam) {
    if (caseSensitiveParam instanceof Boolean) {
      caseSensitive = (Boolean)caseSensitiveParam;
    } else {
      caseSensitive = Boolean.valueOf(caseSensitiveParam.toString());
    }
  }

  @SuppressWarnings({"unchecked"})
  Collection<String> trueValuesParam = args.removeConfigArgs(TRUE_VALUES_PARAM);
  if ( ! trueValuesParam.isEmpty()) {
    trueValues.clear();
    for (String trueVal : trueValuesParam) {
      trueValues.add(caseSensitive ? trueVal : trueVal.toLowerCase(Locale.ROOT));
    }
  }

  @SuppressWarnings({"unchecked"})
  Collection<String> falseValuesParam = args.removeConfigArgs(FALSE_VALUES_PARAM);
  if ( ! falseValuesParam.isEmpty()) {
    falseValues.clear();
    for (String val : falseValuesParam) {
      final String falseVal = caseSensitive ? val : val.toLowerCase(Locale.ROOT);
      if (trueValues.contains(falseVal)) {
        throw new SolrException(ErrorCode.SERVER_ERROR,
            "Param '" + FALSE_VALUES_PARAM + "' contains a value also in param '" + TRUE_VALUES_PARAM
                + "': '" + val + "'");
      }
      falseValues.add(falseVal);
    }
  }
  super.init(args);
}
 
Example 12
Source File: ParseNumericFieldUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
  String localeParam = (String)args.remove(LOCALE_PARAM);
  if (null != localeParam) {
    locale = LocaleUtils.toLocale(localeParam);
  }
  super.init(args);
}
 
Example 13
Source File: SolrIndexConfig.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
private MergeScheduler buildMergeScheduler(SolrResourceLoader resourceLoader) {
  String msClassName = mergeSchedulerInfo == null ? SolrIndexConfig.DEFAULT_MERGE_SCHEDULER_CLASSNAME : mergeSchedulerInfo.className;
  MergeScheduler scheduler = resourceLoader.newInstance(msClassName, MergeScheduler.class);

  if (mergeSchedulerInfo != null) {
    // LUCENE-5080: these two setters are removed, so we have to invoke setMaxMergesAndThreads
    // if someone has them configured.
    if (scheduler instanceof ConcurrentMergeScheduler) {
      @SuppressWarnings({"rawtypes"})
      NamedList args = mergeSchedulerInfo.initArgs.clone();
      Integer maxMergeCount = (Integer) args.remove("maxMergeCount");
      if (maxMergeCount == null) {
        maxMergeCount = ((ConcurrentMergeScheduler) scheduler).getMaxMergeCount();
      }
      Integer maxThreadCount = (Integer) args.remove("maxThreadCount");
      if (maxThreadCount == null) {
        maxThreadCount = ((ConcurrentMergeScheduler) scheduler).getMaxThreadCount();
      }
      ((ConcurrentMergeScheduler)scheduler).setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
      Boolean ioThrottle = (Boolean) args.remove("ioThrottle");
      if (ioThrottle != null && !ioThrottle) { //by-default 'enabled'
          ((ConcurrentMergeScheduler) scheduler).disableAutoIOThrottle();
      }
      SolrPluginUtils.invokeSetters(scheduler, args);
    } else {
      SolrPluginUtils.invokeSetters(scheduler, mergeSchedulerInfo.initArgs);
    }
  }

  return scheduler;
}
 
Example 14
Source File: DOMUtilTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void assertTypeAndValue( NamedList<Object> namedList, String key, Object value ) {
  Object v = namedList.get( key );
  assertNotNull( v );
  assertEquals( key, v.getClass().getSimpleName() );
  assertEquals( value, v );
  namedList.remove( key );
}
 
Example 15
Source File: HybridXMLWriter.java    From SolRDF with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void writeResponse() throws IOException {
	writer.write(XML_PROCESSING_INSTR);

	final String stylesheet = req.getParams().get("stylesheet");
	if (isNotNullOrEmptyString(stylesheet)) {
		writer.write(XML_STYLESHEET);

		escapeAttributeValue(stylesheet, writer);
		
		writer.write(XML_STYLESHEET_END);
	}

	writer.write(RESPONSE_ROOT_ELEMENT_START);

	final NamedList<?> responseValues = rsp.getValues();
	if (req.getParams().getBool(CommonParams.OMIT_HEADER, false)) {
		responseValues.remove(RESPONSE_HEADER);
	} else {
		((NamedList)responseValues.get(RESPONSE_HEADER)).add(Names.QUERY, responseValues.remove(Names.QUERY).toString());
	}
	
	for (final Entry<String, ?> entry : responseValues) {
		writeValue(entry.getKey(), entry.getValue(), responseValues);			
	}

	writer.write(RESPONSE_ROOT_ELEMENT_END);
}
 
Example 16
Source File: OpenNLPExtractNamedEntitiesUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {

  // high level (loose) check for which type of config we have.
  //
  // individual init methods do more strict syntax checking
  if (0 <= args.indexOf(SOURCE_PARAM, 0) && 0 <= args.indexOf(DEST_PARAM, 0) ) {
    initSourceSelectorSyntax(args);
  } else if (0 <= args.indexOf(PATTERN_PARAM, 0) && 0 <= args.indexOf(REPLACEMENT_PARAM, 0)) {
    initSimpleRegexReplacement(args);
  } else {
    throw new SolrException(SERVER_ERROR, "A combination of either '" + SOURCE_PARAM + "' + '"+
        DEST_PARAM + "', or '" + REPLACEMENT_PARAM + "' + '" +
        PATTERN_PARAM + "' init params are mandatory");
  }

  Object modelParam = args.remove(MODEL_PARAM);
  if (null == modelParam) {
    throw new SolrException(SERVER_ERROR, "Missing required init param '" + MODEL_PARAM + "'");
  }
  if ( ! (modelParam instanceof CharSequence)) {
    throw new SolrException(SERVER_ERROR, "Init param '" + MODEL_PARAM + "' must be a <str>");
  }
  modelFile = modelParam.toString();

  Object analyzerFieldTypeParam = args.remove(ANALYZER_FIELD_TYPE_PARAM);
  if (null == analyzerFieldTypeParam) {
    throw new SolrException(SERVER_ERROR, "Missing required init param '" + ANALYZER_FIELD_TYPE_PARAM + "'");
  }
  if ( ! (analyzerFieldTypeParam instanceof CharSequence)) {
    throw new SolrException(SERVER_ERROR, "Init param '" + ANALYZER_FIELD_TYPE_PARAM + "' must be a <str>");
  }
  analyzerFieldType = analyzerFieldTypeParam.toString();

  if (0 < args.size()) {
    throw new SolrException(SERVER_ERROR, "Unexpected init param(s): '" + args.getName(0) + "'");
  }

  super.init(args);
}
 
Example 17
Source File: AddSchemaFieldsUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private static List<TypeMapping> parseTypeMappings(@SuppressWarnings({"rawtypes"})NamedList args) {
  List<TypeMapping> typeMappings = new ArrayList<>();
  @SuppressWarnings({"unchecked"})
  List<Object> typeMappingsParams = args.getAll(TYPE_MAPPING_PARAM);
  for (Object typeMappingObj : typeMappingsParams) {
    if (null == typeMappingObj) {
      throw new SolrException(SERVER_ERROR, "'" + TYPE_MAPPING_PARAM + "' init param cannot be null");
    }
    if ( ! (typeMappingObj instanceof NamedList) ) {
      throw new SolrException(SERVER_ERROR, "'" + TYPE_MAPPING_PARAM + "' init param must be a <lst>");
    }
    @SuppressWarnings({"rawtypes"})
    NamedList typeMappingNamedList = (NamedList)typeMappingObj;

    Object fieldTypeObj = typeMappingNamedList.remove(FIELD_TYPE_PARAM);
    if (null == fieldTypeObj) {
      throw new SolrException(SERVER_ERROR,
          "Each '" + TYPE_MAPPING_PARAM + "' <lst/> must contain a '" + FIELD_TYPE_PARAM + "' <str>");
    }
    if ( ! (fieldTypeObj instanceof CharSequence)) {
      throw new SolrException(SERVER_ERROR, "'" + FIELD_TYPE_PARAM + "' init param must be a <str>");
    }
    if (null != typeMappingNamedList.get(FIELD_TYPE_PARAM)) {
      throw new SolrException(SERVER_ERROR,
          "Each '" + TYPE_MAPPING_PARAM + "' <lst/> may contain only one '" + FIELD_TYPE_PARAM + "' <str>");
    }
    String fieldType = fieldTypeObj.toString();

    @SuppressWarnings({"unchecked"})
    Collection<String> valueClasses
        = typeMappingNamedList.removeConfigArgs(VALUE_CLASS_PARAM);
    if (valueClasses.isEmpty()) {
      throw new SolrException(SERVER_ERROR, 
          "Each '" + TYPE_MAPPING_PARAM + "' <lst/> must contain at least one '" + VALUE_CLASS_PARAM + "' <str>");
    }

    // isDefault (optional)
    Boolean isDefault = false;
    Object isDefaultObj = typeMappingNamedList.remove(IS_DEFAULT_PARAM);
    if (null != isDefaultObj) {
      if ( ! (isDefaultObj instanceof Boolean)) {
        throw new SolrException(SERVER_ERROR, "'" + IS_DEFAULT_PARAM + "' init param must be a <bool>");
      }
      if (null != typeMappingNamedList.get(IS_DEFAULT_PARAM)) {
        throw new SolrException(SERVER_ERROR,
            "Each '" + COPY_FIELD_PARAM + "' <lst/> may contain only one '" + IS_DEFAULT_PARAM + "' <bool>");
      }
      isDefault = Boolean.parseBoolean(isDefaultObj.toString());
    }
    
    Collection<CopyFieldDef> copyFieldDefs = new ArrayList<>(); 
    while (typeMappingNamedList.get(COPY_FIELD_PARAM) != null) {
      Object copyFieldObj = typeMappingNamedList.remove(COPY_FIELD_PARAM);
      if ( ! (copyFieldObj instanceof NamedList)) {
        throw new SolrException(SERVER_ERROR, "'" + COPY_FIELD_PARAM + "' init param must be a <lst>");
      }
      @SuppressWarnings({"rawtypes"})
      NamedList copyFieldNamedList = (NamedList)copyFieldObj;
      // dest
      Object destObj = copyFieldNamedList.remove(DEST_PARAM);
      if (null == destObj) {
        throw new SolrException(SERVER_ERROR,
            "Each '" + COPY_FIELD_PARAM + "' <lst/> must contain a '" + DEST_PARAM + "' <str>");
      }
      if ( ! (destObj instanceof CharSequence)) {
        throw new SolrException(SERVER_ERROR, "'" + COPY_FIELD_PARAM + "' init param must be a <str>");
      }
      if (null != copyFieldNamedList.get(COPY_FIELD_PARAM)) {
        throw new SolrException(SERVER_ERROR,
            "Each '" + COPY_FIELD_PARAM + "' <lst/> may contain only one '" + COPY_FIELD_PARAM + "' <str>");
      }
      String dest = destObj.toString();
      // maxChars (optional)
      Integer maxChars = 0;
      Object maxCharsObj = copyFieldNamedList.remove(MAX_CHARS_PARAM);
      if (null != maxCharsObj) {
        if ( ! (maxCharsObj instanceof Integer)) {
          throw new SolrException(SERVER_ERROR, "'" + MAX_CHARS_PARAM + "' init param must be a <int>");
        }
        if (null != copyFieldNamedList.get(MAX_CHARS_PARAM)) {
          throw new SolrException(SERVER_ERROR,
              "Each '" + COPY_FIELD_PARAM + "' <lst/> may contain only one '" + MAX_CHARS_PARAM + "' <str>");
        }
        maxChars = Integer.parseInt(maxCharsObj.toString());
      }
      copyFieldDefs.add(new CopyFieldDef(dest, maxChars));
    }
    typeMappings.add(new TypeMapping(fieldType, valueClasses, isDefault, copyFieldDefs));
    
    if (0 != typeMappingNamedList.size()) {
      throw new SolrException(SERVER_ERROR, 
          "Unexpected '" + TYPE_MAPPING_PARAM + "' init sub-param(s): '" + typeMappingNamedList.toString() + "'");
    }
    args.remove(TYPE_MAPPING_PARAM);
  }
  return typeMappings;
}
 
Example 18
Source File: SolrXmlConfig.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private static UpdateShardHandlerConfig loadUpdateConfig(NamedList<Object> nl, boolean alwaysDefine) {

    if (nl == null && !alwaysDefine)
      return null;

    if (nl == null)
      return UpdateShardHandlerConfig.DEFAULT;

    boolean defined = false;

    int maxUpdateConnections = HttpClientUtil.DEFAULT_MAXCONNECTIONS;
    int maxUpdateConnectionsPerHost = HttpClientUtil.DEFAULT_MAXCONNECTIONSPERHOST;
    int distributedSocketTimeout = HttpClientUtil.DEFAULT_SO_TIMEOUT;
    int distributedConnectionTimeout = HttpClientUtil.DEFAULT_CONNECT_TIMEOUT;
    String metricNameStrategy = UpdateShardHandlerConfig.DEFAULT_METRICNAMESTRATEGY;
    int maxRecoveryThreads = UpdateShardHandlerConfig.DEFAULT_MAXRECOVERYTHREADS;

    Object muc = nl.remove("maxUpdateConnections");
    if (muc != null) {
      maxUpdateConnections = parseInt("maxUpdateConnections", muc.toString());
      defined = true;
    }

    Object mucph = nl.remove("maxUpdateConnectionsPerHost");
    if (mucph != null) {
      maxUpdateConnectionsPerHost = parseInt("maxUpdateConnectionsPerHost", mucph.toString());
      defined = true;
    }

    Object dst = nl.remove("distribUpdateSoTimeout");
    if (dst != null) {
      distributedSocketTimeout = parseInt("distribUpdateSoTimeout", dst.toString());
      defined = true;
    }

    Object dct = nl.remove("distribUpdateConnTimeout");
    if (dct != null) {
      distributedConnectionTimeout = parseInt("distribUpdateConnTimeout", dct.toString());
      defined = true;
    }

    Object mns = nl.remove("metricNameStrategy");
    if (mns != null)  {
      metricNameStrategy = mns.toString();
      defined = true;
    }

    Object mrt = nl.remove("maxRecoveryThreads");
    if (mrt != null)  {
      maxRecoveryThreads = parseInt("maxRecoveryThreads", mrt.toString());
      defined = true;
    }

    if (!defined && !alwaysDefine)
      return null;

    return new UpdateShardHandlerConfig(maxUpdateConnections, maxUpdateConnectionsPerHost, distributedSocketTimeout,
                                        distributedConnectionTimeout, metricNameStrategy, maxRecoveryThreads);

  }
 
Example 19
Source File: DocBasedVersionConstraintsProcessorFactory.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void init( @SuppressWarnings({"rawtypes"})NamedList args )  {

  Object tmp = args.remove("versionField");
  if (null == tmp) {
    throw new SolrException(SERVER_ERROR,
        "'versionField' must be configured");
  }
  if (! (tmp instanceof String) ) {
    throw new SolrException(SERVER_ERROR,
        "'versionField' must be configured as a <str>");
  }
  versionFields = StrUtils.splitSmart((String)tmp, ',');

  // optional
  tmp = args.remove("deleteVersionParam");
  if (null != tmp) {
    if (! (tmp instanceof String) ) {
      throw new SolrException(SERVER_ERROR,
          "'deleteVersionParam' must be configured as a <str>");
    }
    deleteVersionParamNames = StrUtils.splitSmart((String)tmp, ',');
  }

  if (deleteVersionParamNames.size() > 0 && deleteVersionParamNames.size() != versionFields.size()) {
    throw new SolrException(SERVER_ERROR, "The number of 'deleteVersionParam' params " +
        "must either be 0 or equal to the number of 'versionField' fields");
  }

  // optional - defaults to false
  tmp = args.remove("ignoreOldUpdates");
  if (null != tmp) {
    if (! (tmp instanceof Boolean) ) {
      throw new SolrException(SERVER_ERROR, 
                              "'ignoreOldUpdates' must be configured as a <bool>");
    }
    ignoreOldUpdates = (Boolean) tmp;
  }

  // optional - defaults to false
  tmp = args.remove("supportMissingVersionOnOldDocs");
  if (null != tmp) {
    if (! (tmp instanceof Boolean) ) {
      throw new SolrException(SERVER_ERROR,
              "'supportMissingVersionOnOldDocs' must be configured as a <bool>");
    }
    supportMissingVersionOnOldDocs = ((Boolean)tmp).booleanValue();
  }
  
  tmp = args.remove("tombstoneConfig");
  if (null != tmp) {
    if (! (tmp instanceof NamedList) ) {
      throw new SolrException(SERVER_ERROR,
              "'tombstoneConfig' must be configured as a <lst>.");
    }
    tombstoneConfig = (NamedList<Object>)tmp;
  }

  super.init(args);
}
 
Example 20
Source File: DocExpirationUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 3 votes vote down vote up
private String removeArgStr(@SuppressWarnings({"rawtypes"})final NamedList args,
                            final String arg, final String def,
                            final String errMsg) {

  if (args.indexOf(arg,0) < 0) return def;

  Object tmp = args.remove(arg);
  if (null == tmp) return null;

  if (tmp instanceof String) return tmp.toString();

  throw confErr(arg + " " + errMsg);
}